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