From a1f79c1e0064c7927ef4b8867acca5e061d1da67 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 24 Nov 2000 17:07:12 +0000 Subject: [PATCH] 1. added wxGTK::wxToolBar::SetToolShortHelp() and test for it in sample 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 | 2 ++ include/wx/gtk1/tbargtk.h | 2 ++ samples/console/console.cpp | 10 +++++----- samples/controls/controls.cpp | 7 +++++-- samples/toolbar/toolbar.cpp | 13 ++++++++++--- src/gtk/tbargtk.cpp | 14 +++++++++++++- src/gtk/textctrl.cpp | 9 +++++++++ src/gtk1/tbargtk.cpp | 14 +++++++++++++- src/gtk1/textctrl.cpp | 9 +++++++++ src/msw/listctrl.cpp | 2 ++ 10 files changed, 70 insertions(+), 12 deletions(-) diff --git a/include/wx/gtk/tbargtk.h b/include/wx/gtk/tbargtk.h index 1187c5887f..18f5243a88 100644 --- a/include/wx/gtk/tbargtk.h +++ b/include/wx/gtk/tbargtk.h @@ -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 // -------------------------- diff --git a/include/wx/gtk1/tbargtk.h b/include/wx/gtk1/tbargtk.h index 1187c5887f..18f5243a88 100644 --- a/include/wx/gtk1/tbargtk.h +++ b/include/wx/gtk1/tbargtk.h @@ -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 // -------------------------- diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 0229dcb002..5adda86c6c 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -35,12 +35,12 @@ // 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" diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 2b4e7e17c8..b34e832b30 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -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); } diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index ce30338920..df5e434c44 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -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); diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index d36704d513..cfa38c8eb5 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -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 diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 64c069e006..6194b622bc 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -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 @@ -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 ); } diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index d36704d513..cfa38c8eb5 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -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 diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 64c069e006..6194b622bc 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -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 @@ -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 ); } diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 539992500b..7ec8203164 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -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; } } } -- 2.47.2