1. (trivial) wxGTKColourScheme added
2. wxScrollBar draws almost fine under GTK git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8155 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -36,7 +36,7 @@ public:
|
|||||||
bool refresh = TRUE) = 0;
|
bool refresh = TRUE) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXUNIVERSAL__)
|
||||||
#include "wx/univ/scrolbar.h"
|
#include "wx/univ/scrolbar.h"
|
||||||
#elif defined(__WXMSW__)
|
#elif defined(__WXMSW__)
|
||||||
#include "wx/msw/scrolbar.h"
|
#include "wx/msw/scrolbar.h"
|
||||||
|
@@ -31,6 +31,7 @@ public:
|
|||||||
// the background and text colour for the control
|
// the background and text colour for the control
|
||||||
CONTROL,
|
CONTROL,
|
||||||
CONTROL_TEXT,
|
CONTROL_TEXT,
|
||||||
|
SCROLLBAR,
|
||||||
|
|
||||||
// the background and text colour for the highlighted item
|
// the background and text colour for the highlighted item
|
||||||
HIGHLIGHT,
|
HIGHLIGHT,
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
#pragma interface "control.h"
|
#pragma interface "control.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "wx/bitmap.h" // for m_bitmapBg
|
||||||
|
|
||||||
class WXDLLEXPORT wxControlRenderer;
|
class WXDLLEXPORT wxControlRenderer;
|
||||||
class WXDLLEXPORT wxInputHandler;
|
class WXDLLEXPORT wxInputHandler;
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@ class WXDLLEXPORT wxRenderer
|
|||||||
public:
|
public:
|
||||||
// draw the controls background
|
// draw the controls background
|
||||||
virtual void DrawBackground(wxDC& dc,
|
virtual void DrawBackground(wxDC& dc,
|
||||||
const wxColour& col,
|
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags) = 0;
|
int flags) = 0;
|
||||||
|
|
||||||
@@ -86,7 +85,8 @@ public:
|
|||||||
int thumbPosStart,
|
int thumbPosStart,
|
||||||
int thumbPosEnd,
|
int thumbPosEnd,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags = 0) = 0;
|
int flags = 0,
|
||||||
|
int extraFlags = 0) = 0;
|
||||||
|
|
||||||
// TODO: having this is ugly but I don't see how to solve GetBestSize()
|
// TODO: having this is ugly but I don't see how to solve GetBestSize()
|
||||||
// problem without something like this
|
// problem without something like this
|
||||||
@@ -114,10 +114,9 @@ public:
|
|||||||
wxDelegateRenderer(wxRenderer *renderer) : m_renderer(renderer) { }
|
wxDelegateRenderer(wxRenderer *renderer) : m_renderer(renderer) { }
|
||||||
|
|
||||||
virtual void DrawBackground(wxDC& dc,
|
virtual void DrawBackground(wxDC& dc,
|
||||||
const wxColour& col,
|
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags)
|
int flags)
|
||||||
{ m_renderer->DrawBackground(dc, col, rect, flags); }
|
{ m_renderer->DrawBackground(dc, rect, flags); }
|
||||||
virtual void DrawLabel(wxDC& dc,
|
virtual void DrawLabel(wxDC& dc,
|
||||||
const wxString& label,
|
const wxString& label,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
@@ -153,9 +152,10 @@ public:
|
|||||||
int thumbPosStart,
|
int thumbPosStart,
|
||||||
int thumbPosEnd,
|
int thumbPosEnd,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags = 0)
|
int flags = 0,
|
||||||
|
int extraFlags = 0)
|
||||||
{ m_renderer->DrawScrollbar(dc, orient, thumbPosStart,
|
{ m_renderer->DrawScrollbar(dc, orient, thumbPosStart,
|
||||||
thumbPosEnd, rect, flags); }
|
thumbPosEnd, rect, flags, extraFlags); }
|
||||||
|
|
||||||
virtual void AdjustSize(wxSize *size, const wxWindow *window)
|
virtual void AdjustSize(wxSize *size, const wxWindow *window)
|
||||||
{ m_renderer->AdjustSize(size, window); }
|
{ m_renderer->AdjustSize(size, window); }
|
||||||
@@ -181,7 +181,7 @@ public:
|
|||||||
void DrawButtonBorder();
|
void DrawButtonBorder();
|
||||||
void DrawFrame();
|
void DrawFrame();
|
||||||
void DrawBackgroundBitmap();
|
void DrawBackgroundBitmap();
|
||||||
void DrawScrollbar(int thumbStart, int thumbEnd);
|
void DrawScrollbar(int thumbStart, int thumbEnd, int extraFlags = 0);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
wxRenderer *GetRenderer() const { return m_renderer; }
|
wxRenderer *GetRenderer() const { return m_renderer; }
|
||||||
|
@@ -22,6 +22,12 @@ class WXDLLEXPORT wxInputHandler;
|
|||||||
// the actions supported by this control
|
// the actions supported by this control
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// various parts of scrollbar may be highlighted
|
||||||
|
#define wxACTION_SCROLL_HIGHLIGHT_ARROW_UP _T("focusarrowup")
|
||||||
|
#define wxACTION_SCROLL_HIGHLIGHT_ARROW_DOWN _T("focusarrowdown")
|
||||||
|
#define wxACTION_SCROLL_HIGHLIGHT_THUMB _T("focusthumb")
|
||||||
|
#define wxACTION_SCROLL_HIGHLIGHT_BAR _T("focusbar")
|
||||||
|
|
||||||
// scroll the bar
|
// scroll the bar
|
||||||
#define wxACTION_SCROLL_START _T("start") // to the beginning
|
#define wxACTION_SCROLL_START _T("start") // to the beginning
|
||||||
#define wxACTION_SCROLL_END _T("end") // to the end
|
#define wxACTION_SCROLL_END _T("end") // to the end
|
||||||
@@ -45,6 +51,15 @@ class WXDLLEXPORT wxInputHandler;
|
|||||||
class WXDLLEXPORT wxScrollBar : public wxScrollBarBase
|
class WXDLLEXPORT wxScrollBar : public wxScrollBarBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// which part of scrollbar is currently highlighted?
|
||||||
|
Highlight_Arrow1 = 0x0001,
|
||||||
|
Highlight_Arrow2 = 0x0002,
|
||||||
|
Highlight_Thumb = 0x0004,
|
||||||
|
Highlight_Bar = 0x0008
|
||||||
|
};
|
||||||
|
|
||||||
wxScrollBar() { Init(); }
|
wxScrollBar() { Init(); }
|
||||||
wxScrollBar(wxWindow *parent,
|
wxScrollBar(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
@@ -52,7 +67,7 @@ public:
|
|||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = wxSB_HORIZONTAL,
|
long style = wxSB_HORIZONTAL,
|
||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = wxButtonNameStr)
|
const wxString& name = wxScrollBarNameStr)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
@@ -65,7 +80,7 @@ public:
|
|||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = wxSB_HORIZONTAL,
|
long style = wxSB_HORIZONTAL,
|
||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = wxButtonNameStr);
|
const wxString& name = wxScrollBarNameStr);
|
||||||
|
|
||||||
virtual ~wxScrollBar();
|
virtual ~wxScrollBar();
|
||||||
|
|
||||||
|
@@ -120,7 +120,11 @@ bool MyUnivApp::OnInit()
|
|||||||
MyUnivFrame::MyUnivFrame(const wxString& title)
|
MyUnivFrame::MyUnivFrame(const wxString& title)
|
||||||
: wxFrame(NULL, -1, title, wxDefaultPosition, wxSize(600, 450))
|
: wxFrame(NULL, -1, title, wxDefaultPosition, wxSize(600, 450))
|
||||||
{
|
{
|
||||||
|
#ifdef __WXMSW__
|
||||||
SetBackgroundColour(*wxLIGHT_GREY);
|
SetBackgroundColour(*wxLIGHT_GREY);
|
||||||
|
#else
|
||||||
|
SetBackgroundColour(0xd6d6d6);
|
||||||
|
#endif
|
||||||
|
|
||||||
wxStaticText *text;
|
wxStaticText *text;
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#if wxUSE_CONTROLS
|
#if wxUSE_CONTROLS
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/app.h"
|
||||||
#include "wx/control.h"
|
#include "wx/control.h"
|
||||||
#include "wx/dcclient.h"
|
#include "wx/dcclient.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -48,14 +49,7 @@ BEGIN_EVENT_TABLE(wxControl, wxControlBase)
|
|||||||
EVT_KEY_DOWN(wxControl::OnKeyDown)
|
EVT_KEY_DOWN(wxControl::OnKeyDown)
|
||||||
EVT_KEY_UP(wxControl::OnKeyUp)
|
EVT_KEY_UP(wxControl::OnKeyUp)
|
||||||
|
|
||||||
EVT_LEFT_DOWN(wxControl::OnMouse)
|
EVT_MOUSE_EVENTS(wxControl::OnMouse)
|
||||||
EVT_LEFT_UP(wxControl::OnMouse)
|
|
||||||
EVT_RIGHT_DOWN(wxControl::OnMouse)
|
|
||||||
EVT_RIGHT_UP(wxControl::OnMouse)
|
|
||||||
EVT_MIDDLE_DOWN(wxControl::OnMouse)
|
|
||||||
EVT_MIDDLE_UP(wxControl::OnMouse)
|
|
||||||
EVT_LEAVE_WINDOW(wxControl::OnMouse)
|
|
||||||
EVT_ENTER_WINDOW(wxControl::OnMouse)
|
|
||||||
|
|
||||||
EVT_SET_FOCUS(wxControl::OnFocus)
|
EVT_SET_FOCUS(wxControl::OnFocus)
|
||||||
EVT_KILL_FOCUS(wxControl::OnFocus)
|
EVT_KILL_FOCUS(wxControl::OnFocus)
|
||||||
|
@@ -4,6 +4,7 @@ UNIVOBJS = \
|
|||||||
control.o \
|
control.o \
|
||||||
inphand.o \
|
inphand.o \
|
||||||
renderer.o \
|
renderer.o \
|
||||||
|
scrolbar.o \
|
||||||
statbox.o \
|
statbox.o \
|
||||||
stattext.o \
|
stattext.o \
|
||||||
theme.o \
|
theme.o \
|
||||||
|
@@ -74,8 +74,7 @@ void wxControlRenderer::DrawBorder()
|
|||||||
m_rect, flags, &m_rect);
|
m_rect, flags, &m_rect);
|
||||||
|
|
||||||
// fill the inside (TODO: query the theme for bg bitmap)
|
// fill the inside (TODO: query the theme for bg bitmap)
|
||||||
m_renderer->DrawBackground(m_dc,
|
m_renderer->DrawBackground(m_dc, m_rect, flags);
|
||||||
m_ctrl->GetBackgroundColour(), m_rect, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControlRenderer::DrawLabel()
|
void wxControlRenderer::DrawLabel()
|
||||||
@@ -111,8 +110,7 @@ void wxControlRenderer::DrawButtonBorder()
|
|||||||
|
|
||||||
m_renderer->DrawButtonBorder(m_dc, m_rect, flags, &m_rect);
|
m_renderer->DrawButtonBorder(m_dc, m_rect, flags, &m_rect);
|
||||||
|
|
||||||
m_renderer->DrawBackground(m_dc, m_ctrl->GetBackgroundColour(),
|
m_renderer->DrawBackground(m_dc, m_rect, flags);
|
||||||
m_rect, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControlRenderer::DrawBackgroundBitmap()
|
void wxControlRenderer::DrawBackgroundBitmap()
|
||||||
|
@@ -65,6 +65,10 @@ bool wxScrollBar::Create(wxWindow *parent,
|
|||||||
const wxValidator& validator,
|
const wxValidator& validator,
|
||||||
const wxString &name)
|
const wxString &name)
|
||||||
{
|
{
|
||||||
|
// the scrollbars always have the standard border so far
|
||||||
|
style &= ~wxBORDER_MASK;
|
||||||
|
style |= wxBORDER_SUNKEN;
|
||||||
|
|
||||||
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
|
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@@ -26,13 +26,16 @@
|
|||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/button.h"
|
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
#include "wx/window.h"
|
#include "wx/window.h"
|
||||||
|
|
||||||
|
#include "wx/button.h"
|
||||||
|
#include "wx/scrolbar.h"
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/univ/renderer.h"
|
#include "wx/univ/renderer.h"
|
||||||
#include "wx/univ/inphand.h"
|
#include "wx/univ/inphand.h"
|
||||||
|
#include "wx/univ/colschem.h"
|
||||||
#include "wx/univ/theme.h"
|
#include "wx/univ/theme.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -42,13 +45,12 @@
|
|||||||
class wxGTKRenderer : public wxRenderer
|
class wxGTKRenderer : public wxRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxGTKRenderer();
|
wxGTKRenderer(const wxColourScheme *scheme);
|
||||||
|
|
||||||
// implement the base class pure virtuals
|
// implement the base class pure virtuals
|
||||||
virtual void DrawBackground(wxDC& dc,
|
virtual void DrawBackground(wxDC& dc,
|
||||||
const wxColour& col,
|
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags);
|
int flags = 0);
|
||||||
virtual void DrawLabel(wxDC& dc,
|
virtual void DrawLabel(wxDC& dc,
|
||||||
const wxString& label,
|
const wxString& label,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
@@ -70,10 +72,26 @@ public:
|
|||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags = 0,
|
int flags = 0,
|
||||||
wxRect *rectIn = (wxRect *)NULL);
|
wxRect *rectIn = (wxRect *)NULL);
|
||||||
|
virtual void DrawArrow(wxDC& dc,
|
||||||
|
wxDirection dir,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags = 0);
|
||||||
|
virtual void DrawScrollbar(wxDC& dc,
|
||||||
|
wxOrientation orient,
|
||||||
|
int thumbPosStart,
|
||||||
|
int thumbPosEnd,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags = 0,
|
||||||
|
int extraFlags = 0);
|
||||||
|
|
||||||
virtual void AdjustSize(wxSize *size, const wxWindow *window);
|
virtual void AdjustSize(wxSize *size, const wxWindow *window);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// DrawBackground() helper
|
||||||
|
void DoDrawBackground(wxDC& dc,
|
||||||
|
const wxColour& col,
|
||||||
|
const wxRect& rect);
|
||||||
|
|
||||||
// DrawBorder() helpers: all of them shift and clip the DC after drawing
|
// DrawBorder() helpers: all of them shift and clip the DC after drawing
|
||||||
// the border
|
// the border
|
||||||
|
|
||||||
@@ -97,10 +115,16 @@ protected:
|
|||||||
void DrawRaisedBorder(wxDC& dc, wxRect *rect);
|
void DrawRaisedBorder(wxDC& dc, wxRect *rect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const wxColourScheme *m_scheme;
|
||||||
|
|
||||||
|
// data
|
||||||
|
wxSize m_sizeScrollbarArrow;
|
||||||
|
|
||||||
|
// GDI objects
|
||||||
wxPen m_penBlack,
|
wxPen m_penBlack,
|
||||||
m_penDarkGrey,
|
m_penDarkGrey,
|
||||||
|
m_penGrey,
|
||||||
m_penLightGrey,
|
m_penLightGrey,
|
||||||
m_penWhite,
|
|
||||||
m_penHighlight;
|
m_penHighlight;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -129,6 +153,19 @@ private:
|
|||||||
bool m_winHasMouse;
|
bool m_winHasMouse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class wxGTKScrollBarInputHandler : public wxGTKInputHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxGTKScrollBarInputHandler();
|
||||||
|
|
||||||
|
virtual wxControlActions Map(const wxKeyEvent& event, bool pressed);
|
||||||
|
virtual wxControlActions Map(const wxMouseEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxWindow *m_winCapture;
|
||||||
|
bool m_winHasMouse;
|
||||||
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxGTKColourScheme: uses the standard GTK colours
|
// wxGTKColourScheme: uses the standard GTK colours
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -136,7 +173,7 @@ private:
|
|||||||
class wxGTKColourScheme : public wxColourScheme
|
class wxGTKColourScheme : public wxColourScheme
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual wxColour Get(StdColour col);
|
virtual wxColour Get(StdColour col, int flags = 0) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -153,7 +190,7 @@ public:
|
|||||||
|
|
||||||
virtual wxRenderer *GetRenderer() { return m_renderer; }
|
virtual wxRenderer *GetRenderer() { return m_renderer; }
|
||||||
virtual wxInputHandler *GetInputHandler(const wxString& control);
|
virtual wxInputHandler *GetInputHandler(const wxString& control);
|
||||||
virtual wxColourScheme *GetColourScheme() { return m_scheme; }
|
virtual wxColourScheme *GetColourScheme(const wxString& control) { return m_scheme; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxGTKRenderer *m_renderer;
|
wxGTKRenderer *m_renderer;
|
||||||
@@ -180,8 +217,8 @@ WX_IMPLEMENT_THEME(wxGTKTheme, gtk, wxTRANSLATE("GTK+ theme"));
|
|||||||
|
|
||||||
wxGTKTheme::wxGTKTheme()
|
wxGTKTheme::wxGTKTheme()
|
||||||
{
|
{
|
||||||
m_renderer = new wxGTKRenderer;
|
|
||||||
m_scheme = new wxGTKColourScheme;
|
m_scheme = new wxGTKColourScheme;
|
||||||
|
m_renderer = new wxGTKRenderer(m_scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGTKTheme::~wxGTKTheme()
|
wxGTKTheme::~wxGTKTheme()
|
||||||
@@ -200,6 +237,8 @@ wxInputHandler *wxGTKTheme::GetInputHandler(const wxString& control)
|
|||||||
|
|
||||||
if ( control == wxCONTROL_BUTTON )
|
if ( control == wxCONTROL_BUTTON )
|
||||||
handler = new wxGTKButtonInputHandler;
|
handler = new wxGTKButtonInputHandler;
|
||||||
|
else if ( control == wxCONTROL_SCROLLBAR )
|
||||||
|
handler = new wxGTKScrollBarInputHandler;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( control == wxCONTROL_DEFAULT,
|
wxASSERT_MSG( control == wxCONTROL_DEFAULT,
|
||||||
@@ -222,23 +261,40 @@ wxInputHandler *wxGTKTheme::GetInputHandler(const wxString& control)
|
|||||||
// wxGTKColourScheme
|
// wxGTKColourScheme
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
wxColour wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col)
|
wxColour wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col,
|
||||||
|
int flags) const
|
||||||
{
|
{
|
||||||
switch ( col )
|
switch ( col )
|
||||||
{
|
{
|
||||||
case DARK_SHADOW: return wxColour(0x7f7f7f);
|
case SHADOW_DARK: return *wxBLACK;
|
||||||
case FACE: return wxColour(0xc0c0c0);
|
case SHADOW_HIGHLIGHT: return *wxWHITE;
|
||||||
case HIGHLIGHT: return wxColour(0xe0e0e0);
|
case SHADOW_IN: return wxColour(0xd6d6d6);
|
||||||
case LIGHT: return wxColour(0xffffff);
|
case SHADOW_OUT: return wxColour(0x969696);
|
||||||
case SHADOW: return wxColour(0xc0c0c0);
|
|
||||||
case CONTROL_TEXT: return wxColour(0x000000);
|
case CONTROL:
|
||||||
case HIGHLIGHT: return wxColour(0x0000ff);
|
if ( flags & wxCONTROL_PRESSED )
|
||||||
case HIGHLIGHT_TEXT:return wxColour(0x00ffff);
|
{
|
||||||
|
return wxColour(0x7f7f7f);
|
||||||
|
}
|
||||||
|
else if ( flags & wxCONTROL_CURRENT )
|
||||||
|
{
|
||||||
|
return wxColour(0xeaeaea);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return wxColour(0xd6d6d6);
|
||||||
|
}
|
||||||
|
|
||||||
|
case CONTROL_TEXT: return *wxBLACK;
|
||||||
|
case SCROLLBAR: return wxColour(0xc3c3c3);
|
||||||
|
|
||||||
|
case HIGHLIGHT: return wxColour(0x0000ff);
|
||||||
|
case HIGHLIGHT_TEXT: return wxColour(0x00ffff);
|
||||||
|
|
||||||
case MAX:
|
case MAX:
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG(_T("invalid standard colour"));
|
wxFAIL_MSG(_T("invalid standard colour"));
|
||||||
return wxColour(0x000000);
|
return *wxBLACK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,86 +306,24 @@ wxColour wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col)
|
|||||||
// construction
|
// construction
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxGTKRenderer::wxGTKRenderer()
|
wxGTKRenderer::wxGTKRenderer(const wxColourScheme *scheme)
|
||||||
: m_penBlack(*wxBLACK_PEN),
|
|
||||||
m_penDarkGrey(wxColour(0x7f7f7f), 0, wxSOLID),
|
|
||||||
m_penLightGrey(wxColour(0xc0c0c0), 0, wxSOLID),
|
|
||||||
m_penWhite(*wxWHITE_PEN),
|
|
||||||
m_penHighlight(wxColour(0xe0e0e0), 0, wxSOLID)
|
|
||||||
{
|
{
|
||||||
|
// init data
|
||||||
|
m_scheme = scheme;
|
||||||
|
m_sizeScrollbarArrow = wxSize(12, 12);
|
||||||
|
|
||||||
|
// init pens
|
||||||
|
m_penBlack = wxPen(scheme->Get(wxColourScheme::SHADOW_DARK), 0, wxSOLID);
|
||||||
|
m_penDarkGrey = wxPen(scheme->Get(wxColourScheme::SHADOW_OUT), 0, wxSOLID);
|
||||||
|
m_penGrey = wxPen(scheme->Get(wxColourScheme::SCROLLBAR), 0, wxSOLID);
|
||||||
|
m_penLightGrey = wxPen(scheme->Get(wxColourScheme::SHADOW_IN), 0, wxSOLID);
|
||||||
|
m_penHighlight = wxPen(scheme->Get(wxColourScheme::SHADOW_HIGHLIGHT), 0, wxSOLID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// border stuff
|
// border stuff
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
|
||||||
The raised border in GTK looks like this:
|
|
||||||
|
|
||||||
IIIIIIIIIIIIIIIIIIIIIIB
|
|
||||||
I GB
|
|
||||||
I GB I = white (HILIGHT)
|
|
||||||
I GB H = light grey (LIGHT)
|
|
||||||
I GB G = dark grey (SHADOI)
|
|
||||||
I GB B = black (DKSHADOI)
|
|
||||||
I GB I = hIghlight (COLOR_3DHILIGHT)
|
|
||||||
I GB
|
|
||||||
IGGGGGGGGGGGGGGGGGGGGGB
|
|
||||||
BBBBBBBBBBBBBBBBBBBBBBB
|
|
||||||
|
|
||||||
The sunken border looks like this:
|
|
||||||
|
|
||||||
GGGGGGGGGGGGGGGGGGGGGGI
|
|
||||||
GBBBBBBBBBBBBBBBBBBBBHI
|
|
||||||
GB HI
|
|
||||||
GB HI
|
|
||||||
GB HI
|
|
||||||
GB HI
|
|
||||||
GB HI
|
|
||||||
GB HI
|
|
||||||
GHHHHHHHHHHHHHHHHHHHHHI
|
|
||||||
IIIIIIIIIIIIIIIIIIIIIII
|
|
||||||
|
|
||||||
The static border (used for the controls which don't get focus) is like
|
|
||||||
this:
|
|
||||||
|
|
||||||
GGGGGGGGGGGGGGGGGGGGGGW
|
|
||||||
G W
|
|
||||||
G W
|
|
||||||
G W
|
|
||||||
G W
|
|
||||||
G W
|
|
||||||
G W
|
|
||||||
G W
|
|
||||||
WWWWWWWWWWWWWWWWWWWWWWW
|
|
||||||
|
|
||||||
The most complicated is the double border:
|
|
||||||
|
|
||||||
HHHHHHHHHHHHHHHHHHHHHHB
|
|
||||||
HWWWWWWWWWWWWWWWWWWWWGB
|
|
||||||
HWHHHHHHHHHHHHHHHHHHHGB
|
|
||||||
HWH HGB
|
|
||||||
HWH HGB
|
|
||||||
HWH HGB
|
|
||||||
HWH HGB
|
|
||||||
HWHHHHHHHHHHHHHHHHHHHGB
|
|
||||||
HGGGGGGGGGGGGGGGGGGGGGB
|
|
||||||
BBBBBBBBBBBBBBBBBBBBBBB
|
|
||||||
|
|
||||||
And the simple border is, well, simple:
|
|
||||||
|
|
||||||
BBBBBBBBBBBBBBBBBBBBBBB
|
|
||||||
B B
|
|
||||||
B B
|
|
||||||
B B
|
|
||||||
B B
|
|
||||||
B B
|
|
||||||
B B
|
|
||||||
B B
|
|
||||||
B B
|
|
||||||
BBBBBBBBBBBBBBBBBBBBBBB
|
|
||||||
*/
|
|
||||||
|
|
||||||
void wxGTKRenderer::DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen)
|
void wxGTKRenderer::DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen)
|
||||||
{
|
{
|
||||||
// draw
|
// draw
|
||||||
@@ -572,32 +566,250 @@ void wxGTKRenderer::DrawLabel(wxDC& dc,
|
|||||||
// background
|
// background
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxGTKRenderer::DrawBackground(wxDC& dc,
|
void wxGTKRenderer::DoDrawBackground(wxDC& dc,
|
||||||
const wxColour& col,
|
const wxColour& col,
|
||||||
const wxRect& rect,
|
const wxRect& rect)
|
||||||
int flags)
|
|
||||||
{
|
{
|
||||||
// what colour should we use?
|
wxBrush brush(col, wxSOLID);
|
||||||
wxColour colBg;
|
|
||||||
if ( flags & wxCONTROL_PRESSED )
|
|
||||||
{
|
|
||||||
colBg = wxColour(0x7f7f7f);
|
|
||||||
}
|
|
||||||
else if ( flags & wxCONTROL_CURRENT )
|
|
||||||
{
|
|
||||||
colBg = wxColour(0xe0e0e0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
colBg = col;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBrush brush(colBg, wxSOLID);
|
|
||||||
dc.SetBrush(brush);
|
dc.SetBrush(brush);
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
dc.DrawRectangle(rect);
|
dc.DrawRectangle(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGTKRenderer::DrawBackground(wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
DoDrawBackground(dc, m_scheme->Get(wxColourScheme::CONTROL, flags), rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// scrollbar
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// gtk_default_draw_arrow() takes ~350 lines and we can't do much better here
|
||||||
|
// these people are just crazy :-(
|
||||||
|
void wxGTKRenderer::DrawArrow(wxDC& dc,
|
||||||
|
wxDirection dir,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
Point_First,
|
||||||
|
Point_Second,
|
||||||
|
Point_Third,
|
||||||
|
Point_Max
|
||||||
|
};
|
||||||
|
|
||||||
|
wxPoint ptArrow[Point_Max];
|
||||||
|
|
||||||
|
wxCoord middle;
|
||||||
|
if ( dir == wxUP || dir == wxDOWN )
|
||||||
|
{
|
||||||
|
// horz middle
|
||||||
|
middle = (rect.GetRight() + rect.GetLeft() + 1) / 2;
|
||||||
|
}
|
||||||
|
else // horz arrow
|
||||||
|
{
|
||||||
|
middle = (rect.GetTop() + rect.GetBottom() + 1) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw the arrow interior
|
||||||
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
dc.SetBrush(wxBrush(m_scheme->Get(wxColourScheme::CONTROL), wxSOLID));
|
||||||
|
|
||||||
|
switch ( dir )
|
||||||
|
{
|
||||||
|
case wxUP:
|
||||||
|
ptArrow[Point_First].x = rect.GetLeft();
|
||||||
|
ptArrow[Point_First].y = rect.GetBottom();
|
||||||
|
ptArrow[Point_Second].x = middle;
|
||||||
|
ptArrow[Point_Second].y = rect.GetTop();
|
||||||
|
ptArrow[Point_Third].x = rect.GetRight();
|
||||||
|
ptArrow[Point_Third].y = rect.GetBottom();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxDOWN:
|
||||||
|
ptArrow[Point_First] = rect.GetPosition();
|
||||||
|
ptArrow[Point_Second].x = middle;
|
||||||
|
ptArrow[Point_Second].y = rect.GetBottom();
|
||||||
|
ptArrow[Point_Third].x = rect.GetRight();
|
||||||
|
ptArrow[Point_Third].y = rect.GetTop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxLEFT:
|
||||||
|
ptArrow[Point_First].x = rect.GetRight();
|
||||||
|
ptArrow[Point_First].y = rect.GetTop();
|
||||||
|
ptArrow[Point_Second].x = rect.GetLeft();
|
||||||
|
ptArrow[Point_Second].y = middle;
|
||||||
|
ptArrow[Point_Third].x = rect.GetRight();
|
||||||
|
ptArrow[Point_Third].y = rect.GetBottom();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxRIGHT:
|
||||||
|
ptArrow[Point_First] = rect.GetPosition();
|
||||||
|
ptArrow[Point_Second].x = rect.GetRight();
|
||||||
|
ptArrow[Point_Second].y = middle;
|
||||||
|
ptArrow[Point_Third].x = rect.GetLeft();
|
||||||
|
ptArrow[Point_Third].y = rect.GetBottom();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(_T("unknown arrow direction"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dc.DrawPolygon(WXSIZEOF(ptArrow), ptArrow);
|
||||||
|
|
||||||
|
// draw the arrow border
|
||||||
|
dc.SetPen(m_penHighlight);
|
||||||
|
switch ( dir )
|
||||||
|
{
|
||||||
|
case wxUP:
|
||||||
|
dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_First]);
|
||||||
|
dc.DrawPoint(ptArrow[Point_First]);
|
||||||
|
dc.SetPen(m_penBlack);
|
||||||
|
dc.DrawLine(ptArrow[Point_Second].x + 1, ptArrow[Point_Second].y + 1,
|
||||||
|
ptArrow[Point_Third].x, ptArrow[Point_Third].y);
|
||||||
|
dc.DrawPoint(ptArrow[Point_Third]);
|
||||||
|
dc.DrawLine(ptArrow[Point_Third].x - 2, ptArrow[Point_Third].y,
|
||||||
|
ptArrow[Point_First].x + 1, ptArrow[Point_First].y);
|
||||||
|
dc.SetPen(m_penDarkGrey);
|
||||||
|
dc.DrawLine(ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y,
|
||||||
|
ptArrow[Point_Second].x, ptArrow[Point_Second].y + 1);
|
||||||
|
dc.DrawLine(ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y - 1,
|
||||||
|
ptArrow[Point_First].x + 2, ptArrow[Point_First].y - 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxDOWN:
|
||||||
|
dc.DrawLine(ptArrow[Point_First], ptArrow[Point_Second]);
|
||||||
|
dc.DrawLine(ptArrow[Point_First].x + 2, ptArrow[Point_First].y,
|
||||||
|
ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y);
|
||||||
|
dc.SetPen(m_penDarkGrey);
|
||||||
|
dc.DrawLine(ptArrow[Point_Second].x, ptArrow[Point_Second].y - 1,
|
||||||
|
ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y - 1);
|
||||||
|
dc.SetPen(m_penBlack);
|
||||||
|
dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_Third]);
|
||||||
|
dc.DrawPoint(ptArrow[Point_Third]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxLEFT:
|
||||||
|
dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_First]);
|
||||||
|
dc.DrawPoint(ptArrow[Point_First]);
|
||||||
|
dc.SetPen(m_penDarkGrey);
|
||||||
|
dc.DrawLine(ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y,
|
||||||
|
ptArrow[Point_First].x - 1, ptArrow[Point_First].y + 2);
|
||||||
|
dc.DrawLine(ptArrow[Point_Third].x, ptArrow[Point_Third].y,
|
||||||
|
ptArrow[Point_Second].x + 2, ptArrow[Point_Second].y + 1);
|
||||||
|
dc.SetPen(m_penBlack);
|
||||||
|
dc.DrawLine(ptArrow[Point_Third].x, ptArrow[Point_Third].y,
|
||||||
|
ptArrow[Point_First].x, ptArrow[Point_First].y + 1);
|
||||||
|
dc.DrawLine(ptArrow[Point_Second].x + 1, ptArrow[Point_Second].y + 1,
|
||||||
|
ptArrow[Point_Third].x - 1, ptArrow[Point_Third].y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxRIGHT:
|
||||||
|
dc.DrawLine(ptArrow[Point_First], ptArrow[Point_Third]);
|
||||||
|
dc.DrawLine(ptArrow[Point_First].x + 2, ptArrow[Point_First].y + 1,
|
||||||
|
ptArrow[Point_Second].x, ptArrow[Point_Second].y);
|
||||||
|
dc.SetPen(m_penBlack);
|
||||||
|
dc.DrawLine(ptArrow[Point_Second], ptArrow[Point_Third]);
|
||||||
|
dc.DrawPoint(ptArrow[Point_Third]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(_T("unknown arrow direction"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGTKRenderer::DrawScrollbar(wxDC& dc,
|
||||||
|
wxOrientation orient,
|
||||||
|
int thumbPosStart,
|
||||||
|
int thumbPosEnd,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags,
|
||||||
|
int extraFlags)
|
||||||
|
{
|
||||||
|
// handling of wxCONTROL_CURRENT flag is complicated for the scrollbar
|
||||||
|
// because, though it's only one window, either an arrow or a thumb may be
|
||||||
|
// highlighted depending on where exactly the mouse is
|
||||||
|
int flagsArrows[2], flagsThumb;
|
||||||
|
flagsArrows[0] =
|
||||||
|
flagsArrows[1] =
|
||||||
|
flagsThumb = flags & ~wxCONTROL_CURRENT;
|
||||||
|
if ( flags & wxCONTROL_CURRENT )
|
||||||
|
{
|
||||||
|
if ( extraFlags & wxScrollBar::Highlight_Arrow1 )
|
||||||
|
flagsArrows[0] |= wxCONTROL_CURRENT;
|
||||||
|
if ( extraFlags & wxScrollBar::Highlight_Arrow2 )
|
||||||
|
flagsArrows[1] |= wxCONTROL_CURRENT;
|
||||||
|
if ( extraFlags & wxScrollBar::Highlight_Thumb )
|
||||||
|
flagsThumb |= wxCONTROL_CURRENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// first draw the scrollbar area background
|
||||||
|
wxRect rectBar = rect;
|
||||||
|
DrawAntiShadedRect(dc, &rectBar, m_penDarkGrey, m_penHighlight);
|
||||||
|
DrawAntiShadedRect(dc, &rectBar, m_penBlack, m_penGrey);
|
||||||
|
DoDrawBackground(dc, m_scheme->Get(wxColourScheme::SCROLLBAR), rectBar);
|
||||||
|
|
||||||
|
// next draw the arrows at the ends
|
||||||
|
wxRect rectArrow[2];
|
||||||
|
wxDirection arrowDir[2];
|
||||||
|
|
||||||
|
rectArrow[0] =
|
||||||
|
rectArrow[1] = rectBar;
|
||||||
|
if ( orient == wxVERTICAL )
|
||||||
|
{
|
||||||
|
rectArrow[0].height =
|
||||||
|
rectArrow[1].height = m_sizeScrollbarArrow.y - 1;
|
||||||
|
rectArrow[1].y = rectBar.GetBottom() - rectArrow[1].height + 1;
|
||||||
|
|
||||||
|
arrowDir[0] = wxUP;
|
||||||
|
arrowDir[1] = wxDOWN;
|
||||||
|
}
|
||||||
|
else // horizontal
|
||||||
|
{
|
||||||
|
rectArrow[0].width =
|
||||||
|
rectArrow[1].width = m_sizeScrollbarArrow.x - 1;
|
||||||
|
rectArrow[1].x = rectBar.GetRight() - rectArrow[1].width + 1;
|
||||||
|
|
||||||
|
arrowDir[0] = wxLEFT;
|
||||||
|
arrowDir[1] = wxRIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( size_t nArrow = 0; nArrow < 2; nArrow++ )
|
||||||
|
{
|
||||||
|
DrawArrow(dc, arrowDir[nArrow], rectArrow[nArrow], flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
// and, finally, the thumb, if any
|
||||||
|
if ( thumbPosStart < thumbPosEnd )
|
||||||
|
{
|
||||||
|
wxRect rectThumb;
|
||||||
|
if ( orient == wxVERTICAL )
|
||||||
|
{
|
||||||
|
rectBar.Inflate(0, -m_sizeScrollbarArrow.y);
|
||||||
|
rectThumb = rectBar;
|
||||||
|
rectThumb.y += (rectBar.height*thumbPosStart)/100;
|
||||||
|
rectThumb.height = (rectBar.height*(thumbPosEnd - thumbPosStart))/100;
|
||||||
|
}
|
||||||
|
else // horizontal
|
||||||
|
{
|
||||||
|
rectBar.Inflate(-m_sizeScrollbarArrow.x, 0);
|
||||||
|
rectThumb = rectBar;
|
||||||
|
rectThumb.x += (rectBar.width*thumbPosStart)/100;
|
||||||
|
rectThumb.width = (rectBar.width*(thumbPosEnd - thumbPosStart))/100;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the thumb never has focus border under GTK
|
||||||
|
DrawButtonBorder(dc, rectThumb, flags & ~wxCONTROL_FOCUSED, &rectThumb);
|
||||||
|
DrawBackground(dc, rectThumb, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// size adjustments
|
// size adjustments
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -612,6 +824,16 @@ void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if ( wxDynamicCast(window, wxScrollBar) )
|
||||||
|
{
|
||||||
|
// we only set the width of vert scrollbars and height of the
|
||||||
|
// horizontal ones
|
||||||
|
if ( window->GetWindowStyle() & wxSB_HORIZONTAL )
|
||||||
|
size->y = m_sizeScrollbarArrow.y;
|
||||||
|
else
|
||||||
|
size->x = m_sizeScrollbarArrow.x;
|
||||||
|
}
|
||||||
|
|
||||||
// take into account the border width
|
// take into account the border width
|
||||||
wxBorder border = (wxBorder)(window->GetWindowStyle() & wxBORDER_MASK);
|
wxBorder border = (wxBorder)(window->GetWindowStyle() & wxBORDER_MASK);
|
||||||
switch ( border )
|
switch ( border )
|
||||||
@@ -752,3 +974,28 @@ wxControlActions wxGTKButtonInputHandler::Map(const wxMouseEvent& event)
|
|||||||
|
|
||||||
return wxGTKInputHandler::Map(event);
|
return wxGTKInputHandler::Map(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxGTKScrollBarInputHandler
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxGTKScrollBarInputHandler::wxGTKScrollBarInputHandler()
|
||||||
|
{
|
||||||
|
m_winCapture = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxControlActions wxGTKScrollBarInputHandler::Map(const wxKeyEvent& event,
|
||||||
|
bool pressed)
|
||||||
|
{
|
||||||
|
return wxGTKInputHandler::Map(event, pressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxControlActions wxGTKScrollBarInputHandler::Map(const wxMouseEvent& event)
|
||||||
|
{
|
||||||
|
if ( event.Moving() )
|
||||||
|
{
|
||||||
|
// determin which part of the window mouse is in
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxGTKInputHandler::Map(event);
|
||||||
|
}
|
||||||
|
@@ -29,6 +29,8 @@
|
|||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
#include "wx/window.h"
|
#include "wx/window.h"
|
||||||
|
|
||||||
|
#include "wx/dcmemory.h"
|
||||||
|
|
||||||
#include "wx/button.h"
|
#include "wx/button.h"
|
||||||
#include "wx/scrolbar.h"
|
#include "wx/scrolbar.h"
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
@@ -67,7 +69,6 @@ public:
|
|||||||
|
|
||||||
// implement the base class pure virtuals
|
// implement the base class pure virtuals
|
||||||
virtual void DrawBackground(wxDC& dc,
|
virtual void DrawBackground(wxDC& dc,
|
||||||
const wxColour& col,
|
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int flags = 0);
|
int flags = 0);
|
||||||
virtual void DrawLabel(wxDC& dc,
|
virtual void DrawLabel(wxDC& dc,
|
||||||
@@ -105,6 +106,11 @@ public:
|
|||||||
virtual void AdjustSize(wxSize *size, const wxWindow *window);
|
virtual void AdjustSize(wxSize *size, const wxWindow *window);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// DrawButtonBorder() helper
|
||||||
|
void DoDrawBackground(wxDC& dc,
|
||||||
|
const wxColour& col,
|
||||||
|
const wxRect& rect);
|
||||||
|
|
||||||
// DrawBorder() helpers: all of them shift and clip the DC after drawing
|
// DrawBorder() helpers: all of them shift and clip the DC after drawing
|
||||||
// the border
|
// the border
|
||||||
|
|
||||||
@@ -135,12 +141,13 @@ protected:
|
|||||||
wxArrowStyle arrowStyle);
|
wxArrowStyle arrowStyle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const wxColourScheme *m_scheme;
|
||||||
|
|
||||||
// the sizing parameters (TODO make them changeable)
|
// the sizing parameters (TODO make them changeable)
|
||||||
wxSize m_sizeScrollbarArrow;
|
wxSize m_sizeScrollbarArrow;
|
||||||
|
|
||||||
// GDI objects we use for drawing
|
// GDI objects we use for drawing
|
||||||
wxColour m_colDarkGrey,
|
wxColour m_colDarkGrey,
|
||||||
m_colBg,
|
|
||||||
m_colHighlight;
|
m_colHighlight;
|
||||||
|
|
||||||
wxPen m_penBlack,
|
wxPen m_penBlack,
|
||||||
@@ -314,6 +321,7 @@ wxColour wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col,
|
|||||||
wxWin32Renderer::wxWin32Renderer(const wxColourScheme *scheme)
|
wxWin32Renderer::wxWin32Renderer(const wxColourScheme *scheme)
|
||||||
{
|
{
|
||||||
// init data
|
// init data
|
||||||
|
m_scheme = scheme;
|
||||||
m_sizeScrollbarArrow = wxSize(16, 16);
|
m_sizeScrollbarArrow = wxSize(16, 16);
|
||||||
|
|
||||||
// init colours and pens
|
// init colours and pens
|
||||||
@@ -322,8 +330,7 @@ wxWin32Renderer::wxWin32Renderer(const wxColourScheme *scheme)
|
|||||||
m_colDarkGrey = scheme->Get(wxColourScheme::SHADOW_OUT);
|
m_colDarkGrey = scheme->Get(wxColourScheme::SHADOW_OUT);
|
||||||
m_penDarkGrey = wxPen(m_colDarkGrey, 0, wxSOLID);
|
m_penDarkGrey = wxPen(m_colDarkGrey, 0, wxSOLID);
|
||||||
|
|
||||||
m_colBg = scheme->Get(wxColourScheme::SHADOW_IN);
|
m_penLightGrey = wxPen(scheme->Get(wxColourScheme::SHADOW_IN), 0, wxSOLID);
|
||||||
m_penLightGrey = wxPen(m_colBg, 0, wxSOLID);
|
|
||||||
|
|
||||||
m_colHighlight = scheme->Get(wxColourScheme::SHADOW_HIGHLIGHT);
|
m_colHighlight = scheme->Get(wxColourScheme::SHADOW_HIGHLIGHT);
|
||||||
m_penHighlight = wxPen(m_colHighlight, 0, wxSOLID);
|
m_penHighlight = wxPen(m_colHighlight, 0, wxSOLID);
|
||||||
@@ -805,18 +812,24 @@ void wxWin32Renderer::DrawLabel(wxDC& dc,
|
|||||||
// background
|
// background
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxWin32Renderer::DrawBackground(wxDC& dc,
|
void wxWin32Renderer::DoDrawBackground(wxDC& dc,
|
||||||
const wxColour& col,
|
const wxColour& col,
|
||||||
const wxRect& rect,
|
const wxRect& rect)
|
||||||
int flags)
|
|
||||||
{
|
{
|
||||||
// just fill it with the current colour
|
|
||||||
wxBrush brush(col, wxSOLID);
|
wxBrush brush(col, wxSOLID);
|
||||||
dc.SetBrush(brush);
|
dc.SetBrush(brush);
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
dc.DrawRectangle(rect);
|
dc.DrawRectangle(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxWin32Renderer::DrawBackground(wxDC& dc,
|
||||||
|
const wxRect& rect,
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
// just fill it with the default bg colour
|
||||||
|
DoDrawBackground(dc, m_scheme->Get(wxColourScheme::CONTROL, flags), rect);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// scrollbar
|
// scrollbar
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -922,7 +935,7 @@ void wxWin32Renderer::DrawScrollbar(wxDC& dc,
|
|||||||
else
|
else
|
||||||
rectBar.Inflate(-m_sizeScrollbarArrow.x, 0);
|
rectBar.Inflate(-m_sizeScrollbarArrow.x, 0);
|
||||||
|
|
||||||
DrawBackground(dc, m_colHighlight, rectBar);
|
DoDrawBackground(dc, m_colHighlight, rectBar);
|
||||||
|
|
||||||
// and, finally, the thumb, if any
|
// and, finally, the thumb, if any
|
||||||
if ( thumbPosStart < thumbPosEnd )
|
if ( thumbPosStart < thumbPosEnd )
|
||||||
@@ -940,7 +953,7 @@ void wxWin32Renderer::DrawScrollbar(wxDC& dc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DrawArrowBorder(dc, &rectThumb);
|
DrawArrowBorder(dc, &rectThumb);
|
||||||
DrawBackground(dc, m_colBg, rectThumb);
|
DrawBackground(dc, rectThumb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user