]> git.saurik.com Git - wxWidgets.git/commitdiff
Added support for extra bitmap for toggled tool.
authorRobert Roebling <robert@roebling.de>
Mon, 31 May 1999 10:47:44 +0000 (10:47 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 31 May 1999 10:47:44 +0000 (10:47 +0000)
  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

docs/latex/wx/toolbar.tex
include/wx/tbarbase.h
samples/controls/controls.cpp
samples/toolbar/test.cpp
src/common/tbarbase.cpp
src/gtk/tbargtk.cpp
src/gtk/window.cpp
src/gtk1/tbargtk.cpp
src/gtk1/window.cpp

index e2ac77604134008c54b182586d64b86aae751955..dee3ddd93c0662a35fef953dae465b25341c8d01 100644 (file)
@@ -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.}
 
index 97ff12eafb07377ca84904341def2dac0ed9b959..48f37f7e08c8c2b7f78938c67e0d5861836150b0 100644 (file)
@@ -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
 };
 
index 675230b2d89c10f633fb8007ddff7f45035cedda..c6c8d0f96c52472365e003db1df2e7752037a0d4 100644 (file)
@@ -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:
index 94445a55440d6ed8540ce23d3b354f2de365780c..f9720337ab71d6461518eb7caeab198253eafac6 100644 (file)
@@ -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 );
 
index 751873f2b36ee9c607706c091bf7df3ad7f16b47..318a701601765b1459f2d33c9a5fa35af08c26cf 100644 (file)
@@ -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;
index 16a897245a916f16bec092a219860731fac5b790..9f82a552b5084789d5f8bc85980ded97c32da417 100644 (file)
@@ -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 );
 }
index d12fcf4e69322147d9481d7785b95598c6925287..71396ae3b42530aab42593a3f1ef0a6ff336a2b1 100644 (file)
@@ -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 )
index 16a897245a916f16bec092a219860731fac5b790..9f82a552b5084789d5f8bc85980ded97c32da417 100644 (file)
@@ -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 );
 }
index d12fcf4e69322147d9481d7785b95598c6925287..71396ae3b42530aab42593a3f1ef0a6ff336a2b1 100644 (file)
@@ -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 )