1999-07-26 23:02:32 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/control.h
|
|
|
|
// Purpose: wxControl common interface
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 26.07.99
|
|
|
|
// RCS-ID: $Id$
|
2004-05-23 14:56:36 +00:00
|
|
|
// Copyright: (c) wxWidgets team
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1999-07-26 23:02:32 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_CONTROL_H_BASE_
|
|
|
|
#define _WX_CONTROL_H_BASE_
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-07-26 23:02:32 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-07-09 21:48:53 +00:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#if wxUSE_CONTROLS
|
|
|
|
|
1999-07-26 23:02:32 +00:00
|
|
|
#include "wx/window.h" // base class
|
|
|
|
|
2006-01-16 14:59:55 +00:00
|
|
|
extern WXDLLEXPORT_DATA(const wxChar) wxControlNameStr[];
|
2001-06-26 20:59:19 +00:00
|
|
|
|
1999-07-26 23:02:32 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxControl is the base class for all controls
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxControlBase : public wxWindow
|
|
|
|
{
|
|
|
|
public:
|
2004-06-21 22:58:13 +00:00
|
|
|
wxControlBase() { }
|
2003-07-22 00:24:07 +00:00
|
|
|
|
2002-01-07 21:52:28 +00:00
|
|
|
virtual ~wxControlBase();
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
// Create() function adds the validator parameter
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxControlNameStr);
|
|
|
|
|
|
|
|
// get the control alignment (left/right/centre, top/bottom/centre)
|
|
|
|
int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; }
|
|
|
|
|
2007-04-01 14:13:15 +00:00
|
|
|
// get just the text of the label, without mnemonic characters ('&')
|
|
|
|
wxString GetLabelText() const { return GetLabelText(GetLabel()); }
|
|
|
|
|
|
|
|
virtual void SetLabel(const wxString& label)
|
|
|
|
{
|
|
|
|
m_labelOrig = label;
|
|
|
|
|
|
|
|
InvalidateBestSize();
|
|
|
|
|
|
|
|
wxWindow::SetLabel(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxString GetLabel() const
|
|
|
|
{
|
|
|
|
// return the original string, as it was passed to SetLabel()
|
|
|
|
// (i.e. with wx-style mnemonics)
|
|
|
|
return m_labelOrig;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static utilities:
|
|
|
|
|
2006-07-25 18:40:04 +00:00
|
|
|
// get the string without mnemonic characters ('&')
|
|
|
|
static wxString GetLabelText(const wxString& label);
|
|
|
|
|
2007-04-01 14:13:15 +00:00
|
|
|
// removes the mnemonics characters
|
|
|
|
static wxString RemoveMnemonics(const wxString& str);
|
|
|
|
|
2004-04-01 00:19:39 +00:00
|
|
|
|
2003-10-16 10:00:12 +00:00
|
|
|
// controls by default inherit the colours of their parents, if a
|
|
|
|
// particular control class doesn't want to do it, it can override
|
|
|
|
// ShouldInheritColours() to return false
|
|
|
|
virtual bool ShouldInheritColours() const { return true; }
|
|
|
|
|
2004-04-01 00:19:39 +00:00
|
|
|
|
|
|
|
// WARNING: this doesn't work for all controls nor all platforms!
|
|
|
|
//
|
|
|
|
// simulates the event of given type (i.e. wxButton::Command() is just as
|
|
|
|
// if the button was clicked)
|
|
|
|
virtual void Command(wxCommandEvent &event);
|
|
|
|
|
2004-06-24 20:09:45 +00:00
|
|
|
virtual bool SetFont(const wxFont& font);
|
|
|
|
|
2006-02-12 16:32:50 +00:00
|
|
|
// wxControl-specific processing after processing the update event
|
|
|
|
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
|
|
|
|
|
1999-07-26 23:02:32 +00:00
|
|
|
protected:
|
1999-11-11 00:25:57 +00:00
|
|
|
// creates the control (calls wxWindowBase::CreateBase inside) and adds it
|
|
|
|
// to the list of parents children
|
1999-07-26 23:02:32 +00:00
|
|
|
bool CreateControl(wxWindowBase *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style,
|
|
|
|
const wxValidator& validator,
|
|
|
|
const wxString& name);
|
|
|
|
|
2000-02-25 23:49:41 +00:00
|
|
|
// initialize the common fields of wxCommandEvent
|
|
|
|
void InitCommandEvent(wxCommandEvent& event) const;
|
2003-07-22 00:24:07 +00:00
|
|
|
|
2007-04-01 14:13:15 +00:00
|
|
|
// this field contains the label in wx format, i.e. with '&' mnemonics
|
|
|
|
wxString m_labelOrig;
|
|
|
|
|
2003-07-22 00:24:07 +00:00
|
|
|
DECLARE_NO_COPY_CLASS(wxControlBase)
|
1999-07-26 23:02:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// include platform-dependent wxControl declarations
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-05-09 22:17:03 +00:00
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#if defined(__WXUNIVERSAL__)
|
|
|
|
#include "wx/univ/control.h"
|
2004-12-20 12:44:22 +00:00
|
|
|
#elif defined(__WXPALMOS__)
|
2004-10-19 13:40:30 +00:00
|
|
|
#include "wx/palmos/control.h"
|
2001-06-26 20:59:19 +00:00
|
|
|
#elif defined(__WXMSW__)
|
1999-07-26 23:02:32 +00:00
|
|
|
#include "wx/msw/control.h"
|
1998-07-10 14:15:17 +00:00
|
|
|
#elif defined(__WXMOTIF__)
|
1999-07-26 23:02:32 +00:00
|
|
|
#include "wx/motif/control.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK20__)
|
1999-07-26 23:02:32 +00:00
|
|
|
#include "wx/gtk/control.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK__)
|
|
|
|
#include "wx/gtk1/control.h"
|
1998-08-15 00:23:28 +00:00
|
|
|
#elif defined(__WXMAC__)
|
1999-07-26 23:02:32 +00:00
|
|
|
#include "wx/mac/control.h"
|
2003-03-22 06:18:36 +00:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/control.h"
|
1999-07-28 03:38:12 +00:00
|
|
|
#elif defined(__WXPM__)
|
|
|
|
#include "wx/os2/control.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#endif // wxUSE_CONTROLS
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_CONTROL_H_BASE_
|