2001-06-26 20:59:19 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/univ/control.h
|
|
|
|
// Purpose: universal wxControl: adds handling of mnemonics
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 14.08.00
|
|
|
|
// RCS-ID: $Id$
|
2001-07-02 19:42:27 +00:00
|
|
|
// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
2001-06-26 20:59:19 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_UNIV_CONTROL_H_
|
|
|
|
#define _WX_UNIV_CONTROL_H_
|
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxControlRenderer;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxInputHandler;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxRenderer;
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
// we must include it as most/all control classes derive their handlers from
|
|
|
|
// it
|
|
|
|
#include "wx/univ/inphand.h"
|
|
|
|
|
2001-09-22 11:56:04 +00:00
|
|
|
#include "wx/univ/inpcons.h"
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxControlAction: the action is currently just a string which identifies it,
|
|
|
|
// later it might become an atom (i.e. an opaque handler to string).
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
typedef wxString wxControlAction;
|
|
|
|
|
|
|
|
// the list of actions which apply to all controls (other actions are defined
|
|
|
|
// in the controls headers)
|
|
|
|
|
|
|
|
#define wxACTION_NONE _T("") // no action to perform
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxControl: the base class for all GUI controls
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxControl : public wxControlBase, public wxInputConsumer
|
2001-06-26 20:59:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2004-01-15 13:49:22 +00:00
|
|
|
wxControl() { Init(); }
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
wxControl(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2004-01-15 13:49:22 +00:00
|
|
|
const wxString& name = wxControlNameStr)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
|
|
|
|
Create(parent, id, pos, size, style, validator, name);
|
|
|
|
}
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
// this function will filter out '&' characters and will put the
|
|
|
|
// accelerator char (the one immediately after '&') into m_chAccel
|
2007-04-01 14:13:15 +00:00
|
|
|
virtual void SetLabel(const wxString& label);
|
|
|
|
|
|
|
|
// return the current label
|
|
|
|
virtual wxString GetLabel() const { return m_label; }
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
// wxUniversal-specific methods
|
|
|
|
|
|
|
|
// return the accel index in the string or -1 if none and puts the modified
|
2007-04-01 14:13:15 +00:00
|
|
|
// string into second parameter if non NULL
|
2001-06-26 20:59:19 +00:00
|
|
|
static int FindAccelIndex(const wxString& label,
|
|
|
|
wxString *labelOnly = NULL);
|
|
|
|
|
|
|
|
// return the index of the accel char in the label or -1 if none
|
|
|
|
int GetAccelIndex() const { return m_indexAccel; }
|
|
|
|
|
|
|
|
// return the accel char itself or 0 if none
|
|
|
|
wxChar GetAccelChar() const
|
|
|
|
{
|
2007-03-19 01:21:07 +00:00
|
|
|
return m_indexAccel == -1 ? _T('\0') : (wxChar)m_label[m_indexAccel];
|
2001-06-26 20:59:19 +00:00
|
|
|
}
|
|
|
|
|
2001-09-22 11:56:04 +00:00
|
|
|
virtual wxWindow *GetInputWindow() const { return (wxWindow*)this; }
|
2001-06-26 20:59:19 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
2007-04-01 14:13:15 +00:00
|
|
|
// set m_label and m_indexAccel and refresh the control to show the new
|
|
|
|
// label (but, unlike SetLabel(), don't call the base class SetLabel() thus
|
|
|
|
// avoiding to change wxControlBase::m_labelOrig)
|
|
|
|
void UnivDoSetLabel(const wxString& label);
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
private:
|
|
|
|
// label and accel info
|
|
|
|
wxString m_label;
|
|
|
|
int m_indexAccel;
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxControl)
|
|
|
|
DECLARE_EVENT_TABLE()
|
2001-09-22 11:56:04 +00:00
|
|
|
WX_DECLARE_INPUT_CONSUMER()
|
2001-06-26 20:59:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_UNIV_CONTROL_H_
|