erase separators shown behind the controls added to the toolbar

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-03-15 23:42:42 +00:00
parent ddb0baa06d
commit 7509fa8caa
3 changed files with 172 additions and 49 deletions

View File

@@ -135,6 +135,7 @@ wxMSW:
- showing a dialog from EVT_RADIOBUTTON handler doesn't lead to an infinite
recursion any more
- wxTextCtrl with wxTE_RICH flag scrolls to the end when text is appended to it
- the separators are not seen behind the controls added to the toolbar any more
- wxWindowDC and wxClientDC::GetSize() works correctly now
wxGTK:

View File

@@ -92,9 +92,14 @@ protected:
// should be called whenever the toolbar size changes
void UpdateSize();
// override WndProc to process WM_SIZE
// override WndProc mainly to process WM_SIZE
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
// handlers for various events
bool HandleSize(WXWPARAM wParam, WXLPARAM lParam);
bool HandlePaint(WXWPARAM wParam, WXLPARAM lParam);
void HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam);
// the big bitmap containing all bitmaps of the toolbar buttons
WXHBITMAP m_hBitmap;

View File

@@ -1040,13 +1040,10 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event)
}
}
long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
bool wxToolBar::HandleSize(WXWPARAM wParam, WXLPARAM lParam)
{
if ( nMsg == WM_SIZE )
{
// calculate our minor dimenstion ourselves - we're confusing the
// standard logic (TB_AUTOSIZE) with our horizontal toolbars and other
// hacks
// calculate our minor dimenstion ourselves - we're confusing the standard
// logic (TB_AUTOSIZE) with our horizontal toolbars and other hacks
RECT r;
if ( ::SendMessage(GetHwnd(), TB_GETITEMRECT, 0, (LPARAM)&r) )
{
@@ -1067,7 +1064,8 @@ long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
h = r.bottom - r.top;
if ( m_maxRows )
{
h += 6; // FIXME: this is the separator line height...
// FIXME: 6 is hardcoded separator line height...
h += 6;
h *= m_maxRows;
}
}
@@ -1079,12 +1077,114 @@ long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
}
// message processed
return 0;
return TRUE;
}
}
else if ( nMsg == WM_MOUSEMOVE )
return FALSE;
}
bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam)
{
// erase any dummy separators which we used for aligning the controls if
// any here
// first of all, do we have any controls at all?
wxToolBarToolsList::Node *node;
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
{
wxCoord x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
if ( node->GetData()->IsControl() )
break;
}
if ( !node )
{
// no controls, nothing to erase
return FALSE;
}
// prepare the DC on which we'll be drawing
wxClientDC dc(this);
dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID));
dc.SetPen(*wxTRANSPARENT_PEN);
RECT r;
if ( !GetUpdateRect(GetHwnd(), &r, FALSE) )
{
// nothing to redraw anyhow
return FALSE;
}
wxRect rectUpdate;
wxCopyRECTToRect(r, rectUpdate);
dc.SetClippingRegion(rectUpdate);
// draw the toolbar tools, separators &c normally
wxControl::MSWWindowProc(WM_PAINT, wParam, lParam);
// for each control in the toolbar find all the separators intersecting it
// and erase them
//
// NB: this is really the only way to do it as we don't know if a separator
// corresponds to a control (i.e. is a dummy one) or a real one
// otherwise
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
{
wxToolBarToolBase *tool = node->GetData();
if ( tool->IsControl() )
{
// get the control rect in our client coords
wxControl *control = tool->GetControl();
wxRect rectCtrl = control->GetRect();
control->ClientToScreen(&rectCtrl.x, &rectCtrl.y);
ScreenToClient(&rectCtrl.x, &rectCtrl.y);
// iterate over all buttons
TBBUTTON tbb;
int count = ::SendMessage(GetHwnd(), TB_BUTTONCOUNT, 0, 0);
for ( int n = 0; n < count; n++ )
{
// is it a separator?
if ( !::SendMessage(GetHwnd(), TB_GETBUTTON,
n, (LPARAM)&tbb) )
{
wxLogDebug(_T("TB_GETBUTTON failed?"));
continue;
}
if ( tbb.fsStyle != TBSTYLE_SEP )
continue;
// get the bounding rect of the separator
RECT r;
if ( !::SendMessage(GetHwnd(), TB_GETITEMRECT,
n, (LPARAM)&r) )
{
wxLogDebug(_T("TB_GETITEMRECT failed?"));
continue;
}
// does it intersect the control?
wxRect rectItem;
wxCopyRECTToRect(r, rectItem);
if ( rectCtrl.Intersects(rectItem) )
{
// yes, do erase it!
dc.DrawRectangle(rectItem);
}
}
}
}
return TRUE;
}
void wxToolBar::HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam)
{
wxCoord x = GET_X_LPARAM(lParam),
y = GET_Y_LPARAM(lParam);
wxToolBarToolBase* tool = FindToolForPosition( x, y );
// cursor left current tool
@@ -1100,9 +1200,26 @@ long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
m_pInTool = tool;
OnMouseEnter( tool->GetId() );
}
}
// we don't handle mouse moves, so fall through
// to wxControl::MSWWindowProc
long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
switch ( nMsg )
{
case WM_SIZE:
if ( HandleSize(wParam, lParam) )
return 0;
break;
case WM_MOUSEMOVE:
// we don't handle mouse moves, so always pass the message to
// wxControl::MSWWindowProc
HandleMouseMove(wParam, lParam);
break;
case WM_PAINT:
if ( HandlePaint(wParam, lParam) )
return 0;
}
return wxControl::MSWWindowProc(nMsg, wParam, lParam);