applied (slightly modified) wxToggleButton patch from John Norris and Axel Schlueter

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9333 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-02-08 18:57:23 +00:00
parent bb84929ec5
commit 1db8dc4a2b
29 changed files with 1525 additions and 569 deletions

1114
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -803,6 +803,7 @@ if test $DEBUG_CONFIGURE = 1; then
DEFAULT_wxUSE_STATLINE=no DEFAULT_wxUSE_STATLINE=no
DEFAULT_wxUSE_STATUSBAR=yes DEFAULT_wxUSE_STATUSBAR=yes
DEFAULT_wxUSE_TABDIALOG=no DEFAULT_wxUSE_TABDIALOG=no
DEFAULT_wxUSE_TOGGLEBTN=no
DEFAULT_wxUSE_TOOLBAR=no DEFAULT_wxUSE_TOOLBAR=no
DEFAULT_wxUSE_TOOLBAR_NATIVE=no DEFAULT_wxUSE_TOOLBAR_NATIVE=no
DEFAULT_wxUSE_TOOLBAR_SIMPLE=no DEFAULT_wxUSE_TOOLBAR_SIMPLE=no
@@ -925,6 +926,7 @@ else
DEFAULT_wxUSE_STATLINE=yes DEFAULT_wxUSE_STATLINE=yes
DEFAULT_wxUSE_STATUSBAR=yes DEFAULT_wxUSE_STATUSBAR=yes
DEFAULT_wxUSE_TABDIALOG=no DEFAULT_wxUSE_TABDIALOG=no
DEFAULT_wxUSE_TOGGLEBTN=yes
DEFAULT_wxUSE_TOOLBAR=yes DEFAULT_wxUSE_TOOLBAR=yes
DEFAULT_wxUSE_TOOLBAR_NATIVE=yes DEFAULT_wxUSE_TOOLBAR_NATIVE=yes
DEFAULT_wxUSE_TOOLBAR_SIMPLE=yes DEFAULT_wxUSE_TOOLBAR_SIMPLE=yes
@@ -1145,6 +1147,7 @@ if test "$wxUSE_CONTROLS" = "yes"; then
DEFAULT_wxUSE_STATLINE=yes DEFAULT_wxUSE_STATLINE=yes
DEFAULT_wxUSE_STATUSBAR=yes DEFAULT_wxUSE_STATUSBAR=yes
DEFAULT_wxUSE_TAB_DIALOG=yes DEFAULT_wxUSE_TAB_DIALOG=yes
DEFAULT_wxUSE_TOGGLEBTN=yes
DEFAULT_wxUSE_TOOLBAR=yes DEFAULT_wxUSE_TOOLBAR=yes
DEFAULT_wxUSE_TOOLBAR_NATIVE=yes DEFAULT_wxUSE_TOOLBAR_NATIVE=yes
DEFAULT_wxUSE_TOOLBAR_SIMPLE=yes DEFAULT_wxUSE_TOOLBAR_SIMPLE=yes
@@ -1178,6 +1181,7 @@ elif test "$wxUSE_CONTROLS" = "no"; then
DEFAULT_wxUSE_STATLINE=no DEFAULT_wxUSE_STATLINE=no
DEFAULT_wxUSE_STATUSBAR=no DEFAULT_wxUSE_STATUSBAR=no
DEFAULT_wxUSE_TAB_DIALOG=no DEFAULT_wxUSE_TAB_DIALOG=no
DEFAULT_wxUSE_TOGGLEBTN=no
DEFAULT_wxUSE_TOOLBAR=no DEFAULT_wxUSE_TOOLBAR=no
DEFAULT_wxUSE_TOOLBAR_NATIVE=no DEFAULT_wxUSE_TOOLBAR_NATIVE=no
DEFAULT_wxUSE_TOOLBAR_SIMPLE=no DEFAULT_wxUSE_TOOLBAR_SIMPLE=no
@@ -1212,6 +1216,7 @@ WX_ARG_ENABLE(statbox, [ --enable-statbox use wxStaticBox class], wx
WX_ARG_ENABLE(statline, [ --enable-statline use wxStaticLine class], wxUSE_STATLINE) WX_ARG_ENABLE(statline, [ --enable-statline use wxStaticLine class], wxUSE_STATLINE)
WX_ARG_ENABLE(statusbar, [ --enable-statusbar use wxStatusBar class], wxUSE_STATUSBAR) WX_ARG_ENABLE(statusbar, [ --enable-statusbar use wxStatusBar class], wxUSE_STATUSBAR)
WX_ARG_ENABLE(tabdialog, [ --enable-tabdialog use wxTabControl class], wxUSE_TABDIALOG) WX_ARG_ENABLE(tabdialog, [ --enable-tabdialog use wxTabControl class], wxUSE_TABDIALOG)
WX_ARG_ENABLE(togglebtn, [ --enable-togglebtn use wxToggleButton class], wxUSE_TOGGLEBTN)
WX_ARG_ENABLE(toolbar, [ --enable-toolbar use wxToolBar class], wxUSE_TOOLBAR) WX_ARG_ENABLE(toolbar, [ --enable-toolbar use wxToolBar class], wxUSE_TOOLBAR)
WX_ARG_ENABLE(tbarnative, [ --enable-tbarnative use native wxToolBar class], wxUSE_TOOLBAR_NATIVE) WX_ARG_ENABLE(tbarnative, [ --enable-tbarnative use native wxToolBar class], wxUSE_TOOLBAR_NATIVE)
WX_ARG_ENABLE(tbarsmpl, [ --enable-tbarsmpl use wxToolBarSimple class], wxUSE_TOOLBAR_SIMPLE) WX_ARG_ENABLE(tbarsmpl, [ --enable-tbarsmpl use wxToolBarSimple class], wxUSE_TOOLBAR_SIMPLE)
@@ -3731,6 +3736,10 @@ if test "$wxUSE_TABDIALOG" = "yes"; then
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS tab" SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS tab"
fi fi
if test "$wxUSE_TOGGLEBTN" = "yes"; then
AC_DEFINE(wxUSE_TOGGLEBTN)
fi
if test "$wxUSE_TOOLBAR_SIMPLE" = "yes"; then if test "$wxUSE_TOOLBAR_SIMPLE" = "yes"; then
AC_DEFINE(wxUSE_TOOLBAR_SIMPLE) AC_DEFINE(wxUSE_TOOLBAR_SIMPLE)
wxUSE_TOOLBAR="yes" wxUSE_TOOLBAR="yes"

View File

@@ -307,6 +307,7 @@ taskbar.cpp M 32
tbar95.cpp M 32 tbar95.cpp M 32
tbarmsw.cpp M 16 tbarmsw.cpp M 16
textctrl.cpp M textctrl.cpp M
tglbtn.cpp M
thread.cpp M 32,B thread.cpp M 32,B
timer.cpp M timer.cpp M
tooltip.cpp M 32 tooltip.cpp M 32
@@ -381,6 +382,7 @@ statline.cpp R
stattext.cpp R stattext.cpp R
tbargtk.cpp R tbargtk.cpp R
textctrl.cpp R textctrl.cpp R
tglbtn.cpp R
timer.cpp R timer.cpp R
tooltip.cpp R tooltip.cpp R
utilsgtk.cpp R utilsgtk.cpp R
@@ -720,7 +722,7 @@ tbarsmpl.h W
textctrl.h W textctrl.h W
textdlg.h W textdlg.h W
textfile.h W B textfile.h W B
txtstrm.h W B tglbtn.h W
thread.h W B thread.h W B
time.h W B time.h W B
timer.h W B timer.h W B
@@ -731,6 +733,7 @@ toolbar.h W
tooltip.h W tooltip.h W
treebase.h W treebase.h W
treectrl.h W treectrl.h W
txtstrm.h W B
types.h W types.h W
url.h W B url.h W B
utils.h W B utils.h W B
@@ -809,6 +812,7 @@ statline.h K
stattext.h K stattext.h K
tbargtk.h K tbargtk.h K
textctrl.h K textctrl.h K
tglbtn.h K
timer.h K timer.h K
tooltip.h K tooltip.h K
treectrl.h K treectrl.h K
@@ -961,6 +965,7 @@ taskbar.h 9
tbar95.h 9 tbar95.h 9
tbarmsw.h 9 tbarmsw.h 9
textctrl.h 9 textctrl.h 9
tglbtn.h 9
timer.h 9 timer.h 9
tooltip.h 9 tooltip.h 9
treectrl.h 9 treectrl.h 9

View File

@@ -13,6 +13,10 @@ wxBase:
- wxCopyFile() respects the file permissions (Roland Scholz) - wxCopyFile() respects the file permissions (Roland Scholz)
- wxFTP::GetFileSize() added (S<>ren Erland Vest<73>) - wxFTP::GetFileSize() added (S<>ren Erland Vest<73>)
All (GUI):
- new wxToggleButton class (John Norris, Axel Schlueter)
wxMSW: wxMSW:
- threads: bug in wxCondition::Broadcast fixed (Pieter van der Meulen) - threads: bug in wxCondition::Broadcast fixed (Pieter van der Meulen)

View File

@@ -370,6 +370,7 @@ public:
wxEVT_COMMAND_SCROLLBAR_UPDATED wxEVT_COMMAND_SCROLLBAR_UPDATED
wxEVT_COMMAND_VLBOX_SELECTED wxEVT_COMMAND_VLBOX_SELECTED
wxEVT_COMMAND_COMBOBOX_SELECTED wxEVT_COMMAND_COMBOBOX_SELECTED
wxEVT_COMMAND_TOGGLEBUTTON_CLICKED
*/ */
class WXDLLEXPORT wxCommandEvent : public wxEvent class WXDLLEXPORT wxCommandEvent : public wxEvent

83
include/wx/gtk/tglbtn.h Normal file
View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/tglbtn.h
// Purpose: Declaration of the wxToggleButton class, which implements a
// toggle button under wxGTK.
// Author: John Norris, minor changes by Axel Schlueter
// Modified by:
// Created: 08.02.01
// RCS-ID: $Id$
// Copyright: (c) 2000 Johnny C. Norris II
// License: Rocketeer license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_TOGGLEBUTTON_H_
#define _WX_GTK_TOGGLEBUTTON_H_
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxToggleButton;
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
extern const char *wxCheckBoxNameStr;
//-----------------------------------------------------------------------------
// wxToggleButton
//-----------------------------------------------------------------------------
class wxToggleButton: public wxControl
{
public:
// construction/destruction
wxToggleButton() {}
wxToggleButton(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr)
{
Create(parent, id, label, pos, size, style, validator, name);
}
// Create the control
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
// Get/set the value
void SetValue(bool state);
bool GetValue() const;
// Set the label
void SetLabel(const wxString& label);
bool Enable(bool enable = TRUE);
protected:
// Callback function given to gtk
static void gtk_togglebutton_clicked_callback(GtkWidget *widget,
wxToggleButton *win);
// wx stuff
void ApplyWidgetStyle();
bool IsOwnGtkWindow(GdkWindow *window);
virtual void OnInternalIdle();
virtual wxSize DoGetBestSize() const;
private:
DECLARE_DYNAMIC_CLASS(wxToggleButton)
};
#endif // _WX_GTK_TOGGLEBUTTON_H_

83
include/wx/gtk1/tglbtn.h Normal file
View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/tglbtn.h
// Purpose: Declaration of the wxToggleButton class, which implements a
// toggle button under wxGTK.
// Author: John Norris, minor changes by Axel Schlueter
// Modified by:
// Created: 08.02.01
// RCS-ID: $Id$
// Copyright: (c) 2000 Johnny C. Norris II
// License: Rocketeer license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_TOGGLEBUTTON_H_
#define _WX_GTK_TOGGLEBUTTON_H_
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxToggleButton;
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
extern const char *wxCheckBoxNameStr;
//-----------------------------------------------------------------------------
// wxToggleButton
//-----------------------------------------------------------------------------
class wxToggleButton: public wxControl
{
public:
// construction/destruction
wxToggleButton() {}
wxToggleButton(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr)
{
Create(parent, id, label, pos, size, style, validator, name);
}
// Create the control
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
// Get/set the value
void SetValue(bool state);
bool GetValue() const;
// Set the label
void SetLabel(const wxString& label);
bool Enable(bool enable = TRUE);
protected:
// Callback function given to gtk
static void gtk_togglebutton_clicked_callback(GtkWidget *widget,
wxToggleButton *win);
// wx stuff
void ApplyWidgetStyle();
bool IsOwnGtkWindow(GdkWindow *window);
virtual void OnInternalIdle();
virtual wxSize DoGetBestSize() const;
private:
DECLARE_DYNAMIC_CLASS(wxToggleButton)
};
#endif // _WX_GTK_TOGGLEBUTTON_H_

View File

@@ -379,6 +379,7 @@
#define wxUSE_SPINCTRL 1 #define wxUSE_SPINCTRL 1
#define wxUSE_STATLINE 1 #define wxUSE_STATLINE 1
#define wxUSE_STATUSBAR 1 #define wxUSE_STATUSBAR 1
#define wxUSE_TOGGLEBTN 1 // requires wxButton
#define wxUSE_TOOLTIPS 1 // wxToolTip and wxWindow::SetToolTip() #define wxUSE_TOOLTIPS 1 // wxToolTip and wxWindow::SetToolTip()
// Two status bar implementations are available under Win32: the generic one // Two status bar implementations are available under Win32: the generic one

59
include/wx/msw/tglbtn.h Normal file
View File

@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/tglbtn.h
// Purpose: Declaration of the wxToggleButton class, which implements a
// toggle button under wxMSW.
// Author: John Norris, minor changes by Axel Schlueter
// Modified by:
// Created: 08.02.01
// RCS-ID: $Id$
// Copyright: (c) 2000 Johnny C. Norris II
// License: Rocketeer license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TOGGLEBUTTON_H_
#define _WX_TOGGLEBUTTON_H_
WXDLLEXPORT_DATA(extern const wxChar*) wxCheckBoxNameStr;
// Checkbox item (single checkbox)
class WXDLLEXPORT wxToggleButton : public wxControl
{
public:
wxToggleButton() {}
wxToggleButton(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr)
{
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
virtual void SetValue(bool value);
virtual bool GetValue() const ;
virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual void SetLabel(const wxString& label);
virtual void Command(wxCommandEvent& event);
protected:
virtual wxSize DoGetBestSize() const;
private:
DECLARE_DYNAMIC_CLASS(wxToggleButton)
};
#endif // _WX_TOGGLEBUTTON_H_

50
include/wx/tglbtn.h Normal file
View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/tglbtn.h
// Purpose: This dummy header includes the proper header file for the
// system we're compiling under.
// Author: John Norris, minor changes by Axel Schlueter
// Modified by:
// Created: 08.02.01
// RCS-ID: $Id$
// Copyright: (c) 2000 Johnny C. Norris II
// License: Rocketeer license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TOGGLEBUTTON_H_BASE_
#define _WX_TOGGLEBUTTON_H_BASE_
#include "wx/defs.h"
#if wxUSE_TOGGLEBTN
#include "wx/event.h"
#include "wx/control.h" // base class
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, 19)
END_DECLARE_EVENT_TYPES()
#define EVT_TOGGLEBUTTON(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL ),
#if defined(__WXMSW__)
#include "wx/msw/tglbtn.h"
#elif defined(__WXGTK__)
#include "wx/gtk/tglbtn.h"
/*
# elif defined(__WXMOTIF__)
# include "wx/motif/tglbtn.h"
# elif defined(__WXQT__)
# include "wx/qt/tglbtn.h"
# elif defined(__WXMAC__)
# include "wx/mac/tglbtn.h"
# elif defined(__WXPM__)
# include "wx/os2/tglbtn.h"
# elif defined(__WXSTUBS__)
# include "wx/stubs/tglbtn.h"
*/
#endif
#endif // wxUSE_TOGGLEBTN
#endif // _WX_TOGGLEBUTTON_H_BASE_

View File

@@ -26,6 +26,7 @@
#if !defined( __WXMSW__ ) || defined( __WIN95__ ) #if !defined( __WXMSW__ ) || defined( __WIN95__ )
#include "wx/spinbutt.h" #include "wx/spinbutt.h"
#endif #endif
#include "wx/tglbtn.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/imaglist.h" #include "wx/imaglist.h"
@@ -478,7 +479,7 @@ EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
#if wxUSE_SPINCTRL #if wxUSE_SPINCTRL
EVT_SPINCTRL (ID_SPINCTRL, MyPanel::OnSpinCtrl) EVT_SPINCTRL (ID_SPINCTRL, MyPanel::OnSpinCtrl)
#endif // wxUSE_SPINCTRL #endif // wxUSE_SPINCTRL
EVT_BUTTON (ID_BUTTON_LABEL, MyPanel::OnUpdateLabel) EVT_TOGGLEBUTTON(ID_BUTTON_LABEL, MyPanel::OnUpdateLabel)
EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour) EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour)
EVT_BUTTON (ID_BUTTON_TEST1, MyPanel::OnTestButton) EVT_BUTTON (ID_BUTTON_TEST1, MyPanel::OnTestButton)
EVT_BUTTON (ID_BUTTON_TEST2, MyPanel::OnTestButton) EVT_BUTTON (ID_BUTTON_TEST2, MyPanel::OnTestButton)
@@ -780,12 +781,13 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
( (
panel, -1, panel, -1,
bmp1, bmp1,
wxPoint(30, 50) wxPoint(30, 70)
); );
bmpBtn->SetBitmapSelected(bmp2); bmpBtn->SetBitmapSelected(bmp2);
bmpBtn->SetBitmapFocus(bmp3); bmpBtn->SetBitmapFocus(bmp3);
(void)new wxButton(panel, ID_BUTTON_LABEL, "&Toggle label", wxPoint(250, 20)); (void)new wxToggleButton(panel, ID_BUTTON_LABEL,
"&Toggle label", wxPoint(250, 20));
m_label = new wxStaticText(panel, -1, "Label with some long text", m_label = new wxStaticText(panel, -1, "Label with some long text",
wxPoint(250, 60), wxDefaultSize, wxPoint(250, 60), wxDefaultSize,
wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/); wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/);
@@ -1207,12 +1209,10 @@ void MyPanel::OnSetFont( wxCommandEvent &WXUNUSED(event) )
m_text->SetFont( *wxITALIC_FONT ); m_text->SetFont( *wxITALIC_FONT );
} }
void MyPanel::OnUpdateLabel( wxCommandEvent &WXUNUSED(event) ) void MyPanel::OnUpdateLabel( wxCommandEvent &event )
{ {
static bool s_long = TRUE; m_label->SetLabel(event.GetInt() ? "Very very very very very long text."
: "Shorter text.");
s_long = !s_long;
m_label->SetLabel(s_long ? "Very very very very very long text." : "Shorter text.");
} }
void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) ) void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) )

