///////////////////////////////////////////////////////////////////////////////
-// Name: univ/themes/gtk.cpp
+// Name: src/univ/themes/gtk.cpp
// Purpose: wxUniversal theme implementing GTK-like LNF
// Author: Vadim Zeitlin
// Modified by:
#include "wx/statusbr.h"
#include "wx/settings.h"
+ #include "wx/toplevel.h"
+ #include "wx/image.h"
#endif // WX_PRECOMP
#include "wx/notebook.h"
#include "wx/spinbutt.h"
-#include "wx/toplevel.h"
#include "wx/artprov.h"
-#include "wx/image.h"
+#ifdef wxUSE_TOGGLEBTN
+#include "wx/tglbtn.h"
+#endif // wxUSE_TOGGLEBTN
#include "wx/univ/renderer.h"
#include "wx/univ/inphand.h"
wxAlignment align = wxALIGN_LEFT,
int indexAccel = -1);
+#if wxUSE_TOOLBAR
virtual void DrawToolBarButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rect,
int flags = 0,
- long style = 0);
+ long style = 0,
+ int tbarStyle = 0);
+#endif // wxUSE_TOOLBAR
virtual void DrawTextLine(wxDC& dc,
const wxString& text,
int flags = 0,
int indexAccel = -1);
+#if wxUSE_SLIDER
virtual void DrawSliderShaft(wxDC& dc,
const wxRect& rect,
int lenThumb,
{
// we don't have the ticks in GTK version
}
+#endif // wxUSE_SLIDER
+#if wxUSE_MENUS
virtual void DrawMenuBarItem(wxDC& dc,
const wxRect& rect,
const wxString& label,
virtual void DrawMenuSeparator(wxDC& dc,
wxCoord y,
const wxMenuGeometryInfo& geomInfo);
+#endif // wxUSE_MENUS
+#if wxUSE_STATUSBAR
virtual void DrawStatusField(wxDC& dc,
const wxRect& rect,
const wxString& label,
int flags = 0, int style = 0);
+#endif // wxUSE_STATUSBAR
virtual void DrawFrameTitleBar(wxDC& dc,
const wxRect& rect,
// geometry and hit testing
virtual wxSize GetScrollbarArrowSize() const
{ return m_sizeScrollbarArrow; }
+#if wxUSE_SCROLLBAR
virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
wxScrollBar::Element elem,
int thumbPos = -1) const;
virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
int thumbPos = -1);
virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
+#endif // wxUSE_SCROLLBAR
+
virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
{ return fontHeight + 2; }
virtual wxSize GetCheckBitmapSize() const
virtual wxSize GetToolBarMargin() const
{ return wxSize(6, 6); }
+#if wxUSE_TEXTCTRL
virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
const wxRect& rect) const;
virtual wxRect GetTextClientArea(const wxTextCtrl *text,
const wxRect& rect,
wxCoord *extraSpaceBeyond) const;
+#endif // wxUSE_TEXTCTRL
virtual wxSize GetTabIndent() const { return wxSize(2, 2); }
virtual wxSize GetTabPadding() const { return wxSize(6, 6); }
+#if wxUSE_SLIDER
virtual wxCoord GetSliderDim() const { return 15; }
virtual wxCoord GetSliderTickLen() const { return 0; }
virtual wxRect GetSliderShaftRect(const wxRect& rect,
virtual wxSize GetSliderThumbSize(const wxRect& rect,
int lenThumb,
wxOrientation orient) const;
+#endif // wxUSE_SLIDER
+
virtual wxSize GetProgressBarStep() const { return wxSize(16, 32); }
+#if wxUSE_MENUS
virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const;
virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
const wxMenu& menu) const;
+#endif // wxUSE_MENUS
+#if wxUSE_STATUSBAR
virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const;
+#endif // wxUSE_STATUSBAR
// helpers for "wxBitmap wxColourScheme::Get()"
void DrawCheckBitmap(wxDC& dc, const wxRect& rect);
// rect is drawn with DrawAntiShadedRect() and not DrawShadedRect())
void DrawAntiRaisedBorder(wxDC& dc, wxRect *rect);
+#if wxUSE_SCROLLBAR
// returns the size of the arrow for the scrollbar (depends on
// orientation)
wxSize GetScrollbarArrowSize(const wxScrollBar *scrollbar) const
return size;
}
+#endif // wxUSE_SCROLLBAR
// get the line wrap indicator bitmap
wxBitmap GetLineWrapBitmap() const;
wxGTKRenderer *m_renderer;
};
+#if wxUSE_SCROLLBAR
+
class wxGTKScrollBarInputHandler : public wxStdScrollBarInputHandler
{
public:
}
};
+#endif // wxUSE_SCROLLBAR
+
+#if wxUSE_CHECKBOX
+
class wxGTKCheckboxInputHandler : public wxStdCheckboxInputHandler
{
public:
bool pressed);
};
+#endif // wxUSE_CHECKBOX
+
+#if wxUSE_TEXTCTRL
+
class wxGTKTextCtrlInputHandler : public wxStdTextCtrlInputHandler
{
public:
bool pressed);
};
+#endif // wxUSE_TEXTCTRL
+
// ----------------------------------------------------------------------------
// wxGTKColourScheme: uses the standard GTK colours
// ----------------------------------------------------------------------------
wxInputHandler *wxGTKTheme::GetInputHandler(const wxString& control)
{
- wxInputHandler *handler;
+ wxInputHandler *handler = NULL;
int n = m_handlerNames.Index(control);
if ( n == wxNOT_FOUND )
{
// create a new handler
if ( control == wxINP_HANDLER_SCROLLBAR )
+ {
+#if wxUSE_SCROLLBAR
handler = new wxGTKScrollBarInputHandler(m_renderer,
GetDefaultInputHandler());
+#endif // wxUSE_SCROLLBAR
+ }
#if wxUSE_BUTTON
else if ( control == wxINP_HANDLER_BUTTON )
handler = new wxStdButtonInputHandler(GetDefaultInputHandler());
#endif // wxUSE_TOOLBAR
else if ( control == wxINP_HANDLER_TOPLEVEL )
handler = new wxStdFrameInputHandler(GetDefaultInputHandler());
- else
+
+ if(!handler)
handler = GetDefaultInputHandler();
n = m_handlerNames.Add(control);
// and for the states for which we don't have any specific colours
if ( !col.Ok() || (flags != 0) )
{
+#if wxUSE_SCROLLBAR
if ( wxDynamicCast(win, wxScrollBar) )
col = Get(SCROLLBAR);
- else if ( (flags & wxCONTROL_CURRENT) && win->CanBeHighlighted() )
+ else
+#endif //wxUSE_SCROLLBAR
+ if ( (flags & wxCONTROL_CURRENT) && win->CanBeHighlighted() )
col = Get(CONTROL_CURRENT);
else if ( flags & wxCONTROL_PRESSED )
col = Get(CONTROL_PRESSED);
case GAUGE: return Get(CONTROL_CURRENT);
+ case TITLEBAR: return wxColour(0xaeaaae);
+ case TITLEBAR_ACTIVE: return wxColour(0x820300);
+ case TITLEBAR_TEXT: return wxColour(0xc0c0c0);
+ case TITLEBAR_ACTIVE_TEXT:
+ return *wxWHITE;
+
+ case DESKTOP: return *wxBLACK;
+
case MAX:
default:
wxFAIL_MSG(_T("invalid standard colour"));
flags, align, indexAccel);
}
+#if wxUSE_TOOLBAR
void wxGTKRenderer::DrawToolBarButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rectOrig,
int flags,
- long WXUNUSED(style))
+ long WXUNUSED(style),
+ int tbarStyle)
{
// we don't draw the separators at all
if ( !label.empty() || bitmap.Ok() )
DrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL_CURRENT), rect);
}
- dc.DrawLabel(label, bitmap, rect, wxALIGN_CENTRE);
+ if(tbarStyle & wxTB_TEXT)
+ {
+ if(tbarStyle & wxTB_HORIZONTAL)
+ {
+ dc.DrawLabel(label, bitmap, rect, wxALIGN_CENTRE);
+ }
+ else
+ {
+ dc.DrawLabel(label, bitmap, rect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
+ }
+ }
+ else
+ {
+ int xpoint = (rect.GetLeft() + rect.GetRight() + 1 - bitmap.GetWidth()) / 2;
+ int ypoint = (rect.GetTop() + rect.GetBottom() + 1 - bitmap.GetHeight()) / 2;
+ dc.DrawBitmap(bitmap, xpoint, ypoint);
+ }
}
}
+#endif // wxUSE_TOOLBAR
// ----------------------------------------------------------------------------
// text control
// ----------------------------------------------------------------------------
+#if wxUSE_TEXTCTRL
+
wxRect wxGTKRenderer::GetTextTotalArea(const wxTextCtrl * WXUNUSED(text),
const wxRect& rect) const
{
return rectText;
}
+#endif // wxUSE_TEXTCTRL
+
void wxGTKRenderer::DrawTextLine(wxDC& dc,
const wxString& text,
const wxRect& rect,
dcMem.SetFont(dc.GetFont());
dcMem.SetTextForeground(dc.GetTextForeground());
dcMem.Clear();
- bitmapRotated = wxBitmap( wxImage( bitmap.ConvertToImage() ).Rotate90(dir==wxLEFT) );
+ bitmapRotated =
+#if wxUSE_IMAGE
+ wxBitmap( wxImage( bitmap.ConvertToImage() ).Rotate90(dir==wxLEFT) )
+#else
+ bitmap
+#endif // wxUSE_IMAGE
+ ;
dcMem.DrawLabel(label, bitmapRotated, rectLabel, wxALIGN_CENTRE, indexAccel);
dcMem.SelectObject(wxNullBitmap);
bitmapMem = bitmapMem.GetSubBitmap(rectLabel);
- bitmapMem = wxBitmap(wxImage(bitmapMem.ConvertToImage()).Rotate90(dir==wxRIGHT));
+#if wxUSE_IMAGE
+ bitmapMem = wxBitmap(wxImage(bitmapMem.ConvertToImage()).Rotate90(dir==wxRIGHT))
+#endif
+ ;
+
dc.DrawBitmap(bitmapMem, rectLabel.y, rectLabel.x, false);
}
else
}
}
+#if wxUSE_SLIDER
+
// ----------------------------------------------------------------------------
// slider
// ----------------------------------------------------------------------------
DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
}
+#endif // wxUSE_SLIDER
+
+#if wxUSE_MENUS
+
// ----------------------------------------------------------------------------
// menu and menubar
// ----------------------------------------------------------------------------
return gi;
}
+#endif // wxUSE_MENUS
+
+#if wxUSE_STATUSBAR
+
// ----------------------------------------------------------------------------
// status bar
// ----------------------------------------------------------------------------
{
}
+#endif // wxUSE_STATUSBAR
+
// ----------------------------------------------------------------------------
// combobox
// ----------------------------------------------------------------------------
DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
}
+#if wxUSE_SCROLLBAR
wxRect wxGTKRenderer::GetScrollbarRect(const wxScrollBar *scrollbar,
wxScrollBar::Element elem,
int thumbPos) const
return StandardPixelToScrollbar(scrollbar, coord,
GetScrollbarArrowSize(scrollbar));
}
+#endif // wxUSE_SCROLLBAR
// ----------------------------------------------------------------------------
// size adjustments
size->y += 4;
} else
#endif // wxUSE_BMPBUTTON
-#if wxUSE_BUTTON
- if ( wxDynamicCast(window, wxButton) )
+#if wxUSE_BUTTON || wxUSE_TOGGLEBTN
+ if ( 0
+# if wxUSE_BUTTON
+ || wxDynamicCast(window, wxButton)
+# endif // wxUSE_BUTTON
+# if wxUSE_TOGGLEBTN
+ || wxDynamicCast(window, wxToggleButton)
+# endif // wxUSE_TOGGLEBTN
+ )
{
if ( !(window->GetWindowStyle() & wxBU_EXACTFIT) )
{
size->y += 4;
}
} else
-#endif //wxUSE_BUTTON
+#endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
+#if wxUSE_SCROLLBAR
if ( wxDynamicCast(window, wxScrollBar) )
{
// we only set the width of vert scrollbars and height of the
size->x = m_sizeScrollbarArrow.x;
}
else
+#endif // wxUSE_SCROLLBAR
{
// take into account the border width
wxRect rectBorder = GetBorderDimensions(window->GetBorder());
return true;
}
+#if wxUSE_CHECKBOX
+
// ----------------------------------------------------------------------------
// wxGTKCheckboxInputHandler
// ----------------------------------------------------------------------------
return false;
}
+#endif // wxUSE_CHECKBOX
+
+#if wxUSE_TEXTCTRL
+
// ----------------------------------------------------------------------------
// wxGTKTextCtrlInputHandler
// ----------------------------------------------------------------------------
return wxStdTextCtrlInputHandler::HandleKey(control, event, pressed);
}
+
+#endif // wxUSE_TEXTCTRL