]> git.saurik.com Git - wxWidgets.git/blob - include/wx/pickerbase.h
remove duplicate m_popupInterface (patch 1509424)
[wxWidgets.git] / include / wx / pickerbase.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/pickerbase.h
3 // Purpose: wxPickerBase definition
4 // Author: Francesco Montorsi (based on Vadim Zeitlin's code)
5 // Modified by:
6 // Created: 14/4/2006
7 // Copyright: (c) Vadim Zeitlin, Francesco Montorsi
8 // RCS-ID: $Id$
9 // Licence: wxWindows Licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PICKERBASE_H_BASE_
13 #define _WX_PICKERBASE_H_BASE_
14
15 #include "wx/control.h"
16
17 class WXDLLIMPEXP_CORE wxTextCtrl;
18
19 extern WXDLLEXPORT_DATA(const wxChar) wxButtonNameStr[];
20
21 // ----------------------------------------------------------------------------
22 // wxPickerBase is the base class for the picker controls which support
23 // a wxPB_USE_TEXTCTRL style; i.e. for those pickers which can use an auxiliary
24 // text control next to the 'real' picker.
25 //
26 // The wxTextPickerHelper class manages enabled/disabled state of the text control,
27 // its sizing and positioning.
28 // ----------------------------------------------------------------------------
29
30 #define wxPB_USE_TEXTCTRL 0x0002
31
32 class WXDLLIMPEXP_CORE wxPickerBase : public wxControl
33 {
34 public:
35 // ctor: text is the associated text control
36 wxPickerBase() : m_text(NULL), m_picker(NULL),
37 m_margin(5), m_textProportion(2) {}
38 virtual ~wxPickerBase();
39
40
41 // if present, intercepts wxPB_USE_TEXTCTRL style and creates the text control
42 // The 3rd argument is the initial wxString to display in the text control
43 bool CreateBase(wxWindow *parent, wxWindowID id,
44 const wxString& text = wxEmptyString,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize, long style = 0,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxButtonNameStr);
49
50
51 public: // public API
52
53 // margin between the text control and the picker
54 void SetInternalMargin(int newmargin);
55 int GetInternalMargin() const { return m_margin; }
56
57 // proportion of the text control respect the picker
58 // (which has a fixed proportion value of 1)
59 void SetTextCtrlProportion(int prop) { wxASSERT(prop>=1); m_textProportion=prop; }
60 int GetTextCtrlProportion() const { return m_textProportion; }
61
62 bool HasTextCtrl() const
63 { return m_text != NULL; }
64 wxTextCtrl *GetTextCtrl()
65 { return m_text; }
66 wxControl *GetPickerCtrl()
67 { return m_picker; }
68
69 public: // wxWindow overrides
70
71 void DoSetSizeHints(int minW, int minH,
72 int maxW = wxDefaultCoord, int maxH = wxDefaultCoord,
73 int incW = wxDefaultCoord, int incH = wxDefaultCoord );
74
75 protected:
76 void DoSetSize(int x, int y,
77 int width, int height,
78 int sizeFlags = wxSIZE_AUTO);
79
80 wxSize DoGetBestSize() const;
81
82
83 public: // methods that derived class must/may override
84
85 virtual void UpdatePickerFromTextCtrl() = 0;
86 virtual void UpdateTextCtrlFromPicker() = 0;
87
88 protected: // utility functions
89
90 inline int GetTextCtrlWidth(int given);
91
92 // event handlers
93 void OnTextCtrlDelete(wxWindowDestroyEvent &);
94 void OnTextCtrlUpdate(wxCommandEvent &);
95 void OnTextCtrlKillFocus(wxFocusEvent &);
96
97 // returns the set of styles for the attached wxTextCtrl
98 // from given wxPickerBase's styles
99 virtual long GetTextCtrlStyle(long style) const
100 { return (style & wxWINDOW_STYLE_MASK); }
101
102 // returns the set of styles for the m_picker
103 virtual long GetPickerStyle(long style) const
104 { return (style & wxWINDOW_STYLE_MASK); }
105
106 protected:
107 wxTextCtrl *m_text; // can be NULL
108 wxControl *m_picker;
109
110 int m_margin; // distance between subcontrols
111 int m_textProportion; // proportion between textctrl and other item
112
113 private:
114 DECLARE_ABSTRACT_CLASS(wxPickerBase)
115 };
116
117
118 #endif
119 // _WX_PICKERBASE_H_BASE_