]> git.saurik.com Git - wxWidgets.git/blame - include/wx/palmos/control.h
added Unicode-friendly wxSTRINGIZE_T()
[wxWidgets.git] / include / wx / palmos / control.h
CommitLineData
ffecfa5a 1/////////////////////////////////////////////////////////////////////////////
e1d63b79 2// Name: wx/palmos/control.h
ffecfa5a 3// Purpose: wxControl class
e1d63b79 4// Author: William Osborne - minimal working wxPalmOS port
bdb54365 5// Modified by: Wlodzimierz ABX Skiba - native implementation
ffecfa5a 6// Created: 10/13/04
e1d63b79 7// RCS-ID: $Id$
bdb54365 8// Copyright: (c) William Osborne, Wlodzimierz Skiba
ffecfa5a
JS
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CONTROL_H_
13#define _WX_CONTROL_H_
14
ffecfa5a
JS
15#include "wx/dynarray.h"
16
17// General item class
18class WXDLLEXPORT wxControl : public wxControlBase
19{
20public:
a152561c 21 wxControl() { Init(); }
ffecfa5a
JS
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 {
a152561c 29 Init();
ffecfa5a
JS
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
db101bd3
WS
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;
ffecfa5a 49
bdb54365
WS
50 virtual void SetLabel(const wxString& label);
51 virtual wxString GetLabel();
52
ffecfa5a
JS
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
ffecfa5a
JS
67 const wxArrayLong& GetSubcontrols() const { return m_subControls; }
68
69 void OnEraseBackground(wxEraseEvent& event);
70
ffecfa5a 71protected:
ba889513 72 // regardless how deeply we are in wxWidgets hierarchy always get correct form
20bc5ad8
WS
73 WXFORMPTR GetParentForm() const;
74 WXFORMPTR GetObjectFormIndex(uint16_t& index) const;
a152561c 75 void* GetObjectPtr() const;
ba889513 76
ffecfa5a
JS
77 // choose the default border for this window
78 virtual wxBorder GetDefaultBorder() const;
79
ba889513
WS
80 // on/off-like controls
81 void SetBoolValue(bool value);
82 bool GetBoolValue() const;
83 void SetIntValue(int val);
84
a152561c
WS
85 // native labels access
86 void SetFieldLabel(const wxString& label);
87 void SetControlLabel(const wxString& label);
88 wxString GetFieldLabel();
89 wxString GetControlLabel();
90
ffecfa5a
JS
91 // return default best size (doesn't really make any sense, override this)
92 virtual wxSize DoGetBestSize() const;
93
808e3bce
WS
94 // getting and setting sizes
95 virtual void DoGetPosition( int *x, int *y ) const;
96 virtual void DoGetSize( int *width, int *height ) const;
324eeecb 97 virtual void DoMoveWindow(int x, int y, int width, int height);
808e3bce 98
db101bd3 99 // create the control of the given ControlStyleType: this is typically called
ffecfa5a
JS
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)
20bc5ad8 104 bool PalmCreateControl(int palmStyle,
db101bd3
WS
105 const wxString& label,
106 const wxPoint& pos,
a152561c 107 const wxSize& size,
8be10866 108 uint8_t groupID = 0);
a152561c
WS
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,
20bc5ad8 116 int justification);
a152561c 117 inline bool IsPalmField() const { return m_palmField; }
ffecfa5a
JS
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
11f4a344
WS
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
ffecfa5a 139private:
ba889513 140
a152561c
WS
141 bool m_palmControl:1;
142 bool m_palmField:1;
143
144 // common part of all ctors
145 void Init();
146
20bc5ad8
WS
147 virtual void DoGetBounds( WXRECTANGLEPTR rect ) const;
148 virtual void DoSetBounds( WXRECTANGLEPTR rect );
808e3bce 149
ffecfa5a
JS
150 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl)
151 DECLARE_EVENT_TABLE()
152};
153
154#endif
155 // _WX_CONTROL_H_