moved Arrow_ constants to the base class

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41323 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-09-20 15:38:18 +00:00
parent 3ef4e126a2
commit 0428ac8c47
3 changed files with 108 additions and 79 deletions

View File

@ -104,6 +104,13 @@ public:
wxAlignment align = wxALIGN_LEFT,
int indexAccel = -1);
virtual void DrawScrollbarArrow(wxDC& dc,
wxDirection dir,
const wxRect& rect,
int flags = 0);
virtual void DrawScrollCorner(wxDC& dc,
const wxRect& rect);
#if wxUSE_TEXTCTRL
virtual void DrawTextLine(wxDC& dc,
const wxString& text,
@ -142,6 +149,25 @@ public:
protected:
// various constants
enum ArrowDirection
{
Arrow_Left,
Arrow_Right,
Arrow_Up,
Arrow_Down,
Arrow_Max
};
enum ArrowStyle
{
Arrow_Normal,
Arrow_Disabled,
Arrow_Pressed,
Arrow_Inverted,
Arrow_InvertedDisabled,
Arrow_StateMax
};
enum IndicatorType
{
IndicatorType_Check,
@ -177,6 +203,10 @@ protected:
IndicatorState& state,
IndicatorStatus& status);
// translate wxDirection to ArrowDirection
static ArrowDirection GetArrowDirection(wxDirection dir);
// fill the rectangle with a brush of given colour (must be valid)
void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect);

View File

