Implemented wxToggleButton under Motif.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1200,6 +1200,7 @@ statbmp.h MotifH
|
|||||||
statbox.h MotifH
|
statbox.h MotifH
|
||||||
stattext.h MotifH
|
stattext.h MotifH
|
||||||
textctrl.h MotifH
|
textctrl.h MotifH
|
||||||
|
tglbtn.h MotifH
|
||||||
timer.h MotifH
|
timer.h MotifH
|
||||||
toolbar.h MotifH
|
toolbar.h MotifH
|
||||||
toplevel.h MotifH
|
toplevel.h MotifH
|
||||||
|
@@ -90,6 +90,10 @@ wxMotif
|
|||||||
does not support all the features other ports do); refer to wxFileDialog
|
does not support all the features other ports do); refer to wxFileDialog
|
||||||
documentation for a detailed explanation
|
documentation for a detailed explanation
|
||||||
- implemented wxWakeUpIdle
|
- implemented wxWakeUpIdle
|
||||||
|
- for Motif 2.0, used the native combobox widget instead of the GPL'd
|
||||||
|
xmcombo; xmcombo is still used for Motif 1.x and Lesstif when compiled
|
||||||
|
with Motif 1.x compatibility
|
||||||
|
- implemented wxToggleButton
|
||||||
|
|
||||||
OLD CHANGES
|
OLD CHANGES
|
||||||
===========
|
===========
|
||||||
|
@@ -18,7 +18,8 @@ functionality but looks like a \helpref{wxButton}{wxbutton}.
|
|||||||
You can see wxToggleButton in action in the sixth page of the
|
You can see wxToggleButton in action in the sixth page of the
|
||||||
\helpref{controls}{samplecontrols} sample.
|
\helpref{controls}{samplecontrols} sample.
|
||||||
|
|
||||||
{\bf NB:} This class is only available under wxMSW and wxGTK currently.
|
{\bf NB:} This class is only available under wxMSW, wxGTK and wxMotif
|
||||||
|
currently.
|
||||||
|
|
||||||
\wxheading{Derived from}
|
\wxheading{Derived from}
|
||||||
|
|
||||||
|
@@ -996,10 +996,6 @@
|
|||||||
# undef wxUSE_TAB_DIALOG
|
# undef wxUSE_TAB_DIALOG
|
||||||
# define wxUSE_TAB_DIALOG 1
|
# define wxUSE_TAB_DIALOG 1
|
||||||
#endif
|
#endif
|
||||||
#if defined(__WXMOTIF__) && wxUSE_TOGGLEBTN
|
|
||||||
# undef wxUSE_TOGGLEBTN
|
|
||||||
# define wxUSE_TOGGLEBTN 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* wxMGL-specific dependencies */
|
/* wxMGL-specific dependencies */
|
||||||
#ifdef __WXMGL__
|
#ifdef __WXMGL__
|
||||||
|
@@ -26,13 +26,15 @@ class WXDLLEXPORT wxCheckBox: public wxCheckBoxBase
|
|||||||
DECLARE_DYNAMIC_CLASS(wxCheckBox)
|
DECLARE_DYNAMIC_CLASS(wxCheckBox)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline wxCheckBox() { }
|
inline wxCheckBox() { Init(); }
|
||||||
inline wxCheckBox(wxWindow *parent, wxWindowID id, const wxString& label,
|
inline wxCheckBox(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize, long style = 0,
|
const wxSize& size = wxDefaultSize, long style = 0,
|
||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = wxCheckBoxNameStr)
|
const wxString& name = wxCheckBoxNameStr)
|
||||||
{
|
{
|
||||||
|
Init();
|
||||||
|
|
||||||
Create(parent, id, label, pos, size, style, validator, name);
|
Create(parent, id, label, pos, size, style, validator, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +49,17 @@ public:
|
|||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual void ChangeBackgroundColour();
|
virtual void ChangeBackgroundColour();
|
||||||
|
private:
|
||||||
|
// common part of all constructors
|
||||||
|
void Init()
|
||||||
|
{
|
||||||
|
m_evtType = wxEVT_COMMAND_CHECKBOX_CLICKED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public for the callback
|
||||||
|
public:
|
||||||
|
// either exEVT_COMMAND_CHECKBOX_CLICKED or ..._TOGGLEBUTTON_CLICKED
|
||||||
|
wxEventType m_evtType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
50
include/wx/motif/tglbtn.h
Normal file
50
include/wx/motif/tglbtn.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wx/motif/tglbtn.h
|
||||||
|
// Purpose: Declaration of the wxToggleButton class, which implements a
|
||||||
|
// toggle button under wxMotif.
|
||||||
|
// Author: Mattia Barbon
|
||||||
|
// Modified by:
|
||||||
|
// Created: 10.02.03
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2003 Mattia Barbon
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_TOGGLEBUTTON_H_
|
||||||
|
#define _WX_TOGGLEBUTTON_H_
|
||||||
|
|
||||||
|
#include "wx/checkbox.h"
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxToggleButton : public wxCheckBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxToggleButton() { Init(); }
|
||||||
|
wxToggleButton( wxWindow* parent, wxWindowID id, const wxString& label,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = 0,
|
||||||
|
const wxValidator& val = wxDefaultValidator,
|
||||||
|
const wxString& name = wxCheckBoxNameStr )
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
|
||||||
|
Create( parent, id, label, pos, size, style, val, name );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Create( wxWindow* parent, wxWindowID id, const wxString& label,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = 0,
|
||||||
|
const wxValidator& val = wxDefaultValidator,
|
||||||
|
const wxString &name = wxCheckBoxNameStr );
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxToggleButton);
|
||||||
|
|
||||||
|
// common part of all constructors
|
||||||
|
void Init()
|
||||||
|
{
|
||||||
|
m_evtType = wxEVT_COMMAND_TOGGLEBUTTON_CLICKED;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _WX_TOGGLEBUTTON_H_
|
@@ -30,9 +30,9 @@ END_DECLARE_EVENT_TYPES()
|
|||||||
#include "wx/msw/tglbtn.h"
|
#include "wx/msw/tglbtn.h"
|
||||||
#elif defined(__WXGTK__)
|
#elif defined(__WXGTK__)
|
||||||
#include "wx/gtk/tglbtn.h"
|
#include "wx/gtk/tglbtn.h"
|
||||||
/*
|
|
||||||
# elif defined(__WXMOTIF__)
|
# elif defined(__WXMOTIF__)
|
||||||
# include "wx/motif/tglbtn.h"
|
#include "wx/motif/tglbtn.h"
|
||||||
|
/*
|
||||||
# elif defined(__WXMAC__)
|
# elif defined(__WXMAC__)
|
||||||
# include "wx/mac/tglbtn.h"
|
# include "wx/mac/tglbtn.h"
|
||||||
# elif defined(__WXPM__)
|
# elif defined(__WXPM__)
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
|
|
||||||
#include "wx/checkbox.h"
|
#include "wx/checkbox.h"
|
||||||
|
#include "wx/tglbtn.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
|
|
||||||
#ifdef __VMS__
|
#ifdef __VMS__
|
||||||
@@ -104,7 +105,7 @@ void wxCheckBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
|
|||||||
if (item->InSetValue())
|
if (item->InSetValue())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxCommandEvent event (wxEVT_COMMAND_CHECKBOX_CLICKED, item->GetId());
|
wxCommandEvent event (item->m_evtType, item->GetId());
|
||||||
event.SetInt((int) item->GetValue ());
|
event.SetInt((int) item->GetValue ());
|
||||||
event.SetEventObject(item);
|
event.SetEventObject(item);
|
||||||
item->ProcessCommand (event);
|
item->ProcessCommand (event);
|
||||||
@@ -130,3 +131,46 @@ void wxCheckBox::ChangeBackgroundColour()
|
|||||||
XmNselectColor, selectPixel,
|
XmNselectColor, selectPixel,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// wxToggleButton
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if wxUSE_TOGGLEBTN
|
||||||
|
|
||||||
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED)
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl)
|
||||||
|
|
||||||
|
bool wxToggleButton::Create( wxWindow* parent, wxWindowID id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxValidator& val,
|
||||||
|
const wxString &name )
|
||||||
|
{
|
||||||
|
if( !wxCheckBox::Create( parent, id, label, pos, size, style, val, name ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
XtVaSetValues( (Widget)m_mainWidget,
|
||||||
|
XmNindicatorSize, 0,
|
||||||
|
#if XmVersion >= 2000
|
||||||
|
XmNindicatorOn, XmINDICATOR_NONE,
|
||||||
|
#else
|
||||||
|
XmNindicatorOn, False,
|
||||||
|
#endif
|
||||||
|
XmNfillOnSelect, False,
|
||||||
|
XmNshadowThickness, 2,
|
||||||
|
XmNalignment, XmALIGNMENT_CENTER,
|
||||||
|
XmNmarginLeft, 0,
|
||||||
|
XmNmarginRight, 0,
|
||||||
|
NULL );
|
||||||
|
|
||||||
|
// set it again, because the XtVaSetValue above resets it
|
||||||
|
if( size.x != -1 || size.y != -1 )
|
||||||
|
SetSize( size );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_TOGGLEBUTTON
|
||||||
|
@@ -565,6 +565,7 @@ ALL_HEADERS = \
|
|||||||
motif/statbox.h \
|
motif/statbox.h \
|
||||||
motif/stattext.h \
|
motif/stattext.h \
|
||||||
motif/textctrl.h \
|
motif/textctrl.h \
|
||||||
|
motif/tglbtn.h \
|
||||||
motif/timer.h \
|
motif/timer.h \
|
||||||
motif/toolbar.h \
|
motif/toolbar.h \
|
||||||
motif/toplevel.h \
|
motif/toplevel.h \
|
||||||
|
Reference in New Issue
Block a user