1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-09-27 16:54:43 +00:00
|
|
|
// Name: wx/msw/choice.h
|
1998-05-20 14:12:05 +00:00
|
|
|
// Purpose: wxChoice class
|
|
|
|
// Author: Julian Smart
|
1999-07-26 23:02:32 +00:00
|
|
|
// Modified by: Vadim Zeitlin to derive from wxChoiceBase
|
1998-05-20 14:12:05 +00:00
|
|
|
// Created: 01/02/97
|
1998-08-07 23:52:45 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 23:52:45 +00:00
|
|
|
#ifndef _WX_CHOICE_H_
|
|
|
|
#define _WX_CHOICE_H_
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2012-11-14 13:47:36 +00:00
|
|
|
struct tagCOMBOBOXINFO;
|
|
|
|
|
1999-07-26 23:02:32 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 14:12:05 +00:00
|
|
|
// Choice item
|
1999-07-26 23:02:32 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase
|
1998-05-20 14:12:05 +00:00
|
|
|
{
|
1999-02-22 11:01:13 +00:00
|
|
|
public:
|
1999-07-26 23:02:32 +00:00
|
|
|
// ctors
|
2005-08-17 13:30:33 +00:00
|
|
|
wxChoice() { Init(); }
|
1999-10-23 23:40:55 +00:00
|
|
|
virtual ~wxChoice();
|
1999-07-26 23:02:32 +00:00
|
|
|
|
|
|
|
wxChoice(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n = 0, const wxString choices[] = NULL,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2004-01-15 13:49:22 +00:00
|
|
|
const wxString& name = wxChoiceNameStr)
|
|
|
|
{
|
2005-09-14 12:08:24 +00:00
|
|
|
Init();
|
2004-01-15 13:49:22 +00:00
|
|
|
Create(parent, id, pos, size, n, choices, style, validator, name);
|
|
|
|
}
|
2005-08-17 13:30:33 +00:00
|
|
|
|
2004-01-31 18:21:45 +00:00
|
|
|
wxChoice(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxChoiceNameStr)
|
|
|
|
{
|
2005-09-14 12:08:24 +00:00
|
|
|
Init();
|
2004-01-31 18:21:45 +00:00
|
|
|
Create(parent, id, pos, size, choices, style, validator, name);
|
|
|
|
}
|
1999-02-22 11:01:13 +00:00
|
|
|
|
1999-07-26 23:02:32 +00:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n = 0, const wxString choices[] = NULL,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxChoiceNameStr);
|
2004-01-31 18:21:45 +00:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxChoiceNameStr);
|
1999-07-26 23:02:32 +00:00
|
|
|
|
2012-04-05 18:40:20 +00:00
|
|
|
virtual bool Show(bool show = true);
|
|
|
|
|
2008-02-09 15:22:15 +00:00
|
|
|
virtual void SetLabel(const wxString& label);
|
|
|
|
|
2006-03-23 22:05:23 +00:00
|
|
|
virtual unsigned int GetCount() const;
|
1999-07-26 23:02:32 +00:00
|
|
|
virtual int GetSelection() const;
|
2005-08-17 13:30:33 +00:00
|
|
|
virtual int GetCurrentSelection() const;
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual void SetSelection(int n);
|
|
|
|
|
2005-09-27 16:54:43 +00:00
|
|
|
virtual int FindString(const wxString& s, bool bCase = false) const;
|
2006-03-23 22:05:23 +00:00
|
|
|
virtual wxString GetString(unsigned int n) const;
|
|
|
|
virtual void SetString(unsigned int n, const wxString& s);
|
1999-02-22 11:01:13 +00:00
|
|
|
|
2009-12-21 15:20:37 +00:00
|
|
|
virtual wxVisualAttributes GetDefaultAttributes() const
|
|
|
|
{
|
|
|
|
return GetClassDefaultAttributes(GetWindowVariant());
|
|
|
|
}
|
|
|
|
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
|
|
|
|
1999-07-26 23:02:32 +00:00
|
|
|
// MSW only
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
2004-02-25 10:45:02 +00:00
|
|
|
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
2005-04-10 21:55:12 +00:00
|
|
|
virtual WXHBRUSH MSWControlColor(WXHDC hDC, WXHWND hWnd);
|
2006-02-08 21:47:09 +00:00
|
|
|
virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg);
|
|
|
|
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
1998-08-07 23:52:45 +00:00
|
|
|
|
2007-08-07 19:22:43 +00:00
|
|
|
// returns true if the platform should explicitly apply a theme border
|
|
|
|
virtual bool CanApplyThemeBorder() const { return false; }
|
|
|
|
|
1998-08-07 23:52:45 +00:00
|
|
|
protected:
|
2007-11-13 12:10:34 +00:00
|
|
|
// choose the default border for this window
|
|
|
|
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
|
|
|
|
|
2005-08-17 13:30:33 +00:00
|
|
|
// common part of all ctors
|
2009-05-01 21:49:43 +00:00
|
|
|
void Init()
|
|
|
|
{
|
2012-12-02 23:49:25 +00:00
|
|
|
m_lastAcceptedSelection =
|
|
|
|
m_pendingSelection = wxID_NONE;
|
2009-05-01 21:49:43 +00:00
|
|
|
m_heightOwn = wxDefaultCoord;
|
|
|
|
}
|
2005-08-17 13:30:33 +00:00
|
|
|
|
2007-10-26 06:20:23 +00:00
|
|
|
virtual void DoDeleteOneItem(unsigned int n);
|
|
|
|
virtual void DoClear();
|
|
|
|
|
2007-07-26 13:54:14 +00:00
|
|
|
virtual int DoInsertItems(const wxArrayStringsAdapter& items,
|
|
|
|
unsigned int pos,
|
|
|
|
void **clientData, wxClientDataType type);
|
|
|
|
|
2001-05-19 01:01:21 +00:00
|
|
|
virtual void DoMoveWindow(int x, int y, int width, int height);
|
2006-03-23 22:05:23 +00:00
|
|
|
virtual void DoSetItemClientData(unsigned int n, void* clientData);
|
|
|
|
virtual void* DoGetItemClientData(unsigned int n) const;
|
1998-08-07 23:52:45 +00:00
|
|
|
|
1999-07-26 23:02:32 +00:00
|
|
|
// MSW implementation
|
1999-12-29 23:34:18 +00:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
2004-02-07 18:42:56 +00:00
|
|
|
virtual void DoGetSize(int *w, int *h) const;
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual void DoSetSize(int x, int y,
|
1999-07-02 22:02:05 +00:00
|
|
|
int width, int height,
|
|
|
|
int sizeFlags = wxSIZE_AUTO);
|
2012-11-14 13:47:59 +00:00
|
|
|
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
|
1999-10-23 23:40:55 +00:00
|
|
|
|
2012-04-05 18:40:15 +00:00
|
|
|
// Show or hide the popup part of the control.
|
|
|
|
void MSWDoPopupOrDismiss(bool show);
|
|
|
|
|
2004-02-07 19:26:22 +00:00
|
|
|
// update the height of the drop down list to fit the number of items we
|
|
|
|
// have (without changing the visible height)
|
2009-05-01 21:49:43 +00:00
|
|
|
void MSWUpdateDropDownHeight();
|
|
|
|
|
|
|
|
// set the height of the visible part of the control to m_heightOwn
|
|
|
|
void MSWUpdateVisibleHeight();
|
2004-02-07 19:26:22 +00:00
|
|
|
|
|
|
|
// create and initialize the control
|
|
|
|
bool CreateAndInit(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
int n, const wxString choices[],
|
|
|
|
long style,
|
|
|
|
const wxValidator& validator,
|
|
|
|
const wxString& name);
|
|
|
|
|
1999-10-23 23:40:55 +00:00
|
|
|
// free all memory we have (used by Clear() and dtor)
|
|
|
|
void Free();
|
2003-07-22 00:24:07 +00:00
|
|
|
|
2009-09-24 09:07:13 +00:00
|
|
|
// set the height for simple combo box
|
|
|
|
int SetHeightSimpleComboBox(int nItems) const;
|
|
|
|
|
2009-05-01 21:49:43 +00:00
|
|
|
#if wxUSE_DEFERRED_SIZING
|
|
|
|
virtual void MSWEndDeferWindowPos();
|
|
|
|
#endif // wxUSE_DEFERRED_SIZING
|
2005-08-17 13:30:33 +00:00
|
|
|
|
2012-12-02 23:49:25 +00:00
|
|
|
// These variables are only used while the drop down is opened.
|
|
|
|
//
|
|
|
|
// The first one contains the item that had been originally selected before
|
|
|
|
// the drop down was opened and the second one the item we should select
|
|
|
|
// when the drop down is closed again.
|
|
|
|
int m_lastAcceptedSelection,
|
|
|
|
m_pendingSelection;
|
2005-08-17 13:30:33 +00:00
|
|
|
|
2009-05-01 21:49:43 +00:00
|
|
|
// the height of the control itself if it was set explicitly or
|
|
|
|
// wxDefaultCoord if it hadn't
|
|
|
|
int m_heightOwn;
|
2005-08-17 13:30:33 +00:00
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxChoice);
|
1998-05-20 14:12:05 +00:00
|
|
|
};
|
|
|
|
|
1999-07-26 23:02:32 +00:00
|
|
|
#endif // _WX_CHOICE_H_
|