#include <cartctl.h>
Public Member Functions | |
BOOL | Create (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, wxCamArtControlStyle cacstyle=wxCACS_DEFAULT, wxString opdesc=wxString(_T(""))) |
Initialize the control. | |
void | Init () |
wxCamArtControl () | |
wxCamArtControl (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, wxCamArtControlStyle cacstyle=wxCACS_DEFAULT, wxString opdesc=wxString(_T(""))) | |
~wxCamArtControl () | |
wxSize | DoGetBestSize () const |
Initialize resources. | |
void | OnPaint (wxPaintEvent &event) |
Paints the control. | |
void | OnMouseEvent (wxMouseEvent &event) |
Handles mouse events. | |
void | OnTimer (wxTimerEvent &event) |
Handles autorepeat timer events. | |
void | OnInvoke (wxCamArtControlEvent &event) |
Handles deferred invoke events. | |
void | NewBitmap () |
virtual void | SetStyle (wxCamArtControlStyle style) |
virtual wxCamArtControlStyle | GetStyle () const |
virtual void | SetValue (UINT32 value) |
virtual UINT32 | GetValue () |
virtual bool | Enable (boolenable=true) |
virtual void | SetLabel (const wxString &label) |
wxString | GetOpDesc () |
const ResourceID | GetBitmapId () |
void | SetBitmapId (ResourceID r=0) |
Protected Member Functions | |
void | Invoke () |
Does the work of the button being pressed. | |
void | FindBitmap () |
Find the bitmap associated with the control, and set our cached size. | |
CamArtFlags | GetArtFlags () |
Protected Attributes | |
wxCamArtControlStyle | m_CamArtControlStyle |
UINT32 | m_Value |
wxSize | m_BestSize |
CamArtFlags | m_State |
wxTimer | m_Timer |
UINT32 | m_ARDelay |
UINT32 | m_ARRepeat |
BOOL | m_AREventPending |
wxString | m_OpDesc |
ResourceID | m_BitmapId |
Definition at line 175 of file cartctl.h.
|
Definition at line 201 of file cartctl.h. 00201 { Init(); }
|
|
Definition at line 202 of file cartctl.h. 00203 : Correct*/ 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 }
|
|
Definition at line 211 of file cartctl.h. 00211 { m_Timer.Stop(); }
|
|
Initialize the control.
Definition at line 152 of file cartctl.cpp. 00153 : Correct*/ long style, const wxValidator& validator, 00154 wxCamArtControlStyle cacstyle, 00155 wxString opdesc) 00156 { 00157 if (!wxControl::Create(parent, id, pos, size, style, validator)) 00158 return FALSE; 00159 00160 // Complete bodge to default to small button bars but large toolbars 00161 if (!(cacstyle & wxCACS_TOOLBACKGROUND)) 00162 cacstyle = (wxCamArtControlStyle)(cacstyle | CAF_SMALL); 00163 00164 m_CamArtControlStyle = cacstyle; 00165 m_OpDesc = opdesc; 00166 FindBitmap(); 00167 return TRUE; 00168 }
|
|
Initialize resources.
Definition at line 186 of file cartctl.cpp. 00187 { 00188 ((wxCamArtControl *)this)->FindBitmap(); 00189 00190 wxSize ret = m_BestSize; // ret( wxControl::DoGetBestSize() ); 00191 00192 if ((GetStyle() & wxCACS_TEXT) && (!(GetStyle() & wxCACS_EXACTFIT))) 00193 { 00194 wxSize DefaultSize; 00195 DefaultSize=wxButton::GetDefaultSize(); 00196 if (GetStyle() & wxCACS_HALFHEIGHT) 00197 DefaultSize.y = (DefaultSize.y/2)-2; 00198 if (ret.x < DefaultSize.x) ret.x = DefaultSize.x; 00199 if (ret.y < DefaultSize.y) ret.y = DefaultSize.y; 00200 } 00201 00202 CacheBestSize(ret); 00203 return ret; 00204 }
|
|
Definition at line 237 of file cartctl.h. 00237 : Correct*/ bool Enable(bool /*TYPENOTE: Correct*/ enable = true) 00238 { 00239 if (!enable) 00240 { 00241 m_State = (CamArtFlags)(m_State & ~CAF_BUTTONHOVER); 00242 m_Timer.Stop(); // Don't process more events 00243 } 00244 return wxControl::Enable(enable); 00245 }
|
|
Find the bitmap associated with the control, and set our cached size.
Definition at line 222 of file cartctl.cpp. 00223 { 00224 m_BestSize=(CamArtProvider::Get())->GetSize(GetBitmapId(), GetArtFlags(), GetLabel()); 00225 return; 00226 }
|
|
Definition at line 270 of file cartctl.h. 00270 {return (CamArtFlags)(m_CamArtControlStyle | m_State | (IsEnabled()?0:CAF_GREYED));}
|
|
Definition at line 251 of file cartctl.h. 00251 {return m_BitmapId?m_BitmapId:GetId();}
|
|
Definition at line 249 of file cartctl.h. 00249 {return m_OpDesc;}
|
|
Definition at line 225 of file cartctl.h. 00225 { return m_CamArtControlStyle;}
|
|
Definition at line 234 of file cartctl.h. 00234 { return m_Value;}
|
|
Definition at line 187 of file cartctl.h. 00187 { 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 }
|
|
Does the work of the button being pressed.
Definition at line 430 of file cartctl.cpp. 00431 { 00432 if (!IsEnabled()) 00433 { 00434 m_Timer.Stop(); 00435 return; // Don't even send messages if the control is greyed 00436 } 00437 00438 wxCommandEvent ButtonEvent(wxEVT_COMMAND_BUTTON_CLICKED, GetId()); 00439 ProcessEvent(ButtonEvent); 00440 // If it's attached to an OpDescriptor, we invoke it. 00441 // ControlList::/*Get*/()->Invoke(this); 00442 }
|
|
Definition at line 222 of file cartctl.h. 00222 {FindBitmap(); Refresh();}
|
|
Handles deferred invoke events.
Definition at line 400 of file cartctl.cpp. 00401 { 00402 m_AREventPending = FALSE; 00403 if (!::wxGetMouseState().LeftDown()) 00404 { 00405 m_Timer.Stop(); 00406 return; 00407 } 00408 Invoke(); 00409 }
|
|
Handles mouse events.
Definition at line 269 of file cartctl.cpp. 00270 { 00271 CamArtFlags OldState = m_State; 00272 BOOL ButtonClick=FALSE; 00273 00274 if ((m_CamArtControlStyle & wxCACS_PUSHBUTTON) && IsEnabled()) 00275 { 00276 if (event.LeftDown() || event.LeftDClick()) 00277 { 00278 if (m_CamArtControlStyle & wxCACS_TOGGLEBUTTON) 00279 m_State = (CamArtFlags)(m_State ^ CAF_SELECTED); 00280 else 00281 m_State = (CamArtFlags)(m_State | CAF_SELECTED); 00282 ButtonClick=TRUE; 00283 } 00284 else if (event.LeftUp()) 00285 { 00286 if (!(m_CamArtControlStyle & wxCACS_TOGGLEBUTTON)) 00287 m_State = (CamArtFlags)(m_State & ~CAF_SELECTED); 00288 m_Timer.Stop(); 00289 } 00290 else if (event.Leaving()) 00291 { 00292 if (!(m_CamArtControlStyle & wxCACS_TOGGLEBUTTON)) 00293 m_State = (CamArtFlags)(m_State & ~CAF_SELECTED); 00294 m_State = (CamArtFlags)(m_State & ~CAF_BUTTONHOVER); 00295 m_Timer.Stop(); 00296 } 00297 else if (event.Entering()) 00298 { 00299 if (m_CamArtControlStyle & wxCACS_ALLOWHOVER) 00300 m_State = (CamArtFlags)(m_State | CAF_BUTTONHOVER); 00301 } 00302 m_Value=(m_State & CAF_SELECTED)?1:0; 00303 } 00304 00305 // Irritatingly wxMouseEvent does not propagate to the parent, but we expect it to. 00306 // so we have to fake it (sigh) 00307 // event.Skip(); // pretend we did not handle it, so it falls through to the dialog 00308 00309 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS) ) 00310 { 00311 wxWindow * pParent = GetParent(); 00312 if (pParent && !pParent->IsBeingDeleted()) 00313 { 00314 wxEvtHandler *pHandler = pParent->GetEventHandler(); 00315 if (pHandler && pHandler->IsKindOf(CLASSINFO(DialogEventHandler))) // Only propagate to our own dialogs 00316 { 00317 pHandler->ProcessEvent(event); 00318 } 00319 } 00320 } 00321 00322 if (m_State != OldState) 00323 { 00324 Refresh(); 00325 } 00326 00327 if (ButtonClick) 00328 { 00329 Invoke(); 00330 if (IsEnabled() && !(m_CamArtControlStyle & wxCACS_TOGGLEBUTTON) && !(m_CamArtControlStyle & wxCACS_NOAUTOREPEAT)) // Toggle buttons don't autorepeat 00331 { 00332 // We start the timer at the end, as the Op may be an INT32 one 00333 m_AREventPending = FALSE; // Just in case an event got lost in flight 00334 m_Timer.Start(m_ARDelay, TRUE); 00335 } 00336 } 00337 }
|
|
Paints the control.
Definition at line 244 of file cartctl.cpp. 00245 { 00246 wxPaintDC dc(this); 00247 00248 wxRect rect = GetClientRect(); 00249 CamArtProvider::Get()->Draw(dc, rect, GetBitmapId(), GetArtFlags(), GetLabel()); 00250 }
|
|
Handles autorepeat timer events.
Definition at line 358 of file cartctl.cpp. 00359 { 00360 m_Timer.Stop(); 00361 00362 if (!IsEnabled()) 00363 return; // Don't even send messages if the control is greyed 00364 00365 // Sadly, what can happen is that the Op can set in place a redraw, and during the redraw 00366 // the button will left. But our timer gets her first. So we have to check whether the 00367 // button is still down 00368 if (!::wxGetMouseState().LeftDown()) 00369 return; 00370 00371 if (!m_AREventPending) // don't process if another event was pending 00372 { 00373 m_AREventPending = TRUE; 00374 wxCamArtControlEvent evt(wxEVT_CAMARTCONTROL_INVOKE, GetId()); 00375 GetEventHandler()->AddPendingEvent(evt); // Send it off deferred 00376 } 00377 00378 m_Timer.Start(m_ARRepeat, FALSE); 00379 }
|
|
Definition at line 252 of file cartctl.h. 00252 {m_BitmapId=r; NewBitmap();}
|
|
Definition at line 247 of file cartctl.h. 00247 {if (label!=GetLabel()) {wxControl::SetLabel(label); Refresh(TRUE);}}
|
|
Definition at line 224 of file cartctl.h. 00224 { m_CamArtControlStyle=style; NewBitmap(); }
|
|
Definition at line 227 of file cartctl.h. 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 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|