1999-07-26 19:02:32 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/control.h
|
|
|
|
// Purpose: wxControl common interface
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 26.07.99
|
|
|
|
// RCS-ID: $Id$
|
2004-05-23 10:56:36 -04:00
|
|
|
// Copyright: (c) wxWidgets team
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-07-26 19:02:32 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_CONTROL_H_BASE_
|
|
|
|
#define _WX_CONTROL_H_BASE_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-07-26 19:02:32 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-07-09 17:48:53 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#if wxUSE_CONTROLS
|
|
|
|
|
1999-07-26 19:02:32 -04:00
|
|
|
#include "wx/window.h" // base class
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
extern WXDLLIMPEXP_DATA_CORE(const char) wxControlNameStr[];
|
2001-06-26 16:59:19 -04:00
|
|
|
|
2008-12-28 16:16:00 -05:00
|
|
|
enum wxEllipsizeMode
|
|
|
|
{
|
|
|
|
wxELLIPSIZE_START,
|
|
|
|
wxELLIPSIZE_MIDDLE,
|
|
|
|
wxELLIPSIZE_END
|
|
|
|
};
|
|
|
|
|
1999-07-26 19:02:32 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxControl is the base class for all controls
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxControlBase : public wxWindow
|
1999-07-26 19:02:32 -04:00
|
|
|
{
|
|
|
|
public:
|
2004-06-21 18:58:13 -04:00
|
|
|
wxControlBase() { }
|
2003-07-21 20:24:07 -04:00
|
|
|
|
2002-01-07 16:52:28 -05:00
|
|
|
virtual ~wxControlBase();
|
|
|
|
|
2001-06-26 16:59:19 -04: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 10:13:15 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-12-31 09:14:07 -05:00
|
|
|
// get just the text of the label, without mnemonic characters ('&')
|
|
|
|
wxString GetLabelText() const { return GetLabelText(GetLabel()); }
|
|
|
|
|
|
|
|
void SetLabelText(const wxString& text)
|
|
|
|
{
|
2009-01-01 10:17:05 -05:00
|
|
|
SetLabel(EscapeMnemonics(text));
|
2008-12-31 09:14:07 -05:00
|
|
|
}
|
|
|
|
|
2007-04-01 10:13:15 -04:00
|
|
|
// static utilities:
|
|
|
|
|
2008-12-28 16:16:00 -05:00
|
|
|
// replaces parts of the string with ellipsis if needed
|
|
|
|
static wxString Ellipsize(const wxString& label, const wxDC& dc,
|
|
|
|
wxEllipsizeMode mode, int maxWidth);
|
|
|
|
|
2006-07-25 14:40:04 -04:00
|
|
|
// get the string without mnemonic characters ('&')
|
|
|
|
static wxString GetLabelText(const wxString& label);
|
|
|
|
|
2007-04-01 10:13:15 -04:00
|
|
|
// removes the mnemonics characters
|
|
|
|
static wxString RemoveMnemonics(const wxString& str);
|
|
|
|
|
2008-12-31 09:14:07 -05:00
|
|
|
// escapes (by doubling them) the mnemonics
|
|
|
|
static wxString EscapeMnemonics(const wxString& str);
|
|
|
|
|
2008-10-12 09:04:00 -04:00
|
|
|
// return the accel index in the string or -1 if none and puts the modified
|
|
|
|
// string into second parameter if non NULL
|
|
|
|
static int FindAccelIndex(const wxString& label,
|
|
|
|
wxString *labelOnly = NULL);
|
|
|
|
|
2004-03-31 19:19:39 -05:00
|
|
|
|
2003-10-16 06:00:12 -04: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-03-31 19:19:39 -05: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 16:09:45 -04:00
|
|
|
virtual bool SetFont(const wxFont& font);
|
|
|
|
|
2006-02-12 11:32:50 -05:00
|
|
|
// wxControl-specific processing after processing the update event
|
|
|
|
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
|
|
|
|
|
1999-07-26 19:02:32 -04:00
|
|
|
protected:
|
2007-11-13 07:10:34 -05:00
|
|
|
// choose the default border for this window
|
|
|
|
virtual wxBorder GetDefaultBorder() const;
|
|
|
|
|
1999-11-10 19:25:57 -05:00
|
|
|
// creates the control (calls wxWindowBase::CreateBase inside) and adds it
|
|
|
|
// to the list of parents children
|
1999-07-26 19:02:32 -04:00
|
|
|
bool CreateControl(wxWindowBase *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style,
|
|
|
|
const wxValidator& validator,
|
|
|
|
const wxString& name);
|
|
|
|
|
2000-02-25 18:49:41 -05:00
|
|
|
// initialize the common fields of wxCommandEvent
|
|
|
|
void InitCommandEvent(wxCommandEvent& event) const;
|
2003-07-21 20:24:07 -04:00
|
|
|
|
2007-04-01 10:13:15 -04:00
|
|
|
// this field contains the label in wx format, i.e. with '&' mnemonics
|
|
|
|
wxString m_labelOrig;
|
|
|
|
|
2003-07-21 20:24:07 -04:00
|
|
|
DECLARE_NO_COPY_CLASS(wxControlBase)
|
1999-07-26 19:02:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// include platform-dependent wxControl declarations
|
|
|
|
// ----------------------------------------------------------------------------
|
1999-05-09 18:17:03 -04:00
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#if defined(__WXUNIVERSAL__)
|
|
|
|
#include "wx/univ/control.h"
|
2004-12-20 07:44:22 -05:00
|
|
|
#elif defined(__WXPALMOS__)
|
2004-10-19 09:40:30 -04:00
|
|
|
#include "wx/palmos/control.h"
|
2001-06-26 16:59:19 -04:00
|
|
|
#elif defined(__WXMSW__)
|
1999-07-26 19:02:32 -04:00
|
|
|
#include "wx/msw/control.h"
|
1998-07-10 10:15:17 -04:00
|
|
|
#elif defined(__WXMOTIF__)
|
1999-07-26 19:02:32 -04:00
|
|
|
#include "wx/motif/control.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK20__)
|
1999-07-26 19:02:32 -04:00
|
|
|
#include "wx/gtk/control.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK__)
|
|
|
|
#include "wx/gtk1/control.h"
|
1998-08-14 20:23:28 -04:00
|
|
|
#elif defined(__WXMAC__)
|
2008-06-11 15:17:41 -04:00
|
|
|
#include "wx/osx/control.h"
|
2003-03-22 01:18:36 -05:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/control.h"
|
1999-07-27 23:38:12 -04:00
|
|
|
#elif defined(__WXPM__)
|
|
|
|
#include "wx/os2/control.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#endif // wxUSE_CONTROLS
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_CONTROL_H_BASE_
|