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 #include "wx/dynarray.h"
18 class WXDLLIMPEXP_CORE wxControl
: public wxControlBase
21 wxControl() { Init(); }
23 wxControl(wxWindow
*parent
, wxWindowID id
,
24 const wxPoint
& pos
= wxDefaultPosition
,
25 const wxSize
& size
= wxDefaultSize
, long style
= 0,
26 const wxValidator
& validator
= wxDefaultValidator
,
27 const wxString
& name
= wxControlNameStr
)
30 Create(parent
, id
, pos
, size
, style
, validator
, name
);
33 bool Create(wxWindow
*parent
, wxWindowID id
,
34 const wxPoint
& pos
= wxDefaultPosition
,
35 const wxSize
& size
= wxDefaultSize
, long style
= 0,
36 const wxValidator
& validator
= wxDefaultValidator
,
37 const wxString
& name
= wxControlNameStr
);
42 virtual void Command(wxCommandEvent
& event
) { ProcessCommand(event
); }
44 virtual bool Enable( bool enable
= true );
45 virtual bool IsEnabled() const;
47 virtual bool Show( bool show
= true );
48 virtual bool IsShown() const;
50 virtual void SetLabel(const wxString
& label
);
51 //virtual wxString GetLabel();
53 // implementation from now on
54 // --------------------------
56 virtual wxVisualAttributes
GetDefaultAttributes() const
58 return GetClassDefaultAttributes(GetWindowVariant());
61 static wxVisualAttributes
62 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
64 // Calls the callback and appropriate event handlers
65 bool ProcessCommand(wxCommandEvent
& event
);
67 const wxArrayLong
& GetSubcontrols() const { return m_subControls
; }
69 void OnEraseBackground(wxEraseEvent
& event
);
72 // regardless how deeply we are in wxWidgets hierarchy always get correct form
73 WXFORMPTR
GetParentForm() const;
74 WXFORMPTR
GetObjectFormIndex(uint16_t& index
) const;
75 void* GetObjectPtr() const;
77 // choose the default border for this window
78 virtual wxBorder
GetDefaultBorder() const;
80 // on/off-like controls
81 void SetBoolValue(bool value
);
82 bool GetBoolValue() const;
83 void SetIntValue(int val
);
85 // native labels access
86 void SetFieldLabel(const wxString
& label
);
87 void SetControlLabel(const wxString
& label
);
88 wxString
GetFieldLabel();
89 wxString
GetControlLabel();
91 // return default best size (doesn't really make any sense, override this)
92 virtual wxSize
DoGetBestSize() const;
94 // getting and setting sizes
95 virtual void DoGetPosition( int *x
, int *y
) const;
96 virtual void DoGetSize( int *width
, int *height
) const;
97 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
99 // create the control of the given ControlStyleType: this is typically called
100 // from Create() method of the derived class passing its label, pos and
101 // size parameter (style parameter is not needed because m_windowStyle is
102 // supposed to had been already set and so is used instead when this
103 // function is called)
104 bool PalmCreateControl(int palmStyle
,
105 const wxString
& label
,
108 uint8_t groupID
= 0);
109 inline bool IsPalmControl() const { return m_palmControl
; }
111 bool PalmCreateField(const wxString
& label
,
117 inline bool IsPalmField() const { return m_palmField
; }
119 // this is a helper for the derived class GetClassDefaultAttributes()
120 // implementation: it returns the right colours for the classes which
121 // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of
122 // being simple controls (such as wxButton, wxCheckBox, ...)
123 static wxVisualAttributes
124 GetCompositeControlsDefaultAttributes(wxWindowVariant variant
);
127 // for controls like radiobuttons which are really composite this array
128 // holds the ids (not HWNDs!) of the sub controls
129 wxArrayLong m_subControls
;
131 // m_label stores label in case of wxButton, wxCheckBox, wxToggleButton etc.
132 // We must ensure that it persists for as long as it is being displayed
133 // (that is, for as long as the control is displayed or until we call
134 // CtlSetLabel() with a new string), and we must free the string after
135 // it is no longer in use (typically after the form containing the
136 // control is freed).
141 bool m_palmControl
:1;
144 // common part of all ctors
147 virtual void DoGetBounds( WXRECTANGLEPTR rect
) const;
148 virtual void DoSetBounds( WXRECTANGLEPTR rect
);
150 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl
)
151 DECLARE_EVENT_TABLE()