2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: combo.h
|
2008-04-09 22:57:09 -04:00
|
|
|
// Purpose: interface of wxComboCtrl and wxComboPopup
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-05 17:26:42 -04:00
|
|
|
//
|
|
|
|
// New window styles for wxComboCtrlBase
|
|
|
|
//
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
// Double-clicking a read-only combo triggers call to popup's OnComboPopup.
|
|
|
|
// In wxOwnerDrawnComboBox, for instance, it cycles item.
|
|
|
|
wxCC_SPECIAL_DCLICK = 0x0100,
|
|
|
|
|
|
|
|
// Dropbutton acts like standard push button.
|
|
|
|
wxCC_STD_BUTTON = 0x0200
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxComboPopup
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
In order to use a custom popup with wxComboCtrl, an interface class must be
|
|
|
|
derived from wxComboPopup.
|
2008-03-28 12:19:12 -04:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
For more information on how to use it, see @ref comboctrl_custompopup.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-04-09 22:57:09 -04:00
|
|
|
@category{ctrl}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxComboCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxComboPopup
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Default constructor. It is recommended that internal variables are
|
|
|
|
prepared in Init() instead (because m_combo is not valid in
|
|
|
|
constructor).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxComboPopup();
|
|
|
|
|
|
|
|
/**
|
|
|
|
The derived class must implement this to create the popup control.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the call succeeded, @false otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
virtual bool Create(wxWindow* parent) = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2011-03-31 13:22:51 -04:00
|
|
|
/**
|
|
|
|
You only need to implement this member function if you create
|
|
|
|
your popup class in non-standard way. The default implementation can
|
|
|
|
handle both multiple-inherited popup control (as seen in wxComboCtrl
|
|
|
|
samples) and one allocated separately in heap.
|
2011-04-12 05:35:04 -04:00
|
|
|
|
|
|
|
If you do completely re-implement this function, make sure it calls
|
|
|
|
Destroy() for the popup control and also deletes @a this object
|
|
|
|
(usually as the last thing).
|
2011-03-31 13:22:51 -04:00
|
|
|
*/
|
|
|
|
virtual void DestroyPopup();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Utility function that hides the popup.
|
|
|
|
*/
|
|
|
|
void Dismiss();
|
|
|
|
|
2010-12-20 08:51:24 -05:00
|
|
|
/**
|
|
|
|
Implement to customize matching of value string to an item container
|
|
|
|
entry.
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2010-12-20 08:51:24 -05:00
|
|
|
@param item
|
|
|
|
String entered, usually by user or from SetValue() call.
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2010-12-20 08:51:24 -05:00
|
|
|
@param trueItem
|
|
|
|
When item matches an entry, but the entry's string representation
|
|
|
|
is not exactly the same (case mismatch, for example), then the
|
|
|
|
true item string should be written back to here, if it is not
|
|
|
|
a NULL pointer.
|
|
|
|
|
|
|
|
@remarks
|
|
|
|
Default implementation always return true and does not alter
|
|
|
|
trueItem.
|
|
|
|
*/
|
|
|
|
virtual bool FindItem(const wxString& item, wxString* trueItem=NULL);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class may implement this to return adjusted size for the
|
|
|
|
popup control, according to the variables given.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param minWidth
|
2008-03-09 08:33:59 -04:00
|
|
|
Preferred minimum width.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param prefHeight
|
2008-04-09 22:57:09 -04:00
|
|
|
Preferred height. May be -1 to indicate no preference.
|
2008-08-30 19:58:45 -04:00
|
|
|
@param maxHeight
|
2008-04-09 22:57:09 -04:00
|
|
|
Max height for window, as limited by screen size.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
@remarks This function is called each time popup is about to be shown.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2009-02-22 10:13:29 -05:00
|
|
|
/**
|
|
|
|
Returns pointer to the associated parent wxComboCtrl.
|
|
|
|
*/
|
|
|
|
wxComboCtrl* GetComboCtrl() const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class must implement this to return pointer to the
|
|
|
|
associated control created in Create().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
virtual wxWindow* GetControl() = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class must implement this to return string representation
|
|
|
|
of the value.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
virtual wxString GetStringValue() const = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class must implement this to initialize its internal
|
|
|
|
variables. This method is called immediately after construction
|
|
|
|
finishes. m_combo member variable has been initialized before the call.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void Init();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Utility method that returns @true if Create has been called.
|
2008-04-09 22:57:09 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Useful in conjunction with LazyCreate().
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsCreated() const;
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class may implement this to return @true if it wants to
|
|
|
|
delay call to Create() until the popup is shown for the first time. It
|
|
|
|
is more efficient, but on the other hand it is often more convenient to
|
|
|
|
have the control created immediately.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks Base implementation returns @false.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual bool LazyCreate();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class may implement this to do something when the parent
|
|
|
|
wxComboCtrl gets double-clicked.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void OnComboDoubleClick();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class may implement this to receive key events from the
|
|
|
|
parent wxComboCtrl.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Events not handled should be skipped, as usual.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void OnComboKeyEvent(wxKeyEvent& event);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class may implement this to do special processing when
|
|
|
|
popup is hidden.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void OnDismiss();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class may implement this to do special processing when
|
|
|
|
popup is shown.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void OnPopup();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class may implement this to paint the parent wxComboCtrl.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Default implementation draws value as string.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void PaintComboControl(wxDC& dc, const wxRect& rect);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
The derived class must implement this to receive string value changes
|
|
|
|
from wxComboCtrl.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void SetStringValue(const wxString& value);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2009-02-22 03:51:11 -05:00
|
|
|
protected:
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2009-02-22 03:51:11 -05:00
|
|
|
Parent wxComboCtrl. This member variable is prepared automatically
|
|
|
|
before Init() is called.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-02-22 03:51:11 -05:00
|
|
|
wxComboCtrl* m_combo;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
/**
|
|
|
|
Features enabled for wxComboCtrl.
|
|
|
|
|
|
|
|
@see wxComboCtrl::GetFeatures()
|
|
|
|
*/
|
|
|
|
struct wxComboCtrlFeatures
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MovableButton = 0x0001, ///< Button can be on either side of control.
|
|
|
|
BitmapButton = 0x0002, ///< Button may be replaced with bitmap.
|
|
|
|
ButtonSpacing = 0x0004, ///< Button can have spacing from the edge
|
|
|
|
///< of the control.
|
2009-09-05 08:39:12 -04:00
|
|
|
TextIndent = 0x0008, ///< wxComboCtrl::SetMargins() can be used.
|
2008-04-09 22:57:09 -04:00
|
|
|
PaintControl = 0x0010, ///< Combo control itself can be custom painted.
|
|
|
|
PaintWritable = 0x0020, ///< A variable-width area in front of writable
|
|
|
|
///< combo control's textctrl can be custom
|
|
|
|
///< painted.
|
|
|
|
Borderless = 0x0040, ///< wxNO_BORDER window style works.
|
|
|
|
|
|
|
|
All = MovableButton | BitmapButton | ButtonSpacing |
|
|
|
|
TextIndent | PaintControl | PaintWritable |
|
|
|
|
Borderless ///< All features.
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxComboCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
A combo control is a generic combobox that allows totally custom popup. In
|
|
|
|
addition it has other customization features. For instance, position and
|
|
|
|
size of the dropdown button can be changed.
|
2008-03-28 12:19:12 -04:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
@section comboctrl_custompopup Setting Custom Popup for wxComboCtrl
|
2008-03-28 12:19:12 -04:00
|
|
|
|
|
|
|
wxComboCtrl needs to be told somehow which control to use and this is done
|
2008-04-09 22:57:09 -04:00
|
|
|
by SetPopupControl(). However, we need something more than just a wxControl
|
|
|
|
in this method as, for example, we need to call
|
|
|
|
SetStringValue("initial text value") and wxControl doesn't have such
|
|
|
|
method. So we also need a wxComboPopup which is an interface which must be
|
|
|
|
implemented by a control to be usable as a popup.
|
2008-03-28 12:19:12 -04:00
|
|
|
|
|
|
|
We couldn't derive wxComboPopup from wxControl as this would make it
|
|
|
|
impossible to have a class deriving from a wxWidgets control and from it,
|
|
|
|
so instead it is just a mix-in.
|
|
|
|
|
|
|
|
Here's a minimal sample of wxListView popup:
|
|
|
|
|
|
|
|
@code
|
|
|
|
#include <wx/combo.h>
|
|
|
|
#include <wx/listctrl.h>
|
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
class wxListViewComboPopup : public wxListView, public wxComboPopup
|
2008-03-28 12:19:12 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Initialize member variables
|
|
|
|
virtual void Init()
|
|
|
|
{
|
|
|
|
m_value = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create popup control
|
|
|
|
virtual bool Create(wxWindow* parent)
|
|
|
|
{
|
|
|
|
return wxListView::Create(parent,1,wxPoint(0,0),wxDefaultSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return pointer to the created control
|
|
|
|
virtual wxWindow *GetControl() { return this; }
|
|
|
|
|
|
|
|
// Translate string into a list selection
|
|
|
|
virtual void SetStringValue(const wxString& s)
|
|
|
|
{
|
|
|
|
int n = wxListView::FindItem(-1,s);
|
|
|
|
if ( n >= 0 && n < wxListView::GetItemCount() )
|
|
|
|
wxListView::Select(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get list selection as a string
|
|
|
|
virtual wxString GetStringValue() const
|
|
|
|
{
|
|
|
|
if ( m_value >= 0 )
|
2008-04-09 22:57:09 -04:00
|
|
|
return wxListView::GetItemText(m_value);
|
2008-03-28 12:19:12 -04:00
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do mouse hot-tracking (which is typical in list popups)
|
|
|
|
void OnMouseMove(wxMouseEvent& event)
|
|
|
|
{
|
|
|
|
// TODO: Move selection to cursor
|
|
|
|
}
|
|
|
|
|
|
|
|
// On mouse left up, set the value and close the popup
|
|
|
|
void OnMouseClick(wxMouseEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
m_value = wxListView::GetFirstSelected();
|
|
|
|
|
|
|
|
// TODO: Send event as well
|
|
|
|
|
|
|
|
Dismiss();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2008-04-09 22:57:09 -04:00
|
|
|
|
|
|
|
int m_value; // current item index
|
2008-03-28 12:19:12 -04:00
|
|
|
|
|
|
|
private:
|
2010-06-09 10:28:08 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2008-03-28 12:19:12 -04:00
|
|
|
};
|
|
|
|
|
2010-06-09 10:28:08 -04:00
|
|
|
wxBEGIN_EVENT_TABLE(wxListViewComboPopup, wxListView)
|
2008-03-28 12:19:12 -04:00
|
|
|
EVT_MOTION(wxListViewComboPopup::OnMouseMove)
|
|
|
|
EVT_LEFT_UP(wxListViewComboPopup::OnMouseClick)
|
2010-06-09 10:28:08 -04:00
|
|
|
wxEND_EVENT_TABLE()
|
2008-03-28 12:19:12 -04:00
|
|
|
@endcode
|
|
|
|
|
|
|
|
Here's how you would create and populate it in a dialog constructor:
|
|
|
|
|
|
|
|
@code
|
2008-04-09 22:57:09 -04:00
|
|
|
wxComboCtrl* comboCtrl = new wxComboCtrl(this, wxID_ANY, wxEmptyString);
|
2008-03-28 12:19:12 -04:00
|
|
|
|
|
|
|
wxListViewComboPopup* popupCtrl = new wxListViewComboPopup();
|
|
|
|
|
2009-02-04 12:54:31 -05:00
|
|
|
// It is important to call SetPopupControl() as soon as possible
|
2008-03-28 12:19:12 -04:00
|
|
|
comboCtrl->SetPopupControl(popupCtrl);
|
|
|
|
|
|
|
|
// Populate using wxListView methods
|
2008-04-09 22:57:09 -04:00
|
|
|
popupCtrl->InsertItem(popupCtrl->GetItemCount(), "First Item");
|
|
|
|
popupCtrl->InsertItem(popupCtrl->GetItemCount(), "Second Item");
|
|
|
|
popupCtrl->InsertItem(popupCtrl->GetItemCount(), "Third Item");
|
2008-03-28 12:19:12 -04:00
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCB_READONLY}
|
2008-03-08 08:52:38 -05:00
|
|
|
Text will not be editable.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCB_SORT}
|
2008-03-08 08:52:38 -05:00
|
|
|
Sorts the entries in the list alphabetically.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxTE_PROCESS_ENTER}
|
2013-04-25 06:11:03 -04:00
|
|
|
The control will generate the event @c wxEVT_TEXT_ENTER
|
2008-03-08 08:52:38 -05:00
|
|
|
(otherwise pressing Enter key is either processed internally by the
|
|
|
|
control or used for navigation between dialog controls). Windows
|
|
|
|
only.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCC_SPECIAL_DCLICK}
|
2008-03-08 08:52:38 -05:00
|
|
|
Double-clicking triggers a call to popup's OnComboDoubleClick.
|
|
|
|
Actual behaviour is defined by a derived class. For instance,
|
|
|
|
wxOwnerDrawnComboBox will cycle an item. This style only applies if
|
|
|
|
wxCB_READONLY is used as well.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCC_STD_BUTTON}
|
2008-03-08 08:52:38 -05:00
|
|
|
Drop button will behave more like a standard push button.
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{wxCommandEvent}
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_TEXT(id, func)}
|
2013-04-25 06:11:03 -04:00
|
|
|
Process a @c wxEVT_TEXT event, when the text changes.
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_TEXT_ENTER(id, func)}
|
2013-04-25 06:11:03 -04:00
|
|
|
Process a @c wxEVT_TEXT_ENTER event, when RETURN is pressed in
|
2008-03-08 08:52:38 -05:00
|
|
|
the combo control.
|
2009-10-16 09:54:56 -04:00
|
|
|
@event{EVT_COMBOBOX_DROPDOWN(id, func)}
|
2013-04-25 06:11:03 -04:00
|
|
|
Process a @c wxEVT_COMBOBOX_DROPDOWN event, which is generated
|
2009-09-26 05:15:29 -04:00
|
|
|
when the popup window is shown (drops down).
|
2009-10-16 09:54:56 -04:00
|
|
|
@event{EVT_COMBOBOX_CLOSEUP(id, func)}
|
2013-04-25 06:11:03 -04:00
|
|
|
Process a @c wxEVT_COMBOBOX_CLOSEUP event, which is generated
|
2009-09-26 05:15:29 -04:00
|
|
|
when the popup window of the combo control disappears (closes up).
|
2009-10-02 10:15:35 -04:00
|
|
|
You should avoid adding or deleting items in this event.
|
2008-03-08 08:52:38 -05:00
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2012-10-14 21:17:21 -04:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{ctrl}
|
2012-11-03 14:32:50 -04:00
|
|
|
@appearance{comboctrl}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
@see wxComboBox, wxChoice, wxOwnerDrawnComboBox, wxComboPopup,
|
|
|
|
wxCommandEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2010-12-16 12:21:49 -05:00
|
|
|
class wxComboCtrl : public wxControl,
|
|
|
|
public wxTextEntry
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
2008-04-09 22:57:09 -04:00
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxComboCtrl();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Constructor, creating and showing a combo control.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window. Must not be @NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
Window identifier. The value wxID_ANY indicates a default value.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param value
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial selection string. An empty string indicates no selection.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Window position.
|
2009-04-21 07:21:36 -04:00
|
|
|
If ::wxDefaultPosition is specified then a default position is chosen.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2019-01-30 11:28:08 -05:00
|
|
|
Window size.
|
2009-04-21 07:21:36 -04:00
|
|
|
If ::wxDefaultSize is specified then the window is sized appropriately.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
Window style. See wxComboCtrl.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
Window validator.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Window name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see Create(), wxValidator
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-24 19:29:43 -04:00
|
|
|
wxComboCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& value = wxEmptyString,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-09-21 19:48:04 -04:00
|
|
|
const wxString& name = wxComboBoxNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor, destroying the combo control.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual ~wxComboCtrl();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Copies the selected text to the clipboard.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void Copy();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates the combo control for two-step construction. Derived classes
|
2008-04-09 22:57:09 -04:00
|
|
|
should call or replace this function. See wxComboCtrl() for further
|
|
|
|
details.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-24 19:29:43 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& value = wxEmptyString,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-09-21 19:48:04 -04:00
|
|
|
const wxString& name = wxComboBoxNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Copies the selected text to the clipboard and removes the selection.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void Cut();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2010-12-17 07:08:55 -05:00
|
|
|
/**
|
|
|
|
Dismisses the popup window.
|
|
|
|
|
|
|
|
Notice that calling this function will generate a
|
2013-04-25 06:11:03 -04:00
|
|
|
@c wxEVT_COMBOBOX_CLOSEUP event.
|
2010-12-17 07:08:55 -05:00
|
|
|
|
|
|
|
@since 2.9.2
|
|
|
|
*/
|
|
|
|
virtual void Dismiss();
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Enables or disables popup animation, if any, depending on the value of
|
|
|
|
the argument.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void EnablePopupAnimation(bool enable = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2012-06-05 17:26:42 -04:00
|
|
|
/**
|
|
|
|
Returns true if given key combination should toggle the popup.
|
|
|
|
*/
|
|
|
|
virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Prepare background of combo control or an item in a dropdown list in a
|
|
|
|
way typical on platform. This includes painting the focus/disabled
|
|
|
|
background and setting the clipping region.
|
|
|
|
|
|
|
|
Unless you plan to paint your own focus indicator, you should always
|
|
|
|
call this in your wxComboPopup::PaintComboControl implementation. In
|
|
|
|
addition, it sets pen and text colour to what looks good and proper
|
|
|
|
against the background.
|
|
|
|
|
|
|
|
flags: wxRendererNative flags:
|
|
|
|
wxCONTROL_ISSUBMENU: is drawing a list item instead of combo control
|
|
|
|
wxCONTROL_SELECTED: list item is selected
|
|
|
|
wxCONTROL_DISABLED: control/item is disabled
|
|
|
|
*/
|
|
|
|
virtual void PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if focus indicator should be drawn in the control.
|
|
|
|
*/
|
|
|
|
bool ShouldDrawFocus() const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Returns disabled button bitmap that has been set with
|
|
|
|
SetButtonBitmaps().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2022-01-18 08:29:00 -05:00
|
|
|
@return The disabled state bitmap.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2022-01-18 08:29:00 -05:00
|
|
|
wxBitmap GetBitmapDisabled() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns button mouse hover bitmap that has been set with
|
|
|
|
SetButtonBitmaps().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2022-01-18 08:29:00 -05:00
|
|
|
@return The mouse hover state bitmap.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2022-01-18 08:29:00 -05:00
|
|
|
wxBitmap GetBitmapHover() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns default button bitmap that has been set with
|
|
|
|
SetButtonBitmaps().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2022-01-18 08:29:00 -05:00
|
|
|
@return The normal state bitmap.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2022-01-18 08:29:00 -05:00
|
|
|
wxBitmap GetBitmapNormal() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns depressed button bitmap that has been set with
|
|
|
|
SetButtonBitmaps().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2022-01-18 08:29:00 -05:00
|
|
|
@return The depressed state bitmap.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2022-01-18 08:29:00 -05:00
|
|
|
wxBitmap GetBitmapPressed() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns current size of the dropdown button.
|
|
|
|
*/
|
|
|
|
wxSize GetButtonSize();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns custom painted area in control.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetCustomPaintWidth().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetCustomPaintWidth() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Returns features supported by wxComboCtrl. If needed feature is
|
|
|
|
missing, you need to instead use wxGenericComboCtrl, which however may
|
|
|
|
lack a native look and feel (but otherwise sports identical API).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return Value returned is a combination of the flags defined in
|
|
|
|
wxComboCtrlFeatures.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static int GetFeatures();
|
|
|
|
|
2009-12-26 05:33:35 -05:00
|
|
|
/**
|
|
|
|
Returns the current hint string.
|
|
|
|
|
|
|
|
See SetHint() for more information about hints.
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
|
|
|
virtual wxString GetHint() const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Returns the insertion point for the combo control's text field.
|
2008-04-09 22:57:09 -04:00
|
|
|
|
|
|
|
@note Under Windows, this function always returns 0 if the combo
|
|
|
|
control doesn't have the focus.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual long GetInsertionPoint() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the last position in the combo control text field.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual long GetLastPosition() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2009-09-05 08:39:12 -04:00
|
|
|
/**
|
|
|
|
Returns the margins used by the control. The @c x field of the returned
|
|
|
|
point is the horizontal margin and the @c y field is the vertical one.
|
|
|
|
|
|
|
|
@remarks If given margin cannot be accurately determined, its value
|
|
|
|
will be set to -1.
|
|
|
|
|
|
|
|
@see SetMargins()
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
|
|
|
wxPoint GetMargins() const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Returns current popup interface that has been set with
|
|
|
|
SetPopupControl().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxComboPopup* GetPopupControl();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns popup window containing the popup control.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxWindow* GetPopupWindow() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the text control which is part of the combo control.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxTextCtrl* GetTextCtrl() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns actual indentation in pixels.
|
2009-09-05 08:39:12 -04:00
|
|
|
|
|
|
|
@deprecated Use GetMargins() instead.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxCoord GetTextIndent() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns area covered by the text field (includes everything except
|
|
|
|
borders and the dropdown button).
|
|
|
|
*/
|
2008-09-24 19:29:43 -04:00
|
|
|
const wxRect& GetTextRect() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Returns text representation of the current value. For writable combo
|
|
|
|
control it always returns the value in the text field.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual wxString GetValue() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Dismisses the popup window.
|
2009-09-26 05:15:29 -04:00
|
|
|
|
|
|
|
@param generateEvent
|
|
|
|
Set this to @true in order to generate
|
2013-04-25 06:11:03 -04:00
|
|
|
@c wxEVT_COMBOBOX_CLOSEUP event.
|
2010-12-17 07:08:55 -05:00
|
|
|
|
|
|
|
@deprecated Use Dismiss() instead.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-09-26 05:15:29 -04:00
|
|
|
virtual void HidePopup(bool generateEvent=false);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the popup is currently shown
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsPopupShown() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Returns @true if the popup window is in the given state. Possible
|
|
|
|
values are:
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
@beginTable
|
|
|
|
@row2col{wxComboCtrl::Hidden, Popup window is hidden.}
|
|
|
|
@row2col{wxComboCtrl::Animating, Popup window is being shown, but the
|
|
|
|
popup animation has not yet finished.}
|
|
|
|
@row2col{wxComboCtrl::Visible, Popup window is fully visible.}
|
|
|
|
@endTable
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsPopupWindowState(int state) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Implement in a derived class to define what happens on dropdown button
|
|
|
|
click. Default action is to show the popup.
|
|
|
|
|
|
|
|
@note If you implement this to do something else than show the popup,
|
|
|
|
you must then also implement DoSetPopupControl() to always return
|
|
|
|
@NULL.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void OnButtonClick();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Pastes text from the clipboard to the text field.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void Paste();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2010-12-17 07:08:55 -05:00
|
|
|
/**
|
|
|
|
Shows the popup portion of the combo control.
|
|
|
|
|
|
|
|
Notice that calling this function will generate a
|
2013-04-25 06:11:03 -04:00
|
|
|
@c wxEVT_COMBOBOX_DROPDOWN event.
|
2010-12-17 07:08:55 -05:00
|
|
|
|
|
|
|
@since 2.9.2
|
|
|
|
*/
|
|
|
|
virtual void Popup();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Removes the text between the two positions in the combo control text
|
|
|
|
field.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param from
|
2008-03-09 08:33:59 -04:00
|
|
|
The first position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param to
|
2008-03-09 08:33:59 -04:00
|
|
|
The last position.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void Remove(long from, long to);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Replaces the text between two positions with the given text, in the
|
|
|
|
combo control text field.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param from
|
2008-03-09 08:33:59 -04:00
|
|
|
The first position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param to
|
2008-03-09 08:33:59 -04:00
|
|
|
The second position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param text
|
2008-03-09 08:33:59 -04:00
|
|
|
The text to insert.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-08-30 19:58:45 -04:00
|
|
|
virtual void Replace(long from, long to, const wxString& text);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets custom dropdown button graphics.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bmpNormal
|
2008-03-09 08:33:59 -04:00
|
|
|
Default button image.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pushButtonBg
|
2008-04-09 22:57:09 -04:00
|
|
|
If @true, blank push button background is painted below the image.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bmpPressed
|
2008-03-09 08:33:59 -04:00
|
|
|
Depressed button image.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bmpHover
|
2008-04-09 22:57:09 -04:00
|
|
|
Button image when mouse hovers above it. This should be ignored on
|
|
|
|
platforms and themes that do not generally draw different kind of
|
|
|
|
button on mouse hover.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bmpDisabled
|
2008-03-09 08:33:59 -04:00
|
|
|
Disabled button image.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2022-01-18 08:29:00 -05:00
|
|
|
void SetButtonBitmaps(const wxBitmapBundle& bmpNormal,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool pushButtonBg = false,
|
2022-01-18 08:29:00 -05:00
|
|
|
const wxBitmapBundle& bmpPressed = wxBitmapBundle(),
|
|
|
|
const wxBitmapBundle& bmpHover = wxBitmapBundle(),
|
|
|
|
const wxBitmapBundle& bmpDisabled = wxBitmapBundle());
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets size and position of dropdown button.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param width
|
2008-03-09 08:33:59 -04:00
|
|
|
Button width. Value = 0 specifies default.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param height
|
2008-03-09 08:33:59 -04:00
|
|
|
Button height. Value = 0 specifies default.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param side
|
2008-04-09 22:57:09 -04:00
|
|
|
Indicates which side the button will be placed. Value can be wxLEFT
|
|
|
|
or wxRIGHT.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param spacingX
|
2008-03-09 08:33:59 -04:00
|
|
|
Horizontal spacing around the button. Default is 0.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetButtonPosition(int width = -1, int height = -1,
|
2008-04-09 22:57:09 -04:00
|
|
|
int side = wxRIGHT, int spacingX = 0);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Set width, in pixels, of custom painted area in control without
|
|
|
|
@c wxCB_READONLY style. In read-only wxOwnerDrawnComboBox, this is used
|
2008-03-08 08:52:38 -05:00
|
|
|
to indicate area that is not covered by the focus rectangle.
|
|
|
|
*/
|
|
|
|
void SetCustomPaintWidth(int width);
|
|
|
|
|
2009-12-26 05:33:35 -05:00
|
|
|
/**
|
|
|
|
Sets a hint shown in an empty unfocused combo control.
|
|
|
|
|
|
|
|
Notice that hints are known as <em>cue banners</em> under MSW or
|
2020-07-04 16:08:24 -04:00
|
|
|
<em>placeholder strings</em> under macOS.
|
2009-12-26 05:33:35 -05:00
|
|
|
|
|
|
|
@see wxTextEntry::SetHint()
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
2012-03-10 09:26:26 -05:00
|
|
|
virtual bool SetHint(const wxString& hint);
|
2009-12-26 05:33:35 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Sets the insertion point in the text field.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
The new insertion point.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void SetInsertionPoint(long pos);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the insertion point at the end of the combo control text field.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void SetInsertionPointEnd();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2021-09-08 14:38:28 -04:00
|
|
|
/**
|
|
|
|
Uses the given window instead of the default text control as the main
|
|
|
|
window of the combo control.
|
|
|
|
|
|
|
|
By default, combo controls without @c wxCB_READONLY style create a
|
|
|
|
wxTextCtrl which shows the current value and allows to edit it. This
|
|
|
|
method allows to use some other window instead of this wxTextCtrl.
|
|
|
|
|
|
|
|
This method can be called after creating the combo fully, however in
|
|
|
|
this case a wxTextCtrl is unnecessarily created just to be immediately
|
|
|
|
destroyed when it's replaced by a custom window. If you wish to avoid
|
|
|
|
this, you can use the following approach, also shown in the combo
|
|
|
|
sample:
|
|
|
|
|
|
|
|
@code
|
|
|
|
// Create the combo control using its default ctor.
|
|
|
|
wxComboCtrl* combo = new wxComboCtrl();
|
|
|
|
|
|
|
|
// Create the custom main control using its default ctor too.
|
|
|
|
SomeWindow* main = new SomeWindow();
|
|
|
|
|
|
|
|
// Set the custom main control before creating the combo.
|
|
|
|
combo->SetMainControl(main);
|
|
|
|
|
|
|
|
// And only create it now: wxTextCtrl won't be unnecessarily
|
|
|
|
// created because the combo already has a main window.
|
|
|
|
combo->Create(panel, wxID_ANY, wxEmptyString);
|
|
|
|
|
|
|
|
// Finally create the main window itself, now that its parent was
|
|
|
|
// created.
|
|
|
|
main->Create(combo, ...);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
Note that when a custom main window is used, none of the methods of
|
|
|
|
this class inherited from wxTextEntry, such as SetValue(), Replace(),
|
|
|
|
SetInsertionPoint() etc do anything and simply return.
|
|
|
|
|
|
|
|
@since 3.1.6
|
|
|
|
*/
|
|
|
|
void SetMainControl(wxWindow* win);
|
|
|
|
|
2009-09-05 08:39:12 -04:00
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Attempts to set the control margins. When margins are given as wxPoint,
|
|
|
|
x indicates the left and y the top margin. Use -1 to indicate that
|
|
|
|
an existing value should be used.
|
|
|
|
|
|
|
|
@return
|
|
|
|
@true if setting of all requested margins was successful.
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
|
|
|
bool SetMargins(const wxPoint& pt);
|
|
|
|
bool SetMargins(wxCoord left, wxCoord top = -1);
|
|
|
|
//@}
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Set side of the control to which the popup will align itself. Valid
|
|
|
|
values are @c wxLEFT, @c wxRIGHT and 0. The default value 0 means that
|
|
|
|
the most appropriate side is used (which, currently, is always
|
|
|
|
@c wxLEFT).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetPopupAnchor(int anchorSide);
|
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Set popup interface class derived from wxComboPopup. This method should
|
|
|
|
be called as soon as possible after the control has been created,
|
|
|
|
unless OnButtonClick() has been overridden.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetPopupControl(wxComboPopup* popup);
|
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Extends popup size horizontally, relative to the edges of the combo
|
|
|
|
control.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param extLeft
|
2008-04-09 22:57:09 -04:00
|
|
|
How many pixel to extend beyond the left edge of the control.
|
|
|
|
Default is 0.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param extRight
|
2008-04-09 22:57:09 -04:00
|
|
|
How many pixel to extend beyond the right edge of the control.
|
|
|
|
Default is 0.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
@remarks Popup minimum width may override arguments. It is up to the
|
|
|
|
popup to fully take this into account.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetPopupExtents(int extLeft, int extRight);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets preferred maximum height of the popup.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks Value -1 indicates the default.
|
|
|
|
*/
|
|
|
|
void SetPopupMaxHeight(int height);
|
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Sets minimum width of the popup. If wider than combo control, it will
|
|
|
|
extend to the left.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
@remarks Value -1 indicates the default. Also, popup implementation may
|
|
|
|
choose to ignore this.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetPopupMinWidth(int width);
|
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Selects the text between the two positions, in the combo control text
|
|
|
|
field.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param from
|
2008-03-09 08:33:59 -04:00
|
|
|
The first position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param to
|
2008-03-09 08:33:59 -04:00
|
|
|
The second position.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void SetSelection(long from, long to);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Sets the text for the text field without affecting the popup. Thus,
|
|
|
|
unlike SetValue(), it works equally well with combo control using
|
|
|
|
@c wxCB_READONLY style.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetText(const wxString& value);
|
|
|
|
|
2010-06-13 05:59:32 -04:00
|
|
|
/**
|
|
|
|
Set a custom window style for the embedded wxTextCtrl. Usually you
|
|
|
|
will need to use this during two-step creation, just before Create().
|
|
|
|
For example:
|
|
|
|
|
|
|
|
@code
|
|
|
|
wxComboCtrl* comboCtrl = new wxComboCtrl();
|
|
|
|
|
|
|
|
// Let's make the text right-aligned
|
|
|
|
comboCtrl->SetTextCtrlStyle(wxTE_RIGHT);
|
|
|
|
|
|
|
|
comboCtrl->Create(parent, wxID_ANY, wxEmptyString);
|
|
|
|
@endcode
|
|
|
|
*/
|
|
|
|
void SetTextCtrlStyle( int style );
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
This will set the space in pixels between left edge of the control and
|
|
|
|
the text, regardless whether control is read-only or not. Value -1 can
|
|
|
|
be given to indicate platform default.
|
2009-09-05 08:39:12 -04:00
|
|
|
|
|
|
|
@deprecated Use SetMargins() instead.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetTextIndent(int indent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the text for the combo control text field.
|
2008-04-09 22:57:09 -04:00
|
|
|
|
|
|
|
@note For a combo control with @c wxCB_READONLY style the string must
|
|
|
|
be accepted by the popup (for instance, exist in the dropdown
|
|
|
|
list), otherwise the call to SetValue() is ignored.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void SetValue(const wxString& value);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2012-06-05 17:26:42 -04:00
|
|
|
/**
|
|
|
|
Changes value of the control as if user had done it by selecting an
|
|
|
|
item from a combo box drop-down list.
|
|
|
|
*/
|
|
|
|
void SetValueByUser(const wxString& value);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Show the popup.
|
2010-12-17 07:08:55 -05:00
|
|
|
|
|
|
|
@deprecated Use Popup() instead.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void ShowPopup();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Undoes the last edit in the text field. Windows only.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void Undo();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Enable or disable usage of an alternative popup window, which
|
|
|
|
guarantees ability to focus the popup control, and allows common native
|
|
|
|
controls to function normally. This alternative popup window is usually
|
|
|
|
a wxDialog, and as such, when it is shown, its parent top-level window
|
|
|
|
will appear as if the focus has been lost from it.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void UseAltPopupWindow(bool enable = true);
|
2008-09-29 06:52:37 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
This member function is not normally called in application code.
|
|
|
|
Instead, it can be implemented in a derived class to create a custom
|
|
|
|
popup animation.
|
|
|
|
|
|
|
|
The parameters are the same as those for DoShowPopup().
|
|
|
|
|
|
|
|
@return @true if animation finishes before the function returns,
|
|
|
|
@false otherwise. In the latter case you need to manually call
|
|
|
|
DoShowPopup() after the animation ends.
|
|
|
|
*/
|
|
|
|
virtual bool AnimateShow(const wxRect& rect, int flags);
|
|
|
|
|
|
|
|
/**
|
|
|
|
This member function is not normally called in application code.
|
|
|
|
Instead, it can be implemented in a derived class to return default
|
2011-04-03 16:31:32 -04:00
|
|
|
wxComboPopup, in case @a popup is @NULL.
|
2008-09-29 06:52:37 -04:00
|
|
|
|
|
|
|
@note If you have implemented OnButtonClick() to do something else than
|
|
|
|
show the popup, then DoSetPopupControl() must always set @a popup
|
|
|
|
to @NULL.
|
|
|
|
*/
|
|
|
|
virtual void DoSetPopupControl(wxComboPopup* popup);
|
|
|
|
|
2015-02-05 20:51:27 -05:00
|
|
|
/**
|
|
|
|
Flags for DoShowPopup() and AnimateShow().
|
|
|
|
*/
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ShowBelow = 0x0000, //!< Show popup below the control.
|
|
|
|
ShowAbove = 0x0001, //!< Show popup above the control.
|
|
|
|
CanDeferShow = 0x0002 //!< Can only return true from AnimateShow() if this is set.
|
|
|
|
};
|
|
|
|
|
2008-09-29 06:52:37 -04:00
|
|
|
/**
|
|
|
|
This member function is not normally called in application code.
|
|
|
|
Instead, it must be called in a derived class to make sure popup is
|
|
|
|
properly shown after a popup animation has finished (but only if
|
|
|
|
AnimateShow() did not finish the animation within its function scope).
|
|
|
|
|
|
|
|
@param rect
|
|
|
|
Position to show the popup window at, in screen coordinates.
|
|
|
|
@param flags
|
2015-02-05 20:51:27 -05:00
|
|
|
Combination of any of the following: wxComboCtrl::ShowAbove,
|
|
|
|
and wxComboCtrl::CanDeferShow.
|
2008-09-29 06:52:37 -04:00
|
|
|
*/
|
|
|
|
virtual void DoShowPopup(const wxRect& rect, int flags);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|