Improvements for building minimal builds and new ports: wxUSE_* usage and minor cleaning.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2006-06-08 11:25:30 +00:00
parent b1d8cb4417
commit 9a6384ca1e
22 changed files with 523 additions and 112 deletions

View File

@@ -127,6 +127,8 @@ void wxRenderer::StandardDrawTextLine(wxDC& dc,
// wxRenderer: scrollbar geometry
// ----------------------------------------------------------------------------
#if wxUSE_SCROLLBAR
/* static */
void wxRenderer::StandardScrollBarThumbSize(wxCoord length,
int thumbPos,
@@ -386,6 +388,8 @@ wxHitTest wxRenderer::StandardHitTestScrollbar(const wxScrollBar *scrollbar,
}
}
#endif // wxUSE_SCROLLBAR
wxRenderer::~wxRenderer()
{
}
@@ -500,11 +504,13 @@ void wxControlRenderer::DrawBitmap(wxDC &dc,
}
}
}
#if wxUSE_IMAGE
else if ( stretch & wxEXPAND )
{
// stretch bitmap to fill the entire control
bmp = wxBitmap(wxImage(bmp.ConvertToImage()).Scale(rect.width, rect.height));
}
#endif // wxUSE_IMAGE
else // not stretched, not tiled
{
if ( alignment & wxALIGN_RIGHT )
@@ -538,6 +544,8 @@ void wxControlRenderer::DrawBitmap(wxDC &dc,
dc.DrawBitmap(bmp, x, y, true /* use mask */);
}
#if wxUSE_SCROLLBAR
void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar,
int WXUNUSED(thumbPosOld))
{
@@ -648,6 +656,8 @@ void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar,
}
}
#endif // wxUSE_SCROLLBAR
void wxControlRenderer::DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
{
wxASSERT_MSG( x1 == x2 || y1 == y2,

View File

@@ -49,12 +49,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
// ----------------------------------------------------------------------------
bool wxFrame::Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
return false;

View File

@@ -45,7 +45,9 @@ struct wxScrollArrowCaptureData
m_arrowPressed = wxScrollArrows::Arrow_None;
m_window = NULL;
m_btnCapture = -1;
#if wxUSE_TIMER
m_timerScroll = NULL;
#endif // wxUSE_TIMER
}
~wxScrollArrowCaptureData()
@@ -53,7 +55,9 @@ struct wxScrollArrowCaptureData
if ( m_window )
m_window->ReleaseMouse();
#if wxUSE_TIMER
delete m_timerScroll;
#endif // wxUSE_TIMER
}
// the arrow being held pressed (may be Arrow_None)
@@ -65,14 +69,18 @@ struct wxScrollArrowCaptureData
// the window which has captured the mouse
wxWindow *m_window;
#if wxUSE_TIMER
// the timer for generating the scroll events
wxScrollTimer *m_timerScroll;
#endif
};
// ----------------------------------------------------------------------------
// wxScrollArrowTimer: a wxScrollTimer which calls OnArrow()
// ----------------------------------------------------------------------------
#if wxUSE_TIMER
class wxScrollArrowTimer : public wxScrollTimer
{
public:
@@ -95,6 +103,8 @@ protected:
wxScrollArrows::Arrow m_arrow;
};
#endif // wxUSE_TIMER
// ============================================================================
// implementation of wxScrollArrows
// ============================================================================
@@ -166,6 +176,7 @@ bool wxScrollArrows::HandleMouseMove(const wxMouseEvent& event) const
arrow = m_control->HitTest(event.GetPosition());
}
#if wxUSE_TIMER
if ( m_captureData && m_captureData->m_timerScroll)
{
// the mouse is captured, we may want to pause scrolling if it goes
@@ -199,6 +210,7 @@ bool wxScrollArrows::HandleMouseMove(const wxMouseEvent& event) const
return false;
}
#endif // wxUSE_TIMER
// reset the wxCONTROL_CURRENT flag for the arrows which don't have the
// mouse and set it for the one which has
@@ -242,22 +254,28 @@ bool wxScrollArrows::HandleMouse(const wxMouseEvent& event) const
m_captureData->m_window = m_control->GetWindow();
m_captureData->m_window->CaptureMouse();
// start scrolling
#if wxUSE_TIMER
// start scrolling
wxScrollArrowTimer *tmpTimerScroll =
new wxScrollArrowTimer(m_control, arrow);
#endif // wxUSE_TIMER
// Because in some cases wxScrollArrowTimer can cause
// m_captureData to be destructed we need to test if it
// Because in some cases wxScrollArrowTimer can cause
// m_captureData to be destructed we need to test if it
// is still valid before using.
if (m_captureData)
{
#if wxUSE_TIMER
m_captureData->m_timerScroll = tmpTimerScroll;
#endif // wxUSE_TIMER
m_control->SetArrowFlag(arrow, wxCONTROL_PRESSED, true);
}
else
{
#if wxUSE_TIMER
delete tmpTimerScroll;
#endif // wxUSE_TIMER
}
}
//else: mouse already captured, nothing to do

