]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: control.h | |
3 | // Purpose: wxControl class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
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 | #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(); | |
26 | wxControl(wxWindow *parent, wxWindowID id, | |
27 | const wxPoint& pos = wxDefaultPosition, | |
28 | const wxSize& size = wxDefaultSize, long style = 0, | |
29 | const wxValidator& validator = wxDefaultValidator, | |
30 | const wxString& name = wxControlNameStr) | |
31 | { | |
32 | Create(parent, id, pos, size, style, validator, name); | |
33 | } | |
34 | ||
35 | bool Create(wxWindow *parent, wxWindowID id, | |
36 | const wxPoint& pos = wxDefaultPosition, | |
37 | const wxSize& size = wxDefaultSize, long style = 0, | |
38 | const wxValidator& validator = wxDefaultValidator, | |
39 | const wxString& name = wxControlNameStr); | |
40 | ||
41 | virtual ~wxControl(); | |
42 | ||
43 | // Simulates an event | |
44 | virtual void Command(wxCommandEvent& event) { ProcessCommand(event); } | |
45 | ||
46 | // implementation from now on | |
47 | // -------------------------- | |
48 | ||
49 | // Calls the callback and appropriate event handlers | |
50 | bool ProcessCommand(wxCommandEvent& event); | |
51 | ||
52 | // MSW-specific | |
53 | #ifdef __WIN95__ | |
54 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); | |
55 | #endif // Win95 | |
56 | ||
57 | // For ownerdraw items | |
58 | virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; | |
59 | virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; | |
60 | ||
61 | const wxArrayLong& GetSubcontrols() const { return m_subControls; } | |
62 | ||
63 | void OnEraseBackground(wxEraseEvent& event); | |
64 | ||
65 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, | |
66 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); | |
67 | ||
68 | protected: | |
69 | // choose the default border for this window | |
70 | virtual wxBorder GetDefaultBorder() const; | |
71 | ||
72 | // return default best size (doesn't really make any sense, override this) | |
73 | virtual wxSize DoGetBestSize() const; | |
74 | ||
75 | // create the control of the given Windows class: this is typically called | |
76 | // from Create() method of the derived class passing its label, pos and | |
77 | // size parameter (style parameter is not needed because m_windowStyle is | |
78 | // supposed to had been already set and so is used instead when this | |
79 | // function is called) | |
80 | bool MSWCreateControl(const wxChar *classname, | |
81 | const wxString& label, | |
82 | const wxPoint& pos, | |
83 | const wxSize& size); | |
84 | ||
85 | // NB: the method below is deprecated now, with MSWGetStyle() the method | |
86 | // above should be used instead! Once all the controls are updated to | |
87 | // implement MSWGetStyle() this version will disappear. | |
88 | // | |
89 | // create the control of the given class with the given style (combination | |
90 | // of WS_XXX flags, i.e. Windows style, not wxWindows one), returns | |
91 | // FALSE if creation failed | |
92 | // | |
93 | // All parameters except classname and style are optional, if the | |
94 | // size/position are not given, they should be set later with SetSize() | |
95 | // and, label (the title of the window), of course, is left empty. The | |
96 | // extended style is determined from the style and the app 3D settings | |
97 | // automatically if it's not specified explicitly. | |
98 | bool MSWCreateControl(const wxChar *classname, | |
99 | WXDWORD style, | |
100 | const wxPoint& pos = wxDefaultPosition, | |
101 | const wxSize& size = wxDefaultSize, | |
102 | const wxString& label = wxEmptyString, | |
103 | WXDWORD exstyle = (WXDWORD)-1); | |
104 | ||
105 | // default style for the control include WS_TABSTOP if it AcceptsFocus() | |
106 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; | |
107 | ||
108 | // for controls like radiobuttons which are really composite this array | |
109 | // holds the ids (not HWNDs!) of the sub controls | |
110 | wxArrayLong m_subControls; | |
111 | ||
112 | private: | |
113 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl) | |
114 | DECLARE_EVENT_TABLE() | |
115 | }; | |
116 | ||
117 | #endif | |
118 | // _WX_CONTROL_H_ |