]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/tbargtk.cpp
more 2.0b9 updates
[wxWidgets.git] / src / gtk / tbargtk.cpp
index 7f7d9cbc8b20df49a486f3d6312a7d7ea5139cc5..46ca5bad1f744658803834c40a7fc9a57cfa1354 100644 (file)
 #include "gdk/gdk.h"
 #include "gtk/gtk.h"
 
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
 //-----------------------------------------------------------------------------
 // data
 //-----------------------------------------------------------------------------
@@ -30,6 +37,8 @@ extern bool   g_blockEventsOnDrag;
 
 static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *tool )
 {
+    if (g_isIdle) wxapp_install_idle_handler();
+
     if (g_blockEventsOnDrag) return;
     if (!tool->m_enabled) return;
 
@@ -45,6 +54,8 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *to
 static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget), 
   GdkEventCrossing *WXUNUSED(gdk_event), wxToolBarTool *tool )
 {
+    if (g_isIdle) wxapp_install_idle_handler();
+
     if (g_blockEventsOnDrag) return TRUE;
     
     /* we grey-out the tip text of disabled tool */
@@ -87,6 +98,10 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
 
 IMPLEMENT_DYNAMIC_CLASS(wxToolBar,wxControl)
 
+BEGIN_EVENT_TABLE(wxToolBar, wxControl)
+  EVT_IDLE(wxToolBar::OnIdle)
+END_EVENT_TABLE()
+
 wxToolBar::wxToolBar()
 {
 }
@@ -200,13 +215,13 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
     m_hasToolAlready = TRUE;
     
     wxCHECK_MSG( bitmap.Ok(), (wxToolBarTool *)NULL,
-                 "invalid bitmap for wxToolBar icon" );
+                 _T("invalid bitmap for wxToolBar icon") );
 
     wxCHECK_MSG( bitmap.GetBitmap() == NULL, (wxToolBarTool *)NULL,
-                 "wxToolBar doesn't support GdkBitmap" );
+                 _T("wxToolBar doesn't support GdkBitmap") );
 
     wxCHECK_MSG( bitmap.GetPixmap() != NULL, (wxToolBarTool *)NULL,
-                 "wxToolBar::Add needs a wxBitmap" );
+                 _T("wxToolBar::Add needs a wxBitmap") );
   
     GtkWidget *tool_pixmap = (GtkWidget *)NULL;
   
@@ -234,7 +249,7 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
                       ctype,
                       (GtkWidget *)NULL,
                       (const char *)NULL,
-                      helpString1,
+                      helpString1.mbc_str(),
                       "",
                       tool_pixmap,
                       (GtkSignalFunc)gtk_toolbar_callback,
@@ -260,7 +275,7 @@ void wxToolBar::AddSeparator()
 
 void wxToolBar::ClearTools()
 {
-    wxFAIL_MSG( "wxToolBar::ClearTools not implemented" );
+    wxFAIL_MSG( _T("wxToolBar::ClearTools not implemented") );
 }
 
 bool wxToolBar::Realize()
@@ -310,7 +325,7 @@ void wxToolBar::EnableTool(int toolIndex, bool enable)
         node = node->Next();
     }
   
-    wxFAIL_MSG( "wrong toolbar index" );
+    wxFAIL_MSG( _T("wrong toolbar index") );
 }
 
 void wxToolBar::ToggleTool( int toolIndex, bool toggle ) 
@@ -329,7 +344,7 @@ void wxToolBar::ToggleTool( int toolIndex, bool toggle )
         node = node->Next();
     }
   
-    wxFAIL_MSG( "wrong toolbar index" );
+    wxFAIL_MSG( _T("wrong toolbar index") );
 }
 
 wxObject *wxToolBar::GetToolClientData( int index ) const
@@ -342,7 +357,7 @@ wxObject *wxToolBar::GetToolClientData( int index ) const
         node = node->Next();
     }
   