View File

@@ -320,6 +320,10 @@
* Use this control * Use this control
*/ */
#define wxUSE_STATUSBAR 0 #define wxUSE_STATUSBAR 0
/*
* Use this control
*/
#define wxUSE_TOGGLEBTN 0
/* /*
* Use Tab dialog class - obsolete, use wxNotebook instead * Use Tab dialog class - obsolete, use wxNotebook instead
*/ */

View File

@@ -1,4 +1,4 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BASE.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BASE.T!
ALL_SOURCES = \ ALL_SOURCES = \
common/init.cpp \ common/init.cpp \

View File

@@ -77,7 +77,7 @@ bool wxCheckBox::Create(wxWindow *parent,
!CreateBase( parent, id, pos, size, style, validator, name )) !CreateBase( parent, id, pos, size, style, validator, name ))
{ {
wxFAIL_MSG( wxT("wxCheckBox creation failed") ); wxFAIL_MSG( wxT("wxCheckBox creation failed") );
return FALSE; return FALSE;
} }
wxControl::SetLabel( label ); wxControl::SetLabel( label );
@@ -199,11 +199,11 @@ void wxCheckBox::OnInternalIdle()
if (GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window && cursor.Ok()) if (GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window && cursor.Ok())
{ {
/* I now set the cursor the anew in every OnInternalIdle call /* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is windows above so that checking for the current cursor is
not possible. */ not possible. */
gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window, cursor.GetCursor() ); gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window, cursor.GetCursor() );
} }
UpdateWindowUI(); UpdateWindowUI();