View File

@@ -907,6 +907,8 @@ bool wxStdScrollBarInputHandler::HandleMouseMove(wxInputConsumer *consumer,
#endif // wxUSE_SCROLLBAR
#if wxUSE_TIMER
// ----------------------------------------------------------------------------
// wxScrollTimer
// ----------------------------------------------------------------------------
@@ -949,3 +951,5 @@ void wxScrollTimer::Notify()
(void)DoNotify();
}
}
#endif // wxUSE_TIMER

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: univ/scrthumb.cpp
// Name: src/univ/scrthumb.cpp
// Purpose: wxScrollThumb and related classes
// Author: Vadim Zeitlin
// Modified by:
@@ -25,9 +25,9 @@
#ifndef WX_PRECOMP
#include "wx/window.h"
#include "wx/renderer.h"
#endif // WX_PRECOMP
#include "wx/renderer.h"
#include "wx/univ/scrtimer.h"
#include "wx/univ/scrthumb.h"
@@ -59,7 +59,9 @@ struct WXDLLEXPORT wxScrollThumbCaptureData
m_window->ReleaseMouse();
}
#if wxUSE_TIMER
delete m_timerScroll;
#endif // wxUSE_TIMER
}
// the thumb part being held pressed
@@ -83,6 +85,8 @@ struct WXDLLEXPORT wxScrollThumbCaptureData
// wxScrollTimer: the timer used when the arrow is kept pressed
// ----------------------------------------------------------------------------
#if wxUSE_TIMER
class wxScrollThumbTimer : public wxScrollTimer
{
public:
@@ -120,6 +124,8 @@ protected:
int m_inc;
};
#endif // wxUSE_TIMER
// ============================================================================
// implementation
// ============================================================================
@@ -192,6 +198,7 @@ bool wxScrollThumb::HandleMouse(const wxMouseEvent& event) const
// generate an additional event if we start dragging the thumb
m_control->OnThumbDragStart(GetThumbPos(event));
}
#if wxUSE_TIMER
else // not the thumb
{
// start timer for auto scrolling when the user presses the mouse
@@ -199,6 +206,7 @@ bool wxScrollThumb::HandleMouse(const wxMouseEvent& event) const
m_captureData->m_timerScroll =
new wxScrollThumbTimer(m_control, shaftPart);
}
#endif // wxUSE_TIMER
}
// release mouse if the *same* button went up
else if ( HasCapture() && (btn == m_captureData->m_btnCapture) )

View File

