1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-07-15 19:51:35 +00:00
|
|
|
// Name: wx/msw/combobox.h
|
1998-05-20 14:12:05 +00:00
|
|
|
// Purpose: wxComboBox class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
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_COMBOBOX_H_
|
|
|
|
#define _WX_COMBOBOX_H_
|
1998-05-20 14:12:05 +00:00
|
|
|
|
|
|
|
#include "wx/choice.h"
|
2007-09-26 16:52:48 +00:00
|
|
|
#include "wx/textentry.h"
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_COMBOBOX
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-07-02 22:02:05 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Combobox control
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxComboBox : public wxChoice,
|
2008-09-19 10:08:02 +00:00
|
|
|
public wxTextEntry
|
1998-05-20 14:12:05 +00:00
|
|
|
{
|
1999-07-02 22:02:05 +00:00
|
|
|
public:
|
2008-09-19 10:08:02 +00:00
|
|
|
wxComboBox() { Init(); }
|
1999-07-02 22:02:05 +00:00
|
|
|
|
|
|
|
wxComboBox(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
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 = wxComboBoxNameStr)
|
|
|
|
{
|
2008-09-19 10:08:02 +00:00
|
|
|
Init();
|
2004-01-15 13:49:22 +00:00
|
|
|
Create(parent, id, value, pos, size, n, choices, style, validator, name);
|
2008-09-19 10:08:02 +00:00
|
|
|
|
2004-01-15 13:49:22 +00:00
|
|
|
}
|
2008-09-19 10:08:02 +00:00
|
|
|
|
2004-01-31 18:21:45 +00:00
|
|
|
wxComboBox(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxString& value,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxComboBoxNameStr)
|
|
|
|
{
|
2008-09-19 10:08:02 +00:00
|
|
|
Init();
|
|
|
|
|
2004-01-31 18:21:45 +00:00
|
|
|
Create(parent, id, value, pos, size, choices, style, validator, name);
|
|
|
|
}
|
1999-07-02 22:02:05 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
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 = wxComboBoxNameStr);
|
2004-01-31 18:21:45 +00:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& value,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxComboBoxNameStr);
|
1999-07-02 22:02:05 +00:00
|
|
|
|
2007-09-26 16:52:48 +00:00
|
|
|
// resolve ambiguities among virtual functions inherited from both base
|
|
|
|
// classes
|
2007-09-27 12:49:18 +00:00
|
|
|
virtual void Clear();
|
2007-10-07 11:19:09 +00:00
|
|
|
virtual wxString GetValue() const;
|
1999-07-02 22:02:05 +00:00
|
|
|
virtual void SetValue(const wxString& value);
|
2007-09-26 16:52:48 +00:00
|
|
|
virtual wxString GetStringSelection() const
|
|
|
|
{ return wxChoice::GetStringSelection(); }
|
1999-07-02 22:02:05 +00:00
|
|
|
|
2006-03-12 20:53:27 +00:00
|
|
|
virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
|
2007-09-26 16:52:48 +00:00
|
|
|
virtual void SetSelection(long from, long to)
|
|
|
|
{ wxTextEntry::SetSelection(from, to); }
|
2006-03-12 20:53:27 +00:00
|
|
|
virtual int GetSelection() const { return wxChoice::GetSelection(); }
|
2007-10-07 11:19:09 +00:00
|
|
|
virtual void GetSelection(long *from, long *to) const;
|
2007-09-26 16:52:48 +00:00
|
|
|
|
2006-03-12 20:53:27 +00:00
|
|
|
virtual bool IsEditable() const;
|
2004-12-09 15:16:51 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// implementation only from now on
|
1999-07-02 22:02:05 +00:00
|
|
|
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
2000-07-15 19:51:35 +00:00
|
|
|
bool MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam);
|
2004-02-25 10:45:02 +00:00
|
|
|
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
2007-05-05 13:15:47 +00:00
|
|
|
bool MSWShouldPreProcessMessage(WXMSG *pMsg);
|
2003-07-22 00:24:07 +00:00
|
|
|
|
2004-12-09 15:16:51 +00:00
|
|
|
// Standard event handling
|
|
|
|
void OnCut(wxCommandEvent& event);
|
|
|
|
void OnCopy(wxCommandEvent& event);
|
|
|
|
void OnPaste(wxCommandEvent& event);
|
|
|
|
void OnUndo(wxCommandEvent& event);
|
|
|
|
void OnRedo(wxCommandEvent& event);
|
|
|
|
void OnDelete(wxCommandEvent& event);
|
|
|
|
void OnSelectAll(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnUpdateCut(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateCopy(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdatePaste(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUndo(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateRedo(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateDelete(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateSelectAll(wxUpdateUIEvent& event);
|
|
|
|
|
2004-02-07 19:26:22 +00:00
|
|
|
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
|
|
|
|
2007-10-26 06:20:23 +00:00
|
|
|
protected:
|
2007-09-26 16:23:51 +00:00
|
|
|
#if wxUSE_TOOLTIPS
|
|
|
|
virtual void DoSetToolTip(wxToolTip *tip);
|
|
|
|
#endif
|
|
|
|
|
2007-10-07 11:19:09 +00:00
|
|
|
// this is the implementation of GetEditHWND() which can also be used when
|
|
|
|
// we don't have the edit control, it simply returns NULL then
|
|
|
|
//
|
|
|
|
// try not to use this function unless absolutely necessary (as in the
|
|
|
|
// message handling code where the edit control might not be created yet
|
|
|
|
// for the messages we receive during the control creation) as normally
|
|
|
|
// just testing for IsEditable() and using GetEditHWND() should be enough
|
|
|
|
WXHWND GetEditHWNDIfAvailable() const;
|
|
|
|
|
2008-09-19 10:08:02 +00:00
|
|
|
virtual void EnableTextChangedEvents(bool enable)
|
|
|
|
{
|
|
|
|
m_allowTextEvents = enable;
|
|
|
|
}
|
|
|
|
|
2003-07-22 00:24:07 +00:00
|
|
|
private:
|
2007-10-26 06:20:23 +00:00
|
|
|
// this is the overridden wxTextEntry method which should only be called
|
|
|
|
// when we do have an edit control so it asserts if this is not the case
|
|
|
|
virtual WXHWND GetEditHWND() const;
|
|
|
|
|
2008-09-19 10:08:02 +00:00
|
|
|
// common part of all ctors
|
|
|
|
void Init()
|
|
|
|
{
|
|
|
|
m_allowTextEvents = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// normally true, false if text events are currently disabled
|
|
|
|
bool m_allowTextEvents;
|
|
|
|
|
2003-07-22 00:24:07 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
|
2004-12-09 15:16:51 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-20 14:12:05 +00:00
|
|
|
};
|
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#endif // wxUSE_COMBOBOX
|
2007-09-26 16:52:48 +00:00
|
|
|
|
|
|
|
#endif // _WX_COMBOBOX_H_
|