1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/control.h
3 // Purpose: wxControl class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - native implementation
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CONTROL_H_
13 #define _WX_CONTROL_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "control.h"
19 #include "wx/dynarray.h"
22 class WXDLLEXPORT wxControl
: public wxControlBase
27 wxControl(wxWindow
*parent
, wxWindowID id
,
28 const wxPoint
& pos
= wxDefaultPosition
,
29 const wxSize
& size
= wxDefaultSize
, long style
= 0,
30 const wxValidator
& validator
= wxDefaultValidator
,
31 const wxString
& name
= wxControlNameStr
)
33 Create(parent
, id
, pos
, size
, style
, validator
, name
);
36 bool Create(wxWindow
*parent
, wxWindowID id
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
, long style
= 0,
39 const wxValidator
& validator
= wxDefaultValidator
,
40 const wxString
& name
= wxControlNameStr
);
45 virtual void Command(wxCommandEvent
& event
) { ProcessCommand(event
); }
47 virtual bool Enable( bool enable
= true );
48 virtual bool IsEnabled() const;
50 virtual bool Show( bool show
= true );
51 virtual bool IsShown() const;
53 virtual void SetLabel(const wxString
& label
);
54 virtual wxString
GetLabel();
56 // implementation from now on
57 // --------------------------
59 virtual wxVisualAttributes
GetDefaultAttributes() const
61 return GetClassDefaultAttributes(GetWindowVariant());
64 static wxVisualAttributes
65 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
67 // Calls the callback and appropriate event handlers
68 bool ProcessCommand(wxCommandEvent
& event
);
70 const wxArrayLong
& GetSubcontrols() const { return m_subControls
; }
72 void OnEraseBackground(wxEraseEvent
& event
);
74 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
75 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
78 // regardless how deeply we are in wxWidgets hierarchy always get correct form
79 FormType
* GetParentForm() const;
81 // choose the default border for this window
82 virtual wxBorder
GetDefaultBorder() const;
84 // on/off-like controls
85 void SetBoolValue(bool value
);
86 bool GetBoolValue() const;
87 void SetIntValue(int val
);
89 // return default best size (doesn't really make any sense, override this)
90 virtual wxSize
DoGetBestSize() const;
92 // getting and setting sizes
93 virtual void DoGetPosition( int *x
, int *y
) const;
94 virtual void DoGetSize( int *width
, int *height
) const;
96 // create the control of the given ControlStyleType: this is typically called
97 // from Create() method of the derived class passing its label, pos and
98 // size parameter (style parameter is not needed because m_windowStyle is
99 // supposed to had been already set and so is used instead when this
100 // function is called)
101 bool PalmCreateControl(ControlStyleType style
,
104 const wxString
& label
,
108 // this is a helper for the derived class GetClassDefaultAttributes()
109 // implementation: it returns the right colours for the classes which
110 // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of
111 // being simple controls (such as wxButton, wxCheckBox, ...)
112 static wxVisualAttributes
113 GetCompositeControlsDefaultAttributes(wxWindowVariant variant
);
116 // for controls like radiobuttons which are really composite this array
117 // holds the ids (not HWNDs!) of the sub controls
118 wxArrayLong m_subControls
;
120 ControlType
*m_control
;
124 virtual void DoGetBounds( RectangleType
&rect
) const;
126 // m_label stores label in case of wxButton, wxCheckBox, wxToggleButton etc.
127 // We must ensure that it persists for as long as it is being displayed
128 // (that is, for as long as the control is displayed or until we call
129 // CtlSetLabel() with a new string), and we must free the string after
130 // it is no longer in use (typically after the form containing the
131 // control is freed).
134 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl
)
135 DECLARE_EVENT_TABLE()