@@ -166,6 +166,7 @@ public:
wxAlignment align = wxALIGN_LEFT,
int indexAccel = -1);
#if wxUSE_TOOLBAR
virtual void DrawToolBarButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
@@ -173,6 +174,7 @@ public:
int flags = 0,
long style = 0,
int tbarStyle = 0);
#endif // wxUSE_TOOLBAR
virtual void DrawTextLine(wxDC& dc,
const wxString& text,
@@ -189,6 +191,7 @@ public:
int flags = 0,
int indexAccel = -1);
#if wxUSE_SLIDER
virtual void DrawSliderShaft(wxDC& dc,
const wxRect& rect,
int lenThumb,
@@ -213,7 +216,9 @@ public:
{
// 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,
@@ -230,11 +235,14 @@ public:
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,
@@ -281,6 +289,7 @@ public:
// 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;
@@ -290,6 +299,8 @@ public:
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
@@ -304,15 +315,18 @@ public:
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,
@@ -322,13 +336,19 @@ public:
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);
@@ -400,6 +420,7 @@ protected:
// 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
@@ -417,6 +438,7 @@ protected:
return size;
}
#endif // wxUSE_SCROLLBAR
// get the line wrap indicator bitmap
wxBitmap GetLineWrapBitmap() const;
@@ -515,6 +537,8 @@ protected:
wxGTKRenderer *m_renderer;
};
#if wxUSE_SCROLLBAR
class wxGTKScrollBarInputHandler : public wxStdScrollBarInputHandler
{
public:
@@ -549,6 +573,10 @@ protected:
}
};
#endif // wxUSE_SCROLLBAR
#if wxUSE_CHECKBOX
class wxGTKCheckboxInputHandler : public wxStdCheckboxInputHandler
{
public:
@@ -560,6 +588,10 @@ public:
bool pressed);
};
#endif // wxUSE_CHECKBOX
#if wxUSE_TEXTCTRL
class wxGTKTextCtrlInputHandler : public wxStdTextCtrlInputHandler
{
public:
@@ -571,6 +603,8 @@ public:
bool pressed);
};
#endif // wxUSE_TEXTCTRL
// ----------------------------------------------------------------------------
// wxGTKColourScheme: uses the standard GTK colours
// ----------------------------------------------------------------------------
@@ -705,14 +739,18 @@ wxInputHandler *wxGTKTheme::GetDefaultInputHandler()
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());
@@ -755,7 +793,8 @@ wxInputHandler *wxGTKTheme::GetInputHandler(const wxString& control)
#endif // wxUSE_TOOLBAR
else if ( control == wxINP_HANDLER_TOPLEVEL )
handler = new wxStdFrameInputHandler(GetDefaultInputHandler());
else
if(!handler)
handler = GetDefaultInputHandler();
n = m_handlerNames.Add(control);
@@ -798,9 +837,12 @@ wxColour wxGTKColourScheme::GetBackground(wxWindow *win) const
// 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);
@@ -841,6 +883,14 @@ wxColour wxGTKColourScheme::Get(wxGTKColourScheme::StdColour col) const
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"));
@@ -1679,6 +1729,7 @@ void wxGTKRenderer::DrawRadioButton(wxDC& dc,
flags, align, indexAccel);
}
#if wxUSE_TOOLBAR
void wxGTKRenderer::DrawToolBarButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
@@ -1725,11 +1776,14 @@ void wxGTKRenderer::DrawToolBarButton(wxDC& dc,
}
}
}
#endif // wxUSE_TOOLBAR
// ----------------------------------------------------------------------------
// text control
// ----------------------------------------------------------------------------
#if wxUSE_TEXTCTRL
wxRect wxGTKRenderer::GetTextTotalArea(const wxTextCtrl * WXUNUSED(text),
const wxRect& rect) const
{
@@ -1759,6 +1813,8 @@ wxRect wxGTKRenderer::GetTextClientArea(const wxTextCtrl *text,
return rectText;
}
#endif // wxUSE_TEXTCTRL
void wxGTKRenderer::DrawTextLine(wxDC& dc,
const wxString& text,
const wxRect& rect,
@@ -1883,11 +1939,21 @@ void wxGTKRenderer::DrawTab(wxDC& dc,
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
@@ -1986,6 +2052,8 @@ void wxGTKRenderer::DrawTab(wxDC& dc,
}
}
#if wxUSE_SLIDER
// ----------------------------------------------------------------------------
// slider
// ----------------------------------------------------------------------------
@@ -2075,6 +2143,10 @@ void wxGTKRenderer::DrawSliderThumb(wxDC& dc,
DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
}
#endif // wxUSE_SLIDER
#if wxUSE_MENUS
// ----------------------------------------------------------------------------
// menu and menubar
// ----------------------------------------------------------------------------
@@ -2340,6 +2412,10 @@ wxMenuGeometryInfo *wxGTKRenderer::GetMenuGeometry(wxWindow *win,
return gi;
}
#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR
// ----------------------------------------------------------------------------
// status bar
// ----------------------------------------------------------------------------
@@ -2357,6 +2433,8 @@ void wxGTKRenderer::DrawStatusField(wxDC& WXUNUSED(dc),
{
}
#endif // wxUSE_STATUSBAR
// ----------------------------------------------------------------------------
// combobox
// ----------------------------------------------------------------------------
@@ -2780,6 +2858,7 @@ void wxGTKRenderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
}
#if wxUSE_SCROLLBAR
wxRect wxGTKRenderer::GetScrollbarRect(const wxScrollBar *scrollbar,
wxScrollBar::Element elem,
int thumbPos) const
@@ -2822,6 +2901,7 @@ int wxGTKRenderer::PixelToScrollbar(const wxScrollBar *scrollbar,
return StandardPixelToScrollbar(scrollbar, coord,
GetScrollbarArrowSize(scrollbar));
}
#endif // wxUSE_SCROLLBAR
// ----------------------------------------------------------------------------
// size adjustments
@@ -2859,6 +2939,7 @@ void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
}
} else
#endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
#if wxUSE_SCROLLBAR
if ( wxDynamicCast(window, wxScrollBar) )
{
// we only set the width of vert scrollbars and height of the
@@ -2869,6 +2950,7 @@ void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
size->x = m_sizeScrollbarArrow.x;
}
else
#endif // wxUSE_SCROLLBAR
{
// take into account the border width
wxRect rectBorder = GetBorderDimensions(window->GetBorder());
@@ -3294,6 +3376,8 @@ bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer *control,
return true;
}
#if wxUSE_CHECKBOX
// ----------------------------------------------------------------------------
// wxGTKCheckboxInputHandler
// ----------------------------------------------------------------------------
@@ -3316,6 +3400,10 @@ bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer *control,
return false;
}
#endif // wxUSE_CHECKBOX
#if wxUSE_TEXTCTRL
// ----------------------------------------------------------------------------
// wxGTKTextCtrlInputHandler
// ----------------------------------------------------------------------------
@@ -3409,3 +3497,5 @@ bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer *control,
return wxStdTextCtrlInputHandler::HandleKey(control, event, pressed);
}
#endif // wxUSE_TEXTCTRL

