1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: control.h
|
|
|
|
// Purpose: wxControl class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
1998-08-07 19:52:45 -04:00
|
|
|
// Copyright: (c) Julian Smart
|
1999-05-18 20:53:27 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 19:52:45 -04:00
|
|
|
#ifndef _WX_CONTROL_H_
|
|
|
|
#define _WX_CONTROL_H_
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2003-08-09 08:38:21 -04:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-02-04 18:21:27 -05:00
|
|
|
#pragma interface "control.h"
|
1998-05-20 10:12:05 -04:00
|
|
|
#endif
|
|
|
|
|
1999-11-26 04:53:35 -05:00
|
|
|
#include "wx/dynarray.h"
|
|
|
|
|
1998-05-20 10:12:05 -04:00
|
|
|
// General item class
|
1999-07-26 19:02:32 -04:00
|
|
|
class WXDLLEXPORT wxControl : public wxControlBase
|
1998-05-20 10:12:05 -04:00
|
|
|
{
|
|
|
|
public:
|
2004-03-31 19:07:32 -05:00
|
|
|
wxControl() { }
|
|
|
|
|
2003-07-21 20:24:07 -04:00
|
|
|
wxControl(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxControlNameStr)
|
1999-12-23 14:23:13 -05:00
|
|
|
{
|
|
|
|
Create(parent, id, pos, size, style, validator, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
virtual ~wxControl();
|
1999-02-04 18:21:27 -05:00
|
|
|
|
2000-01-05 10:35:04 -05:00
|
|
|
// Simulates an event
|
|
|
|
virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
|
1999-07-26 19:02:32 -04:00
|
|
|
|
2004-03-31 19:07:32 -05:00
|
|
|
|
2000-01-05 10:35:04 -05:00
|
|
|
// implementation from now on
|
|
|
|
// --------------------------
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2004-03-31 19:07:32 -05:00
|
|
|
virtual wxVisualAttributes GetDefaultAttributes() const
|
|
|
|
{
|
|
|
|
return GetClassDefaultAttributes(GetWindowVariant());
|
|
|
|
}
|
|
|
|
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
|
|
|
|
2000-01-05 10:35:04 -05:00
|
|
|
// Calls the callback and appropriate event handlers
|
|
|
|
bool ProcessCommand(wxCommandEvent& event);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-05 10:35:04 -05:00
|
|
|
// MSW-specific
|
1999-05-13 17:21:04 -04:00
|
|
|
#ifdef __WIN95__
|
2000-01-05 10:35:04 -05:00
|
|
|
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
1999-05-13 17:21:04 -04:00
|
|
|
#endif // Win95
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-05 10:35:04 -05:00
|
|
|
// For ownerdraw items
|
|
|
|
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
|
|
|
|
virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2004-02-19 10:26:03 -05:00
|
|
|
const wxArrayLong& GetSubcontrols() const { return m_subControls; }
|
1999-02-04 18:21:27 -05:00
|
|
|
|
2000-01-05 10:35:04 -05:00
|
|
|
void OnEraseBackground(wxEraseEvent& event);
|
1999-05-13 17:21:04 -04:00
|
|
|
|
2000-01-05 10:35:04 -05:00
|
|
|
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
|
|
|
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
1999-11-25 18:28:41 -05:00
|
|
|
|
1999-05-18 20:53:27 -04:00
|
|
|
protected:
|
2003-07-06 17:35:32 -04:00
|
|
|
// choose the default border for this window
|
|
|
|
virtual wxBorder GetDefaultBorder() const;
|
2000-01-05 10:35:04 -05:00
|
|
|
|
2004-02-09 18:20:04 -05:00
|
|
|
// return default best size (doesn't really make any sense, override this)
|
2000-01-05 10:35:04 -05:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
|
|
|
|
2003-01-10 18:27:17 -05:00
|
|
|
// create the control of the given Windows class: this is typically called
|
|
|
|
// from Create() method of the derived class passing its label, pos and
|
|
|
|
// size parameter (style parameter is not needed because m_windowStyle is
|
|
|
|
// supposed to had been already set and so is used instead when this
|
|
|
|
// function is called)
|
2002-02-19 19:02:51 -05:00
|
|
|
bool MSWCreateControl(const wxChar *classname,
|
|
|
|
const wxString& label,
|
|
|
|
const wxPoint& pos,
|
2003-01-10 18:27:17 -05:00
|
|
|
const wxSize& size);
|
2002-02-19 19:02:51 -05:00
|
|
|
|
|
|
|
// NB: the method below is deprecated now, with MSWGetStyle() the method
|
|
|
|
// above should be used instead! Once all the controls are updated to
|
|
|
|
// implement MSWGetStyle() this version will disappear.
|
|
|
|
//
|
2001-10-07 18:17:24 -04:00
|
|
|
// create the control of the given class with the given style (combination
|
|
|
|
// of WS_XXX flags, i.e. Windows style, not wxWindows one), returns
|
|
|
|
// FALSE if creation failed
|
2000-01-05 10:35:04 -05:00
|
|
|
//
|
|
|
|
// All parameters except classname and style are optional, if the
|
2001-10-07 18:17:24 -04:00
|
|
|
// size/position are not given, they should be set later with SetSize()
|
|
|
|
// and, label (the title of the window), of course, is left empty. The
|
|
|
|
// extended style is determined from the style and the app 3D settings
|
|
|
|
// automatically if it's not specified explicitly.
|
2000-01-05 10:35:04 -05:00
|
|
|
bool MSWCreateControl(const wxChar *classname,
|
2001-10-07 18:17:24 -04:00
|
|
|
WXDWORD style,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
const wxString& label = wxEmptyString,
|
2002-08-22 12:00:45 -04:00
|
|
|
WXDWORD exstyle = (WXDWORD)-1);
|
2000-01-05 10:35:04 -05:00
|
|
|
|
2002-02-19 19:02:51 -05:00
|
|
|
// default style for the control include WS_TABSTOP if it AcceptsFocus()
|
|
|
|
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
1999-07-02 18:02:05 -04:00
|
|
|
|
2004-03-31 19:07:32 -05:00
|
|
|
// this is a helper for the derived class GetClassDefaultAttributes()
|
|
|
|
// implementation: it returns the right colours for the classes which
|
|
|
|
// contain something else (e.g. wxListBox, wxTextCtrl, ...) instead of
|
|
|
|
// being simple controls (such as wxButton, wxCheckBox, ...)
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetCompositeControlsDefaultAttributes(wxWindowVariant variant);
|
|
|
|
|
|
|
|
|
2003-07-06 17:35:32 -04:00
|
|
|
// for controls like radiobuttons which are really composite this array
|
|
|
|
// holds the ids (not HWNDs!) of the sub controls
|
|
|
|
wxArrayLong m_subControls;
|
|
|
|
|
1999-02-04 18:21:27 -05:00
|
|
|
private:
|
2003-07-21 20:24:07 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl)
|
2000-01-05 10:35:04 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-20 10:12:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-08-07 19:52:45 -04:00
|
|
|
// _WX_CONTROL_H_
|