00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #ifndef INC_CARTPROV
00100 #define INC_CARTPROV
00101
00102
00103
00104 class CamArtCacheEntry;
00105 class wxCamArtProviderEvent;
00106
00107 enum CamArtFlags
00108 {
00109
00110
00111 CAF_SELECTED = 1<<0,
00112 CAF_FOCUS = 1<<1,
00113 CAF_GREYED = 1<<2,
00114 CAF_SMALL = 1<<3,
00115
00116 CAF_CACHE_MAX = 1<<4,
00117
00118
00119 CAF_TOOLBACKGROUND = 1<<5,
00120 CAF_PUSHBUTTON = 1<<6,
00121 CAF_TOGGLEBUTTON = 1<<7,
00122 CAF_ALLOWHOVER = 1<<8,
00123 CAF_TEXT = 1<<9,
00124 CAF_EXACTFIT = 1<<10,
00125 CAF_HALFHEIGHT = 1<<11,
00126
00127 CAF_TOP = 1<<12,
00128 CAF_BOTTOM = 1<<13,
00129 CAF_LEFT = 1<<14,
00130 CAF_RIGHT = 1<<15,
00131
00132 CAF_BUTTONHOVER = 1<<16,
00133 CAF_ALWAYS3D = 1<<17,
00134
00135 CAF_NOINTERNALBORDER= 1<<18,
00136
00137 CAF_NOAUTOREPEAT = 1<<19,
00138
00139 CAF_STATUSBARTEXT = 1<<20,
00140
00141
00142 CAF_MAX = 1<<21,
00143
00144
00145 CAF_DEFAULT = 0
00146 };
00147
00148
00149 class ImageAndBitmap : public SimpleCCObject
00150 {
00151 public:
00152 wxImage * m_pImage;
00153 wxBitmap * m_pBitmap;
00154 ImageAndBitmap(wxImage * pImage=NULL, wxBitmap * pBitmap=NULL) : m_pImage(pImage) , m_pBitmap(pBitmap) {}
00155 ~ImageAndBitmap() {if (m_pBitmap) delete (m_pBitmap); m_pBitmap=NULL; m_pImage=NULL; }
00156 };
00157
00158
00159
00160
00161 typedef UINT64 ResourceIDWithFlags;
00162
00163
00164 class ResourceIDWithFlagsHash
00165 {
00166 public:
00167 ResourceIDWithFlagsHash() { }
00168
00169 unsigned long operator()( const ResourceIDWithFlags& k ) const
00170 { return (unsigned long)(k ^ (k>>32));}
00171
00172 ResourceIDWithFlagsHash& operator=(const ResourceIDWithFlagsHash&) { return *this; }
00173 };
00174
00175
00176 class ResourceIDWithFlagsEqual
00177 {
00178 public:
00179 ResourceIDWithFlagsEqual() { }
00180 bool operator()( const ResourceIDWithFlags& a, const ResourceIDWithFlags& b ) const
00181 { return (a==b); }
00182
00183 ResourceIDWithFlagsEqual& operator=(const ResourceIDWithFlagsEqual&) { return *this; }
00184 };
00185
00186 WX_DECLARE_HASH_MAP( ResourceIDWithFlags, ImageAndBitmap, ResourceIDWithFlagsHash, ResourceIDWithFlagsEqual, ResIDWithFlagsToBitmapPtr );
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 class CamArtProvider : public wxEvtHandler
00204 {
00205 public:
00206 CamArtProvider();
00207 ~CamArtProvider();
00208
00209 private:
00210 static CamArtProvider * m_ArtProvider;
00211
00212 public:
00213 static BOOL Init();
00214 static void DeInit();
00215 static CamArtProvider * Get() {return m_ArtProvider;}
00216
00217 void GetBitmapEvent(wxCamArtProviderEvent &event);
00218 void InvalidateArtEvent(wxCamArtProviderEvent &event);
00219 void Draw (wxDC& dc, const wxRect & rect, ResourceID Resource, CamArtFlags Flags = CAF_DEFAULT, const wxString &text = wxEmptyString);
00220
00221 wxSize GetSize(ResourceID r, CamArtFlags Flags=CAF_DEFAULT, const wxString &text = wxEmptyString);
00222
00223 void EnsureBitmapLoaded(ResourceID Resource, BOOL SkipArtLoad = FALSE);
00224 void EnsureChildBitmapsLoaded(wxWindow * pWindow = NULL, BOOL SkipArtLoad = FALSE);
00225 void ReloadAllArt();
00226 wxBitmap * FindBitmap(ResourceID Resource, CamArtFlags Flags = CAF_DEFAULT, BOOL SkipArtLoad=FALSE);
00227 wxImage * FindImage(ResourceID Resource, CamArtFlags Flags = CAF_DEFAULT, BOOL SkipArtLoad=FALSE);
00228
00229 static CamArtFlags GetBitmapFlags(const wxString &str);
00230 static wxString MakeBitmapFlagString(const CamArtFlags flags);
00231
00232 wxImage * GetMissingImage() const {return m_pMissingImage;}
00233 wxBitmap * GetMissingBitmap() const {return m_pMissingBitmap;}
00234
00235 protected:
00236 ResIDWithFlagsToBitmapPtr::iterator Find(ResourceID Resource, CamArtFlags Flags, BOOL SkipArtLoad);
00237
00238 ResourceIDWithFlags CombineFlags(ResourceID Resource, CamArtFlags Flags) { return Resource | (((UINT64)Flags)<<32) ; }
00239 CamArtFlags GetFlags(ResourceIDWithFlags ResWithFlags) { return (CamArtFlags)(ResWithFlags>>32); }
00240 ResourceID GetResourceID(ResourceIDWithFlags ResWithFlags) { return (ResourceID)(ResWithFlags & 0xFFFFFFFF); }
00241
00242 static wxColor DarkenColour(const wxColor& c, INT32 amount);
00243 static wxColor LightenColour(const wxColor& c, INT32 amount);
00244
00245 wxImage * MakeBitmap(ResourceIDWithFlags ResWithFlags);
00246 void InvalidateAllArt();
00247 void InvalidateAllArtInChildren(wxWindow * pWindow);
00248 void DeleteHashContents();
00249 void ArtLoad(BOOL newbitmaps = FALSE, BOOL defer=TRUE);
00250
00251 wxSize GetBorderSize(CamArtFlags Flags=CAF_DEFAULT);
00252 wxString GetTextInfoOrDraw(ResourceID r, CamArtFlags f, wxDC &dc, BOOL Draw=FALSE, wxCoord *w=NULL, wxCoord *h=NULL,
00253 wxCoord x=0, wxCoord y=0, wxCoord MaxWidth=-1, const wxString &text = wxEmptyString);
00254
00255 ResIDWithFlagsToBitmapPtr * m_pHash;
00256 BOOL m_GetBitmapEventPending;
00257 BOOL m_InvalidateArtEventPending;
00258 wxImage * m_pMissingImage;
00259 wxBitmap * m_pMissingBitmap;
00260
00261 DECLARE_CLASS(wxEvtHandler)
00262 DECLARE_EVENT_TABLE()
00263
00264 };
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279 class wxCamArtProviderEvent : public wxEvent
00280 {
00281 public:
00282
00283 wxCamArtProviderEvent(wxEventType commandType = wxEVT_NULL, INT32 id=0, BOOL deferred=FALSE ) : wxEvent(id, commandType) {m_deferred=deferred;}
00284
00285 wxCamArtProviderEvent(const wxCamArtProviderEvent& event) : wxEvent(event) {m_deferred=event.m_deferred;}
00286
00287 virtual wxEvent *Clone() const {return new wxCamArtProviderEvent(*this); }
00288
00289 BOOL m_deferred;
00290
00291 DECLARE_DYNAMIC_CLASS(wxCamArtProviderEvent);
00292
00293 };
00294
00295
00296 typedef void (wxEvtHandler::*wxCamArtProviderEventFunction)(wxCamArtProviderEvent &);
00297
00298 BEGIN_DECLARE_EVENT_TYPES()
00299 DECLARE_EVENT_TYPE(wxEVT_CAMARTPROVIDER_GETBITMAP, 1101)
00300 DECLARE_EVENT_TYPE(wxEVT_CAMARTPROVIDER_INVALIDATEART, 1102)
00301 END_DECLARE_EVENT_TYPES()
00302
00303 #define EVT_CAMARTPROVIDER_GETBITMAP(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CAMARTPROVIDER_GETBITMAP, id, -1, \
00304 (wxObjectEventFunction)(wxEventFunction)(wxCamArtProviderEventFunction) &fn, (wxObject *) NULL),
00305 #define EVT_CAMARTPROVIDER_INVALIDATEART(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CAMARTPROVIDER_INVALIDATEART, id, -1, \
00306 (wxObjectEventFunction)(wxEventFunction)(wxCamArtProviderEventFunction) &fn, (wxObject *) NULL),
00307
00308 #endif
00309