]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/control.h
applied patch 103575 (more efficient wxString comparison)
[wxWidgets.git] / include / wx / os2 / control.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: control.h
3 // Purpose: wxControl class
4 // Author: David Webster
5 // Modified by:
6 // Created: 09/17/99
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_CONTROL_H_
13 #define _WX_CONTROL_H_
14
15 #include "wx/dynarray.h"
16
17 WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr;
18
19 // General item class
20 class WXDLLEXPORT wxControl : public wxControlBase
21 {
22 DECLARE_ABSTRACT_CLASS(wxControl)
23
24 public:
25 wxControl();
26 wxControl(wxWindow *parent,
27 wxWindowID id,
28 const wxPoint& pos = wxDefaultPosition,
29 const wxSize& size = wxDefaultSize,
30 long style = 0,
31 #if wxUSE_VALIDATORS
32 const wxValidator& validator = wxDefaultValidator,
33 #endif
34 const wxString& name = wxControlNameStr)
35 {
36 Create(parent, id, pos, size, style, validator, name);
37 }
38
39 bool Create(wxWindow *parent, wxWindowID id,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize, long style = 0,
42 #if wxUSE_VALIDATORS
43 const wxValidator& validator = wxDefaultValidator,
44 #endif
45 const wxString& name = wxControlNameStr);
46 virtual ~wxControl();
47
48 // Simulates an event
49 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
50
51 // implementation from now on
52 // --------------------------
53
54 // Calls the callback and appropriate event handlers
55 bool ProcessCommand(wxCommandEvent& event);
56
57 // OS2-specific
58 virtual bool OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
59
60 // For ownerdraw items
61 virtual bool OS2OnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
62 virtual bool OS2OnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
63
64 wxArrayLong& GetSubcontrols() { return m_subControls; }
65
66 void OnEraseBackground(wxEraseEvent& event);
67
68 #if WXWIN_COMPATIBILITY
69 virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
70 wxColour* GetButtonColour() const { return NULL; }
71
72 inline virtual void SetLabelFont(const wxFont& font);
73 inline virtual void SetButtonFont(const wxFont& font);
74 inline wxFont& GetLabelFont() const;
75 inline wxFont& GetButtonFont() const;
76
77 // Adds callback
78 inline void Callback(const wxFunction function);
79
80 wxFunction GetCallback() { return m_callback; }
81
82 protected:
83 wxFunction m_callback; // Callback associated with the window
84 #endif // WXWIN_COMPATIBILITY
85
86 protected:
87 // For controls like radiobuttons which are really composite
88 wxArrayLong m_subControls;
89
90 virtual wxSize DoGetBestSize() const;
91
92 // create the control of the given class with the given style, returns FALSE
93 // if creation failed
94 bool OS2CreateControl(const wxChar *classname, WXDWORD style,
95 const wxPoint& pos = wxDefaultPosition,
96 const wxSize& size = wxDefaultSize,
97 const wxString& label = wxEmptyString,
98 WXDWORD exstyle = (WXDWORD)-1);
99
100 // determine the extended styles combination for this window (may slightly
101 // modify styl parameter)
102 WXDWORD GetExStyle(WXDWORD& style) const;
103
104 private:
105 DECLARE_EVENT_TABLE()
106 };
107
108
109 #if WXWIN_COMPATIBILITY
110 inline void wxControl::Callback(const wxFunction f) { m_callback = f; };
111 inline wxFont& wxControl::GetLabelFont() const { return GetFont(); }
112 inline wxFont& wxControl::GetButtonFont() const { return GetFont(); }
113 inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
114 inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
115 #endif // WXWIN_COMPATIBILITY
116
117 #endif
118 // _WX_CONTROL_H_