View File

@@ -1,4 +1,4 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T!
ALL_SOURCES = \ ALL_SOURCES = \
generic/busyinfo.cpp \ generic/busyinfo.cpp \
@@ -198,6 +198,7 @@ ALL_SOURCES = \
gtk/stattext.cpp \ gtk/stattext.cpp \
gtk/tbargtk.cpp \ gtk/tbargtk.cpp \
gtk/textctrl.cpp \ gtk/textctrl.cpp \
gtk/tglbtn.cpp \
gtk/timer.cpp \ gtk/timer.cpp \
gtk/tooltip.cpp \ gtk/tooltip.cpp \
gtk/utilsgtk.cpp \ gtk/utilsgtk.cpp \
@@ -412,6 +413,7 @@ ALL_HEADERS = \
textctrl.h \ textctrl.h \
textdlg.h \ textdlg.h \
textfile.h \ textfile.h \
tglbtn.h \
thread.h \ thread.h \
time.h \ time.h \
timer.h \ timer.h \
@@ -500,6 +502,7 @@ ALL_HEADERS = \
gtk/stattext.h \ gtk/stattext.h \
gtk/tbargtk.h \ gtk/tbargtk.h \
gtk/textctrl.h \ gtk/textctrl.h \
gtk/tglbtn.h \
gtk/timer.h \ gtk/timer.h \
gtk/tooltip.h \ gtk/tooltip.h \
gtk/treectrl.h \ gtk/treectrl.h \
@@ -915,6 +918,7 @@ GUIOBJS = \
stattext.o \ stattext.o \
tbargtk.o \ tbargtk.o \
textctrl.o \ textctrl.o \
tglbtn.o \
timer.o \ timer.o \
tooltip.o \ tooltip.o \
utilsgtk.o \ utilsgtk.o \
@@ -976,6 +980,7 @@ GUIDEPS = \
stattext.d \ stattext.d \
tbargtk.d \ tbargtk.d \
textctrl.d \ textctrl.d \
tglbtn.d \
timer.d \ timer.d \
tooltip.d \ tooltip.d \
utilsgtk.d \ utilsgtk.d \