-    wxFAIL_MSG( "wrong toolbar index" );
+    wxFAIL_MSG( _T("wrong toolbar index") );
   
     return (wxObject*)NULL;
 }
@@ -357,7 +372,7 @@ bool wxToolBar::GetToolState(int toolIndex) const
         node = node->Next();
     }
   
-    wxFAIL_MSG( "wrong toolbar index" );
+    wxFAIL_MSG( _T("wrong toolbar index") );
   
     return FALSE;
 }
@@ -372,14 +387,14 @@ bool wxToolBar::GetToolEnabled(int toolIndex) const
         node = node->Next();
     }
   
-    wxFAIL_MSG( "wrong toolbar index" );
+    wxFAIL_MSG( _T("wrong toolbar index") );
   
     return FALSE;
 }
 
 void wxToolBar::SetMargins( int x, int y )
 {
-    wxCHECK_RET( !m_hasToolAlready, "wxToolBar::SetMargins must be called before adding tool." );
+    wxCHECK_RET( !m_hasToolAlready, _T("wxToolBar::SetMargins must be called before adding tool.") );
     
     if (x > 2) gtk_toolbar_append_space( m_toolbar );  // oh well
     
@@ -389,7 +404,7 @@ void wxToolBar::SetMargins( int x, int y )
 
 void wxToolBar::SetToolPacking( int WXUNUSED(packing) )
 {
-    wxFAIL_MSG( "wxToolBar::SetToolPacking not implemented" );
+    wxFAIL_MSG( _T("wxToolBar::SetToolPacking not implemented") );
 }
 
 void wxToolBar::SetToolSeparation( int separation )
@@ -421,9 +436,9 @@ wxString wxToolBar::GetToolLongHelp(int toolIndex)
         node = node->Next();
     }
   
-    wxFAIL_MSG( "wrong toolbar index" );
+    wxFAIL_MSG( _T("wrong toolbar index") );
     
-    return "";
+    return _T("");
 }
 
 wxString wxToolBar::GetToolShortHelp(int toolIndex)
@@ -439,9 +454,9 @@ wxString wxToolBar::GetToolShortHelp(int toolIndex)
         node = node->Next();
     }
   
-    wxFAIL_MSG( "wrong toolbar index" );
+    wxFAIL_MSG( _T("wrong toolbar index") );
     
-    return "";
+    return _T("");
 }
 
 void wxToolBar::SetToolLongHelp(int toolIndex, const wxString& helpString)
@@ -458,7 +473,7 @@ void wxToolBar::SetToolLongHelp(int toolIndex, const wxString& helpString)
         node = node->Next();
     }
   
-    wxFAIL_MSG( "wrong toolbar index" );
+    wxFAIL_MSG( _T("wrong toolbar index") );
     
     return;
 }
@@ -477,9 +492,36 @@ void wxToolBar::SetToolShortHelp(int toolIndex, const wxString& helpString)
         node = node->Next();
     }
   
-    wxFAIL_MSG( "wrong toolbar index" );
+    wxFAIL_MSG( _T("wrong toolbar index") );
     
     return;
 }
 
+void wxToolBar::OnIdle( wxIdleEvent &WXUNUSED(ievent) )
+{
+    wxEvtHandler* evtHandler = GetEventHandler();
+
+    wxNode* node = m_tools.First();
+    while (node)
+    {
+        wxToolBarTool* tool = (wxToolBarTool*) node->Data();
+
+        wxUpdateUIEvent event( tool->m_index );
+        event.SetEventObject(this);
+
+        if (evtHandler->ProcessEvent( event ))
+        {
+            if (event.GetSetEnabled())
+                EnableTool(tool->m_index, event.GetEnabled());
+            if (event.GetSetChecked())
+                ToggleTool(tool->m_index, event.GetChecked());
+/*
+            if (event.GetSetText())
+                // Set tooltip?
+*/
+        }
+
+        node = node->Next();
+    }
+}