]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/control.h
moved OnExceptionInMainLoop() from wxAppConsole to wxAppBase because
[wxWidgets.git] / include / wx / msw / control.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
1ed64378 2// Name: wx/msw/control.h
2bda0e17
KB
3// Purpose: wxControl class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_CONTROL_H_
13#define _WX_CONTROL_H_
2bda0e17 14
10a0bdb1
VZ
15#include "wx/dynarray.h"
16
2bda0e17 17// General item class
8d99be5f 18class WXDLLEXPORT wxControl : public wxControlBase
2bda0e17 19{
2bda0e17 20public:
34040e31
VZ
21 wxControl() { }
22
fc7a2a60
VZ
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)
8d772832
RD
28 {
29 Create(parent, id, pos, size, style, validator, name);
30 }
31
32 bool Create(wxWindow *parent, wxWindowID id,
33 const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize, long style = 0,
8d772832 35 const wxValidator& validator = wxDefaultValidator,
8d772832
RD
36 const wxString& name = wxControlNameStr);
37
38 virtual ~wxControl();
341c92a8 39
479cd5de
VZ
40 // Simulates an event
41 virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
8d99be5f 42
34040e31 43
479cd5de
VZ
44 // implementation from now on
45 // --------------------------
2bda0e17 46
34040e31
VZ
47 virtual wxVisualAttributes GetDefaultAttributes() const
48 {
49 return GetClassDefaultAttributes(GetWindowVariant());
50 }
51
52 static wxVisualAttributes
53 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
54
479cd5de
VZ
55 // Calls the callback and appropriate event handlers
56 bool ProcessCommand(wxCommandEvent& event);
2bda0e17 57
479cd5de 58 // MSW-specific
479cd5de 59 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
2bda0e17 60
479cd5de 61 // For ownerdraw items
4bf45c9e
WS
62 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return false; };
63 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return false; };
2bda0e17 64
bf25c88b 65 const wxArrayLong& GetSubcontrols() const { return m_subControls; }
341c92a8 66
c3732409
VZ
67 // default handling of WM_CTLCOLORxxx: this is public so that wxWindow
68 // could call it
2bae4332 69 virtual WXHBRUSH MSWControlColor(WXHDC pDC, WXHWND hWnd);
c3732409 70
42e69d6b 71protected:
65bc172c
VZ
72 // choose the default border for this window
73 virtual wxBorder GetDefaultBorder() const;
479cd5de 74
d41f7b20 75 // return default best size (doesn't really make any sense, override this)
479cd5de
VZ
76 virtual wxSize DoGetBestSize() const;
77
4bf45c9e
WS
78 // This is a helper for all wxControls made with UPDOWN native control.
79 // In wxMSW it was only wxSpinCtrl derived from wxSpinButton but in
80 // WinCE of Smartphones this happens also for native wxTextCtrl,
81 // wxChoice and others.
5aaabb37 82 virtual wxSize GetBestSpinnerSize(const bool is_vertical) const;
4bf45c9e 83
6dd16e4f
VZ
84 // create the control of the given Windows class: this is typically called
85 // from Create() method of the derived class passing its label, pos and
86 // size parameter (style parameter is not needed because m_windowStyle is
87 // supposed to had been already set and so is used instead when this
88 // function is called)
5b2f31eb
VZ
89 bool MSWCreateControl(const wxChar *classname,
90 const wxString& label,
91 const wxPoint& pos,
6dd16e4f 92 const wxSize& size);
5b2f31eb
VZ
93
94 // NB: the method below is deprecated now, with MSWGetStyle() the method
95 // above should be used instead! Once all the controls are updated to
96 // implement MSWGetStyle() this version will disappear.
97 //
b225f659 98 // create the control of the given class with the given style (combination
77ffb593 99 // of WS_XXX flags, i.e. Windows style, not wxWidgets one), returns
4bf45c9e 100 // false if creation failed
479cd5de
VZ
101 //
102 // All parameters except classname and style are optional, if the
b225f659
VZ
103 // size/position are not given, they should be set later with SetSize()
104 // and, label (the title of the window), of course, is left empty. The
105 // extended style is determined from the style and the app 3D settings
106 // automatically if it's not specified explicitly.
479cd5de 107 bool MSWCreateControl(const wxChar *classname,
b225f659
VZ
108 WXDWORD style,
109 const wxPoint& pos = wxDefaultPosition,
110 const wxSize& size = wxDefaultSize,
111 const wxString& label = wxEmptyString,
2eb4c3aa 112 WXDWORD exstyle = (WXDWORD)-1);
479cd5de 113
5b2f31eb
VZ
114 // default style for the control include WS_TABSTOP if it AcceptsFocus()
115 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
4438caf4 116
a8da30af 117 // call this from the derived class MSWControlColor() if you want to show
d1a47dfe 118 // the control greyed out (and opaque)
a8da30af
VZ
119 WXHBRUSH MSWControlColorDisabled(WXHDC pDC);
120
dd12ce22
VZ
121 // common part of the 3 functions above: pass wxNullColour to use the
122 // appropriate background colour (meaning ours or our parents) or a fixed
123 // one
2bae4332 124 virtual WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd);
a8da30af 125
34040e31
VZ
126 // this is a helper for the derived class GetClassDefaultAttributes()
127 // implementation: it returns the right colours for the classes which
128 // contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of
129 // being simple controls (such as wxButton, wxCheckBox, ...)
130 static wxVisualAttributes
131 GetCompositeControlsDefaultAttributes(wxWindowVariant variant);
132
65bc172c
VZ
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
341c92a8 137private:
fc7a2a60 138 DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl)
2bda0e17
KB
139};
140
4bf45c9e 141#endif // _WX_CONTROL_H_