1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/pickerbase.h
3 // Purpose: wxPickerBase definition
4 // Author: Francesco Montorsi (based on Vadim Zeitlin's code)
7 // Copyright: (c) Vadim Zeitlin, Francesco Montorsi
9 // Licence: wxWindows Licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PICKERBASE_H_BASE_
13 #define _WX_PICKERBASE_H_BASE_
15 #include "wx/control.h"
17 class WXDLLIMPEXP_CORE wxTextCtrl
;
19 extern WXDLLEXPORT_DATA(const wxChar
) wxButtonNameStr
[];
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.
26 // The wxTextPickerHelper class manages enabled/disabled state of the text control,
27 // its sizing and positioning.
28 // ----------------------------------------------------------------------------
30 #define wxPB_USE_TEXTCTRL 0x0002
32 class WXDLLIMPEXP_CORE wxPickerBase
: public wxControl
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();
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
);
53 // margin between the text control and the picker
54 void SetInternalMargin(int newmargin
);
55 int GetInternalMargin() const { return m_margin
; }
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
; }
62 bool HasTextCtrl() const
63 { return m_text
!= NULL
; }
64 wxTextCtrl
*GetTextCtrl()
66 wxControl
*GetPickerCtrl()
69 public: // wxWindow overrides
71 void DoSetSizeHints(int minW
, int minH
,
72 int maxW
= wxDefaultCoord
, int maxH
= wxDefaultCoord
,
73 int incW
= wxDefaultCoord
, int incH
= wxDefaultCoord
);
76 void DoSetSize(int x
, int y
,
77 int width
, int height
,
78 int sizeFlags
= wxSIZE_AUTO
);
80 wxSize
DoGetBestSize() const;
83 public: // methods that derived class must/may override
85 virtual void UpdatePickerFromTextCtrl() = 0;
86 virtual void UpdateTextCtrlFromPicker() = 0;
88 protected: // utility functions
90 inline int GetTextCtrlWidth(int given
);
93 void OnTextCtrlDelete(wxWindowDestroyEvent
&);
94 void OnTextCtrlUpdate(wxCommandEvent
&);
95 void OnTextCtrlKillFocus(wxFocusEvent
&);
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
); }
102 // returns the set of styles for the m_picker
103 virtual long GetPickerStyle(long style
) const
104 { return (style
& wxWINDOW_STYLE_MASK
); }
107 wxTextCtrl
*m_text
; // can be NULL
110 int m_margin
; // distance between subcontrols
111 int m_textProportion
; // proportion between textctrl and other item
114 DECLARE_ABSTRACT_CLASS(wxPickerBase
)
119 // _WX_PICKERBASE_H_BASE_