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
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@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-04-09 22:57:09 -04:00
|
|
|
virtual bool Create(wxWindow* parent);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Utility function that hides the popup.
|
|
|
|
*/
|
|
|
|
void Dismiss();
|
|
|
|
|
|
|
|
/**
|
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-03-08 09:43:31 -05:00
|
|
|
@param maxWidth
|
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
|
|
|
|
|
|
|
/**
|
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-04-09 22:57:09 -04:00
|
|
|
virtual wxWindow* GetControl();
|
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-04-09 22:57:09 -04:00
|
|
|
virtual wxString GetStringValue() const;
|
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;
|
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
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Parent wxComboCtrl. This is parameter has been prepared before Init()
|
|
|
|
is called.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04: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.
|
|
|
|
TextIndent = 0x0008, ///< wxComboCtrl::SetTextIndent() can be used.
|
|
|
|
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:
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(wxListViewComboPopup, wxListView)
|
|
|
|
EVT_MOTION(wxListViewComboPopup::OnMouseMove)
|
|
|
|
EVT_LEFT_UP(wxListViewComboPopup::OnMouseClick)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
@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();
|
|
|
|
|
|
|
|
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}
|
2008-03-08 08:52:38 -05:00
|
|
|
The control will generate the event wxEVT_COMMAND_TEXT_ENTER
|
|
|
|
(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
|
|
|
|
2008-03-28 12:19:12 -04:00
|
|
|
@beginEventTable{wxCommandEvent}
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_TEXT(id, func)}
|
2008-03-08 08:52:38 -05:00
|
|
|
Process a wxEVT_COMMAND_TEXT_UPDATED event, when the text changes.
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_TEXT_ENTER(id, func)}
|
2008-03-08 08:52:38 -05:00
|
|
|
Process a wxEVT_COMMAND_TEXT_ENTER event, when RETURN is pressed in
|
|
|
|
the combo control.
|
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxbase}
|
|
|
|
@category{ctrl}
|
2008-04-09 22:57:09 -04:00
|
|
|
<!-- @appearance{comboctrl.png} -->
|
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
|
|
|
*/
|
|
|
|
class wxComboCtrl : public wxControl
|
|
|
|
{
|
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-04-09 22:57:09 -04:00
|
|
|
Window size. If wxDefaultSize is specified then the window is sized
|
2008-03-09 08:33:59 -04:00
|
|
|
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-03-08 09:43:31 -05:00
|
|
|
wxComboCtrl(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxString& value = "",
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = "comboCtrl");
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
This member function is not normally called in application code.
|
2008-04-09 22:57:09 -04:00
|
|
|
Instead, it can be implemented in a derived class to create a custom
|
|
|
|
popup animation.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
The parameters are the same as those for DoShowPopup().
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@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.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual bool AnimateShow(const wxRect& rect, int flags);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
*/
|
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxString& value = "",
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = "comboCtrl");
|
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
This member function is not normally called in application code.
|
2008-04-09 22:57:09 -04:00
|
|
|
Instead, it can be implemented in a derived class to return default
|
|
|
|
wxComboPopup, incase @a popup is @NULL.
|
|
|
|
|
|
|
|
@note If you have implemented OnButtonClick() to do something else than
|
|
|
|
show the popup, then DoSetPopupControl() must always set @a popup
|
|
|
|
to @NULL.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void DoSetPopupControl(wxComboPopup* popup);
|
|
|
|
|
|
|
|
/**
|
|
|
|
This member function is not normally called in application code.
|
2008-04-09 22:57:09 -04:00
|
|
|
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).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param rect
|
2008-03-09 08:33:59 -04:00
|
|
|
Position to show the popup window at, in screen coordinates.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param flags
|
2008-03-09 08:33:59 -04:00
|
|
|
Combination of any of the following:
|
2008-04-09 22:57:09 -04:00
|
|
|
@beginTable
|
|
|
|
@row2col{wxComboCtrl::ShowAbove,
|
|
|
|
Popup is shown above the control instead of below.}
|
|
|
|
@row2col{wxComboCtrl::CanDeferShow,
|
|
|
|
Showing the popup can be deferred to happen sometime after
|
|
|
|
ShowPopup() has finished. In this case, AnimateShow() must
|
|
|
|
return false.}
|
|
|
|
@endTable
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual void DoShowPopup(const wxRect& rect, int flags);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
Returns disabled button bitmap that has been set with
|
|
|
|
SetButtonBitmaps().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A reference to the disabled state bitmap.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const 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
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A reference to the mouse hover state bitmap.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const 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
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A reference to the normal state bitmap.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const 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
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return A reference to the depressed state bitmap.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const 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();
|
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
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.
|
|
|
|
*/
|
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-03-09 12:24:26 -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.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
virtual void HidePopup();
|
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
|
|
|
|
|
|
|
/**
|
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-04-09 22:57:09 -04:00
|
|
|
virtual void Replace(long from, long to, const wxString& value);
|
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
|
|
|
*/
|
|
|
|
void SetButtonBitmaps(const wxBitmap& bmpNormal,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool pushButtonBg = false,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxBitmap& bmpPressed = wxNullBitmap,
|
|
|
|
const wxBitmap& bmpHover = wxNullBitmap,
|
|
|
|
const wxBitmap& bmpDisabled = wxNullBitmap);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
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);
|
|
|
|
|
|
|
|
/**
|
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.
|
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
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Same as SetValue(), but also sends wxCommandEvent of type
|
|
|
|
wxEVT_COMMAND_TEXT_UPDATED if @a withEvent is @true.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
void SetValueWithEvent(const wxString& value, bool withEvent = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Show the popup.
|
|
|
|
*/
|
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-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|