View File

@@ -243,6 +243,7 @@ public:
int flags = 0,
wxAlignment align = wxALIGN_LEFT,
int indexAccel = -1);
#if wxUSE_TOOLBAR
virtual void DrawToolBarButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
@@ -250,6 +251,7 @@ public:
int flags = 0,
long style = 0,
int tbarStyle = 0);
#endif // wxUSE_TOOLBAR
virtual void DrawTextLine(wxDC& dc,
const wxString& text,
const wxRect& rect,
@@ -265,6 +267,7 @@ public:
int flags = 0,
int indexAccel = -1);
#if wxUSE_SLIDER
virtual void DrawSliderShaft(wxDC& dc,
const wxRect& rect,
int lenThumb,
@@ -286,7 +289,9 @@ public:
int step = 1,
int flags = 0,
long style = 0);
#endif // wxUSE_SLIDER
#if wxUSE_MENUS
virtual void DrawMenuBarItem(wxDC& dc,
const wxRect& rect,
const wxString& label,
@@ -303,11 +308,14 @@ public:
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
// titlebars
virtual void DrawFrameTitleBar(wxDC& dc,
@@ -352,6 +360,8 @@ public:
virtual wxSize GetScrollbarArrowSize() const
{ return m_sizeScrollbarArrow; }
#if wxUSE_SCROLLBAR
virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
wxScrollBar::Element elem,
int thumbPos = -1) const;
@@ -361,6 +371,8 @@ public:
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
@@ -375,15 +387,19 @@ public:
virtual wxSize GetToolBarMargin() const
{ return wxSize(4, 4); }
#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, 5); }
#if wxUSE_SLIDER
virtual wxCoord GetSliderDim() const { return SLIDER_THUMB_LENGTH + 2*BORDER_THICKNESS; }
virtual wxCoord GetSliderTickLen() const { return SLIDER_TICK_LENGTH; }
virtual wxRect GetSliderShaftRect(const wxRect& rect,
@@ -393,13 +409,19 @@ public:
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
protected:
// helper of DrawLabel() and DrawCheckOrRadioButton()
@@ -543,6 +565,7 @@ protected:
wxWin32Renderer *m_renderer;
};
#if wxUSE_SCROLLBAR
class wxWin32ScrollBarInputHandler : public wxStdScrollBarInputHandler
{
public:
@@ -574,7 +597,9 @@ protected:
// we remember the interval of the timer to be able to restart it
int m_interval;
};
#endif // wxUSE_SCROLLBAR
#if wxUSE_CHECKBOX
class wxWin32CheckboxInputHandler : public wxStdCheckboxInputHandler
{
public:
@@ -585,7 +610,9 @@ public:
const wxKeyEvent& event,
bool pressed);
};
#endif // wxUSE_CHECKBOX
#if wxUSE_TEXTCTRL
class wxWin32TextCtrlInputHandler : public wxStdTextCtrlInputHandler
{
public:
@@ -596,6 +623,7 @@ public:
const wxKeyEvent& event,
bool pressed);
};
#endif // wxUSE_TEXTCTRL
class wxWin32StatusBarInputHandler : public wxStdInputHandler
{
@@ -633,7 +661,9 @@ public:
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
#if wxUSE_MENUS
void PopupSystemMenu(wxTopLevelWindow *window, const wxPoint& pos) const;
#endif // wxUSE_MENUS
private:
// was the mouse over the grip last time we checked?
@@ -1297,14 +1327,18 @@ wxInputHandler *wxWin32Theme::GetDefaultInputHandler()
wxInputHandler *wxWin32Theme::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 wxWin32ScrollBarInputHandler(m_renderer,
GetDefaultInputHandler());
#endif // wxUSE_SCROLLBAR
}
#if wxUSE_BUTTON
else if ( control == wxINP_HANDLER_BUTTON )
handler = new wxStdButtonInputHandler(GetDefaultInputHandler());
@@ -1351,7 +1385,8 @@ wxInputHandler *wxWin32Theme::GetInputHandler(const wxString& control)
#endif // wxUSE_TOOLBAR
else if ( control == wxINP_HANDLER_TOPLEVEL )
handler = new wxWin32FrameInputHandler(GetDefaultInputHandler());
else
if(!handler)
handler = GetDefaultInputHandler();
n = m_handlerNames.Add(control);
@@ -1389,10 +1424,14 @@ wxColour wxWin32ColourScheme::GetBackground(wxWindow *win) const
if ( !win->ShouldInheritColours() )
{
#if wxUSE_TEXTCTRL
wxTextCtrl *text = wxDynamicCast(win, wxTextCtrl);
#endif // wxUSE_TEXTCTRL
#if wxUSE_LISTBOX
wxListBox* listBox = wxDynamicCast(win, wxListBox);
#endif
#endif // wxUSE_LISTBOX
#if wxUSE_TEXTCTRL
if ( text
#if wxUSE_LISTBOX
|| listBox
@@ -1410,6 +1449,7 @@ wxColour wxWin32ColourScheme::GetBackground(wxWindow *win) const
}
}
}
#endif // wxUSE_TEXTCTRL
if (!col.Ok())
col = Get(CONTROL); // Most controls should be this colour, not WINDOW
@@ -1422,10 +1462,12 @@ wxColour wxWin32ColourScheme::GetBackground(wxWindow *win) const
// and for the states for which we don't have any specific colours
if ( !col.Ok() || (flags & wxCONTROL_PRESSED) != 0 )
{
#if wxUSE_SCROLLBAR
if ( wxDynamicCast(win, wxScrollBar) )
col = Get(flags & wxCONTROL_PRESSED ? SCROLLBAR_PRESSED
: SCROLLBAR);
else
#endif // wxUSE_SCROLLBAR
col = Get(CONTROL);
}
}
@@ -2475,6 +2517,7 @@ void wxWin32Renderer::DrawCheckButton(wxDC& dc,
0); // no focus rect offset for checkboxes
}
#if wxUSE_TOOLBAR
void wxWin32Renderer::DrawToolBarButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
@@ -2536,6 +2579,7 @@ void wxWin32Renderer::DrawToolBarButton(wxDC& dc,
}
// don't draw wxTOOL_STYLE_CONTROL
}
#endif // wxUSE_TOOLBAR
// ----------------------------------------------------------------------------
// text control
@@ -2627,12 +2671,20 @@ void wxWin32Renderer::DrawTab(wxDC& dc,
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
;
DrawButtonLabel(dcMem, label, bitmapRotated, rectLabel,
flags, wxALIGN_CENTRE, indexAccel);
dcMem.SelectObject(wxNullBitmap);
bitmapMem = bitmapMem.GetSubBitmap(rectLabel);
#if wxUSE_IMAGE
bitmapMem = wxBitmap(wxImage(bitmapMem.ConvertToImage()).Rotate90(dir==wxRIGHT));
#endif // wxUSE_IMAGE
dc.DrawBitmap(bitmapMem, rectLabel.y, rectLabel.x, false);
}
else
@@ -2737,6 +2789,8 @@ void wxWin32Renderer::DrawTab(wxDC& dc,
#undef REVERSE_FOR_VERTICAL
}
#if wxUSE_SLIDER
// ----------------------------------------------------------------------------
// slider
// ----------------------------------------------------------------------------
@@ -3086,6 +3140,10 @@ void wxWin32Renderer::DrawSliderTicks(wxDC& dc,
}
}
#endif // wxUSE_SLIDER
#if wxUSE_MENUS
// ----------------------------------------------------------------------------
// menu and menubar
// ----------------------------------------------------------------------------
@@ -3348,6 +3406,10 @@ wxMenuGeometryInfo *wxWin32Renderer::GetMenuGeometry(wxWindow *win,
return gi;
}
#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR
// ----------------------------------------------------------------------------
// status bar
// ----------------------------------------------------------------------------
@@ -3440,6 +3502,8 @@ void wxWin32Renderer::DrawStatusField(wxDC& dc,
DrawLabel(dc, label, rectIn, flags, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
}
#endif // wxUSE_STATUSBAR
// ----------------------------------------------------------------------------
// combobox
// ----------------------------------------------------------------------------
@@ -3600,6 +3664,8 @@ void wxWin32Renderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
}
#if wxUSE_SCROLLBAR
wxRect wxWin32Renderer::GetScrollbarRect(const wxScrollBar *scrollbar,
wxScrollBar::Element elem,
int thumbPos) const
@@ -3631,6 +3697,8 @@ int wxWin32Renderer::PixelToScrollbar(const wxScrollBar *scrollbar,
return StandardPixelToScrollbar(scrollbar, coord, m_sizeScrollbarArrow);
}
#endif // wxUSE_SCROLLBAR
// ----------------------------------------------------------------------------
// top level windows
// ----------------------------------------------------------------------------
@@ -4290,6 +4358,8 @@ wxBitmap wxWin32ArtProvider::CreateBitmap(const wxArtID& id,
}
#if wxUSE_TEXTCTRL
// ----------------------------------------------------------------------------
// text control geometry
// ----------------------------------------------------------------------------
@@ -4334,6 +4404,8 @@ wxWin32Renderer::GetTextClientArea(const wxTextCtrl * WXUNUSED(text),
return rectText;
}
#endif // wxUSE_TEXTCTRL
// ----------------------------------------------------------------------------
// size adjustments
// ----------------------------------------------------------------------------
@@ -4446,6 +4518,8 @@ bool wxWin32InputHandler::HandleMouse(wxInputConsumer *control,
return false;
}
#if wxUSE_SCROLLBAR
// ----------------------------------------------------------------------------
// wxWin32ScrollBarInputHandler
// ----------------------------------------------------------------------------
@@ -4628,6 +4702,10 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer *control,
return wxStdScrollBarInputHandler::HandleMouseMove(control, event);
}
#endif // wxUSE_SCROLLBAR
#if wxUSE_CHECKBOX
// ----------------------------------------------------------------------------
// wxWin32CheckboxInputHandler
// ----------------------------------------------------------------------------
@@ -4669,6 +4747,10 @@ bool wxWin32CheckboxInputHandler::HandleKey(wxInputConsumer *control,
return false;
}
#endif // wxUSE_CHECKBOX
#if wxUSE_TEXTCTRL
// ----------------------------------------------------------------------------
// wxWin32TextCtrlInputHandler
// ----------------------------------------------------------------------------
@@ -4707,6 +4789,10 @@ bool wxWin32TextCtrlInputHandler::HandleKey(wxInputConsumer *control,
return wxStdTextCtrlInputHandler::HandleKey(control, event, pressed);
}
#endif // wxUSE_TEXTCTRL
#if wxUSE_STATUSBAR
// ----------------------------------------------------------------------------
// wxWin32StatusBarInputHandler
// ----------------------------------------------------------------------------
@@ -4800,6 +4886,8 @@ bool wxWin32StatusBarInputHandler::HandleMouseMove(wxInputConsumer *consumer,
return wxStdInputHandler::HandleMouseMove(consumer, event);
}
#endif // wxUSE_STATUSBAR
// ----------------------------------------------------------------------------
// wxWin32FrameInputHandler
// ----------------------------------------------------------------------------
@@ -4883,7 +4971,9 @@ void wxWin32SystemMenuEvtHandler::OnSystemMenu(wxCommandEvent &WXUNUSED(event))
m_wnd->SetAcceleratorTable(wxNullAcceleratorTable);
#endif
#if wxUSE_MENUS
m_inputHnd->PopupSystemMenu(m_wnd, pt);
#endif // wxUSE_MENUS
#if wxUSE_ACCEL
m_wnd->SetAcceleratorTable(table);
@@ -4942,7 +5032,9 @@ bool wxWin32FrameInputHandler::HandleMouse(wxInputConsumer *consumer,
(hit == wxHT_TOPLEVEL_TITLEBAR ||
hit == wxHT_TOPLEVEL_ICON)) )
{
#if wxUSE_MENUS
PopupSystemMenu(tlw, event.GetPosition());
#endif // wxUSE_MENUS
return true;
}
}
@@ -4951,6 +5043,8 @@ bool wxWin32FrameInputHandler::HandleMouse(wxInputConsumer *consumer,
return wxStdFrameInputHandler::HandleMouse(consumer, event);
}
#if wxUSE_MENUS
void wxWin32FrameInputHandler::PopupSystemMenu(wxTopLevelWindow *window,
const wxPoint& pos) const
{
@@ -4985,6 +5079,8 @@ void wxWin32FrameInputHandler::PopupSystemMenu(wxTopLevelWindow *window,
delete menu;
}
#endif // wxUSE_MENUS
bool wxWin32FrameInputHandler::HandleActivation(wxInputConsumer *consumer,
bool activated)
{

View File

@@ -239,12 +239,7 @@ void wxTopLevelWindow::OnNcPaint(wxNcPaintEvent& event)
else
{
// get the window rect
wxRect rect;
wxSize size = GetSize();
rect.x =
rect.y = 0;
rect.width = size.x;
rect.height = size.y;
wxRect rect(GetSize());
wxWindowDC dc(this);
m_renderer->DrawFrameTitleBar(dc, rect,
@@ -309,12 +304,14 @@ void wxTopLevelWindow::SetIcons(const wxIconBundle& icons)
m_titlebarIcon = wxNullIcon;
else if ( bmp1.GetWidth() == size.x && bmp1.GetHeight() == size.y )
m_titlebarIcon = icon;
#if wxUSE_IMAGE
else
{
wxImage img = bmp1.ConvertToImage();
img.Rescale(size.x, size.y);
m_titlebarIcon.CopyFromBitmap(wxBitmap(img));
}
#endif // wxUSE_IMAGE
}
}
}

View File

@@ -100,8 +100,10 @@ END_EVENT_TABLE()
void wxWindow::Init()
{
#if wxUSE_SCROLLBAR
m_scrollbarVert =
m_scrollbarHorz = (wxScrollBar *)NULL;
#endif // wxUSE_SCROLLBAR
m_isCurrent = false;
@@ -145,9 +147,11 @@ bool wxWindow::Create(wxWindow *parent,
#if wxUSE_TWO_WINDOWS
SetInsertIntoMain( true );
#endif
#if wxUSE_SCROLLBAR
m_scrollbarVert = new wxScrollBar(this, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
wxSB_VERTICAL);
#endif // wxUSE_SCROLLBAR
#if wxUSE_TWO_WINDOWS
SetInsertIntoMain( false );
#endif
@@ -159,19 +163,23 @@ bool wxWindow::Create(wxWindow *parent,
#if wxUSE_TWO_WINDOWS
SetInsertIntoMain( true );
#endif
#if wxUSE_SCROLLBAR
m_scrollbarHorz = new wxScrollBar(this, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
wxSB_HORIZONTAL);
#endif // wxUSE_SCROLLBAR
#if wxUSE_TWO_WINDOWS
SetInsertIntoMain( false );
#endif
}
#if wxUSE_SCROLLBAR
if (m_scrollbarHorz || m_scrollbarVert)
{
// position it/them
PositionScrollbars();
}
#endif // wxUSE_SCROLLBAR
return true;
}
@@ -225,13 +233,9 @@ void wxWindow::OnNcPaint(wxNcPaintEvent& WXUNUSED(event))
if ( m_renderer )
{
// get the window rect
wxRect rect;
wxSize size = GetSize();
rect.x =
rect.y = 0;
rect.width = size.x;
rect.height = size.y;
wxRect rect(GetSize());
#if wxUSE_SCROLLBAR
// if the scrollbars are outside the border, we must adjust the rect to
// exclude them
if ( !m_renderer->AreScrollbarsInsideBorder() )
@@ -244,6 +248,7 @@ void wxWindow::OnNcPaint(wxNcPaintEvent& WXUNUSED(event))
if ( scrollbar )
rect.height -= scrollbar->GetSize().y;
}
#endif // wxUSE_SCROLLBAR
// get the DC and draw the border on it
wxWindowDC dc(this);
@@ -281,6 +286,7 @@ void wxWindow::OnErase(wxEraseEvent& event)
DoDrawBackground(*event.GetDC());
#if wxUSE_SCROLLBAR
// if we have both scrollbars, we also have a square in the corner between
// them which we must paint
if ( m_scrollbarVert && m_scrollbarHorz )
@@ -300,6 +306,7 @@ void wxWindow::OnErase(wxEraseEvent& event)
m_renderer->DrawScrollCorner(*event.GetDC(), rectCorner);
}
}
#endif // wxUSE_SCROLLBAR
}
bool wxWindow::DoDrawBackground(wxDC& dc)
@@ -533,10 +540,12 @@ void wxWindow::OnSize(wxSizeEvent& event)
{
event.Skip();
#if wxUSE_SCROLLBAR
if ( m_scrollbarVert || m_scrollbarHorz )
{
PositionScrollbars();
}
#endif // wxUSE_SCROLLBAR
#if 0 // ndef __WXMSW__
// Refresh the area (strip) previously occupied by the border
@@ -697,13 +706,19 @@ void wxWindow::DoGetClientSize(int *width, int *height) const
if ( width )
{
#if wxUSE_SCROLLBAR
// in any case, take account of the scrollbar
if ( m_scrollbarVert )
w -= m_scrollbarVert->GetSize().x;
#endif // wxUSE_SCROLLBAR
// if we don't have scrollbar or if it is outside the border (and not
// blended into it), take account of the right border as well
if ( !m_scrollbarVert || inside )
if (
#if wxUSE_SCROLLBAR
!m_scrollbarVert ||
#endif // wxUSE_SCROLLBAR
inside )
w -= rectBorder.width;
// and always account for the left border
@@ -716,10 +731,16 @@ void wxWindow::DoGetClientSize(int *width, int *height) const
if ( height )
{
#if wxUSE_SCROLLBAR
if ( m_scrollbarHorz )
h -= m_scrollbarHorz->GetSize().y;
#endif // wxUSE_SCROLLBAR
if ( !m_scrollbarHorz || inside )
if (
#if wxUSE_SCROLLBAR
!m_scrollbarHorz ||
#endif // wxUSE_SCROLLBAR
inside )
h -= rectBorder.height;
*height = h - rectBorder.y;
@@ -742,14 +763,26 @@ void wxWindow::DoSetClientSize(int width, int height)
// had been called before)
bool inside = m_renderer->AreScrollbarsInsideBorder();
wxSize size = GetSize();
#if wxUSE_SCROLLBAR
if ( m_scrollbarVert )
width += size.x - m_scrollbarVert->GetPosition().x;
if ( !m_scrollbarVert || inside )
#endif // wxUSE_SCROLLBAR
if (
#if wxUSE_SCROLLBAR
!m_scrollbarVert ||
#endif // wxUSE_SCROLLBAR
inside )
width += rectBorder.width;
#if wxUSE_SCROLLBAR
if ( m_scrollbarHorz )
height += size.y - m_scrollbarHorz->GetPosition().y;
if ( !m_scrollbarHorz || inside )
#endif // wxUSE_SCROLLBAR
if (
#if wxUSE_SCROLLBAR
!m_scrollbarHorz ||
#endif // wxUSE_SCROLLBAR
inside )
height += rectBorder.height;
wxWindowNative::DoSetClientSize(width, height);
@@ -758,6 +791,8 @@ void wxWindow::DoSetClientSize(int width, int height)
wxHitTest wxWindow::DoHitTest(wxCoord x, wxCoord y) const
{
wxHitTest ht = wxWindowNative::DoHitTest(x, y);
#if wxUSE_SCROLLBAR
if ( ht == wxHT_WINDOW_INSIDE )
{
if ( m_scrollbarVert && x >= m_scrollbarVert->GetPosition().x )
@@ -772,6 +807,7 @@ wxHitTest wxWindow::DoHitTest(wxCoord x, wxCoord y) const
: wxHT_WINDOW_HORZ_SCROLLBAR;
}
}
#endif // wxUSE_SCROLLBAR
return ht;
}
@@ -784,15 +820,18 @@ wxHitTest wxWindow::DoHitTest(wxCoord x, wxCoord y) const
void wxWindow::RefreshScrollbars()
{
#if wxUSE_SCROLLBAR
if ( m_scrollbarHorz )
m_scrollbarHorz->Refresh();
if ( m_scrollbarVert )
m_scrollbarVert->Refresh();
#endif // wxUSE_SCROLLBAR
}
void wxWindow::PositionScrollbars()
{
#if wxUSE_SCROLLBAR
// do not use GetClientSize/Rect as it relies on the scrollbars being
// correctly positioned
@@ -838,6 +877,7 @@ void wxWindow::PositionScrollbars()
}
RefreshScrollbars();
#endif // wxUSE_SCROLLBAR
}
void wxWindow::SetScrollbar(int orient,
@@ -846,6 +886,7 @@ void wxWindow::SetScrollbar(int orient,
int range,
bool refresh)
{
#if wxUSE_SCROLLBAR
wxASSERT_MSG( pageSize <= range,
_T("page size can't be greater than range") );
@@ -926,10 +967,18 @@ void wxWindow::SetScrollbar(int orient,
(void)GetEventHandler()->ProcessEvent(event);
#endif
}
#else
wxUnusedVar(orient);
wxUnusedVar(pos);
wxUnusedVar(pageSize);
wxUnusedVar(range);
wxUnusedVar(refresh);
#endif // wxUSE_SCROLLBAR
}
void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
{
#if wxUSE_SCROLLBAR
wxScrollBar *scrollbar = GetScrollbar(orient);
if (scrollbar)
@@ -941,24 +990,43 @@ void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
if ( refresh )
Refresh();
#endif
#else
wxUnusedVar(orient);
wxUnusedVar(pos);
#endif // wxUSE_SCROLLBAR
}
int wxWindow::GetScrollPos(int orient) const
{
#if wxUSE_SCROLLBAR
wxScrollBar *scrollbar = GetScrollbar(orient);
return scrollbar ? scrollbar->GetThumbPosition() : 0;
#else
wxUnusedVar(orient);
return 0;
#endif // wxUSE_SCROLLBAR
}
int wxWindow::GetScrollThumb(int orient) const
{
#if wxUSE_SCROLLBAR
wxScrollBar *scrollbar = GetScrollbar(orient);
return scrollbar ? scrollbar->GetThumbSize() : 0;
#else
wxUnusedVar(orient);
return 0;
#endif // wxUSE_SCROLLBAR
}
int wxWindow::GetScrollRange(int orient) const
{
#if wxUSE_SCROLLBAR
wxScrollBar *scrollbar = GetScrollbar(orient);
return scrollbar ? scrollbar->GetRange() : 0;
#else
wxUnusedVar(orient);
return 0;
#endif // wxUSE_SCROLLBAR
}
void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
@@ -995,8 +1063,10 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
node; node = node->GetNext())
{
wxWindow *child = node->GetData();
#if wxUSE_SCROLLBAR
if ( child == m_scrollbarVert || child == m_scrollbarHorz )
continue;
#endif // wxUSE_SCROLLBAR
// VS: Scrolling children has non-trivial semantics. If rect=NULL then
// it is easy: we scroll all children. Otherwise it gets