1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/themes/win32.cpp
3 // Purpose: wxUniversal theme implementing Win32-like LNF
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
31 #include "wx/window.h"
33 #include "wx/dcmemory.h"
35 #include "wx/button.h"
36 #include "wx/bmpbuttn.h"
37 #include "wx/listbox.h"
38 #include "wx/checklst.h"
39 #include "wx/combobox.h"
40 #include "wx/scrolbar.h"
41 #include "wx/slider.h"
42 #include "wx/textctrl.h"
43 #include "wx/toolbar.h"
44 #include "wx/statusbr.h"
47 // for COLOR_* constants
48 #include "wx/msw/private.h"
51 #include "wx/settings.h"
52 #include "wx/toplevel.h"
56 #include "wx/notebook.h"
57 #include "wx/spinbutt.h"
58 #include "wx/artprov.h"
59 #ifdef wxUSE_TOGGLEBTN
60 #include "wx/tglbtn.h"
61 #endif // wxUSE_TOGGLEBTN
63 #include "wx/univ/scrtimer.h"
64 #include "wx/univ/stdrend.h"
65 #include "wx/univ/inpcons.h"
66 #include "wx/univ/inphand.h"
67 #include "wx/univ/colschem.h"
68 #include "wx/univ/theme.h"
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 static const int BORDER_THICKNESS
= 2;
76 // the offset between the label and focus rect around it
77 static const int FOCUS_RECT_OFFSET_X
= 1;
78 static const int FOCUS_RECT_OFFSET_Y
= 1;
80 static const int FRAME_BORDER_THICKNESS
= 3;
81 static const int RESIZEABLE_FRAME_BORDER_THICKNESS
= 4;
82 static const int FRAME_TITLEBAR_HEIGHT
= 18;
83 static const int FRAME_BUTTON_WIDTH
= 16;
84 static const int FRAME_BUTTON_HEIGHT
= 14;
86 static const size_t NUM_STATUSBAR_GRIP_BANDS
= 3;
87 static const size_t WIDTH_STATUSBAR_GRIP_BAND
= 4;
88 static const size_t STATUSBAR_GRIP_SIZE
=
89 WIDTH_STATUSBAR_GRIP_BAND
*NUM_STATUSBAR_GRIP_BANDS
;
91 static const wxCoord SLIDER_MARGIN
= 6; // margin around slider
92 static const wxCoord SLIDER_THUMB_LENGTH
= 18;
93 static const wxCoord SLIDER_TICK_LENGTH
= 6;
95 // wxWin32Renderer: draw the GUI elements in Win32 style
96 // ----------------------------------------------------------------------------
98 class wxWin32Renderer
: public wxStdRenderer
102 enum wxArrowDirection
117 Arrow_InvertedDisabled
,
121 enum wxFrameButtonType
124 FrameButton_Minimize
,
125 FrameButton_Maximize
,
132 wxWin32Renderer(const wxColourScheme
*scheme
);
134 // reimplement the renderer methods which are different for this theme
135 virtual void DrawLabel(wxDC
& dc
,
136 const wxString
& label
,
139 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
141 wxRect
*rectBounds
= NULL
);
142 virtual void DrawButtonLabel(wxDC
& dc
,
143 const wxString
& label
,
144 const wxBitmap
& image
,
147 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
149 wxRect
*rectBounds
= NULL
);
150 virtual void DrawButtonBorder(wxDC
& dc
,
153 wxRect
*rectIn
= NULL
);
154 virtual void DrawArrow(wxDC
& dc
,
158 virtual void DrawScrollbarArrow(wxDC
& dc
,
162 { DrawArrow(dc
, dir
, rect
, flags
); }
163 virtual void DrawScrollbarThumb(wxDC
& dc
,
164 wxOrientation orient
,
167 virtual void DrawScrollbarShaft(wxDC
& dc
,
168 wxOrientation orient
,
171 virtual void DrawScrollCorner(wxDC
& dc
,
173 virtual void DrawCheckItem(wxDC
& dc
,
174 const wxString
& label
,
175 const wxBitmap
& bitmap
,
180 virtual void DrawToolBarButton(wxDC
& dc
,
181 const wxString
& label
,
182 const wxBitmap
& bitmap
,
187 #endif // wxUSE_TOOLBAR
189 virtual void DrawTab(wxDC
& dc
,
192 const wxString
& label
,
193 const wxBitmap
& bitmap
= wxNullBitmap
,
195 int indexAccel
= -1);
198 virtual void DrawSliderShaft(wxDC
& dc
,
201 wxOrientation orient
,
204 wxRect
*rectShaft
= NULL
);
205 virtual void DrawSliderThumb(wxDC
& dc
,
207 wxOrientation orient
,
210 virtual void DrawSliderTicks(wxDC
& dc
,
213 wxOrientation orient
,
219 #endif // wxUSE_SLIDER
222 virtual void DrawMenuBarItem(wxDC
& dc
,
224 const wxString
& label
,
226 int indexAccel
= -1);
227 virtual void DrawMenuItem(wxDC
& dc
,
229 const wxMenuGeometryInfo
& geometryInfo
,
230 const wxString
& label
,
231 const wxString
& accel
,
232 const wxBitmap
& bitmap
= wxNullBitmap
,
234 int indexAccel
= -1);
235 virtual void DrawMenuSeparator(wxDC
& dc
,
237 const wxMenuGeometryInfo
& geomInfo
);
238 #endif // wxUSE_MENUS
241 virtual void DrawStatusField(wxDC
& dc
,
243 const wxString
& label
,
244 int flags
= 0, int style
= 0);
245 #endif // wxUSE_STATUSBAR
248 virtual void DrawFrameTitleBar(wxDC
& dc
,
250 const wxString
& title
,
253 int specialButton
= 0,
254 int specialButtonFlags
= 0);
255 virtual void DrawFrameBorder(wxDC
& dc
,
258 virtual void DrawFrameBackground(wxDC
& dc
,
261 virtual void DrawFrameTitle(wxDC
& dc
,
263 const wxString
& title
,
265 virtual void DrawFrameIcon(wxDC
& dc
,
269 virtual void DrawFrameButton(wxDC
& dc
,
270 wxCoord x
, wxCoord y
,
273 virtual wxRect
GetFrameClientArea(const wxRect
& rect
, int flags
) const;
274 virtual wxSize
GetFrameTotalSize(const wxSize
& clientSize
, int flags
) const;
275 virtual wxSize
GetFrameMinSize(int flags
) const;
276 virtual wxSize
GetFrameIconSize() const;
277 virtual int HitTestFrame(const wxRect
& rect
, const wxPoint
& pt
, int flags
) const;
279 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
281 wxBitmap
*bmpPressed
,
282 wxBitmap
*bmpDisabled
);
284 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
285 virtual bool AreScrollbarsInsideBorder() const;
287 virtual wxSize
GetScrollbarArrowSize() const
288 { return m_sizeScrollbarArrow
; }
290 virtual wxCoord
GetListboxItemHeight(wxCoord fontHeight
)
291 { return fontHeight
+ 2; }
292 virtual wxSize
GetCheckBitmapSize() const
293 { return wxSize(13, 13); }
294 virtual wxSize
GetRadioBitmapSize() const
295 { return wxSize(12, 12); }
296 virtual wxCoord
GetCheckItemMargin() const
299 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
300 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
301 virtual wxSize
GetToolBarMargin() const
302 { return wxSize(4, 4); }
305 virtual wxRect
GetTextTotalArea(const wxTextCtrl
*text
,
306 const wxRect
& rect
) const;
307 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
309 wxCoord
*extraSpaceBeyond
) const;
310 #endif // wxUSE_TEXTCTRL
312 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
313 virtual wxSize
GetTabPadding() const { return wxSize(6, 5); }
317 virtual wxCoord
GetSliderDim() const { return SLIDER_THUMB_LENGTH
+ 2*BORDER_THICKNESS
; }
318 virtual wxCoord
GetSliderTickLen() const { return SLIDER_TICK_LENGTH
; }
319 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
321 wxOrientation orient
,
322 long style
= 0) const;
323 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
325 wxOrientation orient
) const;
326 #endif // wxUSE_SLIDER
328 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
331 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
332 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
333 const wxMenu
& menu
) const;
334 #endif // wxUSE_MENUS
337 virtual wxSize
GetStatusBarBorders(wxCoord
*borderBetweenFields
) const;
338 #endif // wxUSE_STATUSBAR
341 virtual void DrawFrameWithLabel(wxDC
& dc
,
342 const wxString
& label
,
343 const wxRect
& rectFrame
,
344 const wxRect
& rectText
,
350 // draw the border used for scrollbar arrows
351 void DrawArrowBorder(wxDC
& dc
, wxRect
*rect
, bool isPressed
= false);
353 // public DrawArrow()s helper
354 void DrawArrow(wxDC
& dc
, const wxRect
& rect
,
355 wxArrowDirection arrowDir
, wxArrowStyle arrowStyle
);
357 // DrawArrowButton is used by DrawScrollbar and DrawComboButton
358 void DrawArrowButton(wxDC
& dc
, const wxRect
& rect
,
359 wxArrowDirection arrowDir
,
360 wxArrowStyle arrowStyle
);
362 // DrawCheckButton helper
363 void DrawCheckOrRadioButton(wxDC
& dc
,
364 const wxString
& label
,
365 const wxBitmap
& bitmap
,
370 wxCoord focusOffsetY
);
372 // draw a normal or transposed line (useful for using the same code fo both
373 // horizontal and vertical widgets)
374 void DrawLine(wxDC
& dc
,
375 wxCoord x1
, wxCoord y1
,
376 wxCoord x2
, wxCoord y2
,
377 bool transpose
= false)
380 dc
.DrawLine(y1
, x1
, y2
, x2
);
382 dc
.DrawLine(x1
, y1
, x2
, y2
);
385 // get the standard check/radio button bitmap
386 wxBitmap
GetIndicator(IndicatorType indType
, int flags
);
387 wxBitmap
GetCheckBitmap(int flags
)
388 { return GetIndicator(IndicatorType_Check
, flags
); }
389 wxBitmap
GetRadioBitmap(int flags
)
390 { return GetIndicator(IndicatorType_Radio
, flags
); }
393 // the sizing parameters (TODO make them changeable)
394 wxSize m_sizeScrollbarArrow
;
396 wxFont m_titlebarFont
;
398 // the checked and unchecked bitmaps for DrawCheckItem()
399 wxBitmap m_bmpCheckBitmaps
[IndicatorStatus_Max
];
401 // the bitmaps returned by GetIndicator()
402 wxBitmap m_bmpIndicators
[IndicatorType_Max
]
403 [IndicatorState_MaxMenu
]
404 [IndicatorStatus_Max
];
406 // standard defaults for m_bmpCheckBitmaps and m_bmpIndicators
407 static const char **ms_xpmChecked
[IndicatorStatus_Max
];
408 static const char **ms_xpmIndicators
[IndicatorType_Max
]
409 [IndicatorState_MaxMenu
]
410 [IndicatorStatus_Max
];
413 wxBitmap m_bmpFrameButtons
[FrameButton_Max
];
415 // first row is for the normal state, second - for the disabled
416 wxBitmap m_bmpArrows
[Arrow_StateMax
][Arrow_Max
];
419 // ----------------------------------------------------------------------------
420 // wxWin32InputHandler and derived classes: process the keyboard and mouse
421 // messages according to Windows standards
422 // ----------------------------------------------------------------------------
424 class wxWin32InputHandler
: public wxInputHandler
427 wxWin32InputHandler() { }
429 virtual bool HandleKey(wxInputConsumer
*control
,
430 const wxKeyEvent
& event
,
432 virtual bool HandleMouse(wxInputConsumer
*control
,
433 const wxMouseEvent
& event
);
437 class wxWin32ScrollBarInputHandler
: public wxStdScrollBarInputHandler
440 wxWin32ScrollBarInputHandler(wxRenderer
*renderer
,
441 wxInputHandler
*handler
);
443 virtual bool HandleMouse(wxInputConsumer
*control
,
444 const wxMouseEvent
& event
);
445 virtual bool HandleMouseMove(wxInputConsumer
*control
,
446 const wxMouseEvent
& event
);
448 virtual bool OnScrollTimer(wxScrollBar
*scrollbar
,
449 const wxControlAction
& action
);
452 virtual void Highlight(wxScrollBar
* WXUNUSED(scrollbar
),
455 // we don't highlight anything
458 // the first and last event which caused the thumb to move
459 wxMouseEvent m_eventStartDrag
,
462 // have we paused the scrolling because the mouse moved?
465 // we remember the interval of the timer to be able to restart it
468 #endif // wxUSE_SCROLLBAR
471 class wxWin32CheckboxInputHandler
: public wxStdInputHandler
474 wxWin32CheckboxInputHandler(wxInputHandler
*handler
)
475 : wxStdInputHandler(handler
) { }
477 virtual bool HandleKey(wxInputConsumer
*control
,
478 const wxKeyEvent
& event
,
481 #endif // wxUSE_CHECKBOX
484 class wxWin32TextCtrlInputHandler
: public wxStdInputHandler
487 wxWin32TextCtrlInputHandler(wxInputHandler
*handler
)
488 : wxStdInputHandler(handler
) { }
490 virtual bool HandleKey(wxInputConsumer
*control
,
491 const wxKeyEvent
& event
,
494 #endif // wxUSE_TEXTCTRL
496 class wxWin32StatusBarInputHandler
: public wxStdInputHandler
499 wxWin32StatusBarInputHandler(wxInputHandler
*handler
);
501 virtual bool HandleMouse(wxInputConsumer
*consumer
,
502 const wxMouseEvent
& event
);
504 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
505 const wxMouseEvent
& event
);
508 // is the given point over the statusbar grip?
509 bool IsOnGrip(wxWindow
*statbar
, const wxPoint
& pt
) const;
512 // the cursor we had replaced with the resize one
513 wxCursor m_cursorOld
;
515 // was the mouse over the grip last time we checked?
519 class wxWin32SystemMenuEvtHandler
;
521 class wxWin32FrameInputHandler
: public wxStdInputHandler
524 wxWin32FrameInputHandler(wxInputHandler
*handler
);
525 virtual ~wxWin32FrameInputHandler();
527 virtual bool HandleMouse(wxInputConsumer
*control
,
528 const wxMouseEvent
& event
);
530 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
533 void PopupSystemMenu(wxTopLevelWindow
*window
, const wxPoint
& pos
) const;
534 #endif // wxUSE_MENUS
537 // was the mouse over the grip last time we checked?
538 wxWin32SystemMenuEvtHandler
*m_menuHandler
;
541 // ----------------------------------------------------------------------------
542 // wxWin32ColourScheme: uses (default) Win32 colours
543 // ----------------------------------------------------------------------------
545 class wxWin32ColourScheme
: public wxColourScheme
548 virtual wxColour
Get(StdColour col
) const;
549 virtual wxColour
GetBackground(wxWindow
*win
) const;
552 // ----------------------------------------------------------------------------
553 // wxWin32ArtProvider
554 // ----------------------------------------------------------------------------
556 class wxWin32ArtProvider
: public wxArtProvider
559 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
560 const wxArtClient
& client
,
564 // ----------------------------------------------------------------------------
566 // ----------------------------------------------------------------------------
568 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
570 class wxWin32Theme
: public wxTheme
574 virtual ~wxWin32Theme();
576 virtual wxRenderer
*GetRenderer();
577 virtual wxArtProvider
*GetArtProvider();
578 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
579 wxInputConsumer
*consumer
);
580 virtual wxColourScheme
*GetColourScheme();
583 wxWin32Renderer
*m_renderer
;
585 wxWin32ArtProvider
*m_artProvider
;
587 // the names of the already created handlers and the handlers themselves
588 // (these arrays are synchronized)
589 wxSortedArrayString m_handlerNames
;
590 wxArrayHandlers m_handlers
;
592 wxWin32ColourScheme
*m_scheme
;
594 WX_DECLARE_THEME(win32
)
597 // ----------------------------------------------------------------------------
599 // ----------------------------------------------------------------------------
601 // frame buttons bitmaps
603 static const char *frame_button_close_xpm
[] = {
618 static const char *frame_button_help_xpm
[] = {
633 static const char *frame_button_maximize_xpm
[] = {
648 static const char *frame_button_minimize_xpm
[] = {
663 static const char *frame_button_restore_xpm
[] = {
680 static const char *checked_menu_xpm
[] = {
681 /* columns rows colors chars-per-pixel */
697 static const char *selected_checked_menu_xpm
[] = {
698 /* columns rows colors chars-per-pixel */
714 static const char *disabled_checked_menu_xpm
[] = {
715 /* columns rows colors chars-per-pixel */
732 static const char *selected_disabled_checked_menu_xpm
[] = {
733 /* columns rows colors chars-per-pixel */
749 // checkbox and radiobox bitmaps below
751 static const char *checked_xpm
[] = {
752 /* columns rows colors chars-per-pixel */
775 static const char *pressed_checked_xpm
[] = {
776 /* columns rows colors chars-per-pixel */
798 static const char *pressed_disabled_checked_xpm
[] = {
799 /* columns rows colors chars-per-pixel */
821 static const char *checked_item_xpm
[] = {
822 /* columns rows colors chars-per-pixel */
843 static const char *unchecked_xpm
[] = {
844 /* columns rows colors chars-per-pixel */
867 static const char *pressed_unchecked_xpm
[] = {
868 /* columns rows colors chars-per-pixel */
890 static const char *unchecked_item_xpm
[] = {
891 /* columns rows colors chars-per-pixel */
911 static const char *undetermined_xpm
[] = {
912 /* columns rows colors chars-per-pixel */
935 static const char *pressed_undetermined_xpm
[] = {
936 /* columns rows colors chars-per-pixel */
959 static const char *checked_radio_xpm
[] = {
960 /* columns rows colors chars-per-pixel */
983 static const char *pressed_checked_radio_xpm
[] = {
984 /* columns rows colors chars-per-pixel */
1007 static const char *pressed_disabled_checked_radio_xpm
[] = {
1008 /* columns rows colors chars-per-pixel */
1031 static const char *unchecked_radio_xpm
[] = {
1032 /* columns rows colors chars-per-pixel */
1055 static const char *pressed_unchecked_radio_xpm
[] = {
1056 /* columns rows colors chars-per-pixel */
1079 const char **wxWin32Renderer::ms_xpmIndicators
[IndicatorType_Max
]
1080 [IndicatorState_MaxMenu
]
1081 [IndicatorStatus_Max
] =
1086 { checked_xpm
, unchecked_xpm
, undetermined_xpm
},
1089 { pressed_checked_xpm
, pressed_unchecked_xpm
, pressed_undetermined_xpm
},
1092 { pressed_disabled_checked_xpm
, pressed_unchecked_xpm
, pressed_disabled_checked_xpm
},
1098 { checked_radio_xpm
, unchecked_radio_xpm
, NULL
},
1101 { pressed_checked_radio_xpm
, pressed_unchecked_radio_xpm
, NULL
},
1104 { pressed_disabled_checked_radio_xpm
, pressed_unchecked_radio_xpm
, NULL
},
1110 { checked_menu_xpm
, NULL
, NULL
},
1113 { selected_checked_menu_xpm
, NULL
, NULL
},
1116 { disabled_checked_menu_xpm
, NULL
, NULL
},
1118 // disabled selected state
1119 { selected_disabled_checked_menu_xpm
, NULL
, NULL
},
1123 const char **wxWin32Renderer::ms_xpmChecked
[IndicatorStatus_Max
] =
1129 // ============================================================================
1131 // ============================================================================
1133 WX_IMPLEMENT_THEME(wxWin32Theme
, win32
, wxTRANSLATE("Win32 theme"));
1135 // ----------------------------------------------------------------------------
1137 // ----------------------------------------------------------------------------
1139 wxWin32Theme::wxWin32Theme()
1143 m_artProvider
= NULL
;
1146 wxWin32Theme::~wxWin32Theme()
1150 wxArtProvider::RemoveProvider(m_artProvider
);
1153 wxRenderer
*wxWin32Theme::GetRenderer()
1157 m_renderer
= new wxWin32Renderer(GetColourScheme());
1163 wxArtProvider
*wxWin32Theme::GetArtProvider()
1165 if ( !m_artProvider
)
1167 m_artProvider
= new wxWin32ArtProvider
;
1170 return m_artProvider
;
1174 wxWin32Theme::GetInputHandler(const wxString
& control
,
1175 wxInputConsumer
*consumer
)
1177 wxInputHandler
*handler
= NULL
;
1178 int n
= m_handlerNames
.Index(control
);
1179 if ( n
== wxNOT_FOUND
)
1181 static wxWin32InputHandler s_handlerDef
;
1183 wxInputHandler
* const
1184 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
1186 // create a new handler
1187 if ( control
== wxINP_HANDLER_TOPLEVEL
)
1189 static wxWin32FrameInputHandler
s_handler(handlerStd
);
1191 handler
= &s_handler
;
1194 else if ( control
== wxINP_HANDLER_CHECKBOX
)
1196 static wxWin32CheckboxInputHandler
s_handler(handlerStd
);
1198 handler
= &s_handler
;
1200 #endif // wxUSE_CHECKBOX
1202 else if ( control
== wxINP_HANDLER_SCROLLBAR
)
1204 static wxWin32ScrollBarInputHandler
1205 s_handler(GetRenderer(), handlerStd
);
1207 handler
= &s_handler
;
1209 #endif // wxUSE_SCROLLBAR
1211 else if ( control
== wxINP_HANDLER_STATUSBAR
)
1213 static wxWin32StatusBarInputHandler
s_handler(handlerStd
);
1215 handler
= &s_handler
;
1217 #endif // wxUSE_STATUSBAR
1219 else if ( control
== wxINP_HANDLER_TEXTCTRL
)
1221 static wxWin32TextCtrlInputHandler
s_handler(handlerStd
);
1223 handler
= &s_handler
;
1225 #endif // wxUSE_TEXTCTRL
1226 else // no special handler for this control
1228 handler
= handlerStd
;
1231 n
= m_handlerNames
.Add(control
);
1232 m_handlers
.Insert(handler
, n
);
1234 else // we already have it
1236 handler
= m_handlers
[n
];
1242 wxColourScheme
*wxWin32Theme::GetColourScheme()
1246 m_scheme
= new wxWin32ColourScheme
;
1251 // ============================================================================
1252 // wxWin32ColourScheme
1253 // ============================================================================
1255 wxColour
wxWin32ColourScheme::GetBackground(wxWindow
*win
) const
1258 if ( win
->UseBgCol() )
1260 // use the user specified colour
1261 col
= win
->GetBackgroundColour();
1264 if ( !win
->ShouldInheritColours() )
1267 wxTextCtrl
*text
= wxDynamicCast(win
, wxTextCtrl
);
1268 #endif // wxUSE_TEXTCTRL
1270 wxListBox
* listBox
= wxDynamicCast(win
, wxListBox
);
1271 #endif // wxUSE_LISTBOX
1280 if ( !win
->IsEnabled() ) // not IsEditable()
1286 // doesn't depend on the state
1291 #endif // wxUSE_TEXTCTRL
1294 col
= Get(CONTROL
); // Most controls should be this colour, not WINDOW
1298 int flags
= win
->GetStateFlags();
1300 // the colour set by the user should be used for the normal state
1301 // and for the states for which we don't have any specific colours
1302 if ( !col
.Ok() || (flags
& wxCONTROL_PRESSED
) != 0 )
1305 if ( wxDynamicCast(win
, wxScrollBar
) )
1306 col
= Get(flags
& wxCONTROL_PRESSED
? SCROLLBAR_PRESSED
1309 #endif // wxUSE_SCROLLBAR
1317 wxColour
wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col
) const
1321 // use the system colours under Windows
1322 #if defined(__WXMSW__)
1323 case WINDOW
: return wxColour(GetSysColor(COLOR_WINDOW
));
1325 case CONTROL_PRESSED
:
1326 case CONTROL_CURRENT
:
1327 case CONTROL
: return wxColour(GetSysColor(COLOR_BTNFACE
));
1329 case CONTROL_TEXT
: return wxColour(GetSysColor(COLOR_BTNTEXT
));
1331 #if defined(COLOR_3DLIGHT)
1332 case SCROLLBAR
: return wxColour(GetSysColor(COLOR_3DLIGHT
));
1334 case SCROLLBAR
: return wxColour(0xe0e0e0);
1336 case SCROLLBAR_PRESSED
: return wxColour(GetSysColor(COLOR_BTNTEXT
));
1338 case HIGHLIGHT
: return wxColour(GetSysColor(COLOR_HIGHLIGHT
));
1339 case HIGHLIGHT_TEXT
: return wxColour(GetSysColor(COLOR_HIGHLIGHTTEXT
));
1341 #if defined(COLOR_3DDKSHADOW)
1342 case SHADOW_DARK
: return wxColour(GetSysColor(COLOR_3DDKSHADOW
));
1344 case SHADOW_DARK
: return wxColour(GetSysColor(COLOR_3DHADOW
));
1347 case CONTROL_TEXT_DISABLED
:
1348 case SHADOW_HIGHLIGHT
: return wxColour(GetSysColor(COLOR_BTNHIGHLIGHT
));
1350 case SHADOW_IN
: return wxColour(GetSysColor(COLOR_BTNFACE
));
1352 case CONTROL_TEXT_DISABLED_SHADOW
:
1353 case SHADOW_OUT
: return wxColour(GetSysColor(COLOR_BTNSHADOW
));
1355 case TITLEBAR
: return wxColour(GetSysColor(COLOR_INACTIVECAPTION
));
1356 case TITLEBAR_ACTIVE
: return wxColour(GetSysColor(COLOR_ACTIVECAPTION
));
1357 case TITLEBAR_TEXT
: return wxColour(GetSysColor(COLOR_INACTIVECAPTIONTEXT
));
1358 case TITLEBAR_ACTIVE_TEXT
: return wxColour(GetSysColor(COLOR_CAPTIONTEXT
));
1360 case DESKTOP
: return wxColour(0x808000);
1362 // use the standard Windows colours elsewhere
1363 case WINDOW
: return *wxWHITE
;
1365 case CONTROL_PRESSED
:
1366 case CONTROL_CURRENT
:
1367 case CONTROL
: return wxColour(0xc0c0c0);
1369 case CONTROL_TEXT
: return *wxBLACK
;
1371 case SCROLLBAR
: return wxColour(0xe0e0e0);
1372 case SCROLLBAR_PRESSED
: return *wxBLACK
;
1374 case HIGHLIGHT
: return wxColour(0x800000);
1375 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
1377 case SHADOW_DARK
: return *wxBLACK
;
1379 case CONTROL_TEXT_DISABLED
:return wxColour(0xe0e0e0);
1380 case SHADOW_HIGHLIGHT
: return wxColour(0xffffff);
1382 case SHADOW_IN
: return wxColour(0xc0c0c0);
1384 case CONTROL_TEXT_DISABLED_SHADOW
:
1385 case SHADOW_OUT
: return wxColour(0x7f7f7f);
1387 case TITLEBAR
: return wxColour(0xaeaaae);
1388 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
1389 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
1390 case TITLEBAR_ACTIVE_TEXT
:return *wxWHITE
;
1392 case DESKTOP
: return wxColour(0x808000);
1395 case GAUGE
: return Get(HIGHLIGHT
);
1399 wxFAIL_MSG(_T("invalid standard colour"));
1404 // ============================================================================
1406 // ============================================================================
1408 // ----------------------------------------------------------------------------
1410 // ----------------------------------------------------------------------------
1412 wxWin32Renderer::wxWin32Renderer(const wxColourScheme
*scheme
)
1413 : wxStdRenderer(scheme
)
1416 m_sizeScrollbarArrow
= wxSize(16, 16);
1418 m_titlebarFont
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
1419 m_titlebarFont
.SetWeight(wxFONTWEIGHT_BOLD
);
1421 // init the arrow bitmaps
1422 static const size_t ARROW_WIDTH
= 7;
1423 static const size_t ARROW_LENGTH
= 4;
1426 wxMemoryDC dcNormal
,
1429 for ( size_t n
= 0; n
< Arrow_Max
; n
++ )
1431 bool isVertical
= n
> Arrow_Right
;
1444 // disabled arrow is larger because of the shadow
1445 m_bmpArrows
[Arrow_Normal
][n
].Create(w
, h
);
1446 m_bmpArrows
[Arrow_Disabled
][n
].Create(w
+ 1, h
+ 1);
1448 dcNormal
.SelectObject(m_bmpArrows
[Arrow_Normal
][n
]);
1449 dcDisabled
.SelectObject(m_bmpArrows
[Arrow_Disabled
][n
]);
1451 dcNormal
.SetBackground(*wxWHITE_BRUSH
);
1452 dcDisabled
.SetBackground(*wxWHITE_BRUSH
);
1456 dcNormal
.SetPen(m_penBlack
);
1457 dcDisabled
.SetPen(m_penDarkGrey
);
1459 // calculate the position of the point of the arrow
1463 x1
= (ARROW_WIDTH
- 1)/2;
1464 y1
= n
== Arrow_Up
? 0 : ARROW_LENGTH
- 1;
1468 x1
= n
== Arrow_Left
? 0 : ARROW_LENGTH
- 1;
1469 y1
= (ARROW_WIDTH
- 1)/2;
1480 for ( size_t i
= 0; i
< ARROW_LENGTH
; i
++ )
1482 dcNormal
.DrawLine(x1
, y1
, x2
, y2
);
1483 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1490 if ( n
== Arrow_Up
)
1501 else // left or right arrow
1506 if ( n
== Arrow_Left
)
1519 // draw the shadow for the disabled one
1520 dcDisabled
.SetPen(m_penHighlight
);
1525 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1529 x1
= ARROW_LENGTH
- 1;
1530 y1
= (ARROW_WIDTH
- 1)/2 + 1;
1533 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1534 dcDisabled
.DrawLine(++x1
, y1
, x2
, ++y2
);
1539 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1543 x1
= ARROW_WIDTH
- 1;
1545 x2
= (ARROW_WIDTH
- 1)/2;
1547 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1548 dcDisabled
.DrawLine(++x1
, y1
, x2
, ++y2
);
1553 // create the inverted bitmap but only for the right arrow as we only
1554 // use it for the menus
1555 if ( n
== Arrow_Right
)
1557 m_bmpArrows
[Arrow_Inverted
][n
].Create(w
, h
);
1558 dcInverse
.SelectObject(m_bmpArrows
[Arrow_Inverted
][n
]);
1560 dcInverse
.Blit(0, 0, w
, h
,
1563 dcInverse
.SelectObject(wxNullBitmap
);
1565 mask
= new wxMask(m_bmpArrows
[Arrow_Inverted
][n
], *wxBLACK
);
1566 m_bmpArrows
[Arrow_Inverted
][n
].SetMask(mask
);
1568 m_bmpArrows
[Arrow_InvertedDisabled
][n
].Create(w
, h
);
1569 dcInverse
.SelectObject(m_bmpArrows
[Arrow_InvertedDisabled
][n
]);
1571 dcInverse
.Blit(0, 0, w
, h
,
1574 dcInverse
.SelectObject(wxNullBitmap
);
1576 mask
= new wxMask(m_bmpArrows
[Arrow_InvertedDisabled
][n
], *wxBLACK
);
1577 m_bmpArrows
[Arrow_InvertedDisabled
][n
].SetMask(mask
);
1580 dcNormal
.SelectObject(wxNullBitmap
);
1581 dcDisabled
.SelectObject(wxNullBitmap
);
1583 mask
= new wxMask(m_bmpArrows
[Arrow_Normal
][n
], *wxWHITE
);
1584 m_bmpArrows
[Arrow_Normal
][n
].SetMask(mask
);
1585 mask
= new wxMask(m_bmpArrows
[Arrow_Disabled
][n
], *wxWHITE
);
1586 m_bmpArrows
[Arrow_Disabled
][n
].SetMask(mask
);
1588 m_bmpArrows
[Arrow_Pressed
][n
] = m_bmpArrows
[Arrow_Normal
][n
];
1591 // init the frame buttons bitmaps
1592 m_bmpFrameButtons
[FrameButton_Close
] = wxBitmap(frame_button_close_xpm
);
1593 m_bmpFrameButtons
[FrameButton_Minimize
] = wxBitmap(frame_button_minimize_xpm
);
1594 m_bmpFrameButtons
[FrameButton_Maximize
] = wxBitmap(frame_button_maximize_xpm
);
1595 m_bmpFrameButtons
[FrameButton_Restore
] = wxBitmap(frame_button_restore_xpm
);
1596 m_bmpFrameButtons
[FrameButton_Help
] = wxBitmap(frame_button_help_xpm
);
1599 bool wxWin32Renderer::AreScrollbarsInsideBorder() const
1604 // ----------------------------------------------------------------------------
1606 // ----------------------------------------------------------------------------
1608 void wxWin32Renderer::DrawLabel(wxDC
& dc
,
1609 const wxString
& label
,
1616 // the underscores are not drawn for focused controls in wxMSW
1617 if ( flags
& wxCONTROL_FOCUSED
)
1622 if ( flags
& wxCONTROL_DISABLED
)
1624 // the combination of wxCONTROL_SELECTED and wxCONTROL_DISABLED
1625 // currently only can happen for a menu item and it seems that Windows
1626 // doesn't draw the shadow in this case, so we don't do it neither
1627 if ( flags
& wxCONTROL_SELECTED
)
1629 // just make the label text greyed out
1630 dc
.SetTextForeground(m_penDarkGrey
.GetColour());
1632 flags
&= ~wxCONTROL_DISABLED
;
1636 wxStdRenderer::DrawLabel(dc
, label
, rect
, flags
, alignment
,
1637 indexAccel
, rectBounds
);
1640 void wxWin32Renderer::DrawFrameWithLabel(wxDC
& dc
,
1641 const wxString
& label
,
1642 const wxRect
& rectFrame
,
1643 const wxRect
& rectText
,
1649 label2
<< _T(' ') << label
<< _T(' ');
1650 if ( indexAccel
!= -1 )
1652 // adjust it as we prepended a space
1656 wxStdRenderer::DrawFrameWithLabel(dc
, label2
, rectFrame
, rectText
,
1657 flags
, alignment
, indexAccel
);
1660 void wxWin32Renderer::DrawButtonLabel(wxDC
& dc
,
1661 const wxString
& label
,
1662 const wxBitmap
& image
,
1669 // the underscores are not drawn for focused controls in wxMSW
1670 if ( flags
& wxCONTROL_PRESSED
)
1675 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
, alignment
,
1676 indexAccel
, rectBounds
);
1679 void wxWin32Renderer::DrawButtonBorder(wxDC
& dc
,
1680 const wxRect
& rectTotal
,
1684 wxRect rect
= rectTotal
;
1686 wxPen
penOut(*wxBLACK
);
1687 if ( flags
& wxCONTROL_PRESSED
)
1689 // button pressed: draw a double border around it
1690 DrawRect(dc
, &rect
, penOut
);
1691 DrawRect(dc
, &rect
, m_penDarkGrey
);
1693 else // button not pressed
1695 if ( flags
& (wxCONTROL_FOCUSED
| wxCONTROL_ISDEFAULT
) )
1697 // button either default or focused (or both): add an extra border
1699 DrawRect(dc
, &rect
, penOut
);
1702 // now draw a normal button border
1703 DrawRaisedBorder(dc
, &rect
);
1710 // ----------------------------------------------------------------------------
1711 // (check)listbox items
1712 // ----------------------------------------------------------------------------
1714 void wxWin32Renderer::DrawCheckItem(wxDC
& dc
,
1715 const wxString
& label
,
1716 const wxBitmap
& bitmap
,
1725 else // use default bitmap
1727 IndicatorStatus i
= flags
& wxCONTROL_CHECKED
1728 ? IndicatorStatus_Checked
1729 : IndicatorStatus_Unchecked
;
1731 if ( !m_bmpCheckBitmaps
[i
].Ok() )
1733 m_bmpCheckBitmaps
[i
] = wxBitmap(ms_xpmChecked
[i
]);
1736 bmp
= m_bmpCheckBitmaps
[i
];
1739 dc
.DrawBitmap(bmp
, rect
.x
, rect
.y
+ (rect
.height
- bmp
.GetHeight()) / 2 - 1,
1740 true /* use mask */);
1742 wxRect rectLabel
= rect
;
1743 int bmpWidth
= bmp
.GetWidth();
1744 rectLabel
.x
+= bmpWidth
;
1745 rectLabel
.width
-= bmpWidth
;
1747 DrawItem(dc
, label
, rectLabel
, flags
);
1750 // ----------------------------------------------------------------------------
1751 // check/radio buttons
1752 // ----------------------------------------------------------------------------
1754 wxBitmap
wxWin32Renderer::GetIndicator(IndicatorType indType
, int flags
)
1756 IndicatorState indState
;
1757 IndicatorStatus indStatus
;
1758 GetIndicatorsFromFlags(flags
, indState
, indStatus
);
1760 wxBitmap bmp
= m_bmpIndicators
[indType
][indState
][indStatus
];
1763 const char **xpm
= ms_xpmIndicators
[indType
][indState
][indStatus
];
1766 // create and cache it
1767 bmp
= wxBitmap(xpm
);
1768 m_bmpIndicators
[indType
][indState
][indStatus
] = bmp
;
1776 void wxWin32Renderer::DrawToolBarButton(wxDC
& dc
,
1777 const wxString
& label
,
1778 const wxBitmap
& bitmap
,
1779 const wxRect
& rectOrig
,
1784 if (style
== wxTOOL_STYLE_BUTTON
)
1786 wxRect rect
= rectOrig
;
1787 rect
.Deflate(BORDER_THICKNESS
);
1789 if ( flags
& wxCONTROL_PRESSED
)
1791 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
);
1793 else if ( flags
& wxCONTROL_CURRENT
)
1795 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
);
1798 if(tbarStyle
& wxTB_TEXT
)
1800 if(tbarStyle
& wxTB_HORIZONTAL
)
1802 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1806 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1811 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1812 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1813 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1816 else if (style
== wxTOOL_STYLE_SEPARATOR
)
1818 // leave a small gap aroudn the line, also account for the toolbar
1820 if(rectOrig
.height
> rectOrig
.width
)
1823 DrawVerticalLine(dc
, rectOrig
.x
+ rectOrig
.width
/2,
1824 rectOrig
.y
+ 2*BORDER_THICKNESS
,
1825 rectOrig
.GetBottom() - BORDER_THICKNESS
);
1830 DrawHorizontalLine(dc
, rectOrig
.y
+ rectOrig
.height
/2,
1831 rectOrig
.x
+ 2*BORDER_THICKNESS
,
1832 rectOrig
.GetRight() - BORDER_THICKNESS
);
1835 // don't draw wxTOOL_STYLE_CONTROL
1837 #endif // wxUSE_TOOLBAR
1839 // ----------------------------------------------------------------------------
1841 // ----------------------------------------------------------------------------
1843 void wxWin32Renderer::DrawTab(wxDC
& dc
,
1844 const wxRect
& rectOrig
,
1846 const wxString
& label
,
1847 const wxBitmap
& bitmap
,
1851 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1852 #define REVERSE_FOR_VERTICAL(X,Y) \
1853 SELECT_FOR_VERTICAL(X,Y) \
1855 SELECT_FOR_VERTICAL(Y,X)
1857 wxRect rect
= rectOrig
;
1859 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1861 // the current tab is drawn indented (to the top for default case) and
1862 // bigger than the other ones
1863 const wxSize indent
= GetTabIndent();
1864 if ( flags
& wxCONTROL_SELECTED
)
1866 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1867 SELECT_FOR_VERTICAL( 0, indent
.y
));
1871 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1878 rect
.height
+= indent
.y
;
1885 rect
.width
+= indent
.x
;
1890 // draw the text, image and the focus around them (if necessary)
1891 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1892 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1894 rectLabel
.Deflate(1, 1);
1897 // draw it horizontally into memory and rotate for screen
1899 wxBitmap bitmapRotated
,
1900 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1901 rectLabel
.y
+ rectLabel
.height
);
1902 dcMem
.SelectObject(bitmapMem
);
1903 dcMem
.SetBackground(dc
.GetBackground());
1904 dcMem
.SetFont(dc
.GetFont());
1905 dcMem
.SetTextForeground(dc
.GetTextForeground());
1909 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1912 #endif // wxUSE_IMAGE
1914 DrawButtonLabel(dcMem
, label
, bitmapRotated
, rectLabel
,
1915 flags
, wxALIGN_CENTRE
, indexAccel
);
1916 dcMem
.SelectObject(wxNullBitmap
);
1917 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1919 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
));
1920 #endif // wxUSE_IMAGE
1921 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1925 DrawButtonLabel(dc
, label
, bitmap
, rectLabel
,
1926 flags
, wxALIGN_CENTRE
, indexAccel
);
1929 // now draw the tab border itself (maybe use DrawRoundedRectangle()?)
1930 static const wxCoord CUTOFF
= 2; // radius of the rounded corner
1931 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1932 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1933 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1934 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1936 // FIXME: all this code will break if the tab indent or the border width,
1937 // it is tied to the fact that both of them are equal to 2
1943 // left orientation looks like top but IsVertical makes x and y reversed
1945 // top is not vertical so use coordinates in written order
1946 dc
.SetPen(m_penHighlight
);
1947 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1948 REVERSE_FOR_VERTICAL(x
, y
+ CUTOFF
));
1949 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
+ CUTOFF
),
1950 REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y
));
1951 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y
),
1952 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y
));
1954 dc
.SetPen(m_penBlack
);
1955 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1956 REVERSE_FOR_VERTICAL(x2
, y
+ CUTOFF
));
1957 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
+ CUTOFF
),
1958 REVERSE_FOR_VERTICAL(x2
- CUTOFF
, y
));
1960 dc
.SetPen(m_penDarkGrey
);
1961 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1962 REVERSE_FOR_VERTICAL(x2
- 1, y
+ CUTOFF
- 1));
1964 if ( flags
& wxCONTROL_SELECTED
)
1966 dc
.SetPen(m_penLightGrey
);
1968 // overwrite the part of the border below this tab
1969 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1970 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1972 // and the shadow of the tab to the left of us
1973 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ CUTOFF
+ 1),
1974 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1979 // right orientation looks like bottom but IsVertical makes x and y reversed
1981 // bottom is not vertical so use coordinates in written order
1982 dc
.SetPen(m_penHighlight
);
1983 // we need to continue one pixel further to overwrite the corner of
1984 // the border for the selected tab
1985 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1986 REVERSE_FOR_VERTICAL(x
, y2
- CUTOFF
));
1987 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
- CUTOFF
),
1988 REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
));
1990 dc
.SetPen(m_penBlack
);
1991 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
),
1992 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y2
));
1993 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1994 REVERSE_FOR_VERTICAL(x2
, y2
- CUTOFF
));
1995 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
- CUTOFF
),
1996 REVERSE_FOR_VERTICAL(x2
- CUTOFF
, y2
));
1998 dc
.SetPen(m_penDarkGrey
);
1999 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
- 1),
2000 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y2
- 1));
2001 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
2002 REVERSE_FOR_VERTICAL(x2
- 1, y2
- CUTOFF
+ 1));
2004 if ( flags
& wxCONTROL_SELECTED
)
2006 dc
.SetPen(m_penLightGrey
);
2008 // overwrite the part of the (double!) border above this tab
2009 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
2010 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
2011 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
2012 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
2014 // and the shadow of the tab to the left of us
2015 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- CUTOFF
),
2016 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
2021 #undef SELECT_FOR_VERTICAL
2022 #undef REVERSE_FOR_VERTICAL
2027 // ----------------------------------------------------------------------------
2029 // ----------------------------------------------------------------------------
2032 wxWin32Renderer::GetSliderThumbSize(const wxRect
& WXUNUSED(rect
),
2034 wxOrientation orient
) const
2037 wxCoord width
= wxMax (lenThumb
, SLIDER_THUMB_LENGTH
) / 2;
2038 wxCoord height
= wxMax (lenThumb
, SLIDER_THUMB_LENGTH
);
2040 if (orient
== wxHORIZONTAL
)
2054 wxRect
wxWin32Renderer::GetSliderShaftRect(const wxRect
& rectOrig
,
2056 wxOrientation orient
,
2059 bool transpose
= (orient
== wxVERTICAL
);
2060 bool left
= ((style
& wxSL_AUTOTICKS
) != 0) &
2061 (((style
& wxSL_TOP
) != 0) & !transpose
|
2062 ((style
& wxSL_LEFT
) != 0) & transpose
|
2063 ((style
& wxSL_BOTH
) != 0));
2064 bool right
= ((style
& wxSL_AUTOTICKS
) != 0) &
2065 (((style
& wxSL_BOTTOM
) != 0) & !transpose
|
2066 ((style
& wxSL_RIGHT
) != 0) & transpose
|
2067 ((style
& wxSL_BOTH
) != 0));
2069 wxRect rect
= rectOrig
;
2071 wxSize sizeThumb
= GetSliderThumbSize (rect
, lenThumb
, orient
);
2073 if (orient
== wxHORIZONTAL
) {
2074 rect
.x
+= SLIDER_MARGIN
;
2077 rect
.y
+= wxMax ((rect
.height
- 2*BORDER_THICKNESS
) / 2, sizeThumb
.y
/2);
2081 rect
.y
+= wxMax ((rect
.height
- 2*BORDER_THICKNESS
- sizeThumb
.y
/2), sizeThumb
.y
/2);
2085 rect
.y
+= sizeThumb
.y
/2;
2087 rect
.width
-= 2*SLIDER_MARGIN
;
2088 rect
.height
= 2*BORDER_THICKNESS
;
2092 rect
.y
+= SLIDER_MARGIN
;
2095 rect
.x
+= wxMax ((rect
.width
- 2*BORDER_THICKNESS
) / 2, sizeThumb
.x
/2);
2099 rect
.x
+= wxMax ((rect
.width
- 2*BORDER_THICKNESS
- sizeThumb
.x
/2), sizeThumb
.x
/2);
2103 rect
.x
+= sizeThumb
.x
/2;
2105 rect
.width
= 2*BORDER_THICKNESS
;
2106 rect
.height
-= 2*SLIDER_MARGIN
;
2112 void wxWin32Renderer::DrawSliderShaft(wxDC
& dc
,
2113 const wxRect
& rectOrig
,
2115 wxOrientation orient
,
2120 /* show shaft geometry
2138 if (flags
& wxCONTROL_FOCUSED
) {
2139 DrawFocusRect(dc
, rectOrig
);
2142 wxRect rect
= GetSliderShaftRect(rectOrig
, lenThumb
, orient
, style
);
2144 if (rectShaft
) *rectShaft
= rect
;
2146 DrawSunkenBorder(dc
, &rect
);
2149 void wxWin32Renderer::DrawSliderThumb(wxDC
& dc
,
2151 wxOrientation orient
,
2155 /* show thumb geometry
2164 H D B where H is highlight colour
2178 The interior of this shape is filled with the hatched brush if the thumb
2182 DrawBackground(dc
, wxNullColour
, rect
, flags
);
2184 bool transpose
= (orient
== wxVERTICAL
);
2185 bool left
= ((style
& wxSL_AUTOTICKS
) != 0) &
2186 (((style
& wxSL_TOP
) != 0) & !transpose
|
2187 ((style
& wxSL_LEFT
) != 0) & transpose
) &
2188 ((style
& wxSL_BOTH
) == 0);
2189 bool right
= ((style
& wxSL_AUTOTICKS
) != 0) &
2190 (((style
& wxSL_BOTTOM
) != 0) & !transpose
|
2191 ((style
& wxSL_RIGHT
) != 0) & transpose
) &
2192 ((style
& wxSL_BOTH
) == 0);
2194 wxCoord sizeArrow
= (transpose
? rect
.height
: rect
.width
) / 2;
2195 wxCoord c
= ((transpose
? rect
.height
: rect
.width
) - 2*sizeArrow
);
2197 wxCoord x1
, x2
, x3
, y1
, y2
, y3
, y4
;
2198 x1
= (transpose
? rect
.y
: rect
.x
);
2199 x2
= (transpose
? rect
.GetBottom() : rect
.GetRight());
2200 x3
= (x1
-1+c
) + sizeArrow
;
2201 y1
= (transpose
? rect
.x
: rect
.y
);
2202 y2
= (transpose
? rect
.GetRight() : rect
.GetBottom());
2203 y3
= (left
? (y1
-1+c
) + sizeArrow
: y1
);
2204 y4
= (right
? (y2
+1-c
) - sizeArrow
: y2
);
2206 dc
.SetPen(m_penBlack
);
2208 DrawLine(dc
, x3
+1-c
, y1
, x2
, y3
, transpose
);
2210 DrawLine(dc
, x2
, y3
, x2
, y4
, transpose
);
2213 DrawLine(dc
, x3
+1-c
, y2
, x2
, y4
, transpose
);
2217 DrawLine(dc
, x1
, y2
, x2
, y2
, transpose
);
2220 dc
.SetPen(m_penDarkGrey
);
2221 DrawLine(dc
, x2
-1, y3
+1, x2
-1, y4
-1, transpose
);
2223 DrawLine(dc
, x3
+1-c
, y2
-1, x2
-1, y4
, transpose
);
2227 DrawLine(dc
, x1
+1, y2
-1, x2
-1, y2
-1, transpose
);
2230 dc
.SetPen(m_penHighlight
);
2233 DrawLine(dc
, x1
, y3
, x3
, y1
, transpose
);
2234 DrawLine(dc
, x3
+1-c
, y1
+1, x2
-1, y3
, transpose
);
2238 DrawLine(dc
, x1
, y1
, x2
, y1
, transpose
);
2240 DrawLine(dc
, x1
, y3
, x1
, y4
, transpose
);
2243 DrawLine(dc
, x1
, y4
, x3
+c
, y2
+c
, transpose
);
2246 if (flags
& wxCONTROL_PRESSED
) {
2247 // TODO: MSW fills the entire area inside, not just the rect
2248 wxRect rectInt
= rect
;
2251 rectInt
.SetLeft(y3
);
2252 rectInt
.SetRight(y4
);
2257 rectInt
.SetBottom(y4
);
2261 #if !defined(__WXMGL__)
2262 static const char *stipple_xpm
[] = {
2263 /* columns rows colors chars-per-pixel */
2272 // VS: MGL can only do 8x8 stipple brushes
2273 static const char *stipple_xpm
[] = {
2274 /* columns rows colors chars-per-pixel */
2289 dc
.SetBrush(wxBrush(stipple_xpm
));
2291 dc
.SetTextForeground(wxSCHEME_COLOUR(m_scheme
, SHADOW_HIGHLIGHT
));
2292 dc
.SetTextBackground(wxSCHEME_COLOUR(m_scheme
, CONTROL
));
2293 dc
.SetPen(*wxTRANSPARENT_PEN
);
2294 dc
.DrawRectangle(rectInt
);
2298 void wxWin32Renderer::DrawSliderTicks(wxDC
& dc
,
2301 wxOrientation orient
,
2305 int WXUNUSED(flags
),
2308 /* show ticks geometry
2323 if (end
== start
) return;
2325 bool transpose
= (orient
== wxVERTICAL
);
2326 bool left
= ((style
& wxSL_AUTOTICKS
) != 0) &
2327 (((style
& wxSL_TOP
) != 0) & !transpose
|
2328 ((style
& wxSL_LEFT
) != 0) & transpose
|
2329 ((style
& wxSL_BOTH
) != 0));
2330 bool right
= ((style
& wxSL_AUTOTICKS
) != 0) &
2331 (((style
& wxSL_BOTTOM
) != 0) & !transpose
|
2332 ((style
& wxSL_RIGHT
) != 0) & transpose
|
2333 ((style
& wxSL_BOTH
) != 0));
2335 // default thumb size
2336 wxSize sizeThumb
= GetSliderThumbSize (rect
, 0, orient
);
2337 wxCoord defaultLen
= (transpose
? sizeThumb
.x
: sizeThumb
.y
);
2339 // normal thumb size
2340 sizeThumb
= GetSliderThumbSize (rect
, lenThumb
, orient
);
2341 wxCoord widthThumb
= (transpose
? sizeThumb
.y
: sizeThumb
.x
);
2343 wxRect rectShaft
= GetSliderShaftRect (rect
, lenThumb
, orient
, style
);
2345 wxCoord x1
, x2
, y1
, y2
, y3
, y4
, len
;
2346 x1
= (transpose
? rectShaft
.y
: rectShaft
.x
) + widthThumb
/2;
2347 x2
= (transpose
? rectShaft
.GetBottom() : rectShaft
.GetRight()) - widthThumb
/2;
2348 y1
= (transpose
? rectShaft
.x
: rectShaft
.y
) - defaultLen
/2;
2349 y2
= (transpose
? rectShaft
.GetRight() : rectShaft
.GetBottom()) + defaultLen
/2;
2350 y3
= (transpose
? rect
.x
: rect
.y
);
2351 y4
= (transpose
? rect
.GetRight() : rect
.GetBottom());
2354 dc
.SetPen(m_penBlack
);
2356 int range
= end
- start
;
2357 for ( int n
= 0; n
< range
; n
+= step
) {
2358 wxCoord x
= x1
+ (len
*n
) / range
;
2360 if (left
& (y1
> y3
)) {
2361 DrawLine(dc
, x
, y1
, x
, y3
, orient
== wxVERTICAL
);
2363 if (right
& (y4
> y2
)) {
2364 DrawLine(dc
, x
, y2
, x
, y4
, orient
== wxVERTICAL
);
2367 // always draw the line at the end position
2368 if (left
& (y1
> y3
)) {
2369 DrawLine(dc
, x2
, y1
, x2
, y3
, orient
== wxVERTICAL
);
2371 if (right
& (y4
> y2
)) {
2372 DrawLine(dc
, x2
, y2
, x2
, y4
, orient
== wxVERTICAL
);
2376 #endif // wxUSE_SLIDER
2380 // ----------------------------------------------------------------------------
2382 // ----------------------------------------------------------------------------
2384 // wxWin32MenuGeometryInfo: the wxMenuGeometryInfo used by wxWin32Renderer
2385 class WXDLLEXPORT wxWin32MenuGeometryInfo
: public wxMenuGeometryInfo
2388 virtual wxSize
GetSize() const { return m_size
; }
2390 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
2391 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
2393 wxCoord
GetItemHeight() const { return m_heightItem
; }
2396 // the total size of the menu
2399 // the offset of the start of the menu item label
2402 // the offset of the start of the accel label
2405 // the height of a normal (not separator) item
2406 wxCoord m_heightItem
;
2408 friend wxMenuGeometryInfo
*
2409 wxWin32Renderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
2412 // FIXME: all constants are hardcoded but shouldn't be
2413 static const wxCoord MENU_LEFT_MARGIN
= 9;
2414 static const wxCoord MENU_RIGHT_MARGIN
= 18;
2415 static const wxCoord MENU_VERT_MARGIN
= 3;
2417 // the margin around bitmap/check marks (on each side)
2418 static const wxCoord MENU_BMP_MARGIN
= 2;
2420 // the margin between the labels and accel strings
2421 static const wxCoord MENU_ACCEL_MARGIN
= 8;
2423 // the separator height in pixels: in fact, strangely enough, the real height
2424 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
2426 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
2428 // the size of the standard checkmark bitmap
2429 static const wxCoord MENU_CHECK_SIZE
= 9;
2431 void wxWin32Renderer::DrawMenuBarItem(wxDC
& dc
,
2432 const wxRect
& rectOrig
,
2433 const wxString
& label
,
2437 wxRect rect
= rectOrig
;
2440 wxDCTextColourChanger
colChanger(dc
);
2442 if ( flags
& wxCONTROL_SELECTED
)
2444 colChanger
.Set(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
2446 const wxColour colBg
= wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
);
2449 dc
.DrawRectangle(rect
);
2452 // don't draw the focus rect around menu bar items
2453 DrawLabel(dc
, label
, rect
, flags
& ~wxCONTROL_FOCUSED
,
2454 wxALIGN_CENTRE
, indexAccel
);
2457 void wxWin32Renderer::DrawMenuItem(wxDC
& dc
,
2459 const wxMenuGeometryInfo
& gi
,
2460 const wxString
& label
,
2461 const wxString
& accel
,
2462 const wxBitmap
& bitmap
,
2466 const wxWin32MenuGeometryInfo
& geometryInfo
=
2467 (const wxWin32MenuGeometryInfo
&)gi
;
2472 rect
.width
= geometryInfo
.GetSize().x
;
2473 rect
.height
= geometryInfo
.GetItemHeight();
2475 // draw the selected item specially
2476 wxDCTextColourChanger
colChanger(dc
);
2477 if ( flags
& wxCONTROL_SELECTED
)
2479 colChanger
.Set(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
2481 const wxColour colBg
= wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
);
2484 dc
.DrawRectangle(rect
);
2487 // draw the bitmap: use the bitmap provided or the standard checkmark for
2488 // the checkable items
2489 wxBitmap bmp
= bitmap
;
2490 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKED
) )
2492 bmp
= GetIndicator(IndicatorType_Menu
, flags
);
2497 rect
.SetRight(geometryInfo
.GetLabelOffset());
2498 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
2502 rect
.x
= geometryInfo
.GetLabelOffset();
2503 rect
.SetRight(geometryInfo
.GetAccelOffset());
2505 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
2507 // draw the accel string
2508 rect
.x
= geometryInfo
.GetAccelOffset();
2509 rect
.SetRight(geometryInfo
.GetSize().x
);
2511 // NB: no accel index here
2512 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
2514 // draw the submenu indicator
2515 if ( flags
& wxCONTROL_ISSUBMENU
)
2517 rect
.x
= geometryInfo
.GetSize().x
- MENU_RIGHT_MARGIN
;
2518 rect
.width
= MENU_RIGHT_MARGIN
;
2520 wxArrowStyle arrowStyle
;
2521 if ( flags
& wxCONTROL_DISABLED
)
2522 arrowStyle
= flags
& wxCONTROL_SELECTED
? Arrow_InvertedDisabled
2524 else if ( flags
& wxCONTROL_SELECTED
)
2525 arrowStyle
= Arrow_Inverted
;
2527 arrowStyle
= Arrow_Normal
;
2529 DrawArrow(dc
, rect
, Arrow_Right
, arrowStyle
);
2533 void wxWin32Renderer::DrawMenuSeparator(wxDC
& dc
,
2535 const wxMenuGeometryInfo
& geomInfo
)
2537 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
2540 wxSize
wxWin32Renderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
2542 wxSize size
= sizeText
;
2544 // FIXME: menubar height is configurable under Windows
2551 wxMenuGeometryInfo
*wxWin32Renderer::GetMenuGeometry(wxWindow
*win
,
2552 const wxMenu
& menu
) const
2554 // prepare the dc: for now we draw all the items with the system font
2556 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
2558 // the height of a normal item
2559 wxCoord heightText
= dc
.GetCharHeight();
2564 // the max length of label and accel strings: the menu width is the sum of
2565 // them, even if they're for different items (as the accels should be
2568 // the max length of the bitmap is never 0 as Windows always leaves enough
2569 // space for a check mark indicator
2570 wxCoord widthLabelMax
= 0,
2572 widthBmpMax
= MENU_LEFT_MARGIN
;
2574 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
2576 node
= node
->GetNext() )
2578 // height of this item
2581 wxMenuItem
*item
= node
->GetData();
2582 if ( item
->IsSeparator() )
2584 h
= MENU_SEPARATOR_HEIGHT
;
2586 else // not separator
2591 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
2592 if ( widthLabel
> widthLabelMax
)
2594 widthLabelMax
= widthLabel
;
2598 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
2599 if ( widthAccel
> widthAccelMax
)
2601 widthAccelMax
= widthAccel
;
2604 const wxBitmap
& bmp
= item
->GetBitmap();
2607 wxCoord widthBmp
= bmp
.GetWidth();
2608 if ( widthBmp
> widthBmpMax
)
2609 widthBmpMax
= widthBmp
;
2611 //else if ( item->IsCheckable() ): no need to check for this as
2612 // MENU_LEFT_MARGIN is big enough to show the check mark
2615 h
+= 2*MENU_VERT_MARGIN
;
2617 // remember the item position and height
2618 item
->SetGeometry(height
, h
);
2623 // bundle the metrics into a struct and return it
2624 wxWin32MenuGeometryInfo
*gi
= new wxWin32MenuGeometryInfo
;
2626 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
2627 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
2628 if ( widthAccelMax
> 0 )
2630 // if we actually have any accesl, add a margin
2631 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
2634 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
2636 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
2637 gi
->m_size
.y
= height
;
2642 #endif // wxUSE_MENUS
2646 // ----------------------------------------------------------------------------
2648 // ----------------------------------------------------------------------------
2650 static const wxCoord STATBAR_BORDER_X
= 2;
2651 static const wxCoord STATBAR_BORDER_Y
= 2;
2653 wxSize
wxWin32Renderer::GetStatusBarBorders(wxCoord
*borderBetweenFields
) const
2655 if ( borderBetweenFields
)
2656 *borderBetweenFields
= 2;
2658 return wxSize(STATBAR_BORDER_X
, STATBAR_BORDER_Y
);
2661 void wxWin32Renderer::DrawStatusField(wxDC
& dc
,
2663 const wxString
& label
,
2664 int flags
, int style
/*=0*/)
2668 if ( flags
& wxCONTROL_ISDEFAULT
)
2670 // draw the size grip: it is a normal rect except that in the lower
2671 // right corner we have several bands which may be used for dragging
2672 // the status bar corner
2674 // each band consists of 4 stripes: m_penHighlight, double
2675 // m_penDarkGrey and transparent one
2676 wxCoord x2
= rect
.GetRight(),
2677 y2
= rect
.GetBottom();
2679 // draw the upper left part of the rect normally
2680 if (style
!= wxSB_FLAT
)
2682 if (style
== wxSB_RAISED
)
2683 dc
.SetPen(m_penHighlight
);
2685 dc
.SetPen(m_penDarkGrey
);
2686 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(), rect
.GetLeft(), y2
);
2687 dc
.DrawLine(rect
.GetLeft() + 1, rect
.GetTop(), x2
, rect
.GetTop());
2690 // draw the grey stripes of the grip
2692 wxCoord ofs
= WIDTH_STATUSBAR_GRIP_BAND
- 1;
2693 for ( n
= 0; n
< NUM_STATUSBAR_GRIP_BANDS
; n
++, ofs
+= WIDTH_STATUSBAR_GRIP_BAND
)
2695 dc
.DrawLine(x2
- ofs
+ 1, y2
- 1, x2
, y2
- ofs
);
2696 dc
.DrawLine(x2
- ofs
, y2
- 1, x2
, y2
- ofs
- 1);
2699 // draw the white stripes
2700 dc
.SetPen(m_penHighlight
);
2701 ofs
= WIDTH_STATUSBAR_GRIP_BAND
+ 1;
2702 for ( n
= 0; n
< NUM_STATUSBAR_GRIP_BANDS
; n
++, ofs
+= WIDTH_STATUSBAR_GRIP_BAND
)
2704 dc
.DrawLine(x2
- ofs
+ 1, y2
- 1, x2
, y2
- ofs
);
2707 // draw the remaining rect boundaries
2708 if (style
!= wxSB_FLAT
)
2710 if (style
== wxSB_RAISED
)
2711 dc
.SetPen(m_penDarkGrey
);
2713 dc
.SetPen(m_penHighlight
);
2714 ofs
-= WIDTH_STATUSBAR_GRIP_BAND
;
2715 dc
.DrawLine(x2
, rect
.GetTop(), x2
, y2
- ofs
+ 1);
2716 dc
.DrawLine(rect
.GetLeft(), y2
, x2
- ofs
+ 1, y2
);
2722 rectIn
.width
-= STATUSBAR_GRIP_SIZE
;
2726 if (style
== wxSB_RAISED
)
2727 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
, &rectIn
);
2728 else if (style
!= wxSB_FLAT
)
2729 DrawBorder(dc
, wxBORDER_STATIC
, rect
, flags
, &rectIn
);
2732 rectIn
.Deflate(STATBAR_BORDER_X
, STATBAR_BORDER_Y
);
2734 wxDCClipper
clipper(dc
, rectIn
);
2735 DrawLabel(dc
, label
, rectIn
, flags
, wxALIGN_LEFT
| wxALIGN_CENTRE_VERTICAL
);
2738 #endif // wxUSE_STATUSBAR
2740 // ----------------------------------------------------------------------------
2742 // ----------------------------------------------------------------------------
2744 void wxWin32Renderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
2745 wxBitmap
* WXUNUSED(bmpFocus
),
2746 wxBitmap
*bmpPressed
,
2747 wxBitmap
*bmpDisabled
)
2749 static const wxCoord widthCombo
= 16;
2750 static const wxCoord heightCombo
= 17;
2756 bmpNormal
->Create(widthCombo
, heightCombo
);
2757 dcMem
.SelectObject(*bmpNormal
);
2758 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2759 Arrow_Down
, Arrow_Normal
);
2764 bmpPressed
->Create(widthCombo
, heightCombo
);
2765 dcMem
.SelectObject(*bmpPressed
);
2766 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2767 Arrow_Down
, Arrow_Pressed
);
2772 bmpDisabled
->Create(widthCombo
, heightCombo
);
2773 dcMem
.SelectObject(*bmpDisabled
);
2774 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2775 Arrow_Down
, Arrow_Disabled
);
2779 // ----------------------------------------------------------------------------
2781 // ----------------------------------------------------------------------------
2783 void wxWin32Renderer::DrawArrowBorder(wxDC
& dc
, wxRect
*rect
, bool isPressed
)
2787 DrawRect(dc
, rect
, m_penDarkGrey
);
2789 // the arrow is usually drawn inside border of width 2 and is offset by
2790 // another pixel in both directions when it's pressed - as the border
2791 // in this case is more narrow as well, we have to adjust rect like
2799 DrawAntiSunkenBorder(dc
, rect
);
2803 void wxWin32Renderer::DrawArrow(wxDC
& dc
,
2808 // get the bitmap for this arrow
2809 wxArrowDirection arrowDir
;
2812 case wxLEFT
: arrowDir
= Arrow_Left
; break;
2813 case wxRIGHT
: arrowDir
= Arrow_Right
; break;
2814 case wxUP
: arrowDir
= Arrow_Up
; break;
2815 case wxDOWN
: arrowDir
= Arrow_Down
; break;
2818 wxFAIL_MSG(_T("unknown arrow direction"));
2822 wxArrowStyle arrowStyle
;
2823 if ( flags
& wxCONTROL_PRESSED
)
2825 // can't be pressed and disabled
2826 arrowStyle
= Arrow_Pressed
;
2830 arrowStyle
= flags
& wxCONTROL_DISABLED
? Arrow_Disabled
: Arrow_Normal
;
2833 DrawArrowButton(dc
, rect
, arrowDir
, arrowStyle
);
2836 void wxWin32Renderer::DrawArrow(wxDC
& dc
,
2838 wxArrowDirection arrowDir
,
2839 wxArrowStyle arrowStyle
)
2841 const wxBitmap
& bmp
= m_bmpArrows
[arrowStyle
][arrowDir
];
2843 // under Windows the arrows always have the same size so just centre it in
2844 // the provided rectangle
2845 wxCoord x
= rect
.x
+ (rect
.width
- bmp
.GetWidth()) / 2,
2846 y
= rect
.y
+ (rect
.height
- bmp
.GetHeight()) / 2;
2848 // Windows does it like this...
2849 if ( arrowDir
== Arrow_Left
)
2853 dc
.DrawBitmap(bmp
, x
, y
, true /* use mask */);
2856 void wxWin32Renderer::DrawArrowButton(wxDC
& dc
,
2857 const wxRect
& rectAll
,
2858 wxArrowDirection arrowDir
,
2859 wxArrowStyle arrowStyle
)
2861 wxRect rect
= rectAll
;
2862 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), rect
);
2863 DrawArrowBorder(dc
, &rect
, arrowStyle
== Arrow_Pressed
);
2864 DrawArrow(dc
, rect
, arrowDir
, arrowStyle
);
2867 void wxWin32Renderer::DrawScrollbarThumb(wxDC
& dc
,
2868 wxOrientation
WXUNUSED(orient
),
2870 int WXUNUSED(flags
))
2872 // we don't use the flags, the thumb never changes appearance
2873 wxRect rectThumb
= rect
;
2874 DrawArrowBorder(dc
, &rectThumb
);
2875 DrawBackground(dc
, wxNullColour
, rectThumb
);
2878 void wxWin32Renderer::DrawScrollbarShaft(wxDC
& dc
,
2879 wxOrientation
WXUNUSED(orient
),
2880 const wxRect
& rectBar
,
2883 wxColourScheme::StdColour col
= flags
& wxCONTROL_PRESSED
2884 ? wxColourScheme::SCROLLBAR_PRESSED
2885 : wxColourScheme::SCROLLBAR
;
2886 DrawBackground(dc
, m_scheme
->Get(col
), rectBar
);
2889 void wxWin32Renderer::DrawScrollCorner(wxDC
& dc
, const wxRect
& rect
)
2891 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), rect
);
2894 // ----------------------------------------------------------------------------
2895 // top level windows
2896 // ----------------------------------------------------------------------------
2898 int wxWin32Renderer::HitTestFrame(const wxRect
& rect
, const wxPoint
& pt
, int flags
) const
2900 wxRect client
= GetFrameClientArea(rect
, flags
);
2902 if ( client
.Contains(pt
) )
2903 return wxHT_TOPLEVEL_CLIENT_AREA
;
2905 if ( flags
& wxTOPLEVEL_TITLEBAR
)
2907 wxRect client
= GetFrameClientArea(rect
, flags
& ~wxTOPLEVEL_TITLEBAR
);
2909 if ( flags
& wxTOPLEVEL_ICON
)
2911 if ( wxRect(client
.GetPosition(), GetFrameIconSize()).Contains(pt
) )
2912 return wxHT_TOPLEVEL_ICON
;
2915 wxRect
btnRect(client
.GetRight() - 2 - FRAME_BUTTON_WIDTH
,
2916 client
.GetTop() + (FRAME_TITLEBAR_HEIGHT
-FRAME_BUTTON_HEIGHT
)/2,
2917 FRAME_BUTTON_WIDTH
, FRAME_BUTTON_HEIGHT
);
2919 if ( flags
& wxTOPLEVEL_BUTTON_CLOSE
)
2921 if ( btnRect
.Contains(pt
) )
2922 return wxHT_TOPLEVEL_BUTTON_CLOSE
;
2923 btnRect
.x
-= FRAME_BUTTON_WIDTH
+ 2;
2925 if ( flags
& wxTOPLEVEL_BUTTON_MAXIMIZE
)
2927 if ( btnRect
.Contains(pt
) )
2928 return wxHT_TOPLEVEL_BUTTON_MAXIMIZE
;
2929 btnRect
.x
-= FRAME_BUTTON_WIDTH
;
2931 if ( flags
& wxTOPLEVEL_BUTTON_RESTORE
)
2933 if ( btnRect
.Contains(pt
) )
2934 return wxHT_TOPLEVEL_BUTTON_RESTORE
;
2935 btnRect
.x
-= FRAME_BUTTON_WIDTH
;
2937 if ( flags
& wxTOPLEVEL_BUTTON_ICONIZE
)
2939 if ( btnRect
.Contains(pt
) )
2940 return wxHT_TOPLEVEL_BUTTON_ICONIZE
;
2941 btnRect
.x
-= FRAME_BUTTON_WIDTH
;
2943 if ( flags
& wxTOPLEVEL_BUTTON_HELP
)
2945 if ( btnRect
.Contains(pt
) )
2946 return wxHT_TOPLEVEL_BUTTON_HELP
;
2947 btnRect
.x
-= FRAME_BUTTON_WIDTH
;
2950 if ( pt
.y
>= client
.y
&& pt
.y
< client
.y
+ FRAME_TITLEBAR_HEIGHT
)
2951 return wxHT_TOPLEVEL_TITLEBAR
;
2954 if ( (flags
& wxTOPLEVEL_BORDER
) && !(flags
& wxTOPLEVEL_MAXIMIZED
) )
2956 // we are certainly at one of borders, lets decide which one:
2959 // dirty trick, relies on the way wxHT_TOPLEVEL_XXX are defined!
2960 if ( pt
.x
< client
.x
)
2961 border
|= wxHT_TOPLEVEL_BORDER_W
;
2962 else if ( pt
.x
>= client
.width
+ client
.x
)
2963 border
|= wxHT_TOPLEVEL_BORDER_E
;
2964 if ( pt
.y
< client
.y
)
2965 border
|= wxHT_TOPLEVEL_BORDER_N
;
2966 else if ( pt
.y
>= client
.height
+ client
.y
)
2967 border
|= wxHT_TOPLEVEL_BORDER_S
;
2971 return wxHT_NOWHERE
;
2974 void wxWin32Renderer::DrawFrameTitleBar(wxDC
& dc
,
2976 const wxString
& title
,
2980 int specialButtonFlags
)
2982 if ( (flags
& wxTOPLEVEL_BORDER
) && !(flags
& wxTOPLEVEL_MAXIMIZED
) )
2984 DrawFrameBorder(dc
, rect
, flags
);
2986 if ( flags
& wxTOPLEVEL_TITLEBAR
)
2988 DrawFrameBackground(dc
, rect
, flags
);
2989 if ( flags
& wxTOPLEVEL_ICON
)
2990 DrawFrameIcon(dc
, rect
, icon
, flags
);
2991 DrawFrameTitle(dc
, rect
, title
, flags
);
2993 wxRect client
= GetFrameClientArea(rect
, flags
& ~wxTOPLEVEL_TITLEBAR
);
2995 x
= client
.GetRight() - 2 - FRAME_BUTTON_WIDTH
;
2996 y
= client
.GetTop() + (FRAME_TITLEBAR_HEIGHT
-FRAME_BUTTON_HEIGHT
)/2;
2998 if ( flags
& wxTOPLEVEL_BUTTON_CLOSE
)
3000 DrawFrameButton(dc
, x
, y
, wxTOPLEVEL_BUTTON_CLOSE
,
3001 (specialButton
== wxTOPLEVEL_BUTTON_CLOSE
) ?
3002 specialButtonFlags
: 0);
3003 x
-= FRAME_BUTTON_WIDTH
+ 2;
3005 if ( flags
& wxTOPLEVEL_BUTTON_MAXIMIZE
)
3007 DrawFrameButton(dc
, x
, y
, wxTOPLEVEL_BUTTON_MAXIMIZE
,
3008 (specialButton
== wxTOPLEVEL_BUTTON_MAXIMIZE
) ?
3009 specialButtonFlags
: 0);
3010 x
-= FRAME_BUTTON_WIDTH
;
3012 if ( flags
& wxTOPLEVEL_BUTTON_RESTORE
)
3014 DrawFrameButton(dc
, x
, y
, wxTOPLEVEL_BUTTON_RESTORE
,
3015 (specialButton
== wxTOPLEVEL_BUTTON_RESTORE
) ?
3016 specialButtonFlags
: 0);
3017 x
-= FRAME_BUTTON_WIDTH
;
3019 if ( flags
& wxTOPLEVEL_BUTTON_ICONIZE
)
3021 DrawFrameButton(dc
, x
, y
, wxTOPLEVEL_BUTTON_ICONIZE
,
3022 (specialButton
== wxTOPLEVEL_BUTTON_ICONIZE
) ?
3023 specialButtonFlags
: 0);
3024 x
-= FRAME_BUTTON_WIDTH
;
3026 if ( flags
& wxTOPLEVEL_BUTTON_HELP
)
3028 DrawFrameButton(dc
, x
, y
, wxTOPLEVEL_BUTTON_HELP
,
3029 (specialButton
== wxTOPLEVEL_BUTTON_HELP
) ?
3030 specialButtonFlags
: 0);
3035 void wxWin32Renderer::DrawFrameBorder(wxDC
& dc
,
3039 if ( !(flags
& wxTOPLEVEL_BORDER
) ) return;
3043 DrawShadedRect(dc
, &r
, m_penLightGrey
, m_penBlack
);
3044 DrawShadedRect(dc
, &r
, m_penHighlight
, m_penDarkGrey
);
3045 DrawShadedRect(dc
, &r
, m_penLightGrey
, m_penLightGrey
);
3046 if ( flags
& wxTOPLEVEL_RESIZEABLE
)
3047 DrawShadedRect(dc
, &r
, m_penLightGrey
, m_penLightGrey
);
3050 void wxWin32Renderer::DrawFrameBackground(wxDC
& dc
,
3054 if ( !(flags
& wxTOPLEVEL_TITLEBAR
) ) return;
3056 wxColour col
= (flags
& wxTOPLEVEL_ACTIVE
) ?
3057 wxSCHEME_COLOUR(m_scheme
, TITLEBAR_ACTIVE
) :
3058 wxSCHEME_COLOUR(m_scheme
, TITLEBAR
);
3060 wxRect r
= GetFrameClientArea(rect
, flags
& ~wxTOPLEVEL_TITLEBAR
);
3061 r
.height
= FRAME_TITLEBAR_HEIGHT
;
3063 DrawBackground(dc
, col
, r
);
3066 void wxWin32Renderer::DrawFrameTitle(wxDC
& dc
,
3068 const wxString
& title
,
3071 wxColour col
= (flags
& wxTOPLEVEL_ACTIVE
) ?
3072 wxSCHEME_COLOUR(m_scheme
, TITLEBAR_ACTIVE_TEXT
) :
3073 wxSCHEME_COLOUR(m_scheme
, TITLEBAR_TEXT
);
3075 wxRect r
= GetFrameClientArea(rect
, flags
& ~wxTOPLEVEL_TITLEBAR
);
3076 r
.height
= FRAME_TITLEBAR_HEIGHT
;
3077 if ( flags
& wxTOPLEVEL_ICON
)
3079 r
.x
+= FRAME_TITLEBAR_HEIGHT
;
3080 r
.width
-= FRAME_TITLEBAR_HEIGHT
+ 2;
3088 if ( flags
& wxTOPLEVEL_BUTTON_CLOSE
)
3089 r
.width
-= FRAME_BUTTON_WIDTH
+ 2;
3090 if ( flags
& wxTOPLEVEL_BUTTON_MAXIMIZE
)
3091 r
.width
-= FRAME_BUTTON_WIDTH
;
3092 if ( flags
& wxTOPLEVEL_BUTTON_RESTORE
)
3093 r
.width
-= FRAME_BUTTON_WIDTH
;
3094 if ( flags
& wxTOPLEVEL_BUTTON_ICONIZE
)
3095 r
.width
-= FRAME_BUTTON_WIDTH
;
3096 if ( flags
& wxTOPLEVEL_BUTTON_HELP
)
3097 r
.width
-= FRAME_BUTTON_WIDTH
;
3099 dc
.SetFont(m_titlebarFont
);
3100 dc
.SetTextForeground(col
);
3103 dc
.GetTextExtent(title
, &textW
, NULL
);
3104 if ( textW
> r
.width
)
3106 // text is too big, let's shorten it and add "..." after it:
3107 size_t len
= title
.length();
3108 wxCoord WSoFar
, letterW
;
3110 dc
.GetTextExtent(wxT("..."), &WSoFar
, NULL
);
3111 if ( WSoFar
> r
.width
)
3113 // not enough space to draw anything
3119 for (size_t i
= 0; i
< len
; i
++)
3121 dc
.GetTextExtent(title
[i
], &letterW
, NULL
);
3122 if ( letterW
+ WSoFar
> r
.width
)
3128 dc
.DrawLabel(s
, wxNullBitmap
, r
,
3129 wxALIGN_LEFT
| wxALIGN_CENTRE_VERTICAL
);
3132 dc
.DrawLabel(title
, wxNullBitmap
, r
,
3133 wxALIGN_LEFT
| wxALIGN_CENTRE_VERTICAL
);
3136 void wxWin32Renderer::DrawFrameIcon(wxDC
& dc
,
3143 wxRect r
= GetFrameClientArea(rect
, flags
& ~wxTOPLEVEL_TITLEBAR
);
3144 dc
.DrawIcon(icon
, r
.x
, r
.y
);
3148 void wxWin32Renderer::DrawFrameButton(wxDC
& dc
,
3149 wxCoord x
, wxCoord y
,
3153 wxRect
r(x
, y
, FRAME_BUTTON_WIDTH
, FRAME_BUTTON_HEIGHT
);
3158 case wxTOPLEVEL_BUTTON_CLOSE
: idx
= FrameButton_Close
; break;
3159 case wxTOPLEVEL_BUTTON_MAXIMIZE
: idx
= FrameButton_Maximize
; break;
3160 case wxTOPLEVEL_BUTTON_ICONIZE
: idx
= FrameButton_Minimize
; break;
3161 case wxTOPLEVEL_BUTTON_RESTORE
: idx
= FrameButton_Restore
; break;
3162 case wxTOPLEVEL_BUTTON_HELP
: idx
= FrameButton_Help
; break;
3164 wxFAIL_MSG(wxT("incorrect button specification"));
3167 if ( flags
& wxCONTROL_PRESSED
)
3169 DrawShadedRect(dc
, &r
, m_penBlack
, m_penHighlight
);
3170 DrawShadedRect(dc
, &r
, m_penDarkGrey
, m_penLightGrey
);
3171 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), r
);
3172 dc
.DrawBitmap(m_bmpFrameButtons
[idx
], r
.x
+1, r
.y
+1, true);
3176 DrawShadedRect(dc
, &r
, m_penHighlight
, m_penBlack
);
3177 DrawShadedRect(dc
, &r
, m_penLightGrey
, m_penDarkGrey
);
3178 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), r
);
3179 dc
.DrawBitmap(m_bmpFrameButtons
[idx
], r
.x
, r
.y
, true);
3184 wxRect
wxWin32Renderer::GetFrameClientArea(const wxRect
& rect
,
3189 if ( (flags
& wxTOPLEVEL_BORDER
) && !(flags
& wxTOPLEVEL_MAXIMIZED
) )
3191 int border
= (flags
& wxTOPLEVEL_RESIZEABLE
) ?
3192 RESIZEABLE_FRAME_BORDER_THICKNESS
:
3193 FRAME_BORDER_THICKNESS
;
3196 if ( flags
& wxTOPLEVEL_TITLEBAR
)
3198 r
.y
+= FRAME_TITLEBAR_HEIGHT
;
3199 r
.height
-= FRAME_TITLEBAR_HEIGHT
;
3205 wxSize
wxWin32Renderer::GetFrameTotalSize(const wxSize
& clientSize
,
3208 wxSize
s(clientSize
);
3210 if ( (flags
& wxTOPLEVEL_BORDER
) && !(flags
& wxTOPLEVEL_MAXIMIZED
) )
3212 int border
= (flags
& wxTOPLEVEL_RESIZEABLE
) ?
3213 RESIZEABLE_FRAME_BORDER_THICKNESS
:
3214 FRAME_BORDER_THICKNESS
;
3218 if ( flags
& wxTOPLEVEL_TITLEBAR
)
3219 s
.y
+= FRAME_TITLEBAR_HEIGHT
;
3224 wxSize
wxWin32Renderer::GetFrameMinSize(int flags
) const
3228 if ( (flags
& wxTOPLEVEL_BORDER
) && !(flags
& wxTOPLEVEL_MAXIMIZED
) )
3230 int border
= (flags
& wxTOPLEVEL_RESIZEABLE
) ?
3231 RESIZEABLE_FRAME_BORDER_THICKNESS
:
3232 FRAME_BORDER_THICKNESS
;
3237 if ( flags
& wxTOPLEVEL_TITLEBAR
)
3239 s
.y
+= FRAME_TITLEBAR_HEIGHT
;
3241 if ( flags
& wxTOPLEVEL_ICON
)
3242 s
.x
+= FRAME_TITLEBAR_HEIGHT
+ 2;
3243 if ( flags
& wxTOPLEVEL_BUTTON_CLOSE
)
3244 s
.x
+= FRAME_BUTTON_WIDTH
+ 2;
3245 if ( flags
& wxTOPLEVEL_BUTTON_MAXIMIZE
)
3246 s
.x
+= FRAME_BUTTON_WIDTH
;
3247 if ( flags
& wxTOPLEVEL_BUTTON_RESTORE
)
3248 s
.x
+= FRAME_BUTTON_WIDTH
;
3249 if ( flags
& wxTOPLEVEL_BUTTON_ICONIZE
)
3250 s
.x
+= FRAME_BUTTON_WIDTH
;
3251 if ( flags
& wxTOPLEVEL_BUTTON_HELP
)
3252 s
.x
+= FRAME_BUTTON_WIDTH
;
3258 wxSize
wxWin32Renderer::GetFrameIconSize() const
3260 return wxSize(16, 16);
3264 // ----------------------------------------------------------------------------
3266 // ----------------------------------------------------------------------------
3268 /* Copyright (c) Julian Smart */
3269 static char *error_xpm
[]={
3270 /* columns rows colors chars-per-pixel */
3347 " $oooooooooooo%& ",
3348 " *=-ooooooooooooo;: ",
3349 " *oooooooooooooooooo> ",
3350 " =ooooooooooooooooooo, ",
3351 " $-ooooooooooooooooooo<1 ",
3352 " .oooooo2334ooo533oooooo6 ",
3353 " +ooooooo789oo2883oooooo0q ",
3354 " oooooooo2w83o78eoooooooor ",
3355 " toooooooooy88u884oooooooori ",
3356 " Xooooooooooe888poooooooooas ",
3357 " ooooooooooo4889doooooooooof ",
3358 " ooooooooooo588w2oooooooooofi ",
3359 " oooooooooodw8887oooooooooofi ",
3360 " goooooooooh8w588jooooooookli ",
3361 " tooooooooz885op8wdooooooorix ",
3362 " oooooood98cood98cooooooori ",
3363 " @oooooop8w2ooo5885ooooovbi ",
3364 " n%ooooooooooooooooooooomiM ",
3365 " &;oooooooooooooooooooNBiV ",
3366 " :ooooooooooooooooooCZiA ",
3367 " nSooooooooooooooooCDiF ",
3368 " nG<oooooooooooooNZiiH ",
3369 " 160ooooooooovmBiFH ",
3370 " nqrraoookrrbiiA ",
3377 /* Copyright (c) Julian Smart */
3378 static char *info_xpm
[]={
3379 /* columns rows colors chars-per-pixel */
3401 " ..XXXXXXXXXXXXX.. ",
3402 " .XXXXXXXXXXXXXXXXX. ",
3403 " .XXXXXXXXoO+XXXXXXXX. ",
3404 " .XXXXXXXXX@#OXXXXXXXXX. ",
3405 " .XXXXXXXXXX$@oXXXXXXXXXX. ",
3406 " .XXXXXXXXXXXXXXXXXXXXXXX.% ",
3407 " .XXXXXXXXX&*=-XXXXXXXXXX.%% ",
3408 ".XXXXXXXXXX;:#>XXXXXXXXXXX.% ",
3409 ".XXXXXXXXXXX;#+XXXXXXXXXXX.% ",
3410 ".XXXXXXXXXXX;#+XXXXXXXXXXX.%% ",
3411 " .XXXXXXXXXX;#+XXXXXXXXXX.%%% ",
3412 " .XXXXXXXXXX;#+XXXXXXXXXX.%%% ",
3413 " .XXXXXXXXXX;#+XXXXXXXXXX.%% ",
3414 " .XXXXXXXX*-##+XXXXXXXX.%%% ",
3415 " .XXXXXXXXXXXXXXXXXXX.%%%% ",
3416 " .XXXXXXXXXXXXXXXXX.%%%% ",
3417 " ..XXXXXXXXXXXXX..%%%% ",
3418 " %...XXXXXXXX..%%%%% ",
3419 " %%%..XXXXXX.%%%%% ",
3433 /* Copyright (c) Julian Smart */
3434 static char *question_xpm
[]={
3435 /* columns rows colors chars-per-pixel */
3456 " ..XXXXXXXXXXXXX.. ",
3457 " .XXXXXXoO++@XXXXXX. ",
3458 " .XXXXXXO#$$$$#%XXXXX. ",
3459 " .XXXXXX@$$#&&#$#oXXXXX. ",
3460 " .XXXXXXX*$$%XX%$$=XXXXXX. ",
3461 " .XXXXXXX+-;XXXX$$-XXXXXX.: ",
3462 " .XXXXXXXXXXXXX+$$&XXXXXX.:: ",
3463 ".XXXXXXXXXXXXo;$$*oXXXXXXX.: ",
3464 ".XXXXXXXXXXXo*$$*oXXXXXXXX.: ",
3465 ".XXXXXXXXXXX+$$*oXXXXXXXXX.:: ",
3466 " .XXXXXXXXXX-$$oXXXXXXXXX.::: ",
3467 " .XXXXXXXXXXX--XXXXXXXXXX.::: ",
3468 " .XXXXXXXXXXXXXXXXXXXXXXX.:: ",
3469 " .XXXXXXXXX-$$XXXXXXXXX.::: ",
3470 " .XXXXXXXX-$$XXXXXXXX.:::: ",
3471 " .XXXXXXXO++XXXXXXX.:::: ",
3472 " ..XXXXXXXXXXXXX..:::: ",
3473 " :...XXXXXXXX..::::: ",
3474 " :::..XXXXXX.::::: ",
3488 /* Copyright (c) Julian Smart */
3489 static char *warning_xpm
[]={
3490 /* columns rows colors chars-per-pixel */
3516 " ..XXXXO@#XXX... ",
3517 " ...XXXXO@#XXXX.. ",
3518 " ..XXXXXO@#XXXX... ",
3519 " ...XXXXXo@OXXXXX.. ",
3520 " ...XXXXXXo@OXXXXXX.. ",
3521 " ..XXXXXXX$@OXXXXXX... ",
3522 " ...XXXXXXXX@XXXXXXXX.. ",
3523 " ...XXXXXXXXXXXXXXXXXX... ",
3524 " ..XXXXXXXXXXOXXXXXXXXX.. ",
3525 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
3526 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
3527 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
3528 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
3529 " .............................. ",
3530 " .............................. ",
3537 wxBitmap
wxWin32ArtProvider::CreateBitmap(const wxArtID
& id
,
3538 const wxArtClient
& WXUNUSED(client
),
3539 const wxSize
& WXUNUSED(size
))
3541 if ( id
== wxART_INFORMATION
)
3542 return wxBitmap(info_xpm
);
3543 if ( id
== wxART_ERROR
)
3544 return wxBitmap(error_xpm
);
3545 if ( id
== wxART_WARNING
)
3546 return wxBitmap(warning_xpm
);
3547 if ( id
== wxART_QUESTION
)
3548 return wxBitmap(question_xpm
);
3549 return wxNullBitmap
;
3555 // ----------------------------------------------------------------------------
3556 // text control geometry
3557 // ----------------------------------------------------------------------------
3559 static inline int GetTextBorderWidth()
3565 wxWin32Renderer::GetTextTotalArea(const wxTextCtrl
* WXUNUSED(text
),
3566 const wxRect
& rect
) const
3568 wxRect rectTotal
= rect
;
3570 wxCoord widthBorder
= GetTextBorderWidth();
3571 rectTotal
.Inflate(widthBorder
);
3573 // this is what Windows does
3580 wxWin32Renderer::GetTextClientArea(const wxTextCtrl
* WXUNUSED(text
),
3582 wxCoord
*extraSpaceBeyond
) const
3584 wxRect rectText
= rect
;
3586 // undo GetTextTotalArea()
3587 if ( rectText
.height
> 0 )
3590 wxCoord widthBorder
= GetTextBorderWidth();
3591 rectText
.Inflate(-widthBorder
);
3593 if ( extraSpaceBeyond
)
3594 *extraSpaceBeyond
= 0;
3599 #endif // wxUSE_TEXTCTRL
3601 // ----------------------------------------------------------------------------
3603 // ----------------------------------------------------------------------------
3605 void wxWin32Renderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
3608 if ( wxDynamicCast(window
, wxScrollBar
) )
3610 // we only set the width of vert scrollbars and height of the
3612 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
3613 size
->y
= m_sizeScrollbarArrow
.y
;
3615 size
->x
= m_sizeScrollbarArrow
.x
;
3617 // skip border width adjustments, they don't make sense for us
3620 #endif // wxUSE_SCROLLBAR
3623 if ( wxDynamicCast(window
, wxBitmapButton
) )
3627 #endif // wxUSE_BMPBUTTON
3628 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
3631 || wxDynamicCast(window
, wxButton
)
3632 # endif // wxUSE_BUTTON
3633 # if wxUSE_TOGGLEBTN
3634 || wxDynamicCast(window
, wxToggleButton
)
3635 # endif // wxUSE_TOGGLEBTN
3638 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
3640 // TODO: don't harcode all this
3641 size
->x
+= 3*window
->GetCharWidth();
3643 wxCoord heightBtn
= (11*(window
->GetCharHeight() + 8))/10;
3644 if ( size
->y
< heightBtn
- 8 )
3645 size
->y
= heightBtn
;
3650 // for compatibility with other ports, the buttons default size is never
3651 // less than the standard one, but not when display not PDAs.
3652 if (wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA
)
3654 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
3656 wxSize szDef
= wxButton::GetDefaultSize();
3657 if ( size
->x
< szDef
.x
)
3662 // no border width adjustments for buttons
3665 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
3667 // take into account the border width
3668 wxRect rectBorder
= GetBorderDimensions(window
->GetBorder());
3669 size
->x
+= rectBorder
.x
+ rectBorder
.width
;
3670 size
->y
+= rectBorder
.y
+ rectBorder
.height
;
3673 // ============================================================================
3675 // ============================================================================
3677 // ----------------------------------------------------------------------------
3678 // wxWin32InputHandler
3679 // ----------------------------------------------------------------------------
3681 bool wxWin32InputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
3682 const wxKeyEvent
& WXUNUSED(event
),
3683 bool WXUNUSED(pressed
))
3688 bool wxWin32InputHandler::HandleMouse(wxInputConsumer
*control
,
3689 const wxMouseEvent
& event
)
3691 // clicking on the control gives it focus
3692 if ( event
.ButtonDown() )
3694 wxWindow
*win
= control
->GetInputWindow();
3696 if ( (wxWindow::FindFocus() != control
->GetInputWindow()) &&
3697 win
->AcceptsFocus() )
3710 // ----------------------------------------------------------------------------
3711 // wxWin32ScrollBarInputHandler
3712 // ----------------------------------------------------------------------------
3714 wxWin32ScrollBarInputHandler::
3715 wxWin32ScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
3716 : wxStdScrollBarInputHandler(renderer
, handler
)
3718 m_scrollPaused
= false;
3722 bool wxWin32ScrollBarInputHandler::OnScrollTimer(wxScrollBar
*scrollbar
,
3723 const wxControlAction
& action
)
3725 // stop if went beyond the position of the original click (this can only
3726 // happen when we scroll by pages)
3728 if ( action
== wxACTION_SCROLL_PAGE_DOWN
)
3730 stop
= m_renderer
->HitTestScrollbar(scrollbar
, m_ptStartScrolling
)
3731 != wxHT_SCROLLBAR_BAR_2
;
3733 else if ( action
== wxACTION_SCROLL_PAGE_UP
)
3735 stop
= m_renderer
->HitTestScrollbar(scrollbar
, m_ptStartScrolling
)
3736 != wxHT_SCROLLBAR_BAR_1
;
3741 StopScrolling(scrollbar
);
3743 scrollbar
->Refresh();
3748 return wxStdScrollBarInputHandler::OnScrollTimer(scrollbar
, action
);
3751 bool wxWin32ScrollBarInputHandler::HandleMouse(wxInputConsumer
*control
,
3752 const wxMouseEvent
& event
)
3754 // remember the current state
3755 bool wasDraggingThumb
= m_htLast
== wxHT_SCROLLBAR_THUMB
;
3757 // do process the message
3758 bool rc
= wxStdScrollBarInputHandler::HandleMouse(control
, event
);
3760 // analyse the changes
3761 if ( !wasDraggingThumb
&& (m_htLast
== wxHT_SCROLLBAR_THUMB
) )
3763 // we just started dragging the thumb, remember its initial position to
3764 // be able to restore it if the drag is cancelled later
3765 m_eventStartDrag
= event
;
3771 bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer
*control
,
3772 const wxMouseEvent
& event
)
3774 // we don't highlight scrollbar elements, so there is no need to process
3775 // mouse move events normally - only do it while mouse is captured (i.e.
3776 // when we're dragging the thumb or pressing on something)
3777 if ( !m_winCapture
)
3780 if ( event
.Entering() )
3782 // we're not interested in this at all
3786 wxScrollBar
*scrollbar
= wxStaticCast(control
->GetInputWindow(), wxScrollBar
);
3788 if ( m_scrollPaused
)
3790 // check if the mouse returned to its original location
3792 if ( event
.Leaving() )
3798 ht
= m_renderer
->HitTestScrollbar(scrollbar
, event
.GetPosition());
3799 if ( ht
== m_htLast
)
3801 // yes it did, resume scrolling
3802 m_scrollPaused
= false;
3803 if ( m_timerScroll
)
3805 // we were scrolling by line/page, restart timer
3806 m_timerScroll
->Start(m_interval
);
3808 Press(scrollbar
, true);
3810 else // we were dragging the thumb
3812 // restore its last location
3813 HandleThumbMove(scrollbar
, m_eventLastDrag
);
3819 else // normal case, scrolling hasn't been paused
3821 // if we're scrolling the scrollbar because the arrow or the shaft was
3822 // pressed, check that the mouse stays on the same scrollbar element
3825 // Always let thumb jump back if we leave the scrollbar
3826 if ( event
.Moving() )
3828 ht
= m_renderer
->HitTestScrollbar(scrollbar
, event
.GetPosition());
3830 else // event.Leaving()
3835 // Jump back only if we get far away from it
3836 wxPoint pos
= event
.GetPosition();
3837 if (scrollbar
->HasFlag( wxVERTICAL
))
3839 if (pos
.x
> -40 && pos
.x
< scrollbar
->GetSize().x
+40)
3844 if (pos
.y
> -40 && pos
.y
< scrollbar
->GetSize().y
+40)
3847 ht
= m_renderer
->HitTestScrollbar(scrollbar
, pos
);
3850 // if we're dragging the thumb and the mouse stays in the scrollbar, it
3851 // is still ok - we only want to catch the case when the mouse leaves
3852 // the scrollbar here
3853 if ( m_htLast
== wxHT_SCROLLBAR_THUMB
&& ht
!= wxHT_NOWHERE
)
3855 ht
= wxHT_SCROLLBAR_THUMB
;
3858 if ( ht
!= m_htLast
)
3860 // what were we doing? 2 possibilities: either an arrow/shaft was
3861 // pressed in which case we have a timer and so we just stop it or
3862 // we were dragging the thumb
3863 if ( m_timerScroll
)
3866 m_interval
= m_timerScroll
->GetInterval();
3867 m_timerScroll
->Stop();
3868 m_scrollPaused
= true;
3870 // unpress the arrow
3871 Press(scrollbar
, false);
3873 else // we were dragging the thumb
3875 // remember the current thumb position to be able to restore it
3876 // if the mouse returns to it later
3877 m_eventLastDrag
= event
;
3879 // and restore the original position (before dragging) of the
3881 HandleThumbMove(scrollbar
, m_eventStartDrag
);
3888 return wxStdInputHandler::HandleMouseMove(control
, event
);
3891 #endif // wxUSE_SCROLLBAR
3895 // ----------------------------------------------------------------------------
3896 // wxWin32CheckboxInputHandler
3897 // ----------------------------------------------------------------------------
3899 bool wxWin32CheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
3900 const wxKeyEvent
& event
,
3905 wxControlAction action
;
3906 int keycode
= event
.GetKeyCode();
3910 action
= wxACTION_CHECKBOX_TOGGLE
;
3914 case WXK_NUMPAD_SUBTRACT
:
3915 action
= wxACTION_CHECKBOX_CHECK
;
3919 case WXK_NUMPAD_ADD
:
3920 case WXK_NUMPAD_EQUAL
:
3921 action
= wxACTION_CHECKBOX_CLEAR
;
3925 if ( !action
.IsEmpty() )
3927 control
->PerformAction(action
);
3936 #endif // wxUSE_CHECKBOX
3940 // ----------------------------------------------------------------------------
3941 // wxWin32TextCtrlInputHandler
3942 // ----------------------------------------------------------------------------
3944 bool wxWin32TextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
3945 const wxKeyEvent
& event
,
3948 // handle only MSW-specific text bindings here, the others are handled in
3952 int keycode
= event
.GetKeyCode();
3954 wxControlAction action
;
3955 if ( keycode
== WXK_DELETE
&& event
.ShiftDown() )
3957 action
= wxACTION_TEXT_CUT
;
3959 else if ( keycode
== WXK_INSERT
)
3961 if ( event
.ControlDown() )
3962 action
= wxACTION_TEXT_COPY
;
3963 else if ( event
.ShiftDown() )
3964 action
= wxACTION_TEXT_PASTE
;
3967 if ( action
!= wxACTION_NONE
)
3969 control
->PerformAction(action
);
3975 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
3978 #endif // wxUSE_TEXTCTRL
3982 // ----------------------------------------------------------------------------
3983 // wxWin32StatusBarInputHandler
3984 // ----------------------------------------------------------------------------
3986 wxWin32StatusBarInputHandler::
3987 wxWin32StatusBarInputHandler(wxInputHandler
*handler
)
3988 : wxStdInputHandler(handler
)
3993 bool wxWin32StatusBarInputHandler::IsOnGrip(wxWindow
*statbar
,
3994 const wxPoint
& pt
) const
3996 if ( statbar
->HasFlag(wxST_SIZEGRIP
) &&
3997 statbar
->GetParent()->HasFlag(wxRESIZE_BORDER
) )
4000 parentTLW
= wxDynamicCast(statbar
->GetParent(), wxTopLevelWindow
);
4002 wxCHECK_MSG( parentTLW
, false,
4003 _T("the status bar should be a child of a TLW") );
4005 // a maximized window can't be resized anyhow
4006 if ( !parentTLW
->IsMaximized() )
4008 // VZ: I think that the standard Windows behaviour is to only
4009 // show the resizing cursor when the mouse is on top of the
4010 // grip itself but apparently different Windows versions behave
4011 // differently (?) and it seems a better UI to allow resizing
4012 // the status bar even when the mouse is above the grip
4013 wxSize sizeSbar
= statbar
->GetSize();
4015 int diff
= sizeSbar
.x
- pt
.x
;
4016 return diff
>= 0 && diff
< (wxCoord
)STATUSBAR_GRIP_SIZE
;
4023 bool wxWin32StatusBarInputHandler::HandleMouse(wxInputConsumer
*consumer
,
4024 const wxMouseEvent
& event
)
4026 if ( event
.Button(1) )
4028 if ( event
.ButtonDown(1) )
4030 wxWindow
*statbar
= consumer
->GetInputWindow();
4032 if ( IsOnGrip(statbar
, event
.GetPosition()) )
4034 wxTopLevelWindow
*tlw
= wxDynamicCast(statbar
->GetParent(),
4038 tlw
->PerformAction(wxACTION_TOPLEVEL_RESIZE
,
4039 wxHT_TOPLEVEL_BORDER_SE
);
4041 statbar
->SetCursor(m_cursorOld
);
4049 return wxStdInputHandler::HandleMouse(consumer
, event
);
4052 bool wxWin32StatusBarInputHandler::HandleMouseMove(wxInputConsumer
*consumer
,
4053 const wxMouseEvent
& event
)
4055 wxWindow
*statbar
= consumer
->GetInputWindow();
4057 bool isOnGrip
= IsOnGrip(statbar
, event
.GetPosition());
4058 if ( isOnGrip
!= m_isOnGrip
)
4060 m_isOnGrip
= isOnGrip
;
4063 m_cursorOld
= statbar
->GetCursor();
4064 statbar
->SetCursor(wxCURSOR_SIZENWSE
);
4068 statbar
->SetCursor(m_cursorOld
);
4072 return wxStdInputHandler::HandleMouseMove(consumer
, event
);
4075 #endif // wxUSE_STATUSBAR
4077 // ----------------------------------------------------------------------------
4078 // wxWin32FrameInputHandler
4079 // ----------------------------------------------------------------------------
4081 class wxWin32SystemMenuEvtHandler
: public wxEvtHandler
4084 wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler
*handler
);
4086 void Attach(wxInputConsumer
*consumer
);
4090 DECLARE_EVENT_TABLE()
4091 void OnSystemMenu(wxCommandEvent
&event
);
4092 void OnCloseFrame(wxCommandEvent
&event
);
4093 void OnClose(wxCloseEvent
&event
);
4095 wxWin32FrameInputHandler
*m_inputHnd
;
4096 wxTopLevelWindow
*m_wnd
;
4098 wxAcceleratorTable m_oldAccelTable
;
4102 wxWin32SystemMenuEvtHandler::
4103 wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler
*handler
)
4105 m_inputHnd
= handler
;
4109 void wxWin32SystemMenuEvtHandler::Attach(wxInputConsumer
*consumer
)
4111 wxASSERT_MSG( m_wnd
== NULL
, _T("can't attach the handler twice!") );
4113 m_wnd
= wxStaticCast(consumer
->GetInputWindow(), wxTopLevelWindow
);
4114 m_wnd
->PushEventHandler(this);
4117 // VS: This code relies on using generic implementation of
4118 // wxAcceleratorTable in wxUniv!
4119 wxAcceleratorTable table
= *m_wnd
->GetAcceleratorTable();
4120 m_oldAccelTable
= table
;
4121 table
.Add(wxAcceleratorEntry(wxACCEL_ALT
, WXK_SPACE
, wxID_SYSTEM_MENU
));
4122 table
.Add(wxAcceleratorEntry(wxACCEL_ALT
, WXK_F4
, wxID_CLOSE_FRAME
));
4123 m_wnd
->SetAcceleratorTable(table
);
4127 void wxWin32SystemMenuEvtHandler::Detach()
4132 m_wnd
->SetAcceleratorTable(m_oldAccelTable
);
4134 m_wnd
->RemoveEventHandler(this);
4139 BEGIN_EVENT_TABLE(wxWin32SystemMenuEvtHandler
, wxEvtHandler
)
4140 EVT_MENU(wxID_SYSTEM_MENU
, wxWin32SystemMenuEvtHandler::OnSystemMenu
)
4141 EVT_MENU(wxID_CLOSE_FRAME
, wxWin32SystemMenuEvtHandler::OnCloseFrame
)
4142 EVT_CLOSE(wxWin32SystemMenuEvtHandler::OnClose
)
4145 void wxWin32SystemMenuEvtHandler::OnSystemMenu(wxCommandEvent
&WXUNUSED(event
))
4147 int border
= ((m_wnd
->GetWindowStyle() & wxRESIZE_BORDER
) &&
4148 !m_wnd
->IsMaximized()) ?
4149 RESIZEABLE_FRAME_BORDER_THICKNESS
:
4150 FRAME_BORDER_THICKNESS
;
4151 wxPoint pt
= m_wnd
->GetClientAreaOrigin();
4152 pt
.x
= -pt
.x
+ border
;
4153 pt
.y
= -pt
.y
+ border
+ FRAME_TITLEBAR_HEIGHT
;
4156 wxAcceleratorTable table
= *m_wnd
->GetAcceleratorTable();
4157 m_wnd
->SetAcceleratorTable(wxNullAcceleratorTable
);
4161 m_inputHnd
->PopupSystemMenu(m_wnd
, pt
);
4162 #endif // wxUSE_MENUS
4165 m_wnd
->SetAcceleratorTable(table
);
4169 void wxWin32SystemMenuEvtHandler::OnCloseFrame(wxCommandEvent
&WXUNUSED(event
))
4171 m_wnd
->PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
4172 wxTOPLEVEL_BUTTON_CLOSE
);
4175 void wxWin32SystemMenuEvtHandler::OnClose(wxCloseEvent
&event
)
4182 wxWin32FrameInputHandler::wxWin32FrameInputHandler(wxInputHandler
*handler
)
4183 : wxStdInputHandler(handler
)
4185 m_menuHandler
= new wxWin32SystemMenuEvtHandler(this);
4188 wxWin32FrameInputHandler::~wxWin32FrameInputHandler()
4190 if ( m_menuHandler
)
4192 m_menuHandler
->Detach();
4193 delete m_menuHandler
;
4197 bool wxWin32FrameInputHandler::HandleMouse(wxInputConsumer
*consumer
,
4198 const wxMouseEvent
& event
)
4200 if ( event
.LeftDClick() || event
.LeftDown() || event
.RightDown() )
4202 wxTopLevelWindow
*tlw
=
4203 wxStaticCast(consumer
->GetInputWindow(), wxTopLevelWindow
);
4205 long hit
= tlw
->HitTest(event
.GetPosition());
4207 if ( event
.LeftDClick() && hit
== wxHT_TOPLEVEL_TITLEBAR
)
4209 tlw
->PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
4210 tlw
->IsMaximized() ? wxTOPLEVEL_BUTTON_RESTORE
4211 : wxTOPLEVEL_BUTTON_MAXIMIZE
);
4214 else if ( tlw
->GetWindowStyle() & wxSYSTEM_MENU
)
4216 if ( (event
.LeftDown() && hit
== wxHT_TOPLEVEL_ICON
) ||
4217 (event
.RightDown() &&
4218 (hit
== wxHT_TOPLEVEL_TITLEBAR
||
4219 hit
== wxHT_TOPLEVEL_ICON
)) )
4222 PopupSystemMenu(tlw
, event
.GetPosition());
4223 #endif // wxUSE_MENUS
4229 return wxStdInputHandler::HandleMouse(consumer
, event
);
4234 void wxWin32FrameInputHandler::PopupSystemMenu(wxTopLevelWindow
*window
,
4235 const wxPoint
& pos
) const
4237 wxMenu
*menu
= new wxMenu
;
4239 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
4240 menu
->Append(wxID_RESTORE_FRAME
, _("&Restore"));
4241 menu
->Append(wxID_MOVE_FRAME
, _("&Move"));
4242 if ( window
->GetWindowStyle() & wxRESIZE_BORDER
)
4243 menu
->Append(wxID_RESIZE_FRAME
, _("&Size"));
4244 if ( wxSystemSettings::HasFeature(wxSYS_CAN_ICONIZE_FRAME
) )
4245 menu
->Append(wxID_ICONIZE_FRAME
, _("Mi&nimize"));
4246 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
4247 menu
->Append(wxID_MAXIMIZE_FRAME
, _("Ma&ximize"));
4248 menu
->AppendSeparator();
4249 menu
->Append(wxID_CLOSE_FRAME
, _("Close\tAlt-F4"));
4251 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
4253 if ( window
->IsMaximized() )
4255 menu
->Enable(wxID_MAXIMIZE_FRAME
, false);
4256 menu
->Enable(wxID_MOVE_FRAME
, false);
4257 if ( window
->GetWindowStyle() & wxRESIZE_BORDER
)
4258 menu
->Enable(wxID_RESIZE_FRAME
, false);
4261 menu
->Enable(wxID_RESTORE_FRAME
, false);
4264 window
->PopupMenu(menu
, pos
);
4268 #endif // wxUSE_MENUS
4270 bool wxWin32FrameInputHandler::HandleActivation(wxInputConsumer
*consumer
,
4273 if ( consumer
->GetInputWindow()->GetWindowStyle() & wxSYSTEM_MENU
)
4275 // always detach if active frame changed:
4276 m_menuHandler
->Detach();
4280 m_menuHandler
->Attach(consumer
);
4284 return wxStdInputHandler::HandleActivation(consumer
, activated
);