Added support for extra bitmap for toggled tool.

Implemented WarpPointer() and added a test for it
    to controls.
  Some minor documention updates.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2599 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-05-31 10:47:44 +00:00
parent 1759ff9e91
commit 85eb36c267
9 changed files with 127 additions and 23 deletions

View File

@@ -37,15 +37,18 @@ You may also create a toolbar that is managed by the frame, by
calling \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}. calling \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}.
{\bf wxToolBar95:} Note that this toolbar paints tools to reflect user-selected colours. {\bf wxToolBar95:} Note that this toolbar paints tools to reflect user-selected colours.
The toolbar orientation must always be {\bf wxVERTICAL}. The toolbar orientation must always be {\bf wxHORIZONTAL}.
{\bf wxToolBarGtk:} The toolbar orientation is ignored and is always {\bf wxHORIZONTAL}.
\wxheading{Window styles} \wxheading{Window styles}
\twocolwidtha{5cm} \twocolwidtha{5cm}
\begin{twocollist}\itemsep=0pt \begin{twocollist}\itemsep=0pt
\twocolitem{\windowstyle{wxTB\_FLAT}}{Gives the toolbar a flat look ('coolbar' or 'flatbar' style). Windows 95 only.} \twocolitem{\windowstyle{wxTB\_FLAT}}{Gives the toolbar a flat look ('coolbar' or 'flatbar' style). Windows 95 and GTK 1.2 only.}
\twocolitem{\windowstyle{wxTB\_DOCKABLE}}{Makes the toolbar floatable and dockable. GTK only.}
\twocolitem{\windowstyle{wxTB\_HORIZONTAL}}{Specifies horizontal layout.} \twocolitem{\windowstyle{wxTB\_HORIZONTAL}}{Specifies horizontal layout.}
\twocolitem{\windowstyle{wxTB\_VERTICAL}}{Specifies vertical layout (not available for the Windows 95 \twocolitem{\windowstyle{wxTB\_VERTICAL}}{Specifies vertical layout (not available for the GTK and Windows 95
toolbar).} toolbar).}
\twocolitem{\windowstyle{wxTB\_3DBUTTONS}}{Gives wxToolBarSimple a mild 3D look to its buttons.} \twocolitem{\windowstyle{wxTB\_3DBUTTONS}}{Gives wxToolBarSimple a mild 3D look to its buttons.}
\end{twocollist} \end{twocollist}
@@ -170,11 +173,10 @@ two states, whereas a non-toggle tool is just a button.}
\docparam{bitmap1}{The primary tool bitmap for toggle and button tools.} \docparam{bitmap1}{The primary tool bitmap for toggle and button tools.}
\docparam{bitmap2}{The second bitmap specifies the on-state bitmap for a toggle \docparam{bitmap2}{The second bitmap specifies the on-state bitmap for a toggle
tool. If this is NULL, either an inverted version of the primary bitmap is tool. If this is wxNullBitmap, either an inverted version of the primary bitmap is
used for the on-state of a toggle tool (monochrome displays) or a black used for the on-state of a toggle tool (monochrome displays) or a black
border is drawn around the tool (colour displays). Note that to pass a NULL value, border is drawn around the tool (colour displays) or the pixmap is shown
you need to cast it to (wxBitmap *) so that C++ can construct an appropriate temporary as a pressed button (GTK). }
wxBitmap object.}
\docparam{xPos}{Specifies the x position of the tool if automatic layout is not suitable.} \docparam{xPos}{Specifies the x position of the tool if automatic layout is not suitable.}

View File

