From cdde63f53542ceba62b2fc90600d5633b0d45051 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 May 2000 20:35:00 +0000 Subject: [PATCH] 1. buttons now generate double click events 2. double clicking in the tree ctrl generates an activate event 3. bug with hidden listbox mysteriously being shown fixed 4. tried to adjust the checkbox size git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7364 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/button.cpp | 7 ++++++- src/msw/checkbox.cpp | 28 ++++++++++++++++++--------- src/msw/listbox.cpp | 15 +++++++++++---- src/msw/treectrl.cpp | 46 ++++++++++++++++++++++++++------------------ src/msw/window.cpp | 5 +++-- 5 files changed, 66 insertions(+), 35 deletions(-) diff --git a/src/msw/button.cpp b/src/msw/button.cpp index e65488b210..904e3998f5 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -74,7 +74,7 @@ bool wxButton::Create(wxWindow *parent, m_backgroundColour = parent->GetBackgroundColour(); m_foregroundColour = parent->GetForegroundColour(); - long msStyle = WS_VISIBLE | WS_TABSTOP | WS_CHILD /* | WS_CLIPSIBLINGS */ ; + long msStyle = WS_VISIBLE | WS_TABSTOP | WS_CHILD /* | WS_CLIPSIBLINGS */ ; #ifdef __WIN32__ if(m_windowStyle & wxBU_LEFT) @@ -280,11 +280,16 @@ long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) // let the default processign take place too } + // VZ: I don't remember any more why was this needed but everything seems + // to work just fine without this code and it prevents LDCLICK events + // from being generated, so I will probably remoe it completely soon +#if 0 else if ( nMsg == WM_LBUTTONDBLCLK ) { // trick the base class into thinking that this was just a click nMsg = WM_LBUTTONDOWN; } +#endif // 0 // let the base class do all real processing return wxControl::MSWWindowProc(nMsg, wParam, lParam); diff --git a/src/msw/checkbox.cpp b/src/msw/checkbox.cpp index fe6bfcece0..51a2563918 100644 --- a/src/msw/checkbox.cpp +++ b/src/msw/checkbox.cpp @@ -142,29 +142,39 @@ bool wxCheckBox::Create(wxWindow *parent, void wxCheckBox::SetLabel(const wxString& label) { - SetWindowText(GetHwnd(), label); + SetWindowText(GetHwnd(), label); } -#define CHECK_SIZE 13 - wxSize wxCheckBox::DoGetBestSize() const { - int wCheckbox, hCheckbox; + static int s_checkSize = 0; + + if ( !s_checkSize ) + { + wxScreenDC dc; + dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + + // the height of a standard button in the dialog units is 8, + // translate this to pixels (as one dialog unit is precisely equal to + // 8 character heights, it's just the char height) + s_checkSize = dc.GetCharHeight(); + } wxString str = wxGetWindowText(GetHWND()); + int wCheckbox, hCheckbox; if ( !str.IsEmpty() ) { GetTextExtent(str, &wCheckbox, &hCheckbox); - wCheckbox += CHECK_SIZE + GetCharWidth(); + wCheckbox += s_checkSize + GetCharWidth(); - if ( hCheckbox < CHECK_SIZE ) - hCheckbox = CHECK_SIZE; + if ( hCheckbox < s_checkSize ) + hCheckbox = s_checkSize; } else { - wCheckbox = CHECK_SIZE; - hCheckbox = CHECK_SIZE; + wCheckbox = s_checkSize; + hCheckbox = s_checkSize; } return wxSize(wCheckbox, hCheckbox); diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 15b3c4c629..5a4f08ef23 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -221,8 +221,6 @@ bool wxListBox::Create(wxWindow *parent, SetSize(x, y, width, height); - Show(TRUE); - return TRUE; } @@ -292,7 +290,12 @@ int wxListBox::DoAppend(const wxString& item) void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) { - ShowWindow(GetHwnd(), SW_HIDE); + // avoid flicker - but don't need to do this for a hidden listbox + bool hideAndShow = IsShown(); + if ( hideAndShow ) + { + ShowWindow(GetHwnd(), SW_HIDE); + } ListBox_ResetContent(GetHwnd()); @@ -333,7 +336,11 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) SetHorizontalExtent(); - ShowWindow(GetHwnd(), SW_SHOW); + if ( hideAndShow ) + { + // show the listbox back if we hid it + ShowWindow(GetHwnd(), SW_SHOW); + } } int wxListBox::FindString(const wxString& s) const diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 1a6d535c85..17de6a6068 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1940,25 +1940,6 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) switch ( hdr->code ) { - case NM_RCLICK: - { - if ( wxControl::MSWOnNotify(idCtrl, lParam, result) ) - return TRUE; - - TV_HITTESTINFO tvhti; - ::GetCursorPos(&(tvhti.pt)); - ::ScreenToClient(GetHwnd(),&(tvhti.pt)); - if ( TreeView_HitTest(GetHwnd(),&tvhti) ) - { - if( tvhti.flags & TVHT_ONITEM ) - { - event.m_item = (WXHTREEITEM) tvhti.hItem; - eventType = wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK; - } - } - } - break; - case TVN_BEGINDRAG: eventType = wxEVT_COMMAND_TREE_BEGIN_DRAG; // fall through @@ -2203,6 +2184,27 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) break; #endif // _WIN32_IE >= 0x300 + case NM_DBLCLK: + case NM_RCLICK: + { + TV_HITTESTINFO tvhti; + ::GetCursorPos(&tvhti.pt); + ::ScreenToClient(GetHwnd(), &tvhti.pt); + if ( TreeView_HitTest(GetHwnd(), &tvhti) ) + { + if ( tvhti.flags & TVHT_ONITEM ) + { + event.m_item = (WXHTREEITEM) tvhti.hItem; + eventType = hdr->code == NM_DBLCLK + ? wxEVT_COMMAND_TREE_ITEM_ACTIVATED + : wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK; + } + + break; + } + } + // fall through + default: return wxControl::MSWOnNotify(idCtrl, lParam, result); } @@ -2215,6 +2217,12 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // post processing switch ( hdr->code ) { + case NM_DBLCLK: + // return TRUE to prevent the default processing which consists in + // toggling the state of the item under the mouse + *result = processed; + break; + case TVN_BEGINDRAG: case TVN_BEGINRDRAG: if ( event.IsAllowed() ) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 03049a5b76..f89cf5d4da 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1624,7 +1624,10 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) #endif // 0 if ( ::IsDialogMessage(GetHwnd(), msg) ) + { + // IsDialogMessage() did something... return TRUE; + } } #if wxUSE_TOOLTIPS @@ -2435,8 +2438,6 @@ bool wxWindow::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) if ( child->MSWOnNotify(idCtrl, lParam, result) ) { return TRUE; - - break; } node = node->GetNext();