198
src/gtk/tglbtn.cpp Normal file
View File

@@ -0,0 +1,198 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/tglbtn.cpp
// Purpose: Definition of the wxToggleButton class, which implements a
// toggle button under wxGTK.
// Author: John Norris, minor changes by Axel Schlueter
// Modified by:
// Created: 08.02.01
// RCS-ID: $Id$
// Copyright: (c) 2000 Johnny C. Norris II
// License: Rocketeer license
/////////////////////////////////////////////////////////////////////////////
#include "wx/tglbtn.h"
#if wxUSE_TOGGLEBTN
#include <gdk/gdk.h>
#include <gtk/gtk.h>
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
// void gtk_togglebutton_clicked_callback(GtkWidget *widget, wxToggleButton *cb)
// Callback function given to gtk.
void wxToggleButton::gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb)
{
if (g_isIdle)
wxapp_install_idle_handler();
if (!cb->m_hasVMT || g_blockEventsOnDrag)
return;
// Generate a wx event.
wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, cb->GetId());
event.SetInt(cb->GetValue());
event.SetEventObject(cb);
cb->GetEventHandler()->ProcessEvent(event);
}
IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED)
// bool Create(wxWindow *parent, wxWindowID id, const wxString &label,
// const wxPoint &pos, const wxSize &size, long style,
// const wxValidator& validator, const wxString &name)
// Create the control.
bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
const wxString &label, const wxPoint &pos,
const wxSize &size, long style,
const wxValidator& validator,
const wxString &name)
{
m_needParent = TRUE;
m_acceptsFocus = TRUE;
if (!PreCreation(parent, pos, size) ||
!CreateBase(parent, id, pos, size, style, validator, name )) {
wxFAIL_MSG(wxT("wxToggleButton creation failed"));
return FALSE;
}
wxControl::SetLabel(label);
// Create the gtk widget.
m_widget = gtk_toggle_button_new_with_label(m_label.mbc_str());
gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
(gpointer *)this);
m_parent->DoAddChild(this);
PostCreation();
SetFont(parent->GetFont());
wxSize size_best(DoGetBestSize());
wxSize new_size(size);
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize(new_size.x, new_size.y);
SetBackgroundColour(parent->GetBackgroundColour());
SetForegroundColour(parent->GetForegroundColour());
Show(TRUE);
return TRUE;
}
// void SetValue(bool state)
// Set the value of the toggle button.
void wxToggleButton::SetValue(bool state)
{
wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));
if (state == GetValue())
return;
gtk_signal_disconnect_by_func(GTK_OBJECT(m_widget),
GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
(gpointer *)this);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(m_widget), state);
gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
(gpointer *)this);
}
// bool GetValue() const
// Get the value of the toggle button.
bool wxToggleButton::GetValue() const
{
wxCHECK_MSG(m_widget != NULL, FALSE, wxT("invalid toggle button"));
return GTK_TOGGLE_BUTTON(m_widget)->active;
}
// void SetLabel(const wxString& label)
// Set the button's label.
void wxToggleButton::SetLabel(const wxString& label)
{
wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));
wxControl::SetLabel(label);
gtk_label_set(GTK_LABEL(GTK_BUTTON(m_widget)->child),
GetLabel().mbc_str());
}
// bool Enable(bool enable)
// Enable (or disable) the control.
bool wxToggleButton::Enable(bool enable /*=TRUE*/)
{
if (!wxControl::Enable(enable))
return FALSE;
gtk_widget_set_sensitive(GTK_BUTTON(m_widget)->child, enable);
return TRUE;
}
// void ApplyWidgetStyle()
// I don't really know what this does.
void wxToggleButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style(m_widget, m_widgetStyle);
gtk_widget_set_style(GTK_BUTTON(m_widget)->child, m_widgetStyle);
}
// bool IsOwnGtkWindow(GdkWindow *window)
// I'm not really sure what this is for, either.
bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window)
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
}
// void OnInternalIdle()
// Apparently gtk cursors are difficult to deal with.
void wxToggleButton::OnInternalIdle()
{
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok())
cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widget)->event_window && cursor.Ok()) {
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor(GTK_TOGGLE_BUTTON(m_widget)->event_window,
cursor.GetCursor());
}
UpdateWindowUI();
}
// wxSize DoGetBestSize() const
// Get the "best" size for this control.
wxSize wxToggleButton::DoGetBestSize() const
{
wxSize ret(wxControl::DoGetBestSize());
if (ret.x < 80)
ret.x = 80;
return ret;
}
#endif // wxUSE_TOGGLEBTN

