]> git.saurik.com Git - wxWidgets.git/commitdiff
1. added wxGTK::wxToolBar::SetToolShortHelp() and test for it in sample
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 24 Nov 2000 17:07:12 +0000 (17:07 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 24 Nov 2000 17:07:12 +0000 (17:07 +0000)
2. fix a crash if SetSelection is called too early in wxTextCtrl
3. patch for mouse position in wxTreeCtrl events

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8805 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/tbargtk.h
include/wx/gtk1/tbargtk.h
samples/console/console.cpp
samples/controls/controls.cpp
samples/toolbar/toolbar.cpp
src/gtk/tbargtk.cpp
src/gtk/textctrl.cpp
src/gtk1/tbargtk.cpp
src/gtk1/textctrl.cpp
src/msw/listctrl.cpp

index 1187c5887fcddc1affce22a3a7e48d09ef4b32ab..18f5243a8884a3aa7efda39e1f6c4b23bdd7e57e 100644 (file)
@@ -52,6 +52,8 @@ public:
 
     virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
 
+    virtual void SetToolShortHelp(int id, const wxString& helpString);
+
     // implementation from now on
     // --------------------------
 
index 1187c5887fcddc1affce22a3a7e48d09ef4b32ab..18f5243a8884a3aa7efda39e1f6c4b23bdd7e57e 100644 (file)
@@ -52,6 +52,8 @@ public:
 
     virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
 
+    virtual void SetToolShortHelp(int id, const wxString& helpString);
+
     // implementation from now on
     // --------------------------
 
index 0229dcb00286f2ddfeb94cd0dd42be7182cfe1c9..5adda86c6c9528e73dc0bf7d2209af8c38636eb3 100644 (file)
 
 // what to test (in alphabetic order)?
 
-#define TEST_ARRAYS
+//#define TEST_ARRAYS
 //#define TEST_CMDLINE
 //#define TEST_DATETIME
 //#define TEST_DIR
 //#define TEST_DLLLOADER
-//#define TEST_EXECUTE
+#define TEST_EXECUTE
 //#define TEST_FILE
 //#define TEST_FILECONF
 //#define TEST_HASH
@@ -49,7 +49,7 @@
 //#define TEST_LONGLONG
 //#define TEST_MIME
 //#define TEST_INFO_FUNCTIONS
-#define TEST_REGISTRY
+//#define TEST_REGISTRY
 //#define TEST_SOCKETS
 //#define TEST_STREAMS
 //#define TEST_STRINGS
@@ -296,9 +296,9 @@ static void TestExecute()
     puts("*** testing wxExecute ***");
 
 #ifdef __UNIX__
-    #define COMMAND "echo hi"
+    #define COMMAND "cat -n ../../Makefile" // "echo hi"
     #define SHELL_COMMAND "echo hi from shell"
-    #define REDIRECT_COMMAND "date"
+    #define REDIRECT_COMMAND COMMAND // "date"
 #elif defined(__WXMSW__)
     #define COMMAND "command.com -c 'echo hi'"
     #define SHELL_COMMAND "echo hi"
index 2b4e7e17c8499886d7061b9709ad1ec9941b72f7..b34e832b304289f268ec2822f1fad66e22a0bfe2 100644 (file)
@@ -175,8 +175,11 @@ private:
     void UpdateStatusBar(const wxPoint& pos, const wxSize& size)
     {
         wxString msg;
-        msg.Printf(_("pos=(%d, %d), size=%dx%d"),
-                   pos.x, pos.y, size.x, size.y);
+        wxSize sizeCl = GetClientSize();
+        msg.Printf(_("pos=(%d, %d), size=%dx%d (client=%dx%d)"),
+                   pos.x, pos.y,
+                   size.x, size.y,
+                   sizeCl.x, sizeCl.y);
         SetStatusText(msg, 1);
     }
 
index ce3033892006f4b6a2c521a2f7168b35d8964dcd..df5e434c44f07e50842f004552b0a3c7e63abdc6 100644 (file)
@@ -109,6 +109,7 @@ public:
     void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); }
     void OnDeletePrint(wxCommandEvent& WXUNUSED(event)) { DoDeletePrint(); }
     void OnInsertPrint(wxCommandEvent& event);
+    void OnChangeToolTip(wxCommandEvent& event);
     void OnToggleHelp(wxCommandEvent& WXUNUSED(event)) { DoToggleHelp(); }
 
     void OnToolLeftClick(wxCommandEvent& event);
@@ -161,6 +162,7 @@ enum
     IDM_TOOLBAR_TOGGLEHELP,
     IDM_TOOLBAR_TOGGLEFULLSCREEN,
     IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR,
+    IDM_TOOLBAR_CHANGE_TOOLTIP,
 
     ID_COMBO = 1000
 };
@@ -189,6 +191,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_MENU(IDM_TOOLBAR_INSERTPRINT, MyFrame::OnInsertPrint)
     EVT_MENU(IDM_TOOLBAR_TOGGLEHELP, MyFrame::OnToggleHelp)
     EVT_MENU(IDM_TOOLBAR_TOGGLEFULLSCREEN, MyFrame::OnToggleFullScreen)
+    EVT_MENU(IDM_TOOLBAR_CHANGE_TOOLTIP, MyFrame::OnChangeToolTip)
 
     EVT_MENU(-1, MyFrame::OnToolLeftClick)
 
