--- /dev/null
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Name: bitmaptglbtn.tex
+%% Purpose: wxBitmapToggleButton documentation
+%% Author: Robert Roebling
+%% License: wxWindows license
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{\class{wxBitmapToggleButton}}\label{wxbitmaptogglebutton}
+
+wxBitmapToggleButton is a a \helpref{wxToggleButton}{wxtogglebutton}
+that contains a bitmap instead of text.
+
+This control emits a update UI event.
+
+\wxheading{Derived from}
+
+\helpref{wxControl}{wxcontrol}\\
+\helpref{wxWindow}{wxwindow}\\
+\helpref{wxEvtHandler}{wxevthandler}\\
+\helpref{wxObject}{wxobject}
+
+\wxheading{Include files}
+
+<wx/tglbtn.h>
+
+\wxheading{Library}
+
+\helpref{wxCore}{librarieslist}
+
+\wxheading{Window styles}
+
+There are no special styles for wxBitmapToggleButton.
+
+\wxheading{Event handling}
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf EVT\_TOGGLEBUTTON(id, func)}}{Handles a toggle button click event.}
+\end{twocollist}
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxBitmapToggleButton::wxBitmapToggleButton}\label{wxbitmaptogglebuttonconstr}
+
+\func{}{wxBitmapToggleButton}{\void}
+
+Default constructor.
+
+\func{}{wxBitmapToggleButton}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
+\param{const wxBitmap\& }{label}, \param{const wxPoint\& }{pos = wxDefaultPosition},\rtfsp
+\param{const wxSize\& }{size = wxDefaultSize}, \param{long}{ style = 0},\rtfsp
+\param{const wxValidator\& }{val}, \param{const wxString\& }{name = ``checkBox"}}
+
+Constructor, creating and showing a toggle button with the bitmap {\it label}.
+Internally calls Create().
+
+\membersection{wxBitmapToggleButton::Create}\label{wxbitmaptogglebuttoncreate}
+
+\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp
+\param{const wxBitmap\& }{label}, \param{const wxPoint\& }{pos = wxDefaultPosition},\rtfsp
+\param{const wxSize\& }{size = wxDefaultSize}, \param{long}{ style = 0},\rtfsp
+\param{const wxValidator\& }{val}, \param{const wxString\& }{name = ``checkBox"}}
+
+Create method for two-step construction.
+
+\membersection{wxBitmapToggleButton::GetValue}\label{wxbitmaptogglebuttongetvalue}
+
+\constfunc{bool}{GetValue}{\void}
+
+Gets the state of the toggle button.
+
+\wxheading{Return value}
+
+Returns {\tt true} if it is pressed, {\tt false} otherwise.
+
+\membersection{wxBitmapToggleButton::SetValue}\label{wxbitmaptogglebuttonsetvalue}
+
+\func{void}{SetValue}{\param{bool}{ state}}
+
+Sets the toggle button to the given state. This does not cause a
+{\tt EVT\_TOGGLEBUTTON} event to be emitted.
+
+\wxheading{Parameters}
+
+\docparam{state}{If {\tt true}, the button is pressed.}
+
\twocolitem{\helpref{wxBitmapButton}{wxbitmapbutton}}{Push button control, displaying a bitmap}
\twocolitem{\helpref{wxBitmapComboBox}{wxbitmapcombobox}}{A combobox with bitmaps next to text items}
\twocolitem{\helpref{wxToggleButton}{wxtogglebutton}}{A button which stays pressed when clicked by user.}
+\twocolitem{\helpref{wxBitmapToggleButton}{wxbitmaptogglebutton}}{A toggle button with bitmaps.}
\twocolitem{\helpref{wxCalendarCtrl}{wxcalendarctrl}}{Control showing an entire calendar month}
\twocolitem{\helpref{wxCheckBox}{wxcheckbox}}{Checkbox control}
\twocolitem{\helpref{wxCheckListBox}{wxchecklistbox}}{A listbox with a checkbox to the left of each item}
\input autoobj.tex
\input bitmap.tex
\input bitmapcombobox.tex
+\input bitmaptgnbtn.tex
\input bbutton.tex
\input bmpdatob.tex
\input bmphand.tex
other words, it is similar to \helpref{wxCheckBox}{wxcheckbox} in
functionality but looks like a \helpref{wxButton}{wxbutton}.
+Since wxWidgets version 2.9.0 this control emits a update UI event.
+
You can see wxToggleButton in action in the sixth page of the
\helpref{controls}{samplecontrols} sample.
\wxheading{See also}
-\helpref{wxCheckBox}{wxcheckbox}, \helpref{wxButton}{wxbutton}
+\helpref{wxCheckBox}{wxcheckbox}, \helpref{wxButton}{wxbutton},
+\helpref{wxToggleBitmapButton}{wxtogglebitmapbutton}
\latexignore{\rtfignore{\wxheading{Members}}}
\wxheading{Parameters}
\docparam{state}{If {\tt true}, the button is pressed.}
+
extern WXDLLIMPEXP_CORE const char wxCheckBoxNameStr[];
//-----------------------------------------------------------------------------
-// wxToggleBitmapButton
+// wxBitmapToggleButton
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxToggleBitmapButton: public wxControl
+class WXDLLIMPEXP_CORE wxBitmapToggleButton: public wxToggleButtonBase
{
public:
// construction/destruction
- wxToggleBitmapButton() {}
- wxToggleBitmapButton(wxWindow *parent,
+ wxBitmapToggleButton() {}
+ wxBitmapToggleButton(wxWindow *parent,
wxWindowID id,
const wxBitmap& label,
const wxPoint& pos = wxDefaultPosition,
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private:
- DECLARE_DYNAMIC_CLASS(wxToggleBitmapButton)
+ DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton)
};
//-----------------------------------------------------------------------------
// wxToggleButton
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxToggleButton: public wxControl
+class WXDLLIMPEXP_CORE wxToggleButton: public wxToggleButtonBase
{
public:
// construction/destruction
DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, 19)
END_DECLARE_EVENT_TYPES()
+// ----------------------------------------------------------------------------
+// wxToggleButtonBase
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxToggleButtonBase : public wxControl
+{
+public:
+ wxToggleButtonBase() { }
+
+ // Get/set the value
+ virtual void SetValue(bool state) = 0;
+ virtual bool GetValue() const = 0;
+
+ void UpdateWindowUI(long flags)
+ {
+ wxControl::UpdateWindowUI(flags);
+
+ if ( !IsShown() )
+ return;
+
+ wxWindow *tlw = wxGetTopLevelParent( this );
+ if (tlw && wxPendingDelete.Member( tlw ))
+ return;
+
+ wxUpdateUIEvent event( GetId() );
+ event.SetEventObject(this);
+
+ if (GetEventHandler()->ProcessEvent(event) )
+ {
+ if ( event.GetSetChecked() )
+ SetValue( event.GetChecked() );
+ }
+ }
+
+ // Buttons on MSW can look bad if they are not native colours, because
+ // then they become owner-drawn and not theme-drawn. Disable it here
+ // in wxToggleButtonBase to make it consistent.
+ virtual bool ShouldInheritColours() const { return false; }
+
+protected:
+ // choose the default border for this window
+ virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
+
+ DECLARE_NO_COPY_CLASS(wxToggleButtonBase)
+};
+
+
#define EVT_TOGGLEBUTTON(id, fn) \
wx__DECLARE_EVT1(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, id, wxCommandEventHandler(fn))
}
} else
#endif
+
#if wxUSE_TOGGLEBTN
if (m_validatorWindow->IsKindOf(CLASSINFO(wxToggleButton)) )
{
return true;
}
} else
+#if defined(__WXMAC__) || defined(__WXGTK20__)
+ if (m_validatorWindow->IsKindOf(CLASSINFO(wxBitmapToggleButton)) )
+ {
+ wxBitmapToggleButton * pControl = (wxBitmapToggleButton *) m_validatorWindow;
+ if (m_pBool)
+ {
+ pControl->SetValue(*m_pBool);
+ return true;
+ }
+ } else
+#endif
#endif
// int controls
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED)
// ------------------------------------------------------------------------
-// wxToggleBitmapButton
+// wxBitmapToggleButton
// ------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxToggleBitmapButton, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapToggleButton, wxControl)
-bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
+bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id,
const wxBitmap &label, const wxPoint &pos,
const wxSize &size, long style,
const wxValidator& validator,
if (!PreCreation(parent, pos, size) ||
!CreateBase(parent, id, pos, size, style, validator, name ))
{
- wxFAIL_MSG(wxT("wxToggleBitmapButton creation failed"));
+ wxFAIL_MSG(wxT("wxBitmapToggleButton creation failed"));
return false;
}
// void SetValue(bool state)
// Set the value of the toggle button.
-void wxToggleBitmapButton::SetValue(bool state)
+void wxBitmapToggleButton::SetValue(bool state)
{
wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));
// bool GetValue() const
// Get the value of the toggle button.
-bool wxToggleBitmapButton::GetValue() const
+bool wxBitmapToggleButton::GetValue() const
{
wxCHECK_MSG(m_widget != NULL, false, wxT("invalid toggle button"));
return gtk_toggle_button_get_active((GtkToggleButton*)m_widget);
}
-void wxToggleBitmapButton::SetLabel(const wxBitmap& label)
+void wxBitmapToggleButton::SetLabel(const wxBitmap& label)
{
wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));
OnSetBitmap();
}
-void wxToggleBitmapButton::OnSetBitmap()
+void wxBitmapToggleButton::OnSetBitmap()
{
if (!m_bitmap.Ok()) return;
}
}
-bool wxToggleBitmapButton::Enable(bool enable /*=true*/)
+bool wxBitmapToggleButton::Enable(bool enable /*=true*/)
{
if (!wxControl::Enable(enable))
return false;
return true;
}
-void wxToggleBitmapButton::DoApplyWidgetStyle(GtkRcStyle *style)
+void wxBitmapToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
gtk_widget_modify_style(m_widget, style);
gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
}
GdkWindow *
-wxToggleBitmapButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
+wxBitmapToggleButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
return GTK_BUTTON(m_widget)->event_window;
}
// Get the "best" size for this control.
-wxSize wxToggleBitmapButton::DoGetBestSize() const
+wxSize wxBitmapToggleButton::DoGetBestSize() const
{
wxSize best;
// static
wxVisualAttributes
-wxToggleBitmapButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+wxBitmapToggleButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{
return GetDefaultAttributesFromGTKWidget(gtk_toggle_button_new);
}
}
// ----------------------------------------------------------------------------
-// wxToggleBitmapButton
+// wxBitmapToggleButton
// ----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxToggleBitmapButton, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapToggleButton, wxControl)
-bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
+bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id,
const wxBitmap& label,
const wxPoint& pos,
const wxSize& size, long style,
return TRUE;
}
-wxSize wxToggleBitmapButton::DoGetBestSize() const
+wxSize wxBitmapToggleButton::DoGetBestSize() const
{
if (!m_bitmap.IsOk())
return wxSize(20,20);
return wxSize ( m_bitmap.GetWidth()+6, m_bitmap.GetHeight()+6 ) ;
}
-void wxToggleBitmapButton::SetValue(bool val)
+void wxBitmapToggleButton::SetValue(bool val)
{
m_peer->SetValue( val ) ;
}
-bool wxToggleBitmapButton::GetValue() const
+bool wxBitmapToggleButton::GetValue() const
{
return m_peer->GetValue() ;
}
-void wxToggleBitmapButton::Command(wxCommandEvent & event)
+void wxBitmapToggleButton::Command(wxCommandEvent & event)
{
SetValue((event.GetInt() != 0));
ProcessCommand(event);
}
-wxInt32 wxToggleBitmapButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
+wxInt32 wxBitmapToggleButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
event.SetInt(GetValue());