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_
16 #include "wx/control.h"
17 #include "wx/textctrl.h"
19 // ----------------------------------------------------------------------------
20 // wxPickerBase is the base class for the picker controls which support
21 // a wxPB_USE_TEXTCTRL style; i.e. for those pickers which can use an auxiliary
22 // text control next to the 'real' picker.
24 // The wxTextPickerHelper class manages enabled/disabled state of the text control,
25 // its sizing and positioning.
26 // ----------------------------------------------------------------------------
28 #define wxPB_USE_TEXTCTRL 0x0002
30 class WXDLLIMPEXP_CORE wxPickerBase
: public wxControl
33 // ctor: text is the associated text control
34 wxPickerBase() : m_text(NULL
), m_picker(NULL
),
35 m_margin(5), m_textProportion(2) {}
36 virtual ~wxPickerBase();
39 // if present, intercepts wxPB_USE_TEXTCTRL style and creates the text control
40 // The 3rd argument is the initial wxString to display in the text control
41 bool CreateBase(wxWindow
*parent
, wxWindowID id
,
42 const wxString
& text
= wxEmptyString
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
, long style
= 0,
45 const wxValidator
& validator
= wxDefaultValidator
,
46 const wxString
& name
= wxButtonNameStr
);
51 // margin between the text control and the picker
52 void SetInternalMargin(int newmargin
);
53 int GetInternalMargin() const { return m_margin
; }
55 // proportion of the text control respect the picker
56 // (which has a fixed proportion value of 1)
57 void SetTextCtrlProportion(int prop
) { wxASSERT(prop
>=1); m_textProportion
=prop
; }
58 int GetTextCtrlProportion() const { return m_textProportion
; }
60 bool HasTextCtrl() const
61 { return m_text
!= NULL
; }
62 wxTextCtrl
*GetTextCtrl()
64 wxControl
*GetPickerCtrl()
67 public: // wxWindow overrides
69 void DoSetSizeHints(int minW
, int minH
,
70 int maxW
= wxDefaultCoord
, int maxH
= wxDefaultCoord
,
71 int incW
= wxDefaultCoord
, int incH
= wxDefaultCoord
);
73 void DoSetSize(int x
, int y
,
74 int width
, int height
,
75 int sizeFlags
= wxSIZE_AUTO
);
77 wxSize
DoGetBestSize() const;
80 public: // methods that derived class must/may override
82 virtual void UpdatePickerFromTextCtrl() = 0;
83 virtual void UpdateTextCtrlFromPicker() = 0;
85 protected: // utility functions
87 inline int GetTextCtrlWidth(int given
);
90 void OnTextCtrlDelete(wxWindowDestroyEvent
&);
91 void OnTextCtrlUpdate(wxCommandEvent
&);
92 void OnTextCtrlKillFocus(wxFocusEvent
&);
94 // returns the set of styles for the attached wxTextCtrl
95 // from given wxPickerBase's styles
96 virtual long GetTextCtrlStyle(long style
) const
97 { return (style
& wxWINDOW_STYLE_MASK
); }
99 // returns the set of styles for the m_picker
100 virtual long GetPickerStyle(long style
) const
101 { return (style
& wxWINDOW_STYLE_MASK
); }
104 wxTextCtrl
*m_text
; // can be NULL
107 int m_margin
; // distance between subcontrols
108 int m_textProportion
; // proportion between textctrl and other item
111 DECLARE_ABSTRACT_CLASS(wxPickerBase
)
116 // _WX_PICKERBASE_H_BASE_