]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/control.h
add missing header to allow ../src/common/docview.cpp to compile
[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 #include "wx/dynarray.h"
16
17 // General item class
18 class WXDLLEXPORT wxControl : public wxControlBase
19 {
20 public:
21 wxControl() { Init(); }
22
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)
28 {
29 Init();
30 Create(parent, id, pos, size, style, validator, name);
31 }
32
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);
38
39 virtual ~wxControl();
40
41 // Simulates an event
42 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
43
44 virtual bool Enable( bool enable = true );
45 virtual bool IsEnabled() const;
46
47 virtual bool Show( bool show = true );
48 virtual bool IsShown() const;
49
50 virtual void SetLabel(const wxString& label);
51 virtual wxString GetLabel();
52
53 // implementation from now on
54 // --------------------------
55
56 virtual wxVisualAttributes GetDefaultAttributes() const
57 {
58 return GetClassDefaultAttributes(GetWindowVariant());
59 }
60
61 static wxVisualAttributes
62 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
63
64 // Calls the callback and appropriate event handlers
65 bool ProcessCommand(wxCommandEvent& event);
66
67 const wxArrayLong& GetSubcontrols() const { return m_subControls; }
68
69 void OnEraseBackground(wxEraseEvent& event);
70
71 protected:
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;
76
77 // choose the default border for this window
78 virtual wxBorder GetDefaultBorder() const;
79
80 // on/off-like controls
81 void SetBoolValue(bool value);
82 bool GetBoolValue() const;
83 void SetIntValue(int val);
84
85 // native labels access
86 void SetFieldLabel(const wxString& label);
87 void SetControlLabel(const wxString& label);
88 wxString GetFieldLabel();
89 wxString GetControlLabel();
90
91 // return default best size (doesn't really make any sense, override this)
92 virtual wxSize DoGetBestSize() const;
93
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);
98
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,
106 const wxPoint& pos,
107 const wxSize& size,
108 uint8_t groupID = 0);
109 inline bool IsPalmControl() const { return m_palmControl; }
110
111 bool PalmCreateField(const wxString& label,
112 const wxPoint& pos,
113 const wxSize& size,
114 bool editable,
115 bool underlined,
116 int justification);
117 inline bool IsPalmField() const { return m_palmField; }
118
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);
125
126
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;
130
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).
137 wxString m_label;
138
139 private:
140
141 bool m_palmControl:1;
142 bool m_palmField:1;
143
144 // common part of all ctors
145 void Init();
146
147 virtual void DoGetBounds( WXRECTANGLEPTR rect ) const;
148 virtual void DoSetBounds( WXRECTANGLEPTR rect );
149
150 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl)
151 DECLARE_EVENT_TABLE()
152 };
153
154 #endif
155 // _WX_CONTROL_H_