@@ -44,7 +44,7 @@ class WXDLLEXPORT wxToolBarTool: public wxObject
int theIndex = 0, const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap, int theIndex = 0, const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap,
bool toggle = FALSE, wxObject *clientData = (wxObject *) NULL, bool toggle = FALSE, wxObject *clientData = (wxObject *) NULL,
const wxString& shortHelpString = "", const wxString& longHelpString = "", const wxString& shortHelpString = "", const wxString& longHelpString = "",
GtkWidget *item = (GtkWidget *) NULL ); GtkWidget *pixmap = (GtkWidget *) NULL );
#else #else
wxToolBarTool(int theIndex, const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap, wxToolBarTool(int theIndex, const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap,
bool toggle = FALSE, long xPos = -1, long yPos = -1, bool toggle = FALSE, long xPos = -1, long yPos = -1,
@@ -75,6 +75,7 @@ public:
#ifdef __WXGTK__ #ifdef __WXGTK__
wxToolBar *m_owner; wxToolBar *m_owner;
GtkWidget *m_item; GtkWidget *m_item;
GtkWidget *m_pixmap;
#endif #endif
}; };

View File

@@ -126,6 +126,8 @@ public:
wxGauge *m_gauge; wxGauge *m_gauge;
wxSlider *m_slider; wxSlider *m_slider;
wxButton *m_fontButton; wxButton *m_fontButton;
wxButton *m_lbSelectNum;
wxButton *m_lbSelectThis;
#ifndef wxUSE_SPINBUTTON #ifndef wxUSE_SPINBUTTON
wxSpinButton *m_spinbutton; wxSpinButton *m_spinbutton;
wxButton *m_btnProgress; wxButton *m_btnProgress;
@@ -600,8 +602,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
m_listbox->SetToolTip( "This is a list box" ); m_listbox->SetToolTip( "This is a list box" );
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
(void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); m_lbSelectNum = new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); m_lbSelectThis = new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
@@ -900,11 +902,13 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
case ID_LISTBOX_SEL_NUM: case ID_LISTBOX_SEL_NUM:
{ {
m_listbox->SetSelection( 2 ); m_listbox->SetSelection( 2 );
m_lbSelectThis->WarpPointer( 40, 14 );
break; break;
} }
case ID_LISTBOX_SEL_STR: case ID_LISTBOX_SEL_STR:
{ {
m_listbox->SetStringSelection( "This" ); m_listbox->SetStringSelection( "This" );
m_lbSelectNum->WarpPointer( 40, 14 );
break; break;
} }
case ID_LISTBOX_CLEAR: case ID_LISTBOX_CLEAR:

View File

@@ -139,7 +139,7 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print"); toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print");
currentX += width + 5; currentX += width + 5;
toolBar->AddSeparator(); toolBar->AddSeparator();
toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help"); toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), *(toolBarBitmaps[6]), TRUE, currentX, -1, (wxObject *) NULL, "Help");
toolBar->EnableTool( wxID_PRINT, FALSE ); toolBar->EnableTool( wxID_PRINT, FALSE );

View File

@@ -55,7 +55,7 @@ wxToolBarTool::wxToolBarTool(wxToolBar *owner, int theIndex,
const wxBitmap& theBitmap1, const wxBitmap& theBitmap2, const wxBitmap& theBitmap1, const wxBitmap& theBitmap2,
bool toggle, wxObject *clientData, bool toggle, wxObject *clientData,
const wxString& helpS1, const wxString& helpS2, const wxString& helpS1, const wxString& helpS2,
GtkWidget *item ) GtkWidget *pixmap )
#else #else
wxToolBarTool::wxToolBarTool(int theIndex, wxToolBarTool::wxToolBarTool(int theIndex,
const wxBitmap& theBitmap1, const wxBitmap& theBitmap2, bool toggle, const wxBitmap& theBitmap1, const wxBitmap& theBitmap2, bool toggle,
@@ -65,7 +65,8 @@ wxToolBarTool::wxToolBarTool(int theIndex,
m_toolStyle = wxTOOL_STYLE_BUTTON; m_toolStyle = wxTOOL_STYLE_BUTTON;
#ifdef __WXGTK__ #ifdef __WXGTK__
m_owner = owner; m_owner = owner;
m_item = item; m_pixmap = pixmap;
m_item = (GtkWidget*) NULL;
m_clientData = clientData; m_clientData = clientData;
m_x = 0; m_x = 0;
m_y = 0; m_y = 0;

View File

@@ -42,7 +42,23 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *to
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
if (!tool->m_enabled) return; if (!tool->m_enabled) return;
if (tool->m_isToggle) tool->m_toggleState = !tool->m_toggleState; if (tool->m_isToggle)
{
tool->m_toggleState = !tool->m_toggleState;
if (tool->m_bitmap2.Ok())
{
wxBitmap bitmap = tool->m_bitmap1;
if (tool->m_toggleState) bitmap = tool->m_bitmap2;
GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap );
GdkBitmap *mask = (GdkBitmap *) NULL;
if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap();
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
}
}
tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState ); tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState );
} }

