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_CARTCTL
00100 #define INC_CARTCTL
00101
00102 #include "cartprov.h"
00103 #include "ctrllist.h"
00104
00105 enum wxCamArtControlStyle
00106 {
00107
00108
00109 wxCACS_TOOLBACKGROUND = CAF_TOOLBACKGROUND,
00110 wxCACS_PUSHBUTTON = CAF_PUSHBUTTON,
00111 wxCACS_TOGGLEBUTTON = CAF_TOGGLEBUTTON,
00112 wxCACS_ALWAYS3D = CAF_ALWAYS3D,
00113 wxCACS_ALLOWHOVER = CAF_ALLOWHOVER,
00114 wxCACS_NOINTERNALBORDER = CAF_NOINTERNALBORDER,
00115 wxCACS_TEXT = CAF_TEXT,
00116 wxCACS_EXACTFIT = CAF_EXACTFIT,
00117 wxCACS_HALFHEIGHT = CAF_HALFHEIGHT,
00118 wxCACS_TOP = CAF_TOP,
00119 wxCACS_BOTTOM = CAF_BOTTOM,
00120 wxCACS_LEFT = CAF_LEFT,
00121 wxCACS_RIGHT = CAF_RIGHT,
00122 wxCACS_NOAUTOREPEAT = CAF_NOAUTOREPEAT,
00123 wxCACS_STATUSBARTEXT = CAF_STATUSBARTEXT,
00124
00125 wxCACS_DEFAULT = 0
00126 };
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 class wxCamArtControlEvent : public wxEvent
00141 {
00142 public:
00143
00144 wxCamArtControlEvent(wxEventType commandType = wxEVT_NULL, INT32 id=0 ) : wxEvent(id, commandType) {}
00145
00146 wxCamArtControlEvent(const wxCamArtControlEvent& event) : wxEvent(event) {}
00147
00148 virtual wxEvent *Clone() const {return new wxCamArtControlEvent(*this); }
00149
00150 DECLARE_DYNAMIC_CLASS(wxCamArtControlEvent);
00151
00152 };
00153
00154 typedef void (wxEvtHandler::*wxCamArtControlEventFunction)(wxCamArtControlEvent &);
00155
00156 DECLARE_EVENT_TYPE(wxEVT_CAMARTCONTROL_INVOKE, -1);
00157
00158 #define EVT_CAMARTCONTROL_INVOKE(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_CAMARTCONTROL_INVOKE, id, -1, \
00159 (wxObjectEventFunction)(wxEventFunction)(wxCamArtControlEventFunction) &fn, (wxObject *) NULL),
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 class wxCamArtControl : public wxControl
00176 {
00177 DECLARE_DYNAMIC_CLASS(wxControl)
00178 DECLARE_EVENT_TABLE()
00179 public:
00180
00181 BOOL Create( wxWindow * parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
00182 long style = 0, const wxValidator& validator = wxDefaultValidator,
00183 wxCamArtControlStyle cacstyle = wxCACS_DEFAULT,
00184 wxString opdesc = wxString(_T("")));
00185
00186
00187 void Init() {
00188 m_Value=0;
00189 m_CamArtControlStyle=wxCACS_DEFAULT;
00190 m_BestSize=wxDefaultSize;
00191 m_State=CAF_DEFAULT;
00192 m_OpDesc=wxString(_T(""));
00193 m_Timer.SetOwner(this, _R(IDC_WXCAMARTCONTROL_AUTOREPEAT));
00194 m_ARDelay=500;
00195 m_ARRepeat=50;
00196 m_AREventPending=FALSE;
00197 m_BitmapId=0;
00198 }
00199
00200
00201 wxCamArtControl() { Init(); }
00202 wxCamArtControl( wxWindow * parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
00203 long style = 0, const wxValidator& validator = wxDefaultValidator,
00204 wxCamArtControlStyle cacstyle = wxCACS_DEFAULT,
00205 wxString opdesc = wxString(_T("")))
00206 {
00207 Init();
00208 ControlList::Get()->NewControl(this);
00209 Create(parent, id, pos, size, style, validator, cacstyle, opdesc);
00210 }
00211 ~wxCamArtControl() { m_Timer.Stop(); }
00212
00213 wxSize DoGetBestSize() const;
00214
00215
00216 void OnPaint(wxPaintEvent & event);
00217 void OnMouseEvent(wxMouseEvent & event);
00218 void OnTimer(wxTimerEvent& event);
00219 void OnInvoke(wxCamArtControlEvent& event);
00220
00221
00222 void NewBitmap() {FindBitmap(); Refresh();}
00223
00224 virtual void SetStyle(wxCamArtControlStyle style) { m_CamArtControlStyle=style; NewBitmap(); }
00225 virtual wxCamArtControlStyle GetStyle() const { return m_CamArtControlStyle;}
00226
00227 virtual void SetValue(UINT32 value)
00228 {
00229 m_Value=value;
00230 CamArtFlags o=m_State;
00231 if (value) m_State=(CamArtFlags)(m_State | CAF_SELECTED); else m_State =(CamArtFlags)(m_State & ~CAF_SELECTED);
00232 if (o!=m_State) Refresh();
00233 }
00234 virtual UINT32 GetValue() { return m_Value;}
00235
00236
00237 virtual bool Enable(bool enable = true)
00238 {
00239 if (!enable)
00240 {
00241 m_State = (CamArtFlags)(m_State & ~CAF_BUTTONHOVER);
00242 m_Timer.Stop();
00243 }
00244 return wxControl::Enable(enable);
00245 }
00246
00247 virtual void SetLabel(const wxString& label) {if (label!=GetLabel()) {wxControl::SetLabel(label); Refresh(TRUE);}}
00248
00249 wxString GetOpDesc() {return m_OpDesc;}
00250
00251 const ResourceID GetBitmapId() {return m_BitmapId?m_BitmapId:GetId();}
00252 void SetBitmapId(ResourceID r=0) {m_BitmapId=r; NewBitmap();}
00253
00254 protected:
00255 wxCamArtControlStyle m_CamArtControlStyle;
00256 UINT32 m_Value;
00257 wxSize m_BestSize;
00258 CamArtFlags m_State;
00259
00260 wxTimer m_Timer;
00261 UINT32 m_ARDelay;
00262 UINT32 m_ARRepeat;
00263 BOOL m_AREventPending;
00264
00265 wxString m_OpDesc;
00266
00267 void Invoke();
00268
00269 void FindBitmap();
00270 CamArtFlags GetArtFlags() {return (CamArtFlags)(m_CamArtControlStyle | m_State | (IsEnabled()?0:CAF_GREYED));}
00271
00272 ResourceID m_BitmapId;
00273
00274 };
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288 class wxCamArtControlXmlHandler : public wxXmlResourceHandler
00289 {
00290 DECLARE_DYNAMIC_CLASS(wxCamArtControlXmlHandler)
00291 public:
00292 wxCamArtControlXmlHandler();
00293 virtual wxObject *DoCreateResource();
00294 virtual bool CanHandle(wxXmlNode *node);
00295 };
00296
00297
00298 #endif
00299