@@ -378,11 +381,10 @@ MyFrame::MyFrame(wxFrame* parent,
     tbarMenu->Append(IDM_TOOLBAR_DELETEPRINT, "&Delete print button\tCtrl-D", "");
     tbarMenu->Append(IDM_TOOLBAR_INSERTPRINT, "&Insert print button\tCtrl-I", "");
     tbarMenu->Append(IDM_TOOLBAR_TOGGLEHELP, "Toggle &help button\tCtrl-T", "");
-
-#ifdef __WXMSW__
+    tbarMenu->AppendSeparator();
+    tbarMenu->Append(IDM_TOOLBAR_CHANGE_TOOLTIP, "Change tool tip", "");
     tbarMenu->AppendSeparator();
     tbarMenu->Append(IDM_TOOLBAR_TOGGLEFULLSCREEN, "Toggle &full screen mode\tCtrl-F", "");
-#endif
 
     wxMenu *fileMenu = new wxMenu;
     fileMenu->Append(wxID_EXIT, "E&xit", "Quit toolbar sample" );
@@ -567,6 +569,11 @@ void MyFrame::OnUpdateCopyAndCut(wxUpdateUIEvent& event)
     event.Enable( m_textWindow->CanCopy() );
 }
 
+void MyFrame::OnChangeToolTip(wxCommandEvent& WXUNUSED(event))
+{
+    GetToolBar()->SetToolShortHelp(wxID_NEW, _T("New toolbar button"));
+}
+
 void MyFrame::OnInsertPrint(wxCommandEvent& WXUNUSED(event))
 {
     wxBitmap bmp = wxBITMAP(print);
index d36704d5138eb212854bb2c471693ad2dc39764f..cfa38c8eb520533adffcdbe68b3e0a02e5882355 100644 (file)
@@ -506,6 +506,18 @@ void wxToolBar::SetToolSeparation( int separation )
     m_toolSeparation = separation;
 }
 
+void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
+{
+    wxToolBarTool *tool = (wxToolBarTool *)FindById(id);
+
+    if ( tool )
+    {
+        (void)tool->SetShortHelp(helpString);
+        gtk_tooltips_set_tip(m_toolbar->tooltips, tool->m_item,
+                             helpString.mbc_str(), "");
+    }
+}
+
 // ----------------------------------------------------------------------------
 // wxToolBar idle handling
 // ----------------------------------------------------------------------------
@@ -555,4 +567,4 @@ void wxToolBar::OnInternalIdle()
     UpdateWindowUI();
 }
 
-#endif
+#endif // wxUSE_TOOLBAR_NATIVE
index 64c069e006a5a8e0408ec45c77b629d570c91a5a..6194b622bc2d71c3efd0df4bc4708587bd13aeb1 100644 (file)
@@ -14,6 +14,7 @@
 #include "wx/textctrl.h"
 #include "wx/utils.h"
 #include "wx/intl.h"
+#include "wx/log.h"
 #include "wx/settings.h"
 
 #include <sys/types.h>
@@ -646,6 +647,14 @@ void wxTextCtrl::SetSelection( long from, long to )
 {
     wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
 
+    if ( (m_windowStyle & wxTE_MULTILINE) &&
+         !GTK_TEXT(m_text)->line_start_cache )
+    {
+        // tell the programmer that it didn't work
+        wxLogDebug(_T("Can't call SetSelection() before realizing the control"));
+        return;
+    }
+
     gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
 }
 
index d36704d5138eb212854bb2c471693ad2dc39764f..cfa38c8eb520533adffcdbe68b3e0a02e5882355 100644 (file)
@@ -506,6 +506,18 @@ void wxToolBar::SetToolSeparation( int separation )
     m_toolSeparation = separation;
 }
 
+void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
+{
+    wxToolBarTool *tool = (wxToolBarTool *)FindById(id);
+
+    if ( tool )
+    {
+        (void)tool->SetShortHelp(helpString);
+        gtk_tooltips_set_tip(m_toolbar->tooltips, tool->m_item,
+                             helpString.mbc_str(), "");
+    }
+}
+
 // ----------------------------------------------------------------------------
 // wxToolBar idle handling
 // ----------------------------------------------------------------------------
@@ -555,4 +567,4 @@ void wxToolBar::OnInternalIdle()
     UpdateWindowUI();
 }
 
-#endif
+#endif // wxUSE_TOOLBAR_NATIVE
index 64c069e006a5a8e0408ec45c77b629d570c91a5a..6194b622bc2d71c3efd0df4bc4708587bd13aeb1 100644 (file)
@@ -14,6 +14,7 @@
 #include "wx/textctrl.h"
 #include "wx/utils.h"
 #include "wx/intl.h"
+#include "wx/log.h"
 #include "wx/settings.h"
 
 #include <sys/types.h>
@@ -646,6 +647,14 @@ void wxTextCtrl::SetSelection( long from, long to )
 {
     wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
 
+    if ( (m_windowStyle & wxTE_MULTILINE) &&
+         !GTK_TEXT(m_text)->line_start_cache )
+    {
+        // tell the programmer that it didn't work
+        wxLogDebug(_T("Can't call SetSelection() before realizing the control"));
+        return;
+    }
+
     gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
 }
 
index 539992500b9bcf2e7c8b69af95a1a9011a030b7b..7ec82031641b97af315df748b5dbba7a63aa4ad2 100644 (file)
@@ -1540,6 +1540,8 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     {
                         eventType = wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK;
                         event.m_itemIndex = lvhti.iItem;
+                        event.m_pointDrag.x = lvhti.pt.x;
+                        event.m_pointDrag.y = lvhti.pt.y;
                     }
                 }
             }