@ -89,6 +89,55 @@ void wxStdRenderer::DrawShadedRect(wxDC& dc, wxRect *rect,
rect->Inflate(-1);
}
// ----------------------------------------------------------------------------
// translate various flags into corresponding renderer constants
// ----------------------------------------------------------------------------
/* static */
void wxStdRenderer::GetIndicatorsFromFlags(int flags,
IndicatorState& state,
IndicatorStatus& status)
{
if ( flags & wxCONTROL_SELECTED )
state = flags & wxCONTROL_DISABLED ? IndicatorState_SelectedDisabled
: IndicatorState_Selected;
else if ( flags & wxCONTROL_DISABLED )
state = IndicatorState_Disabled;
else if ( flags & wxCONTROL_PRESSED )
state = IndicatorState_Pressed;
else
state = IndicatorState_Normal;
status = flags & wxCONTROL_CHECKED ? IndicatorStatus_Checked
: flags & wxCONTROL_UNDETERMINED
? IndicatorStatus_Undetermined
: IndicatorStatus_Unchecked;
}
/* static */
wxStdRenderer::ArrowDirection wxStdRenderer::GetArrowDirection(wxDirection dir)
{
switch ( dir )
{
case wxLEFT:
return Arrow_Left;
case wxRIGHT:
return Arrow_Right;
case wxUP:
return Arrow_Up;
case wxDOWN:
return Arrow_Down;
default:
wxFAIL_MSG(_T("unknown arrow direction"));
}
return Arrow_Max;
}
// ----------------------------------------------------------------------------
// background
// ----------------------------------------------------------------------------
@ -560,27 +609,6 @@ void wxStdRenderer::DrawCheckItem(wxDC& dc,
// check and radio bitmaps
// ----------------------------------------------------------------------------
/* static */
void wxStdRenderer::GetIndicatorsFromFlags(int flags,
IndicatorState& state,
IndicatorStatus& status)
{
if ( flags & wxCONTROL_SELECTED )
state = flags & wxCONTROL_DISABLED ? IndicatorState_SelectedDisabled
: IndicatorState_Selected;
else if ( flags & wxCONTROL_DISABLED )
state = IndicatorState_Disabled;
else if ( flags & wxCONTROL_PRESSED )
state = IndicatorState_Pressed;
else
state = IndicatorState_Normal;
status = flags & wxCONTROL_CHECKED ? IndicatorStatus_Checked
: flags & wxCONTROL_UNDETERMINED
? IndicatorStatus_Undetermined
: IndicatorStatus_Unchecked;
}
void wxStdRenderer::DrawCheckButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
@ -738,6 +766,23 @@ wxRect wxStdRenderer::GetTextClientArea(const wxTextCtrl *text,
#endif // wxUSE_TEXTCTRL
// ----------------------------------------------------------------------------
// scrollbars drawing
// ----------------------------------------------------------------------------
void wxStdRenderer::DrawScrollbarArrow(wxDC& dc,
wxDirection dir,
const wxRect& rect,
int flags)
{
DrawArrow(dc, dir, rect, flags);
}
void wxStdRenderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
{
DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
}
// ----------------------------------------------------------------------------
// scrollbars geometry
// ----------------------------------------------------------------------------

View File

@ -98,26 +98,6 @@ static const wxCoord SLIDER_TICK_LENGTH = 6;
class wxWin32Renderer : public wxStdRenderer
{
public:
// constants
enum wxArrowDirection
{
Arrow_Left,
Arrow_Right,
Arrow_Up,
Arrow_Down,
Arrow_Max
};
enum wxArrowStyle
{
Arrow_Normal,
Arrow_Disabled,
Arrow_Pressed,
Arrow_Inverted,
Arrow_InvertedDisabled,
Arrow_StateMax
};
enum wxFrameButtonType
{
FrameButton_Close,
@ -151,15 +131,11 @@ public:
const wxRect& rect,
int flags = 0,
wxRect *rectIn = NULL);
virtual void DrawArrow(wxDC& dc,
wxDirection dir,
const wxRect& rect,
int flags = 0);
virtual void DrawScrollbarArrow(wxDC& dc,
wxDirection dir,
const wxRect& rect,
int flags = 0)
{ DrawArrow(dc, dir, rect, flags); }
virtual void DrawScrollbarThumb(wxDC& dc,
wxOrientation orient,
const wxRect& rect,
@ -168,8 +144,6 @@ public:
wxOrientation orient,
const wxRect& rect,
int flags = 0);
virtual void DrawScrollCorner(wxDC& dc,
const wxRect& rect);
#if wxUSE_TOOLBAR
virtual void DrawToolBarButton(wxDC& dc,
@ -357,12 +331,12 @@ protected:
// public DrawArrow()s helper
void DrawArrow(wxDC& dc, const wxRect& rect,
wxArrowDirection arrowDir, wxArrowStyle arrowStyle);
ArrowDirection arrowDir, ArrowStyle arrowStyle);
// DrawArrowButton is used by DrawScrollbar and DrawComboButton
void DrawArrowButton(wxDC& dc, const wxRect& rect,
wxArrowDirection arrowDir,
wxArrowStyle arrowStyle);
ArrowDirection arrowDir,
ArrowStyle arrowStyle);
// draw a normal or transposed line (useful for using the same code fo both
// horizontal and vertical widgets)
@ -1744,7 +1718,7 @@ wxBitmap wxWin32Renderer::GetIndicator(IndicatorType indType, int flags)
IndicatorStatus indStatus;
GetIndicatorsFromFlags(flags, indState, indStatus);
wxBitmap bmp = m_bmpIndicators[indType][indState][indStatus];
wxBitmap& bmp = m_bmpIndicators[indType][indState][indStatus];
if ( !bmp.Ok() )
{
const char **xpm = ms_xpmIndicators[indType][indState][indStatus];
@ -1752,7 +1726,6 @@ wxBitmap wxWin32Renderer::GetIndicator(IndicatorType indType, int flags)
{
// create and cache it
bmp = wxBitmap(xpm);
m_bmpIndicators[indType][indState][indStatus] = bmp;
}
}
@ -2512,7 +2485,7 @@ void wxWin32Renderer::DrawMenuItem(wxDC& dc,
rect.x = geometryInfo.GetSize().x - MENU_RIGHT_MARGIN;
rect.width = MENU_RIGHT_MARGIN;
wxArrowStyle arrowStyle;
ArrowStyle arrowStyle;
if ( flags & wxCONTROL_DISABLED )
arrowStyle = flags & wxCONTROL_SELECTED ? Arrow_InvertedDisabled
: Arrow_Disabled;
@ -2800,21 +2773,7 @@ void wxWin32Renderer::DrawArrow(wxDC& dc,
const wxRect& rect,
int flags)
{
// get the bitmap for this arrow
wxArrowDirection arrowDir;
switch ( dir )
{
case wxLEFT: arrowDir = Arrow_Left; break;
case wxRIGHT: arrowDir = Arrow_Right; break;
case wxUP: arrowDir = Arrow_Up; break;
case wxDOWN: arrowDir = Arrow_Down; break;
default:
wxFAIL_MSG(_T("unknown arrow direction"));
return;
}
wxArrowStyle arrowStyle;
ArrowStyle arrowStyle;
if ( flags & wxCONTROL_PRESSED )
{
// can't be pressed and disabled
@ -2825,13 +2784,13 @@ void wxWin32Renderer::DrawArrow(wxDC& dc,
arrowStyle = flags & wxCONTROL_DISABLED ? Arrow_Disabled : Arrow_Normal;
}
DrawArrowButton(dc, rect, arrowDir, arrowStyle);
DrawArrowButton(dc, rect, GetArrowDirection(dir), arrowStyle);
}
void wxWin32Renderer::DrawArrow(wxDC& dc,
const wxRect& rect,
wxArrowDirection arrowDir,
wxArrowStyle arrowStyle)
ArrowDirection arrowDir,
ArrowStyle arrowStyle)
{
const wxBitmap& bmp = m_bmpArrows[arrowStyle][arrowDir];
@ -2850,8 +2809,8 @@ void wxWin32Renderer::DrawArrow(wxDC& dc,
void wxWin32Renderer::DrawArrowButton(wxDC& dc,
const wxRect& rectAll,
wxArrowDirection arrowDir,
wxArrowStyle arrowStyle)
ArrowDirection arrowDir,
ArrowStyle arrowStyle)
{
wxRect rect = rectAll;
DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
@ -2881,11 +2840,6 @@ void wxWin32Renderer::DrawScrollbarShaft(wxDC& dc,
DrawBackground(dc, m_scheme->Get(col), rectBar);
}
void wxWin32Renderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
{
DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
}
// ----------------------------------------------------------------------------
// top level windows
// ----------------------------------------------------------------------------