]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/control.h
Further cleaning of the wxPalmOS radiobox code. Sending update event from slider...
[wxWidgets.git] / include / wx / palmos / control.h
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
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_CONTROL_H_
13 #define _WX_CONTROL_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "control.h"
17 #endif
18
19 #include "wx/dynarray.h"
20
21 // General item class
22 class WXDLLEXPORT wxControl : public wxControlBase
23 {
24 public:
25 wxControl() { Init(); }
26
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)
32 {
33 Init();
34 Create(parent, id, pos, size, style, validator, name);
35 }
36
37 bool Create(wxWindow *parent, wxWindowID id,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize, long style = 0,
40 const wxValidator& validator = wxDefaultValidator,
41 const wxString& name = wxControlNameStr);
42
43 virtual ~wxControl();
44
45 // Simulates an event
46 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
47
48 virtual bool Enable( bool enable = true );
49 virtual bool IsEnabled() const;
50
51 virtual bool Show( bool show = true );
52 virtual bool IsShown() const;
53
54 virtual void SetLabel(const wxString& label);
55 virtual wxString GetLabel();
56
57 // implementation from now on
58 // --------------------------
59
60 virtual wxVisualAttributes GetDefaultAttributes() const
61 {
62 return GetClassDefaultAttributes(GetWindowVariant());
63 }
64
65 static wxVisualAttributes
66 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
67
68 // Calls the callback and appropriate event handlers
69 bool ProcessCommand(wxCommandEvent& event);
70
71 const wxArrayLong& GetSubcontrols() const { return m_subControls; }
72
73 void OnEraseBackground(wxEraseEvent& event);
74
75 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
76 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
77
78 protected:
79 // regardless how deeply we are in wxWidgets hierarchy always get correct form
80 FormType* GetParentForm() const;
81 uint16_t GetObjectIndex() const;
82 void* GetObjectPtr() const;
83
84 // choose the default border for this window
85 virtual wxBorder GetDefaultBorder() const;
86
87 // on/off-like controls
88 void SetBoolValue(bool value);
89 bool GetBoolValue() const;
90 void SetIntValue(int val);
91
92 // native labels access
93 void SetFieldLabel(const wxString& label);
94 void SetControlLabel(const wxString& label);
95 wxString GetFieldLabel();
96 wxString GetControlLabel();
97
98 // return default best size (doesn't really make any sense, override this)
99 virtual wxSize DoGetBestSize() const;
100
101 // getting and setting sizes
102 virtual void DoGetPosition( int *x, int *y ) const;
103 virtual void DoGetSize( int *width, int *height ) const;
104
105 // create the control of the given ControlStyleType: this is typically called
106 // from Create() method of the derived class passing its label, pos and
107 // size parameter (style parameter is not needed because m_windowStyle is
108 // supposed to had been already set and so is used instead when this
109 // function is called)
110 bool PalmCreateControl(ControlStyleType style,
111 const wxString& label,
112 const wxPoint& pos,
113 const wxSize& size,
114 int groupID = 0);
115 inline bool IsPalmControl() const { return m_palmControl; }
116
117 bool PalmCreateField(const wxString& label,
118 const wxPoint& pos,
119 const wxSize& size,
120 bool editable,
121 bool underlined,
122 JustificationType justification);
123 inline bool IsPalmField() const { return m_palmField; }
124
125 // this is a helper for the derived class GetClassDefaultAttributes()
126 // implementation: it returns the right colours for the classes which
127 // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of
128 // being simple controls (such as wxButton, wxCheckBox, ...)
129 static wxVisualAttributes
130 GetCompositeControlsDefaultAttributes(wxWindowVariant variant);
131
132
133 // for controls like radiobuttons which are really composite this array
134 // holds the ids (not HWNDs!) of the sub controls
135 wxArrayLong m_subControls;
136
137 private:
138
139 bool m_palmControl:1;
140 bool m_palmField:1;
141
142 // common part of all ctors
143 void Init();
144
145 virtual void DoGetBounds( RectangleType &rect ) const;
146
147 // m_label stores label in case of wxButton, wxCheckBox, wxToggleButton etc.
148 // We must ensure that it persists for as long as it is being displayed
149 // (that is, for as long as the control is displayed or until we call
150 // CtlSetLabel() with a new string), and we must free the string after
151 // it is no longer in use (typically after the form containing the
152 // control is freed).
153 wxString m_label;
154
155 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl)
156 DECLARE_EVENT_TABLE()
157 };
158
159 #endif
160 // _WX_CONTROL_H_