1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: control.h
|
|
|
|
// Purpose: wxControl 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
|
1999-05-19 00:53:27 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 23:52:45 +00:00
|
|
|
#ifndef _WX_CONTROL_H_
|
|
|
|
#define _WX_CONTROL_H_
|
1998-05-20 14:12:05 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
1999-02-04 23:21:27 +00:00
|
|
|
#pragma interface "control.h"
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
|
|
|
|
1999-11-26 09:53:35 +00:00
|
|
|
#include "wx/dynarray.h"
|
|
|
|
|
1999-12-23 19:23:13 +00:00
|
|
|
WXDLLEXPORT_DATA(extern const wxChar*) wxControlNameStr;
|
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
// General item class
|
1999-07-26 23:02:32 +00:00
|
|
|
class WXDLLEXPORT wxControl : public wxControlBase
|
1998-05-20 14:12:05 +00:00
|
|
|
{
|
1999-02-04 23:21:27 +00:00
|
|
|
DECLARE_ABSTRACT_CLASS(wxControl)
|
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
public:
|
1999-02-04 23:21:27 +00:00
|
|
|
wxControl();
|
1999-12-23 19:23:13 +00: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)
|
|
|
|
{
|
|
|
|
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 23:21:27 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
// Simulates an event
|
|
|
|
virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
|
1999-07-26 23:02:32 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
// implementation from now on
|
|
|
|
// --------------------------
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
// Calls the callback and appropriate event handlers
|
|
|
|
bool ProcessCommand(wxCommandEvent& event);
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
// MSW-specific
|
1999-05-13 21:21:04 +00:00
|
|
|
#ifdef __WIN95__
|
2000-01-05 15:35:04 +00:00
|
|
|
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
1999-05-13 21:21:04 +00:00
|
|
|
#endif // Win95
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
// For ownerdraw items
|
|
|
|
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
|
|
|
|
virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
wxArrayLong GetSubcontrols() { return m_subControls; }
|
1999-02-04 23:21:27 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
void OnEraseBackground(wxEraseEvent& event);
|
1999-05-13 21:21:04 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
|
|
|
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
1999-11-25 23:28:41 +00:00
|
|
|
|
1999-05-19 00:53:27 +00:00
|
|
|
#if WXWIN_COMPATIBILITY
|
2000-01-05 15:35:04 +00:00
|
|
|
virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
|
|
|
|
wxColour* GetButtonColour() const { return NULL; }
|
1999-05-19 00:53:27 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
inline virtual void SetLabelFont(const wxFont& font);
|
|
|
|
inline virtual void SetButtonFont(const wxFont& font);
|
|
|
|
inline wxFont& GetLabelFont() const;
|
|
|
|
inline wxFont& GetButtonFont() const;
|
1999-05-19 00:53:27 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
// Adds callback
|
|
|
|
inline void Callback(const wxFunction function);
|
1999-05-19 00:53:27 +00:00
|
|
|
|
2000-01-05 15:35:04 +00:00
|
|
|
wxFunction GetCallback() { return m_callback; }
|
1999-05-19 00:53:27 +00:00
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
protected:
|
2000-01-05 15:35:04 +00:00
|
|
|
wxFunction m_callback; // Callback associated with the window
|
1999-05-19 00:53:27 +00:00
|
|
|
#endif // WXWIN_COMPATIBILITY
|
|
|
|
|
|
|
|
protected:
|
2000-01-05 15:35:04 +00:00
|
|
|
// for controls like radiobuttons which are really composite this array
|
|
|
|
// holds the ids (not HWNDs!) of the sub controls
|
|
|
|
wxArrayLong m_subControls;
|
|
|
|
|
|
|
|
virtual wxSize DoGetBestSize() const;
|
|
|
|
|
|
|
|
// create the control of the given class with the given style, returns FALSE
|
|
|
|
// if creation failed
|
|
|
|
//
|
|
|
|
// All parameters except classname and style are optional, if the
|
|
|
|
// 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.
|
|
|
|
bool MSWCreateControl(const wxChar *classname,
|
|
|
|
WXDWORD style,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
const wxString& label = wxEmptyString,
|
|
|
|
WXDWORD exstyle = (WXDWORD)-1);
|
|
|
|
|
|
|
|
// determine the extended styles combination for this window (may slightly
|
|
|
|
// modify style parameter, this is why it's non const)
|
|
|
|
WXDWORD GetExStyle(WXDWORD& style, bool *want3D) const;
|
1999-07-02 22:02:05 +00:00
|
|
|
|
1999-02-04 23:21:27 +00:00
|
|
|
private:
|
2000-01-05 15:35:04 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-20 14:12:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#if WXWIN_COMPATIBILITY
|
1999-05-19 00:53:27 +00:00
|
|
|
inline void wxControl::Callback(const wxFunction f) { m_callback = f; };
|
1999-07-26 23:02:32 +00:00
|
|
|
inline wxFont& wxControl::GetLabelFont() const { return GetFont(); }
|
|
|
|
inline wxFont& wxControl::GetButtonFont() const { return GetFont(); }
|
1999-02-04 23:21:27 +00:00
|
|
|
inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
|
|
|
|
inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
|
1999-05-19 00:53:27 +00:00
|
|
|
#endif // WXWIN_COMPATIBILITY
|
1998-05-20 14:12:05 +00:00
|
|
|
|
|
|
|
#endif
|
1998-08-07 23:52:45 +00:00
|
|
|
// _WX_CONTROL_H_
|