added wxRenderer::DrawTextBorder() to deal with GTK+ text borders
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8811 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -106,6 +106,14 @@ public:
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL) = 0;
|
||||
|
||||
// draw text control border (I hate to have a separate method for this but
|
||||
// it is needed to accomodate GTK+)
|
||||
virtual void DrawTextBorder(wxDC& dc,
|
||||
wxBorder border,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL) = 0;
|
||||
|
||||
// draw push button border and return the rectangle left for the label
|
||||
virtual void DrawButtonBorder(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
@@ -312,6 +320,17 @@ public:
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL)
|
||||
{ m_renderer->DrawBorder(dc, border, rect, flags, rectIn); }
|
||||
virtual void DrawTextBorder(wxDC& dc,
|
||||
wxBorder border,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL)
|
||||
{ m_renderer->DrawTextBorder(dc, border, rect, flags, rectIn); }
|
||||
virtual void DrawButtonBorder(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL)
|
||||
{ m_renderer->DrawButtonBorder(dc, rect, flags, rectIn); }
|
||||
virtual void DrawFrame(wxDC& dc,
|
||||
const wxString& label,
|
||||
const wxRect& rect,
|
||||
@@ -325,11 +344,6 @@ public:
|
||||
virtual void DrawVerticalLine(wxDC& dc,
|
||||
wxCoord x, wxCoord y1, wxCoord y2)
|
||||
{ m_renderer->DrawVerticalLine(dc, x, y1, y2); }
|
||||
virtual void DrawButtonBorder(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL)
|
||||
{ m_renderer->DrawButtonBorder(dc, rect, flags, rectIn); }
|
||||
virtual void DrawArrow(wxDC& dc,
|
||||
wxDirection dir,
|
||||
const wxRect& rect,
|
||||
|
@@ -250,7 +250,7 @@ public:
|
||||
// override this to take into account our scrollbar-less scrolling
|
||||
virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
|
||||
|
||||
// set the right colours
|
||||
// set the right colours and border
|
||||
virtual bool IsContainerWindow() const { return TRUE; }
|
||||
virtual wxBorder GetDefaultBorder() const { return wxBORDER_SUNKEN; }
|
||||
|
||||
@@ -271,6 +271,8 @@ protected:
|
||||
|
||||
void DoDrawTextInRect(wxDC& dc, const wxRect& rectUpdate);
|
||||
|
||||
// override base class methods
|
||||
virtual void DoDrawBorder(wxDC& dc, const wxRect& rect);
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
||||
// calc the size from the text extent
|
||||
|
@@ -195,7 +195,7 @@ protected:
|
||||
virtual bool DoDrawBackground(wxDC& dc);
|
||||
|
||||
// draw the controls border
|
||||
virtual void DoDrawBorder(wxDC& dc);
|
||||
virtual void DoDrawBorder(wxDC& dc, const wxRect& rect);
|
||||
|
||||
// draw the controls contents
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
@@ -2772,7 +2772,16 @@ void wxTextCtrl::RefreshTextRect(const wxRect& rectClient)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// drawing
|
||||
// border drawing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTextCtrl::DoDrawBorder(wxDC& dc, const wxRect& rect)
|
||||
{
|
||||
m_renderer->DrawTextBorder(dc, GetBorder(), rect, GetStateFlags());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// client area drawing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
@@ -3622,12 +3631,10 @@ bool wxStdTextCtrlInputHandler::HandleFocus(wxControl *control,
|
||||
if ( event.GetEventType() == wxEVT_KILL_FOCUS )
|
||||
{
|
||||
wxStaticCast(control, wxTextCtrl)->ClearSelection();
|
||||
|
||||
// don't refresh
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return wxStdInputHandler::HandleFocus(control, event);
|
||||
// refresh
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
@@ -91,6 +91,11 @@ public:
|
||||
int flags = 0,
|
||||
int alignment = wxALIGN_LEFT,
|
||||
int indexAccel = -1);
|
||||
virtual void DrawTextBorder(wxDC& dc,
|
||||
wxBorder border,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL);
|
||||
virtual void DrawButtonBorder(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
@@ -677,7 +682,7 @@ void wxGTKRenderer::DrawRaisedBorder(wxDC& dc, wxRect *rect)
|
||||
void wxGTKRenderer::DrawBorder(wxDC& dc,
|
||||
wxBorder border,
|
||||
const wxRect& rectTotal,
|
||||
int WXUNUSED(flags),
|
||||
int flags,
|
||||
wxRect *rectIn)
|
||||
{
|
||||
size_t width;
|
||||
@@ -773,9 +778,32 @@ bool wxGTKRenderer::AreScrollbarsInsideBorder() const
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// borders
|
||||
// special borders
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxGTKRenderer::DrawTextBorder(wxDC& dc,
|
||||
wxBorder border,
|
||||
const wxRect& rectOrig,
|
||||
int flags,
|
||||
wxRect *rectIn)
|
||||
{
|
||||
wxRect rect = rectOrig;
|
||||
|
||||
if ( flags & wxCONTROL_FOCUSED )
|
||||
{
|
||||
DrawRect(dc, &rect, m_penBlack);
|
||||
DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
|
||||
}
|
||||
else // !focused
|
||||
{
|
||||
DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
|
||||
DrawAntiShadedRect(dc, &rect, m_penBlack, m_penHighlight);
|
||||
}
|
||||
|
||||
if ( rectIn )
|
||||
*rectIn = rect;
|
||||
}
|
||||
|
||||
void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
|
||||
const wxRect& rectTotal,
|
||||
int flags,
|
||||
|
@@ -111,6 +111,11 @@ public:
|
||||
int flags = 0,
|
||||
int alignment = wxALIGN_LEFT,
|
||||
int indexAccel = -1);
|
||||
virtual void DrawTextBorder(wxDC& dc,
|
||||
wxBorder border,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL);
|
||||
virtual void DrawButtonBorder(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
@@ -1173,6 +1178,16 @@ bool wxWin32Renderer::AreScrollbarsInsideBorder() const
|
||||
// borders
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxWin32Renderer::DrawTextBorder(wxDC& dc,
|
||||
wxBorder border,
|
||||
const wxRect& rect,
|
||||
int flags,
|
||||
wxRect *rectIn)
|
||||
{
|
||||
// text controls are not special under windows
|
||||
return DrawBorder(dc, border, rect, flags, rectIn);
|
||||
}
|
||||
|
||||
void wxWin32Renderer::DrawButtonBorder(wxDC& dc,
|
||||
const wxRect& rectTotal,
|
||||
int flags,
|
||||
|
@@ -191,11 +191,30 @@ void wxWindow::OnNcPaint(wxPaintEvent& event)
|
||||
{
|
||||
if ( m_renderer )
|
||||
{
|
||||
// get the DC to use and create renderer on it
|
||||
wxWindowDC dc(this);
|
||||
// get the window rect
|
||||
wxRect rect;
|
||||
wxSize size = GetSize();
|
||||
rect.x =
|
||||
rect.y = 0;
|
||||
rect.width = size.x;
|
||||
rect.height = size.y;
|
||||
|
||||
// draw the border
|
||||
DoDrawBorder(dc);
|
||||
// if the scrollbars are outside the border, we must adjust the rect to
|
||||
// exclude them
|
||||
if ( !m_renderer->AreScrollbarsInsideBorder() )
|
||||
{
|
||||
wxScrollBar *scrollbar = GetScrollbar(wxVERTICAL);
|
||||
if ( scrollbar )
|
||||
rect.width -= scrollbar->GetSize().x;
|
||||
|
||||
scrollbar = GetScrollbar(wxHORIZONTAL);
|
||||
if ( scrollbar )
|
||||
rect.height -= scrollbar->GetSize().y;
|
||||
}
|
||||
|
||||
// get the DC and draw the border on it
|
||||
wxWindowDC dc(this);
|
||||
DoDrawBorder(dc, rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,37 +268,15 @@ bool wxWindow::DoDrawBackground(wxDC& dc)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxWindow::DoDrawBorder(wxDC& dc)
|
||||
void wxWindow::DoDrawBorder(wxDC& dc, const wxRect& rect)
|
||||
{
|
||||
// get the window rect
|
||||
wxRect rect;
|
||||
wxSize size = GetSize();
|
||||
rect.x =
|
||||
rect.y = 0;
|
||||
rect.width = size.x;
|
||||
rect.height = size.y;
|
||||
|
||||
// if the scrollbars are outside the border, we must adjust the rect to
|
||||
// exclude them
|
||||
if ( !m_renderer->AreScrollbarsInsideBorder() )
|
||||
{
|
||||
wxScrollBar *scrollbar = GetScrollbar(wxVERTICAL);
|
||||
if ( scrollbar )
|
||||
rect.width -= scrollbar->GetSize().x;
|
||||
|
||||
scrollbar = GetScrollbar(wxHORIZONTAL);
|
||||
if ( scrollbar )
|
||||
rect.height -= scrollbar->GetSize().y;
|
||||
}
|
||||
|
||||
// draw outline unless the update region is enitrely inside it in which
|
||||
// case we don't need to do it
|
||||
#if 0 // doesn't seem to work, why?
|
||||
if ( wxRegion(rect).Contains(GetUpdateRegion().GetBox()) != wxInRegion )
|
||||
#endif
|
||||
{
|
||||
m_renderer->DrawBorder(dc, GetBorder(),
|
||||
rect, GetStateFlags(), &rect);
|
||||
m_renderer->DrawBorder(dc, GetBorder(), rect, GetStateFlags());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user