View File

@@ -77,7 +77,7 @@ bool wxCheckBox::Create(wxWindow *parent,
!CreateBase( parent, id, pos, size, style, validator, name )) !CreateBase( parent, id, pos, size, style, validator, name ))
{ {
wxFAIL_MSG( wxT("wxCheckBox creation failed") ); wxFAIL_MSG( wxT("wxCheckBox creation failed") );
return FALSE; return FALSE;
} }
wxControl::SetLabel( label ); wxControl::SetLabel( label );
@@ -199,11 +199,11 @@ void wxCheckBox::OnInternalIdle()
if (GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window && cursor.Ok()) if (GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window && cursor.Ok())
{ {
/* I now set the cursor the anew in every OnInternalIdle call /* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is windows above so that checking for the current cursor is
not possible. */ not possible. */
gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window, cursor.GetCursor() ); gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widgetCheckbox)->event_window, cursor.GetCursor() );
} }
UpdateWindowUI(); UpdateWindowUI();

View File

@@ -1,4 +1,4 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T!
ALL_SOURCES = \ ALL_SOURCES = \
generic/busyinfo.cpp \ generic/busyinfo.cpp \
@@ -198,6 +198,7 @@ ALL_SOURCES = \
gtk/stattext.cpp \ gtk/stattext.cpp \
gtk/tbargtk.cpp \ gtk/tbargtk.cpp \
gtk/textctrl.cpp \ gtk/textctrl.cpp \
gtk/tglbtn.cpp \
gtk/timer.cpp \ gtk/timer.cpp \
gtk/tooltip.cpp \ gtk/tooltip.cpp \
gtk/utilsgtk.cpp \ gtk/utilsgtk.cpp \
@@ -412,6 +413,7 @@ ALL_HEADERS = \
textctrl.h \ textctrl.h \
textdlg.h \ textdlg.h \
textfile.h \ textfile.h \
tglbtn.h \
thread.h \ thread.h \
time.h \ time.h \
timer.h \ timer.h \
@@ -500,6 +502,7 @@ ALL_HEADERS = \
gtk/stattext.h \ gtk/stattext.h \
gtk/tbargtk.h \ gtk/tbargtk.h \
gtk/textctrl.h \ gtk/textctrl.h \
gtk/tglbtn.h \
gtk/timer.h \ gtk/timer.h \
gtk/tooltip.h \ gtk/tooltip.h \
gtk/treectrl.h \ gtk/treectrl.h \
@@ -915,6 +918,7 @@ GUIOBJS = \
stattext.o \ stattext.o \
tbargtk.o \ tbargtk.o \
textctrl.o \ textctrl.o \
tglbtn.o \
timer.o \ timer.o \
tooltip.o \ tooltip.o \
utilsgtk.o \ utilsgtk.o \
@@ -976,6 +980,7 @@ GUIDEPS = \
stattext.d \ stattext.d \
tbargtk.d \ tbargtk.d \
textctrl.d \ textctrl.d \
tglbtn.d \
timer.d \ timer.d \
tooltip.d \ tooltip.d \
utilsgtk.d \ utilsgtk.d \

198
src/gtk1/tglbtn.cpp Normal file
View File