View File

@@ -44,9 +44,7 @@
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#if (GTK_MINOR_VERSION == 0)
#include "gdk/gdkx.h" #include "gdk/gdkx.h"
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// documentation on internals // documentation on internals
@@ -179,6 +177,32 @@ void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window
#endif // Debug #endif // Debug
//-----------------------------------------------------------------------------
// missing gdk functions
//-----------------------------------------------------------------------------
void
gdk_window_warp_pointer (GdkWindow *window,
gint x,
gint y)
{
GdkWindowPrivate *priv;
if (!window)
window = (GdkWindow*) &gdk_root_parent;
priv = (GdkWindowPrivate*) window;
if (!priv->destroyed)
{
XWarpPointer (priv->xdisplay,
None, /* not source window -> move from anywhere */
priv->xwindow, /* dest window */
0, 0, 0, 0, /* not source window -> move from anywhere */
x, y );
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -2430,9 +2454,17 @@ bool wxWindow::SetCursor( const wxCursor &cursor )
return TRUE; return TRUE;
} }
void wxWindow::WarpPointer( int WXUNUSED(x), int WXUNUSED(y) ) void wxWindow::WarpPointer( int x, int y )
{ {
// TODO wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget->window)
{
/* we provide this function ourselves as it is
missing in GDK */
gdk_window_warp_pointer( connect_widget->window, x, y );
}
} }
void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )

View File

@@ -42,7 +42,23 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *to
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
if (!tool->m_enabled) return; if (!tool->m_enabled) return;
if (tool->m_isToggle) tool->m_toggleState = !tool->m_toggleState; if (tool->m_isToggle)
{
tool->m_toggleState = !tool->m_toggleState;
if (tool->m_bitmap2.Ok())
{
wxBitmap bitmap = tool->m_bitmap1;
if (tool->m_toggleState) bitmap = tool->m_bitmap2;
GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap );
GdkBitmap *mask = (GdkBitmap *) NULL;
if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap();
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
}
}
tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState ); tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState );
} }

View File

@@ -44,9 +44,7 @@
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#if (GTK_MINOR_VERSION == 0)
#include "gdk/gdkx.h" #include "gdk/gdkx.h"
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// documentation on internals // documentation on internals
@@ -179,6 +177,32 @@ void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window
#endif // Debug #endif // Debug
//-----------------------------------------------------------------------------
// missing gdk functions
//-----------------------------------------------------------------------------
void
gdk_window_warp_pointer (GdkWindow *window,
gint x,
gint y)
{
GdkWindowPrivate *priv;
if (!window)
window = (GdkWindow*) &gdk_root_parent;
priv = (GdkWindowPrivate*) window;
if (!priv->destroyed)
{
XWarpPointer (priv->xdisplay,
None, /* not source window -> move from anywhere */
priv->xwindow, /* dest window */
0, 0, 0, 0, /* not source window -> move from anywhere */
x, y );
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// idle system // idle system
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -2430,9 +2454,17 @@ bool wxWindow::SetCursor( const wxCursor &cursor )
return TRUE; return TRUE;
} }
void wxWindow::WarpPointer( int WXUNUSED(x), int WXUNUSED(y) ) void wxWindow::WarpPointer( int x, int y )
{ {
// TODO wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget->window)
{
/* we provide this function ourselves as it is
missing in GDK */
gdk_window_warp_pointer( connect_widget->window, x, y );
}
} }
void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )