From 63da7df70114ff2c535d6cdeec5d0aca83ce97f3 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 3 Aug 2000 16:11:51 +0000 Subject: [PATCH] Added ability to call wxWindow::OnPaint under Windows (experimental). Added wxTR_NO_LINES to remove lines from tree control (MSW only). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/treectrl.tex | 4 ++++ include/wx/defs.h | 1 + include/wx/msw/dcclient.h | 3 +++ include/wx/msw/window.h | 1 + src/msw/dcclient.cpp | 17 +++++++++++++++++ src/msw/treectrl.cpp | 4 +++- src/msw/window.cpp | 10 ++++++++++ 7 files changed, 39 insertions(+), 1 deletion(-) diff --git a/docs/latex/wx/treectrl.tex b/docs/latex/wx/treectrl.tex index 0bd2bdc467..90244948cc 100644 --- a/docs/latex/wx/treectrl.tex +++ b/docs/latex/wx/treectrl.tex @@ -22,6 +22,10 @@ To intercept events from a tree control, use the event table macros described in \begin{twocollist}\itemsep=0pt \twocolitem{\windowstyle{wxTR\_HAS\_BUTTONS}}{Use this style to show + and - buttons to the left of parent items. Win32 only. } +\twocolitem{\windowstyle{wxTR\_NO\_LINES}}{Use this style to hide vertical lines. +Win32 only. } +\twocolitem{\windowstyle{wxTR\_LINES\_AT\_ROOT}}{Use this style to show lines at the +tree root. Win32 only.} \twocolitem{\windowstyle{wxTR\_EDIT\_LABELS}}{Use this style if you wish the user to be able to edit labels in the tree control.} \twocolitem{\windowstyle{wxTR\_MULTIPLE}}{Use this style to allow the user to diff --git a/include/wx/defs.h b/include/wx/defs.h index d1ecfe8ca2..4629929b53 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1087,6 +1087,7 @@ enum wxStretch #define wxTR_MULTIPLE 0x0020 #define wxTR_EXTENDED 0x0040 #define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080 +#define wxTR_NO_LINES 0x0100 /* * wxListCtrl flags diff --git a/include/wx/msw/dcclient.h b/include/wx/msw/dcclient.h index 997f2cfc6e..5568f0a6a2 100644 --- a/include/wx/msw/dcclient.h +++ b/include/wx/msw/dcclient.h @@ -74,6 +74,9 @@ public: virtual ~wxPaintDC(); + // find the entry for this DC in the cache (keyed by the window) + static WXHDC FindDCInCache(wxWindow* win); + protected: static wxArrayDCInfo ms_cache; diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 72126d5668..f440f5652a 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -185,6 +185,7 @@ public: void OnSetFocus(wxFocusEvent& event); void OnEraseBackground(wxEraseEvent& event); void OnIdle(wxIdleEvent& event); + void OnPaint(wxPaintEvent& event); public: // For implementation purposes - sometimes decorations make the client area diff --git a/src/msw/dcclient.cpp b/src/msw/dcclient.cpp index 483fd55376..46642e078f 100644 --- a/src/msw/dcclient.cpp +++ b/src/msw/dcclient.cpp @@ -262,3 +262,20 @@ wxPaintDCInfo *wxPaintDC::FindInCache(size_t *index) const return info; } + +// find the entry for this DC in the cache (keyed by the window) +WXHDC wxPaintDC::FindDCInCache(wxWindow* win) +{ + wxPaintDCInfo *info = NULL; + size_t nCache = ms_cache.GetCount(); + for ( size_t n = 0; n < nCache; n++ ) + { + info = &ms_cache[n]; + if ( info->hwnd == win->GetHWND() ) + { + return info->hdc; + } + } + return 0; +} + diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 73e8d4d856..0d54480eb5 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -519,8 +519,10 @@ bool wxTreeCtrl::Create(wxWindow *parent, return FALSE; DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP | - TVS_HASLINES | TVS_SHOWSELALWAYS /* | WS_CLIPSIBLINGS */; + TVS_SHOWSELALWAYS /* | WS_CLIPSIBLINGS */; + if ((m_windowStyle & wxTR_NO_LINES) == 0) + wstyle |= TVS_HASLINES; if ( m_windowStyle & wxTR_HAS_BUTTONS ) wstyle |= TVS_HASBUTTONS; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index c238a8b21c..6aa913b6b2 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2952,6 +2952,16 @@ bool wxWindow::HandlePaint() return GetEventHandler()->ProcessEvent(event); } +// Can be called from an application's OnPaint handler +void wxWindow::OnPaint(wxPaintEvent& event) +{ + HDC hDC = (HDC) wxPaintDC::FindDCInCache((wxWindow*) event.GetEventObject()); + if (hDC != 0) + { + MSWDefWindowProc(WM_PAINT, (WPARAM) hDC, 0); + } +} + bool wxWindow::HandleEraseBkgnd(WXHDC hdc) { // Prevents flicker when dragging -- 2.45.2