@@ -0,0 +1,198 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/tglbtn.cpp
// Purpose: Definition of the wxToggleButton class, which implements a
// toggle button under wxGTK.
// Author: John Norris, minor changes by Axel Schlueter
// Modified by:
// Created: 08.02.01
// RCS-ID: $Id$
// Copyright: (c) 2000 Johnny C. Norris II
// License: Rocketeer license
/////////////////////////////////////////////////////////////////////////////
#include "wx/tglbtn.h"
#if wxUSE_TOGGLEBTN
#include <gdk/gdk.h>
#include <gtk/gtk.h>
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
// void gtk_togglebutton_clicked_callback(GtkWidget *widget, wxToggleButton *cb)
// Callback function given to gtk.
void wxToggleButton::gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb)
{
if (g_isIdle)
wxapp_install_idle_handler();
if (!cb->m_hasVMT || g_blockEventsOnDrag)
return;
// Generate a wx event.
wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, cb->GetId());
event.SetInt(cb->GetValue());
event.SetEventObject(cb);
cb->GetEventHandler()->ProcessEvent(event);
}
IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED)
// bool Create(wxWindow *parent, wxWindowID id, const wxString &label,
// const wxPoint &pos, const wxSize &size, long style,
// const wxValidator& validator, const wxString &name)
// Create the control.
bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
const wxString &label, const wxPoint &pos,
const wxSize &size, long style,
const wxValidator& validator,
const wxString &name)
{
m_needParent = TRUE;
m_acceptsFocus = TRUE;
if (!PreCreation(parent, pos, size) ||
!CreateBase(parent, id, pos, size, style, validator, name )) {
wxFAIL_MSG(wxT("wxToggleButton creation failed"));
return FALSE;
}
wxControl::SetLabel(label);
// Create the gtk widget.
m_widget = gtk_toggle_button_new_with_label(m_label.mbc_str());
gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
(gpointer *)this);
m_parent->DoAddChild(this);
PostCreation();
SetFont(parent->GetFont());
wxSize size_best(DoGetBestSize());
wxSize new_size(size);
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize(new_size.x, new_size.y);
SetBackgroundColour(parent->GetBackgroundColour());
SetForegroundColour(parent->GetForegroundColour());
Show(TRUE);
return TRUE;
}
// void SetValue(bool state)
// Set the value of the toggle button.
void wxToggleButton::SetValue(bool state)
{
wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));
if (state == GetValue())
return;
gtk_signal_disconnect_by_func(GTK_OBJECT(m_widget),
GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
(gpointer *)this);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(m_widget), state);
gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
(gpointer *)this);
}
// bool GetValue() const
// Get the value of the toggle button.
bool wxToggleButton::GetValue() const
{
wxCHECK_MSG(m_widget != NULL, FALSE, wxT("invalid toggle button"));
return GTK_TOGGLE_BUTTON(m_widget)->active;
}
// void SetLabel(const wxString& label)
// Set the button's label.
void wxToggleButton::SetLabel(const wxString& label)
{
wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));
wxControl::SetLabel(label);
gtk_label_set(GTK_LABEL(GTK_BUTTON(m_widget)->child),
GetLabel().mbc_str());
}
// bool Enable(bool enable)
// Enable (or disable) the control.
bool wxToggleButton::Enable(bool enable /*=TRUE*/)
{
if (!wxControl::Enable(enable))
return FALSE;
gtk_widget_set_sensitive(GTK_BUTTON(m_widget)->child, enable);
return TRUE;
}
// void ApplyWidgetStyle()
// I don't really know what this does.
void wxToggleButton::ApplyWidgetStyle()
{
SetWidgetStyle();
gtk_widget_set_style(m_widget, m_widgetStyle);
gtk_widget_set_style(GTK_BUTTON(m_widget)->child, m_widgetStyle);
}
// bool IsOwnGtkWindow(GdkWindow *window)
// I'm not really sure what this is for, either.
bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window)
{
return (window == GTK_TOGGLE_BUTTON(m_widget)->event_window);
}
// void OnInternalIdle()
// Apparently gtk cursors are difficult to deal with.
void wxToggleButton::OnInternalIdle()
{
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok())
cursor = g_globalCursor;
if (GTK_TOGGLE_BUTTON(m_widget)->event_window && cursor.Ok()) {
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor(GTK_TOGGLE_BUTTON(m_widget)->event_window,
cursor.GetCursor());
}
UpdateWindowUI();
}
// wxSize DoGetBestSize() const
// Get the "best" size for this control.
wxSize wxToggleButton::DoGetBestSize() const
{
wxSize ret(wxControl::DoGetBestSize());
if (ret.x < 80)
ret.x = 80;
return ret;
}
#endif // wxUSE_TOGGLEBTN

View File

@@ -1,4 +1,4 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE MOTIF.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE MOTIF.T!
ALL_SOURCES = \ ALL_SOURCES = \
generic/busyinfo.cpp \ generic/busyinfo.cpp \
@@ -409,6 +409,7 @@ ALL_HEADERS = \
textctrl.h \ textctrl.h \
textdlg.h \ textdlg.h \
textfile.h \ textfile.h \
tglbtn.h \
thread.h \ thread.h \
time.h \ time.h \
timer.h \ timer.h \

View File

@@ -1,4 +1,4 @@
# This file was automatically generated by tmake at 02:34, 2001/02/08 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE MSW.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE MSW.T!
ALL_SOURCES = \ ALL_SOURCES = \
generic/busyinfo.cpp \ generic/busyinfo.cpp \
@@ -223,6 +223,7 @@ ALL_SOURCES = \
msw/taskbar.cpp \ msw/taskbar.cpp \
msw/tbar95.cpp \ msw/tbar95.cpp \
msw/textctrl.cpp \ msw/textctrl.cpp \
msw/tglbtn.cpp \
msw/thread.cpp \ msw/thread.cpp \
msw/timer.cpp \ msw/timer.cpp \
msw/tooltip.cpp \ msw/tooltip.cpp \
@@ -432,6 +433,7 @@ ALL_HEADERS = \
textctrl.h \ textctrl.h \
textdlg.h \ textdlg.h \
textfile.h \ textfile.h \
tglbtn.h \
thread.h \ thread.h \
time.h \ time.h \
timer.h \ timer.h \
@@ -550,6 +552,7 @@ ALL_HEADERS = \
msw/tbar95.h \ msw/tbar95.h \
msw/tbarmsw.h \ msw/tbarmsw.h \
msw/textctrl.h \ msw/textctrl.h \
msw/tglbtn.h \
msw/timer.h \ msw/timer.h \
msw/tooltip.h \ msw/tooltip.h \
msw/treectrl.h \ msw/treectrl.h \
@@ -972,6 +975,7 @@ GUIOBJS = \
taskbar.o \ taskbar.o \
tbar95.o \ tbar95.o \
textctrl.o \ textctrl.o \
tglbtn.o \
thread.o \ thread.o \
timer.o \ timer.o \
tooltip.o \ tooltip.o \
@@ -1069,6 +1073,7 @@ GUIDEPS = \
taskbar.d \ taskbar.d \
tbar95.d \ tbar95.d \
textctrl.d \ textctrl.d \
tglbtn.d \
thread.d \ thread.d \
timer.d \ timer.d \
tooltip.d \ tooltip.d \

