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:
@@ -37,15 +37,18 @@ You may also create a toolbar that is managed by the frame, by
|
||||
calling \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}.
|
||||
|
||||
{\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}
|
||||
|
||||
\twocolwidtha{5cm}
|
||||
\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\_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).}
|
||||
\twocolitem{\windowstyle{wxTB\_3DBUTTONS}}{Gives wxToolBarSimple a mild 3D look to its buttons.}
|
||||
\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{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
|
||||
border is drawn around the tool (colour displays). Note that to pass a NULL value,
|
||||
you need to cast it to (wxBitmap *) so that C++ can construct an appropriate temporary
|
||||
wxBitmap object.}
|
||||
border is drawn around the tool (colour displays) or the pixmap is shown
|
||||
as a pressed button (GTK). }
|
||||
|
||||
\docparam{xPos}{Specifies the x position of the tool if automatic layout is not suitable.}
|
||||
|
||||
|
@@ -44,7 +44,7 @@ class WXDLLEXPORT wxToolBarTool: public wxObject
|
||||
int theIndex = 0, const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap,
|
||||
bool toggle = FALSE, wxObject *clientData = (wxObject *) NULL,
|
||||
const wxString& shortHelpString = "", const wxString& longHelpString = "",
|
||||
GtkWidget *item = (GtkWidget *) NULL );
|
||||
GtkWidget *pixmap = (GtkWidget *) NULL );
|
||||
#else
|
||||
wxToolBarTool(int theIndex, const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap,
|
||||
bool toggle = FALSE, long xPos = -1, long yPos = -1,
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
#ifdef __WXGTK__
|
||||
wxToolBar *m_owner;
|
||||
GtkWidget *m_item;
|
||||
GtkWidget *m_pixmap;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@@ -126,6 +126,8 @@ public:
|
||||
wxGauge *m_gauge;
|
||||
wxSlider *m_slider;
|
||||
wxButton *m_fontButton;
|
||||
wxButton *m_lbSelectNum;
|
||||
wxButton *m_lbSelectThis;
|
||||
#ifndef wxUSE_SPINBUTTON
|
||||
wxSpinButton *m_spinbutton;
|
||||
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" );
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
(void)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_lbSelectNum = new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,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_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) );
|
||||
@@ -900,11 +902,13 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
|
||||
case ID_LISTBOX_SEL_NUM:
|
||||
{
|
||||
m_listbox->SetSelection( 2 );
|
||||
m_lbSelectThis->WarpPointer( 40, 14 );
|
||||
break;
|
||||
}
|
||||
case ID_LISTBOX_SEL_STR:
|
||||
{
|
||||
m_listbox->SetStringSelection( "This" );
|
||||
m_lbSelectNum->WarpPointer( 40, 14 );
|
||||
break;
|
||||
}
|
||||
case ID_LISTBOX_CLEAR:
|
||||
|
@@ -139,7 +139,7 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
|
||||
toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print");
|
||||
currentX += width + 5;
|
||||
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 );
|
||||
|
||||
|
@@ -55,7 +55,7 @@ wxToolBarTool::wxToolBarTool(wxToolBar *owner, int theIndex,
|
||||
const wxBitmap& theBitmap1, const wxBitmap& theBitmap2,
|
||||
bool toggle, wxObject *clientData,
|
||||
const wxString& helpS1, const wxString& helpS2,
|
||||
GtkWidget *item )
|
||||
GtkWidget *pixmap )
|
||||
#else
|
||||
wxToolBarTool::wxToolBarTool(int theIndex,
|
||||
const wxBitmap& theBitmap1, const wxBitmap& theBitmap2, bool toggle,
|
||||
@@ -65,7 +65,8 @@ wxToolBarTool::wxToolBarTool(int theIndex,
|
||||
m_toolStyle = wxTOOL_STYLE_BUTTON;
|
||||
#ifdef __WXGTK__
|
||||
m_owner = owner;
|
||||
m_item = item;
|
||||
m_pixmap = pixmap;
|
||||
m_item = (GtkWidget*) NULL;
|
||||
m_clientData = clientData;
|
||||
m_x = 0;
|
||||
m_y = 0;
|
||||
|
@@ -42,7 +42,23 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *to
|
||||
if (g_blockEventsOnDrag) 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 );
|
||||
}
|
||||
|
@@ -44,9 +44,7 @@
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "wx/gtk/win_gtk.h"
|
||||
|
||||
#if (GTK_MINOR_VERSION == 0)
|
||||
#include "gdk/gdkx.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// documentation on internals
|
||||
@@ -179,6 +177,32 @@ void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window
|
||||
|
||||
#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
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -2430,9 +2454,17 @@ bool wxWindow::SetCursor( const wxCursor &cursor )
|
||||
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 )
|
||||
|
@@ -42,7 +42,23 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *to
|
||||
if (g_blockEventsOnDrag) 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 );
|
||||
}
|
||||
|
@@ -44,9 +44,7 @@
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "wx/gtk/win_gtk.h"
|
||||
|
||||
#if (GTK_MINOR_VERSION == 0)
|
||||
#include "gdk/gdkx.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// documentation on internals
|
||||
@@ -179,6 +177,32 @@ void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window
|
||||
|
||||
#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
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -2430,9 +2454,17 @@ bool wxWindow::SetCursor( const wxCursor &cursor )
|
||||
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 )
|
||||
|
Reference in New Issue
Block a user