View File

@@ -1,6 +1,6 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
# #
@@ -316,6 +316,7 @@ MSWOBJS = $(MSWDIR)\accel.obj \
$(MSWDIR)\taskbar.obj \ $(MSWDIR)\taskbar.obj \
$(MSWDIR)\tbar95.obj \ $(MSWDIR)\tbar95.obj \
$(MSWDIR)\textctrl.obj \ $(MSWDIR)\textctrl.obj \
$(MSWDIR)\tglbtn.obj \
$(MSWDIR)\thread.obj \ $(MSWDIR)\thread.obj \
$(MSWDIR)\timer.obj \ $(MSWDIR)\timer.obj \
$(MSWDIR)\tooltip.obj \ $(MSWDIR)\tooltip.obj \
@@ -579,6 +580,8 @@ $(MSWDIR)\tbar95.obj: $(MSWDIR)\tbar95.$(SRCSUFF)
$(MSWDIR)\textctrl.obj: $(MSWDIR)\textctrl.$(SRCSUFF) $(MSWDIR)\textctrl.obj: $(MSWDIR)\textctrl.$(SRCSUFF)
$(MSWDIR)\tglbtn.obj: $(MSWDIR)\tglbtn.$(SRCSUFF)
$(MSWDIR)\thread.obj: $(MSWDIR)\thread.$(SRCSUFF) $(MSWDIR)\thread.obj: $(MSWDIR)\thread.$(SRCSUFF)
$(MSWDIR)\timer.obj: $(MSWDIR)\timer.$(SRCSUFF) $(MSWDIR)\timer.obj: $(MSWDIR)\timer.$(SRCSUFF)

View File

@@ -1,6 +1,6 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
# #
@@ -275,6 +275,7 @@ MSWOBJS = $(MSWDIR)\accel.obj \
$(MSWDIR)\tabctrl.obj \ $(MSWDIR)\tabctrl.obj \
$(MSWDIR)\tbarmsw.obj \ $(MSWDIR)\tbarmsw.obj \
$(MSWDIR)\textctrl.obj \ $(MSWDIR)\textctrl.obj \
$(MSWDIR)\tglbtn.obj \
$(MSWDIR)\timer.obj \ $(MSWDIR)\timer.obj \
$(MSWDIR)\utils.obj \ $(MSWDIR)\utils.obj \
$(MSWDIR)\utilsexc.obj \ $(MSWDIR)\utilsexc.obj \
@@ -466,6 +467,8 @@ $(MSWDIR)\tbarmsw.obj: $(MSWDIR)\tbarmsw.$(SRCSUFF)
$(MSWDIR)\textctrl.obj: $(MSWDIR)\textctrl.$(SRCSUFF) $(MSWDIR)\textctrl.obj: $(MSWDIR)\textctrl.$(SRCSUFF)
$(MSWDIR)\tglbtn.obj: $(MSWDIR)\tglbtn.$(SRCSUFF)
$(MSWDIR)\timer.obj: $(MSWDIR)\timer.$(SRCSUFF) $(MSWDIR)\timer.obj: $(MSWDIR)\timer.$(SRCSUFF)
$(MSWDIR)\utils.obj: $(MSWDIR)\utils.$(SRCSUFF) $(MSWDIR)\utils.obj: $(MSWDIR)\utils.$(SRCSUFF)

View File

@@ -1,4 +1,4 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
# #
@@ -264,6 +264,7 @@ MSWOBJS2 = $(MSWDIR)\palette.obj \
$(MSWDIR)\tabctrl.obj \ $(MSWDIR)\tabctrl.obj \
$(MSWDIR)\tbarmsw.obj \ $(MSWDIR)\tbarmsw.obj \
$(MSWDIR)\textctrl.obj \ $(MSWDIR)\textctrl.obj \
$(MSWDIR)\tglbtn.obj \
$(MSWDIR)\timer.obj \ $(MSWDIR)\timer.obj \
$(MSWDIR)\utils.obj \ $(MSWDIR)\utils.obj \
$(MSWDIR)\utilsexc.obj \ $(MSWDIR)\utilsexc.obj \
@@ -726,6 +727,11 @@ $(MSWDIR)/textctrl.obj: $*.$(SRCSUFF)
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
<< <<
$(MSWDIR)/tglbtn.obj: $*.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
<<
$(MSWDIR)/timer.obj: $*.$(SRCSUFF) $(MSWDIR)/timer.obj: $*.$(SRCSUFF)
cl @<< cl @<<
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)

View File

@@ -1,4 +1,4 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
# #
@@ -312,6 +312,7 @@ MSWOBJS = \
$(MSWDIR)/taskbar.$(OBJSUFF) \ $(MSWDIR)/taskbar.$(OBJSUFF) \
$(MSWDIR)/tbar95.$(OBJSUFF) \ $(MSWDIR)/tbar95.$(OBJSUFF) \
$(MSWDIR)/textctrl.$(OBJSUFF) \ $(MSWDIR)/textctrl.$(OBJSUFF) \
$(MSWDIR)/tglbtn.$(OBJSUFF) \
$(MSWDIR)/thread.$(OBJSUFF) \ $(MSWDIR)/thread.$(OBJSUFF) \
$(MSWDIR)/timer.$(OBJSUFF) \ $(MSWDIR)/timer.$(OBJSUFF) \
$(MSWDIR)/tooltip.$(OBJSUFF) \ $(MSWDIR)/tooltip.$(OBJSUFF) \

View File

@@ -1,6 +1,6 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
# Symantec C++ makefile for the msw objects # Symantec C++ makefile for the msw objects
@@ -253,6 +253,7 @@ MSWOBJS = $(MSWDIR)\accel.obj \
$(MSWDIR)\tbar95.obj \ $(MSWDIR)\tbar95.obj \
$(MSWDIR)\tbarmsw.obj \ $(MSWDIR)\tbarmsw.obj \
$(MSWDIR)\textctrl.obj \ $(MSWDIR)\textctrl.obj \
$(MSWDIR)\tglbtn.obj \
$(MSWDIR)\thread.obj \ $(MSWDIR)\thread.obj \
$(MSWDIR)\timer.obj \ $(MSWDIR)\timer.obj \
$(MSWDIR)\tooltip.obj \ $(MSWDIR)\tooltip.obj \

View File

@@ -1,4 +1,4 @@
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
# File: makefile.vc # File: makefile.vc
@@ -331,6 +331,7 @@ MSWOBJS = ..\msw\$D\accel.obj \
..\msw\$D\taskbar.obj \ ..\msw\$D\taskbar.obj \
..\msw\$D\tbar95.obj \ ..\msw\$D\tbar95.obj \
..\msw\$D\textctrl.obj \ ..\msw\$D\textctrl.obj \
..\msw\$D\tglbtn.obj \
..\msw\$D\thread.obj \ ..\msw\$D\thread.obj \
..\msw\$D\timer.obj \ ..\msw\$D\timer.obj \
..\msw\$D\tooltip.obj \ ..\msw\$D\tooltip.obj \

View File

@@ -1,6 +1,6 @@
#!/binb/wmake.exe #!/binb/wmake.exe
# This file was automatically generated by tmake at 01:14, 2001/02/06 # This file was automatically generated by tmake at 19:20, 2001/02/08
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
# #
@@ -293,6 +293,7 @@ MSWOBJS = accel.obj &
tbar95.obj & tbar95.obj &
tbarmsw.obj & tbarmsw.obj &
textctrl.obj & textctrl.obj &
tglbtn.obj &
thread.obj & thread.obj &
timer.obj & timer.obj &
tooltip.obj & tooltip.obj &
@@ -614,6 +615,9 @@ tbarmsw.obj: $(MSWDIR)\tbarmsw.cpp
textctrl.obj: $(MSWDIR)\textctrl.cpp textctrl.obj: $(MSWDIR)\textctrl.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $< *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
tglbtn.obj: $(MSWDIR)\tglbtn.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
thread.obj: $(MSWDIR)\thread.cpp thread.obj: $(MSWDIR)\thread.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $< *$(CCC) $(CPPFLAGS) $(IFLAGS) $<

174
src/msw/tglbtn.cpp Normal file
View File

@@ -0,0 +1,174 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/msw/tglbtn.cpp
// Purpose: Definition of the wxToggleButton class, which implements a
// toggle button under wxMSW.
// Author: John Norris, minor changes by Axel Schlueter
// Modified by:
// Created: 08.02.01
// RCS-ID: $Id$
// Copyright: (c) 2000 Johnny C. Norris II
// License: Rocketeer license
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declatations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/tglbtn.h"
#if wxUSE_TOGGLEBTN
#ifndef WX_PRECOMP
#include "wx/button.h"
#include "wx/brush.h"
#include "wx/dcscreen.h"
#include "wx/settings.h"
#include "wx/log.h"
#endif // WX_PRECOMP
#include "wx/msw/private.h"
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED)
#define BUTTON_HEIGHT_FROM_CHAR_HEIGHT(cy) (11*EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)/10)
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxToggleButton
// ----------------------------------------------------------------------------
bool wxToggleButton::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
{
wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
event.SetInt(GetValue());
event.SetEventObject(this);
ProcessCommand(event);
return TRUE;
}
// Single check box item
bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
if (!CreateBase(parent, id, pos, size, style, validator, name))
return FALSE;
parent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
long msStyle = BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP | WS_CHILD | WS_VISIBLE;
#ifdef __WIN32__
if(m_windowStyle & wxBU_LEFT)
msStyle |= BS_LEFT;
if(m_windowStyle & wxBU_RIGHT)
msStyle |= BS_RIGHT;
if(m_windowStyle & wxBU_TOP)
msStyle |= BS_TOP;
if(m_windowStyle & wxBU_BOTTOM)
msStyle |= BS_BOTTOM;
#endif
m_hWnd = (WXHWND)CreateWindowEx(MakeExtendedStyle(m_windowStyle),
wxT("BUTTON"), label,
msStyle, 0, 0, 0, 0,
(HWND)parent->GetHWND(),
(HMENU)m_windowId,
wxGetInstance(), NULL);
if ( m_hWnd == 0 )
{
wxLogError(_T("Failed to create a toggle button"));
return FALSE;
}
// Subclass again for purposes of dialog editing mode
SubclassWin(m_hWnd);
SetFont(parent->GetFont());
SetSize(pos.x, pos.y, size.x, size.y);
return TRUE;
}
void wxToggleButton::SetLabel(const wxString& label)
{
SetWindowText(GetHwnd(), label);
}
wxSize wxToggleButton::DoGetBestSize() const
{
wxString label = wxGetWindowText(GetHWND());
int wBtn;
GetTextExtent(label, &wBtn, NULL);
int wChar, hChar;
wxGetCharSize(GetHWND(), &wChar, &hChar, &GetFont());
// add a margin - the button is wider than just its label
wBtn += 3*wChar;
// the button height is proportional to the height of the font used
int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
wxSize sz = wxButton::GetDefaultSize();
if (wBtn > sz.x)
sz.x = wBtn;
if (hBtn > sz.y)
sz.y = hBtn;
return sz;
}
void wxToggleButton::SetValue(bool val)
{
SendMessage(GetHwnd(), BM_SETCHECK, val, 0);
}
#ifndef BST_CHECKED
#define BST_CHECKED 0x0001
#endif
bool wxToggleButton::GetValue() const
{
#ifdef __WIN32__
return (SendMessage(GetHwnd(), BM_GETCHECK, 0, 0) == BST_CHECKED);
#else
return ((0x001 & SendMessage(GetHwnd(), BM_GETCHECK, 0, 0)) == 0x001);
#endif
}
void wxToggleButton::Command(wxCommandEvent & event)
{
SetValue((event.GetInt() != 0));
ProcessCommand(event);
}
#endif // wxUSE_TOGGLEBTN