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 static const size_t NUM_STATUSBAR_GRIP_BANDS
= 3;
77 static const size_t WIDTH_STATUSBAR_GRIP_BAND
= 4;
78 static const size_t STATUSBAR_GRIP_SIZE
=
79 WIDTH_STATUSBAR_GRIP_BAND
*NUM_STATUSBAR_GRIP_BANDS
;
81 static const wxCoord SLIDER_MARGIN
= 6; // margin around slider
82 static const wxCoord SLIDER_THUMB_LENGTH
= 18;
83 static const wxCoord SLIDER_TICK_LENGTH
= 6;
85 // wxWin32Renderer: draw the GUI elements in Win32 style
86 // ----------------------------------------------------------------------------
88 class wxWin32Renderer
: public wxStdRenderer
92 wxWin32Renderer(const wxColourScheme
*scheme
);
94 // reimplement the renderer methods which are different for this theme
95 virtual void DrawLabel(wxDC
& dc
,
96 const wxString
& label
,
99 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
101 wxRect
*rectBounds
= NULL
);
102 virtual void DrawButtonLabel(wxDC
& dc
,
103 const wxString
& label
,
104 const wxBitmap
& image
,
107 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
109 wxRect
*rectBounds
= NULL
);
110 virtual void DrawButtonBorder(wxDC
& dc
,
113 wxRect
*rectIn
= NULL
);
115 virtual void DrawArrow(wxDC
& dc
,
119 virtual void DrawScrollbarThumb(wxDC
& dc
,
120 wxOrientation orient
,
123 virtual void DrawScrollbarShaft(wxDC
& dc
,
124 wxOrientation orient
,
129 virtual void DrawToolBarButton(wxDC
& dc
,
130 const wxString
& label
,
131 const wxBitmap
& bitmap
,
136 #endif // wxUSE_TOOLBAR
139 virtual void DrawTab(wxDC
& dc
,
142 const wxString
& label
,
143 const wxBitmap
& bitmap
= wxNullBitmap
,
145 int indexAccel
= -1);
146 #endif // wxUSE_NOTEBOOK
149 virtual void DrawSliderShaft(wxDC
& dc
,
152 wxOrientation orient
,
155 wxRect
*rectShaft
= NULL
);
156 virtual void DrawSliderThumb(wxDC
& dc
,
158 wxOrientation orient
,
161 virtual void DrawSliderTicks(wxDC
& dc
,
164 wxOrientation orient
,
170 #endif // wxUSE_SLIDER
173 virtual void DrawMenuBarItem(wxDC
& dc
,
175 const wxString
& label
,
177 int indexAccel
= -1);
178 virtual void DrawMenuItem(wxDC
& dc
,
180 const wxMenuGeometryInfo
& geometryInfo
,
181 const wxString
& label
,
182 const wxString
& accel
,
183 const wxBitmap
& bitmap
= wxNullBitmap
,
185 int indexAccel
= -1);
186 virtual void DrawMenuSeparator(wxDC
& dc
,
188 const wxMenuGeometryInfo
& geomInfo
);
189 #endif // wxUSE_MENUS
192 virtual void DrawStatusField(wxDC
& dc
,
194 const wxString
& label
,
195 int flags
= 0, int style
= 0);
196 #endif // wxUSE_STATUSBAR
198 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
200 wxBitmap
*bmpPressed
,
201 wxBitmap
*bmpDisabled
);
203 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
204 virtual bool AreScrollbarsInsideBorder() const;
206 virtual wxSize
GetScrollbarArrowSize() const
207 { return m_sizeScrollbarArrow
; }
209 virtual wxSize
GetCheckBitmapSize() const
210 { return wxSize(13, 13); }
211 virtual wxSize
GetRadioBitmapSize() const
212 { return wxSize(12, 12); }
213 virtual wxCoord
GetCheckItemMargin() const
217 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
218 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
219 virtual wxSize
GetToolBarMargin() const
220 { return wxSize(4, 4); }
221 #endif // wxUSE_TOOLBAR
224 virtual wxRect
GetTextTotalArea(const wxTextCtrl
*text
,
225 const wxRect
& rect
) const;
226 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
228 wxCoord
*extraSpaceBeyond
) const;
229 #endif // wxUSE_TEXTCTRL
232 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
233 virtual wxSize
GetTabPadding() const { return wxSize(6, 5); }
234 #endif // wxUSE_NOTEBOOK
238 virtual wxCoord
GetSliderDim() const { return SLIDER_THUMB_LENGTH
+ 2*BORDER_THICKNESS
; }
239 virtual wxCoord
GetSliderTickLen() const { return SLIDER_TICK_LENGTH
; }
240 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
242 wxOrientation orient
,
243 long style
= 0) const;
244 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
246 wxOrientation orient
) const;
247 #endif // wxUSE_SLIDER
249 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
252 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
253 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
254 const wxMenu
& menu
) const;
255 #endif // wxUSE_MENUS
258 // overridden wxStdRenderer methods
259 virtual void DrawFrameWithLabel(wxDC
& dc
,
260 const wxString
& label
,
261 const wxRect
& rectFrame
,
262 const wxRect
& rectText
,
267 virtual void DrawCheckItemBitmap(wxDC
& dc
,
268 const wxBitmap
& bitmap
,
273 // draw the border used for scrollbar arrows
274 void DrawArrowBorder(wxDC
& dc
, wxRect
*rect
, bool isPressed
= false);
276 // public DrawArrow()s helper
277 void DrawArrow(wxDC
& dc
, const wxRect
& rect
,
278 ArrowDirection arrowDir
, ArrowStyle arrowStyle
);
280 // DrawArrowButton is used by DrawScrollbar and DrawComboButton
281 void DrawArrowButton(wxDC
& dc
, const wxRect
& rect
,
282 ArrowDirection arrowDir
,
283 ArrowStyle arrowStyle
);
285 // draw a normal or transposed line (useful for using the same code fo both
286 // horizontal and vertical widgets)
287 void DrawLine(wxDC
& dc
,
288 wxCoord x1
, wxCoord y1
,
289 wxCoord x2
, wxCoord y2
,
290 bool transpose
= false)
293 dc
.DrawLine(y1
, x1
, y2
, x2
);
295 dc
.DrawLine(x1
, y1
, x2
, y2
);
298 // get the standard check/radio button bitmap
299 wxBitmap
GetIndicator(IndicatorType indType
, int flags
);
300 virtual wxBitmap
GetCheckBitmap(int flags
)
301 { return GetIndicator(IndicatorType_Check
, flags
); }
302 virtual wxBitmap
GetRadioBitmap(int flags
)
303 { return GetIndicator(IndicatorType_Radio
, flags
); }
305 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType type
);
308 // the sizing parameters (TODO make them changeable)
309 wxSize m_sizeScrollbarArrow
;
311 // the checked and unchecked bitmaps for DrawCheckItemBitmap()
312 wxBitmap m_bmpCheckBitmaps
[IndicatorStatus_Max
];
314 // the bitmaps returned by GetIndicator()
315 wxBitmap m_bmpIndicators
[IndicatorType_Max
]
316 [IndicatorState_MaxMenu
]
317 [IndicatorStatus_Max
];
320 wxBitmap m_bmpFrameButtons
[FrameButton_Max
];
322 // standard defaults for the above bitmaps
323 static const char **ms_xpmChecked
[IndicatorStatus_Max
];
324 static const char **ms_xpmIndicators
[IndicatorType_Max
]
325 [IndicatorState_MaxMenu
]
326 [IndicatorStatus_Max
];
327 static const char **ms_xpmFrameButtons
[FrameButton_Max
];
329 // first row is for the normal state, second - for the disabled
330 wxBitmap m_bmpArrows
[Arrow_StateMax
][Arrow_Max
];
333 // ----------------------------------------------------------------------------
334 // wxWin32InputHandler and derived classes: process the keyboard and mouse
335 // messages according to Windows standards
336 // ----------------------------------------------------------------------------
338 class wxWin32InputHandler
: public wxInputHandler
341 wxWin32InputHandler() { }
343 virtual bool HandleKey(wxInputConsumer
*control
,
344 const wxKeyEvent
& event
,
346 virtual bool HandleMouse(wxInputConsumer
*control
,
347 const wxMouseEvent
& event
);
351 class wxWin32ScrollBarInputHandler
: public wxStdScrollBarInputHandler
354 wxWin32ScrollBarInputHandler(wxRenderer
*renderer
,
355 wxInputHandler
*handler
);
357 virtual bool HandleMouse(wxInputConsumer
*control
,
358 const wxMouseEvent
& event
);
359 virtual bool HandleMouseMove(wxInputConsumer
*control
,
360 const wxMouseEvent
& event
);
362 virtual bool OnScrollTimer(wxScrollBar
*scrollbar
,
363 const wxControlAction
& action
);
366 virtual void Highlight(wxScrollBar
* WXUNUSED(scrollbar
),
369 // we don't highlight anything
372 // the first and last event which caused the thumb to move
373 wxMouseEvent m_eventStartDrag
,
376 // have we paused the scrolling because the mouse moved?
379 // we remember the interval of the timer to be able to restart it
382 #endif // wxUSE_SCROLLBAR
385 class wxWin32CheckboxInputHandler
: public wxStdInputHandler
388 wxWin32CheckboxInputHandler(wxInputHandler
*handler
)
389 : wxStdInputHandler(handler
) { }
391 virtual bool HandleKey(wxInputConsumer
*control
,
392 const wxKeyEvent
& event
,
395 #endif // wxUSE_CHECKBOX
398 class wxWin32TextCtrlInputHandler
: public wxStdInputHandler
401 wxWin32TextCtrlInputHandler(wxInputHandler
*handler
)
402 : wxStdInputHandler(handler
) { }
404 virtual bool HandleKey(wxInputConsumer
*control
,
405 const wxKeyEvent
& event
,
408 #endif // wxUSE_TEXTCTRL
410 class wxWin32StatusBarInputHandler
: public wxStdInputHandler
413 wxWin32StatusBarInputHandler(wxInputHandler
*handler
);
415 virtual bool HandleMouse(wxInputConsumer
*consumer
,
416 const wxMouseEvent
& event
);
418 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
419 const wxMouseEvent
& event
);
422 // is the given point over the statusbar grip?
423 bool IsOnGrip(wxWindow
*statbar
, const wxPoint
& pt
) const;
426 // the cursor we had replaced with the resize one
427 wxCursor m_cursorOld
;
429 // was the mouse over the grip last time we checked?
433 class wxWin32SystemMenuEvtHandler
;
435 class wxWin32FrameInputHandler
: public wxStdInputHandler
438 wxWin32FrameInputHandler(wxInputHandler
*handler
);
439 virtual ~wxWin32FrameInputHandler();
441 virtual bool HandleMouse(wxInputConsumer
*control
,
442 const wxMouseEvent
& event
);
444 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
447 void PopupSystemMenu(wxTopLevelWindow
*window
) const;
448 #endif // wxUSE_MENUS
451 // was the mouse over the grip last time we checked?
452 wxWin32SystemMenuEvtHandler
*m_menuHandler
;
455 // ----------------------------------------------------------------------------
456 // wxWin32ColourScheme: uses (default) Win32 colours
457 // ----------------------------------------------------------------------------
459 class wxWin32ColourScheme
: public wxColourScheme
462 virtual wxColour
Get(StdColour col
) const;
463 virtual wxColour
GetBackground(wxWindow
*win
) const;
466 // ----------------------------------------------------------------------------
467 // wxWin32ArtProvider
468 // ----------------------------------------------------------------------------
470 class wxWin32ArtProvider
: public wxArtProvider
473 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
474 const wxArtClient
& client
,
478 // ----------------------------------------------------------------------------
480 // ----------------------------------------------------------------------------
482 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
484 class wxWin32Theme
: public wxTheme
488 virtual ~wxWin32Theme();
490 virtual wxRenderer
*GetRenderer();
491 virtual wxArtProvider
*GetArtProvider();
492 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
493 wxInputConsumer
*consumer
);
494 virtual wxColourScheme
*GetColourScheme();
497 wxWin32Renderer
*m_renderer
;
499 wxWin32ArtProvider
*m_artProvider
;
501 // the names of the already created handlers and the handlers themselves
502 // (these arrays are synchronized)
503 wxSortedArrayString m_handlerNames
;
504 wxArrayHandlers m_handlers
;
506 wxWin32ColourScheme
*m_scheme
;
508 WX_DECLARE_THEME(win32
)
511 // ----------------------------------------------------------------------------
513 // ----------------------------------------------------------------------------
515 // frame buttons bitmaps
516 static const char *frame_button_close_xpm
[] = {
531 static const char *frame_button_help_xpm
[] = {
546 static const char *frame_button_maximize_xpm
[] = {
561 static const char *frame_button_minimize_xpm
[] = {
576 static const char *frame_button_restore_xpm
[] = {
591 const char **wxWin32Renderer::ms_xpmFrameButtons
[FrameButton_Max
] =
593 frame_button_close_xpm
,
594 frame_button_minimize_xpm
,
595 frame_button_maximize_xpm
,
596 frame_button_restore_xpm
,
597 frame_button_help_xpm
,
602 static const char *checked_menu_xpm
[] = {
603 /* columns rows colors chars-per-pixel */
619 static const char *selected_checked_menu_xpm
[] = {
620 /* columns rows colors chars-per-pixel */
636 static const char *disabled_checked_menu_xpm
[] = {
637 /* columns rows colors chars-per-pixel */
654 static const char *selected_disabled_checked_menu_xpm
[] = {
655 /* columns rows colors chars-per-pixel */
671 // checkbox and radiobox bitmaps below
673 static const char *checked_xpm
[] = {
674 /* columns rows colors chars-per-pixel */
697 static const char *pressed_checked_xpm
[] = {
698 /* columns rows colors chars-per-pixel */
720 static const char *pressed_disabled_checked_xpm
[] = {
721 /* columns rows colors chars-per-pixel */
743 static const char *checked_item_xpm
[] = {
744 /* columns rows colors chars-per-pixel */
765 static const char *unchecked_xpm
[] = {
766 /* columns rows colors chars-per-pixel */
789 static const char *pressed_unchecked_xpm
[] = {
790 /* columns rows colors chars-per-pixel */
812 static const char *unchecked_item_xpm
[] = {
813 /* columns rows colors chars-per-pixel */
833 static const char *undetermined_xpm
[] = {
834 /* columns rows colors chars-per-pixel */
857 static const char *pressed_undetermined_xpm
[] = {
858 /* columns rows colors chars-per-pixel */
881 static const char *checked_radio_xpm
[] = {
882 /* columns rows colors chars-per-pixel */
905 static const char *pressed_checked_radio_xpm
[] = {
906 /* columns rows colors chars-per-pixel */
929 static const char *pressed_disabled_checked_radio_xpm
[] = {
930 /* columns rows colors chars-per-pixel */
953 static const char *unchecked_radio_xpm
[] = {
954 /* columns rows colors chars-per-pixel */
977 static const char *pressed_unchecked_radio_xpm
[] = {
978 /* columns rows colors chars-per-pixel */
1001 const char **wxWin32Renderer::ms_xpmIndicators
[IndicatorType_Max
]
1002 [IndicatorState_MaxMenu
]
1003 [IndicatorStatus_Max
] =
1008 { checked_xpm
, unchecked_xpm
, undetermined_xpm
},
1011 { pressed_checked_xpm
, pressed_unchecked_xpm
, pressed_undetermined_xpm
},
1014 { pressed_disabled_checked_xpm
, pressed_unchecked_xpm
, pressed_disabled_checked_xpm
},
1020 { checked_radio_xpm
, unchecked_radio_xpm
, NULL
},
1023 { pressed_checked_radio_xpm
, pressed_unchecked_radio_xpm
, NULL
},
1026 { pressed_disabled_checked_radio_xpm
, pressed_unchecked_radio_xpm
, NULL
},
1032 { checked_menu_xpm
, NULL
, NULL
},
1035 { selected_checked_menu_xpm
, NULL
, NULL
},
1038 { disabled_checked_menu_xpm
, NULL
, NULL
},
1040 // disabled selected state
1041 { selected_disabled_checked_menu_xpm
, NULL
, NULL
},
1045 const char **wxWin32Renderer::ms_xpmChecked
[IndicatorStatus_Max
] =
1051 // ============================================================================
1053 // ============================================================================
1055 WX_IMPLEMENT_THEME(wxWin32Theme
, win32
, wxTRANSLATE("Win32 theme"));
1057 // ----------------------------------------------------------------------------
1059 // ----------------------------------------------------------------------------
1061 wxWin32Theme::wxWin32Theme()
1065 m_artProvider
= NULL
;
1068 wxWin32Theme::~wxWin32Theme()
1072 delete m_artProvider
;
1075 wxRenderer
*wxWin32Theme::GetRenderer()
1079 m_renderer
= new wxWin32Renderer(GetColourScheme());
1085 wxArtProvider
*wxWin32Theme::GetArtProvider()
1087 if ( !m_artProvider
)
1089 m_artProvider
= new wxWin32ArtProvider
;
1092 return m_artProvider
;
1096 wxWin32Theme::GetInputHandler(const wxString
& control
,
1097 wxInputConsumer
*consumer
)
1099 wxInputHandler
*handler
= NULL
;
1100 int n
= m_handlerNames
.Index(control
);
1101 if ( n
== wxNOT_FOUND
)
1103 static wxWin32InputHandler s_handlerDef
;
1105 wxInputHandler
* const
1106 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
1108 // create a new handler
1109 if ( control
== wxINP_HANDLER_TOPLEVEL
)
1111 static wxWin32FrameInputHandler
s_handler(handlerStd
);
1113 handler
= &s_handler
;
1116 else if ( control
== wxINP_HANDLER_CHECKBOX
)
1118 static wxWin32CheckboxInputHandler
s_handler(handlerStd
);
1120 handler
= &s_handler
;
1122 #endif // wxUSE_CHECKBOX
1124 else if ( control
== wxINP_HANDLER_SCROLLBAR
)
1126 static wxWin32ScrollBarInputHandler
1127 s_handler(GetRenderer(), handlerStd
);
1129 handler
= &s_handler
;
1131 #endif // wxUSE_SCROLLBAR
1133 else if ( control
== wxINP_HANDLER_STATUSBAR
)
1135 static wxWin32StatusBarInputHandler
s_handler(handlerStd
);
1137 handler
= &s_handler
;
1139 #endif // wxUSE_STATUSBAR
1141 else if ( control
== wxINP_HANDLER_TEXTCTRL
)
1143 static wxWin32TextCtrlInputHandler
s_handler(handlerStd
);
1145 handler
= &s_handler
;
1147 #endif // wxUSE_TEXTCTRL
1148 else // no special handler for this control
1150 handler
= handlerStd
;
1153 n
= m_handlerNames
.Add(control
);
1154 m_handlers
.Insert(handler
, n
);
1156 else // we already have it
1158 handler
= m_handlers
[n
];
1164 wxColourScheme
*wxWin32Theme::GetColourScheme()
1168 m_scheme
= new wxWin32ColourScheme
;
1173 // ============================================================================
1174 // wxWin32ColourScheme
1175 // ============================================================================
1177 wxColour
wxWin32ColourScheme::GetBackground(wxWindow
*win
) const
1180 if ( win
->UseBgCol() )
1182 // use the user specified colour
1183 col
= win
->GetBackgroundColour();
1186 if ( !win
->ShouldInheritColours() )
1189 wxTextCtrl
*text
= wxDynamicCast(win
, wxTextCtrl
);
1190 #endif // wxUSE_TEXTCTRL
1192 wxListBox
* listBox
= wxDynamicCast(win
, wxListBox
);
1193 #endif // wxUSE_LISTBOX
1202 if ( !win
->IsEnabled() ) // not IsEditable()
1208 // doesn't depend on the state
1213 #endif // wxUSE_TEXTCTRL
1216 col
= Get(CONTROL
); // Most controls should be this colour, not WINDOW
1220 int flags
= win
->GetStateFlags();
1222 // the colour set by the user should be used for the normal state
1223 // and for the states for which we don't have any specific colours
1224 if ( !col
.Ok() || (flags
& wxCONTROL_PRESSED
) != 0 )
1227 if ( wxDynamicCast(win
, wxScrollBar
) )
1228 col
= Get(flags
& wxCONTROL_PRESSED
? SCROLLBAR_PRESSED
1231 #endif // wxUSE_SCROLLBAR
1239 wxColour
wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col
) const
1243 // use the system colours under Windows
1244 #if defined(__WXMSW__)
1245 case WINDOW
: return wxColour(GetSysColor(COLOR_WINDOW
));
1247 case CONTROL_PRESSED
:
1248 case CONTROL_CURRENT
:
1249 case CONTROL
: return wxColour(GetSysColor(COLOR_BTNFACE
));
1251 case CONTROL_TEXT
: return wxColour(GetSysColor(COLOR_BTNTEXT
));
1253 #if defined(COLOR_3DLIGHT)
1254 case SCROLLBAR
: return wxColour(GetSysColor(COLOR_3DLIGHT
));
1256 case SCROLLBAR
: return wxColour(0xe0e0e0);
1258 case SCROLLBAR_PRESSED
: return wxColour(GetSysColor(COLOR_BTNTEXT
));
1260 case HIGHLIGHT
: return wxColour(GetSysColor(COLOR_HIGHLIGHT
));
1261 case HIGHLIGHT_TEXT
: return wxColour(GetSysColor(COLOR_HIGHLIGHTTEXT
));
1263 #if defined(COLOR_3DDKSHADOW)
1264 case SHADOW_DARK
: return wxColour(GetSysColor(COLOR_3DDKSHADOW
));
1266 case SHADOW_DARK
: return wxColour(GetSysColor(COLOR_3DHADOW
));
1269 case CONTROL_TEXT_DISABLED
:
1270 case SHADOW_HIGHLIGHT
: return wxColour(GetSysColor(COLOR_BTNHIGHLIGHT
));
1272 case SHADOW_IN
: return wxColour(GetSysColor(COLOR_BTNFACE
));
1274 case CONTROL_TEXT_DISABLED_SHADOW
:
1275 case SHADOW_OUT
: return wxColour(GetSysColor(COLOR_BTNSHADOW
));
1277 case TITLEBAR
: return wxColour(GetSysColor(COLOR_INACTIVECAPTION
));
1278 case TITLEBAR_ACTIVE
: return wxColour(GetSysColor(COLOR_ACTIVECAPTION
));
1279 case TITLEBAR_TEXT
: return wxColour(GetSysColor(COLOR_INACTIVECAPTIONTEXT
));
1280 case TITLEBAR_ACTIVE_TEXT
: return wxColour(GetSysColor(COLOR_CAPTIONTEXT
));
1282 case DESKTOP
: return wxColour(0x808000);
1284 // use the standard Windows colours elsewhere
1285 case WINDOW
: return *wxWHITE
;
1287 case CONTROL_PRESSED
:
1288 case CONTROL_CURRENT
:
1289 case CONTROL
: return wxColour(0xc0c0c0);
1291 case CONTROL_TEXT
: return *wxBLACK
;
1293 case SCROLLBAR
: return wxColour(0xe0e0e0);
1294 case SCROLLBAR_PRESSED
: return *wxBLACK
;
1296 case HIGHLIGHT
: return wxColour(0x800000);
1297 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
1299 case SHADOW_DARK
: return *wxBLACK
;
1301 case CONTROL_TEXT_DISABLED
:return wxColour(0xe0e0e0);
1302 case SHADOW_HIGHLIGHT
: return wxColour(0xffffff);
1304 case SHADOW_IN
: return wxColour(0xc0c0c0);
1306 case CONTROL_TEXT_DISABLED_SHADOW
:
1307 case SHADOW_OUT
: return wxColour(0x7f7f7f);
1309 case TITLEBAR
: return wxColour(0xaeaaae);
1310 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
1311 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
1312 case TITLEBAR_ACTIVE_TEXT
:return *wxWHITE
;
1314 case DESKTOP
: return wxColour(0x808000);
1317 case GAUGE
: return Get(HIGHLIGHT
);
1321 wxFAIL_MSG(_T("invalid standard colour"));
1326 // ============================================================================
1328 // ============================================================================
1330 // ----------------------------------------------------------------------------
1332 // ----------------------------------------------------------------------------
1334 wxWin32Renderer::wxWin32Renderer(const wxColourScheme
*scheme
)
1335 : wxStdRenderer(scheme
)
1338 m_sizeScrollbarArrow
= wxSize(16, 16);
1340 // init the arrow bitmaps
1341 static const size_t ARROW_WIDTH
= 7;
1342 static const size_t ARROW_LENGTH
= 4;
1345 wxMemoryDC dcNormal
,
1348 for ( size_t n
= 0; n
< Arrow_Max
; n
++ )
1350 bool isVertical
= n
> Arrow_Right
;
1363 // disabled arrow is larger because of the shadow
1364 m_bmpArrows
[Arrow_Normal
][n
].Create(w
, h
);
1365 m_bmpArrows
[Arrow_Disabled
][n
].Create(w
+ 1, h
+ 1);
1367 dcNormal
.SelectObject(m_bmpArrows
[Arrow_Normal
][n
]);
1368 dcDisabled
.SelectObject(m_bmpArrows
[Arrow_Disabled
][n
]);
1370 dcNormal
.SetBackground(*wxWHITE_BRUSH
);
1371 dcDisabled
.SetBackground(*wxWHITE_BRUSH
);
1375 dcNormal
.SetPen(m_penBlack
);
1376 dcDisabled
.SetPen(m_penDarkGrey
);
1378 // calculate the position of the point of the arrow
1382 x1
= (ARROW_WIDTH
- 1)/2;
1383 y1
= n
== Arrow_Up
? 0 : ARROW_LENGTH
- 1;
1387 x1
= n
== Arrow_Left
? 0 : ARROW_LENGTH
- 1;
1388 y1
= (ARROW_WIDTH
- 1)/2;
1399 for ( size_t i
= 0; i
< ARROW_LENGTH
; i
++ )
1401 dcNormal
.DrawLine(x1
, y1
, x2
, y2
);
1402 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1409 if ( n
== Arrow_Up
)
1420 else // left or right arrow
1425 if ( n
== Arrow_Left
)
1438 // draw the shadow for the disabled one
1439 dcDisabled
.SetPen(m_penHighlight
);
1444 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1448 x1
= ARROW_LENGTH
- 1;
1449 y1
= (ARROW_WIDTH
- 1)/2 + 1;
1452 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1453 dcDisabled
.DrawLine(++x1
, y1
, x2
, ++y2
);
1458 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1462 x1
= ARROW_WIDTH
- 1;
1464 x2
= (ARROW_WIDTH
- 1)/2;
1466 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1467 dcDisabled
.DrawLine(++x1
, y1
, x2
, ++y2
);
1472 // create the inverted bitmap but only for the right arrow as we only
1473 // use it for the menus
1474 if ( n
== Arrow_Right
)
1476 m_bmpArrows
[Arrow_Inverted
][n
].Create(w
, h
);
1477 dcInverse
.SelectObject(m_bmpArrows
[Arrow_Inverted
][n
]);
1479 dcInverse
.Blit(0, 0, w
, h
,
1482 dcInverse
.SelectObject(wxNullBitmap
);
1484 mask
= new wxMask(m_bmpArrows
[Arrow_Inverted
][n
], *wxBLACK
);
1485 m_bmpArrows
[Arrow_Inverted
][n
].SetMask(mask
);
1487 m_bmpArrows
[Arrow_InvertedDisabled
][n
].Create(w
, h
);
1488 dcInverse
.SelectObject(m_bmpArrows
[Arrow_InvertedDisabled
][n
]);
1490 dcInverse
.Blit(0, 0, w
, h
,
1493 dcInverse
.SelectObject(wxNullBitmap
);
1495 mask
= new wxMask(m_bmpArrows
[Arrow_InvertedDisabled
][n
], *wxBLACK
);
1496 m_bmpArrows
[Arrow_InvertedDisabled
][n
].SetMask(mask
);
1499 dcNormal
.SelectObject(wxNullBitmap
);
1500 dcDisabled
.SelectObject(wxNullBitmap
);
1502 mask
= new wxMask(m_bmpArrows
[Arrow_Normal
][n
], *wxWHITE
);
1503 m_bmpArrows
[Arrow_Normal
][n
].SetMask(mask
);
1504 mask
= new wxMask(m_bmpArrows
[Arrow_Disabled
][n
], *wxWHITE
);
1505 m_bmpArrows
[Arrow_Disabled
][n
].SetMask(mask
);
1507 m_bmpArrows
[Arrow_Pressed
][n
] = m_bmpArrows
[Arrow_Normal
][n
];
1511 bool wxWin32Renderer::AreScrollbarsInsideBorder() const
1516 // ----------------------------------------------------------------------------
1518 // ----------------------------------------------------------------------------
1520 void wxWin32Renderer::DrawLabel(wxDC
& dc
,
1521 const wxString
& label
,
1528 // the underscores are not drawn for focused controls in wxMSW
1529 if ( flags
& wxCONTROL_FOCUSED
)
1534 if ( flags
& wxCONTROL_DISABLED
)
1536 // the combination of wxCONTROL_SELECTED and wxCONTROL_DISABLED
1537 // currently only can happen for a menu item and it seems that Windows
1538 // doesn't draw the shadow in this case, so we don't do it neither
1539 if ( flags
& wxCONTROL_SELECTED
)
1541 // just make the label text greyed out
1542 dc
.SetTextForeground(m_penDarkGrey
.GetColour());
1544 flags
&= ~wxCONTROL_DISABLED
;
1548 wxStdRenderer::DrawLabel(dc
, label
, rect
, flags
, alignment
,
1549 indexAccel
, rectBounds
);
1552 void wxWin32Renderer::DrawFrameWithLabel(wxDC
& dc
,
1553 const wxString
& label
,
1554 const wxRect
& rectFrame
,
1555 const wxRect
& rectText
,
1561 label2
<< _T(' ') << label
<< _T(' ');
1562 if ( indexAccel
!= -1 )
1564 // adjust it as we prepended a space
1568 wxStdRenderer::DrawFrameWithLabel(dc
, label2
, rectFrame
, rectText
,
1569 flags
, alignment
, indexAccel
);
1572 void wxWin32Renderer::DrawButtonLabel(wxDC
& dc
,
1573 const wxString
& label
,
1574 const wxBitmap
& image
,
1581 // the underscores are not drawn for focused controls in wxMSW
1582 if ( flags
& wxCONTROL_PRESSED
)
1587 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
, alignment
,
1588 indexAccel
, rectBounds
);
1591 void wxWin32Renderer::DrawButtonBorder(wxDC
& dc
,
1592 const wxRect
& rectTotal
,
1596 wxRect rect
= rectTotal
;
1598 wxPen
penOut(*wxBLACK
);
1599 if ( flags
& wxCONTROL_PRESSED
)
1601 // button pressed: draw a double border around it
1602 DrawRect(dc
, &rect
, penOut
);
1603 DrawRect(dc
, &rect
, m_penDarkGrey
);
1605 else // button not pressed
1607 if ( flags
& (wxCONTROL_FOCUSED
| wxCONTROL_ISDEFAULT
) )
1609 // button either default or focused (or both): add an extra border
1611 DrawRect(dc
, &rect
, penOut
);
1614 // now draw a normal button border
1615 DrawRaisedBorder(dc
, &rect
);
1622 // ----------------------------------------------------------------------------
1623 // (check)listbox items
1624 // ----------------------------------------------------------------------------
1626 void wxWin32Renderer::DrawCheckItemBitmap(wxDC
& dc
,
1627 const wxBitmap
& bitmap
,
1636 else // use default bitmap
1638 IndicatorStatus i
= flags
& wxCONTROL_CHECKED
1639 ? IndicatorStatus_Checked
1640 : IndicatorStatus_Unchecked
;
1642 if ( !m_bmpCheckBitmaps
[i
].Ok() )
1644 m_bmpCheckBitmaps
[i
] = wxBitmap(ms_xpmChecked
[i
]);
1647 bmp
= m_bmpCheckBitmaps
[i
];
1650 dc
.DrawBitmap(bmp
, rect
.x
, rect
.y
+ (rect
.height
- bmp
.GetHeight()) / 2 - 1,
1651 true /* use mask */);
1654 // ----------------------------------------------------------------------------
1655 // check/radio buttons
1656 // ----------------------------------------------------------------------------
1658 wxBitmap
wxWin32Renderer::GetIndicator(IndicatorType indType
, int flags
)
1660 IndicatorState indState
;
1661 IndicatorStatus indStatus
;
1662 GetIndicatorsFromFlags(flags
, indState
, indStatus
);
1664 wxBitmap
& bmp
= m_bmpIndicators
[indType
][indState
][indStatus
];
1667 const char **xpm
= ms_xpmIndicators
[indType
][indState
][indStatus
];
1670 // create and cache it
1671 bmp
= wxBitmap(xpm
);
1678 // ----------------------------------------------------------------------------
1680 // ----------------------------------------------------------------------------
1683 void wxWin32Renderer::DrawToolBarButton(wxDC
& dc
,
1684 const wxString
& label
,
1685 const wxBitmap
& bitmap
,
1686 const wxRect
& rectOrig
,
1691 if (style
== wxTOOL_STYLE_BUTTON
)
1693 wxRect rect
= rectOrig
;
1694 rect
.Deflate(BORDER_THICKNESS
);
1696 if ( flags
& wxCONTROL_PRESSED
)
1698 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
);
1700 else if ( flags
& wxCONTROL_CURRENT
)
1702 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
);
1705 if(tbarStyle
& wxTB_TEXT
)
1707 if(tbarStyle
& wxTB_HORIZONTAL
)
1709 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1713 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1718 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1719 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1720 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
);
1723 else if (style
== wxTOOL_STYLE_SEPARATOR
)
1725 // leave a small gap aroudn the line, also account for the toolbar
1727 if(rectOrig
.height
> rectOrig
.width
)
1730 DrawVerticalLine(dc
, rectOrig
.x
+ rectOrig
.width
/2,
1731 rectOrig
.y
+ 2*BORDER_THICKNESS
,
1732 rectOrig
.GetBottom() - BORDER_THICKNESS
);
1737 DrawHorizontalLine(dc
, rectOrig
.y
+ rectOrig
.height
/2,
1738 rectOrig
.x
+ 2*BORDER_THICKNESS
,
1739 rectOrig
.GetRight() - BORDER_THICKNESS
);
1742 // don't draw wxTOOL_STYLE_CONTROL
1744 #endif // wxUSE_TOOLBAR
1746 // ----------------------------------------------------------------------------
1748 // ----------------------------------------------------------------------------
1752 void wxWin32Renderer::DrawTab(wxDC
& dc
,
1753 const wxRect
& rectOrig
,
1755 const wxString
& label
,
1756 const wxBitmap
& bitmap
,
1760 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1761 #define REVERSE_FOR_VERTICAL(X,Y) \
1762 SELECT_FOR_VERTICAL(X,Y) \
1764 SELECT_FOR_VERTICAL(Y,X)
1766 wxRect rect
= rectOrig
;
1768 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1770 // the current tab is drawn indented (to the top for default case) and
1771 // bigger than the other ones
1772 const wxSize indent
= GetTabIndent();
1773 if ( flags
& wxCONTROL_SELECTED
)
1775 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1776 SELECT_FOR_VERTICAL( 0, indent
.y
));
1780 wxFAIL_MSG(_T("invaild notebook tab orientation"));
1787 rect
.height
+= indent
.y
;
1794 rect
.width
+= indent
.x
;
1799 // draw the text, image and the focus around them (if necessary)
1800 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1801 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1803 rectLabel
.Deflate(1, 1);
1806 // draw it horizontally into memory and rotate for screen
1808 wxBitmap bitmapRotated
,
1809 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1810 rectLabel
.y
+ rectLabel
.height
);
1811 dcMem
.SelectObject(bitmapMem
);
1812 dcMem
.SetBackground(dc
.GetBackground());
1813 dcMem
.SetFont(dc
.GetFont());
1814 dcMem
.SetTextForeground(dc
.GetTextForeground());
1818 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1821 #endif // wxUSE_IMAGE
1823 DrawButtonLabel(dcMem
, label
, bitmapRotated
, rectLabel
,
1824 flags
, wxALIGN_CENTRE
, indexAccel
);
1825 dcMem
.SelectObject(wxNullBitmap
);
1826 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1828 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
));
1829 #endif // wxUSE_IMAGE
1830 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1834 DrawButtonLabel(dc
, label
, bitmap
, rectLabel
,
1835 flags
, wxALIGN_CENTRE
, indexAccel
);
1838 // now draw the tab border itself (maybe use DrawRoundedRectangle()?)
1839 static const wxCoord CUTOFF
= 2; // radius of the rounded corner
1840 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1841 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1842 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1843 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1845 // FIXME: all this code will break if the tab indent or the border width,
1846 // it is tied to the fact that both of them are equal to 2
1852 // left orientation looks like top but IsVertical makes x and y reversed
1854 // top is not vertical so use coordinates in written order
1855 dc
.SetPen(m_penHighlight
);
1856 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1857 REVERSE_FOR_VERTICAL(x
, y
+ CUTOFF
));
1858 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
+ CUTOFF
),
1859 REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y
));
1860 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y
),
1861 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y
));
1863 dc
.SetPen(m_penBlack
);
1864 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1865 REVERSE_FOR_VERTICAL(x2
, y
+ CUTOFF
));
1866 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
+ CUTOFF
),
1867 REVERSE_FOR_VERTICAL(x2
- CUTOFF
, y
));
1869 dc
.SetPen(m_penDarkGrey
);
1870 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1871 REVERSE_FOR_VERTICAL(x2
- 1, y
+ CUTOFF
- 1));
1873 if ( flags
& wxCONTROL_SELECTED
)
1875 dc
.SetPen(m_penLightGrey
);
1877 // overwrite the part of the border below this tab
1878 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1879 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1881 // and the shadow of the tab to the left of us
1882 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ CUTOFF
+ 1),
1883 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1888 // right orientation looks like bottom but IsVertical makes x and y reversed
1890 // bottom is not vertical so use coordinates in written order
1891 dc
.SetPen(m_penHighlight
);
1892 // we need to continue one pixel further to overwrite the corner of
1893 // the border for the selected tab
1894 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1895 REVERSE_FOR_VERTICAL(x
, y2
- CUTOFF
));
1896 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
- CUTOFF
),
1897 REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
));
1899 dc
.SetPen(m_penBlack
);
1900 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
),
1901 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y2
));
1902 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1903 REVERSE_FOR_VERTICAL(x2
, y2
- CUTOFF
));
1904 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
- CUTOFF
),
1905 REVERSE_FOR_VERTICAL(x2
- CUTOFF
, y2
));
1907 dc
.SetPen(m_penDarkGrey
);
1908 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
- 1),
1909 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y2
- 1));
1910 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1911 REVERSE_FOR_VERTICAL(x2
- 1, y2
- CUTOFF
+ 1));
1913 if ( flags
& wxCONTROL_SELECTED
)
1915 dc
.SetPen(m_penLightGrey
);
1917 // overwrite the part of the (double!) border above this tab
1918 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1919 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1920 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1921 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1923 // and the shadow of the tab to the left of us
1924 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- CUTOFF
),
1925 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1930 #undef SELECT_FOR_VERTICAL
1931 #undef REVERSE_FOR_VERTICAL
1934 #endif // wxUSE_NOTEBOOK
1938 // ----------------------------------------------------------------------------
1940 // ----------------------------------------------------------------------------
1943 wxWin32Renderer::GetSliderThumbSize(const wxRect
& WXUNUSED(rect
),
1945 wxOrientation orient
) const
1948 wxCoord width
= wxMax (lenThumb
, SLIDER_THUMB_LENGTH
) / 2;
1949 wxCoord height
= wxMax (lenThumb
, SLIDER_THUMB_LENGTH
);
1951 if (orient
== wxHORIZONTAL
)
1965 wxRect
wxWin32Renderer::GetSliderShaftRect(const wxRect
& rectOrig
,
1967 wxOrientation orient
,
1970 bool transpose
= (orient
== wxVERTICAL
);
1971 bool left
= ((style
& wxSL_AUTOTICKS
) != 0) &
1972 (((style
& wxSL_TOP
) != 0) & !transpose
|
1973 ((style
& wxSL_LEFT
) != 0) & transpose
|
1974 ((style
& wxSL_BOTH
) != 0));
1975 bool right
= ((style
& wxSL_AUTOTICKS
) != 0) &
1976 (((style
& wxSL_BOTTOM
) != 0) & !transpose
|
1977 ((style
& wxSL_RIGHT
) != 0) & transpose
|
1978 ((style
& wxSL_BOTH
) != 0));
1980 wxRect rect
= rectOrig
;
1982 wxSize sizeThumb
= GetSliderThumbSize (rect
, lenThumb
, orient
);
1984 if (orient
== wxHORIZONTAL
) {
1985 rect
.x
+= SLIDER_MARGIN
;
1988 rect
.y
+= wxMax ((rect
.height
- 2*BORDER_THICKNESS
) / 2, sizeThumb
.y
/2);
1992 rect
.y
+= wxMax ((rect
.height
- 2*BORDER_THICKNESS
- sizeThumb
.y
/2), sizeThumb
.y
/2);
1996 rect
.y
+= sizeThumb
.y
/2;
1998 rect
.width
-= 2*SLIDER_MARGIN
;
1999 rect
.height
= 2*BORDER_THICKNESS
;
2003 rect
.y
+= SLIDER_MARGIN
;
2006 rect
.x
+= wxMax ((rect
.width
- 2*BORDER_THICKNESS
) / 2, sizeThumb
.x
/2);
2010 rect
.x
+= wxMax ((rect
.width
- 2*BORDER_THICKNESS
- sizeThumb
.x
/2), sizeThumb
.x
/2);
2014 rect
.x
+= sizeThumb
.x
/2;
2016 rect
.width
= 2*BORDER_THICKNESS
;
2017 rect
.height
-= 2*SLIDER_MARGIN
;
2023 void wxWin32Renderer::DrawSliderShaft(wxDC
& dc
,
2024 const wxRect
& rectOrig
,
2026 wxOrientation orient
,
2031 /* show shaft geometry
2049 if (flags
& wxCONTROL_FOCUSED
) {
2050 DrawFocusRect(dc
, rectOrig
);
2053 wxRect rect
= GetSliderShaftRect(rectOrig
, lenThumb
, orient
, style
);
2055 if (rectShaft
) *rectShaft
= rect
;
2057 DrawSunkenBorder(dc
, &rect
);
2060 void wxWin32Renderer::DrawSliderThumb(wxDC
& dc
,
2062 wxOrientation orient
,
2066 /* show thumb geometry
2075 H D B where H is highlight colour
2089 The interior of this shape is filled with the hatched brush if the thumb
2093 DrawBackground(dc
, wxNullColour
, rect
, flags
);
2095 bool transpose
= (orient
== wxVERTICAL
);
2096 bool left
= ((style
& wxSL_AUTOTICKS
) != 0) &
2097 (((style
& wxSL_TOP
) != 0) & !transpose
|
2098 ((style
& wxSL_LEFT
) != 0) & transpose
) &
2099 ((style
& wxSL_BOTH
) == 0);
2100 bool right
= ((style
& wxSL_AUTOTICKS
) != 0) &
2101 (((style
& wxSL_BOTTOM
) != 0) & !transpose
|
2102 ((style
& wxSL_RIGHT
) != 0) & transpose
) &
2103 ((style
& wxSL_BOTH
) == 0);
2105 wxCoord sizeArrow
= (transpose
? rect
.height
: rect
.width
) / 2;
2106 wxCoord c
= ((transpose
? rect
.height
: rect
.width
) - 2*sizeArrow
);
2108 wxCoord x1
, x2
, x3
, y1
, y2
, y3
, y4
;
2109 x1
= (transpose
? rect
.y
: rect
.x
);
2110 x2
= (transpose
? rect
.GetBottom() : rect
.GetRight());
2111 x3
= (x1
-1+c
) + sizeArrow
;
2112 y1
= (transpose
? rect
.x
: rect
.y
);
2113 y2
= (transpose
? rect
.GetRight() : rect
.GetBottom());
2114 y3
= (left
? (y1
-1+c
) + sizeArrow
: y1
);
2115 y4
= (right
? (y2
+1-c
) - sizeArrow
: y2
);
2117 dc
.SetPen(m_penBlack
);
2119 DrawLine(dc
, x3
+1-c
, y1
, x2
, y3
, transpose
);
2121 DrawLine(dc
, x2
, y3
, x2
, y4
, transpose
);
2124 DrawLine(dc
, x3
+1-c
, y2
, x2
, y4
, transpose
);
2128 DrawLine(dc
, x1
, y2
, x2
, y2
, transpose
);
2131 dc
.SetPen(m_penDarkGrey
);
2132 DrawLine(dc
, x2
-1, y3
+1, x2
-1, y4
-1, transpose
);
2134 DrawLine(dc
, x3
+1-c
, y2
-1, x2
-1, y4
, transpose
);
2138 DrawLine(dc
, x1
+1, y2
-1, x2
-1, y2
-1, transpose
);
2141 dc
.SetPen(m_penHighlight
);
2144 DrawLine(dc
, x1
, y3
, x3
, y1
, transpose
);
2145 DrawLine(dc
, x3
+1-c
, y1
+1, x2
-1, y3
, transpose
);
2149 DrawLine(dc
, x1
, y1
, x2
, y1
, transpose
);
2151 DrawLine(dc
, x1
, y3
, x1
, y4
, transpose
);
2154 DrawLine(dc
, x1
, y4
, x3
+c
, y2
+c
, transpose
);
2157 if (flags
& wxCONTROL_PRESSED
) {
2158 // TODO: MSW fills the entire area inside, not just the rect
2159 wxRect rectInt
= rect
;
2162 rectInt
.SetLeft(y3
);
2163 rectInt
.SetRight(y4
);
2168 rectInt
.SetBottom(y4
);
2172 #if !defined(__WXMGL__)
2173 static const char *stipple_xpm
[] = {
2174 /* columns rows colors chars-per-pixel */
2183 // VS: MGL can only do 8x8 stipple brushes
2184 static const char *stipple_xpm
[] = {
2185 /* columns rows colors chars-per-pixel */
2200 dc
.SetBrush(wxBrush(stipple_xpm
));
2202 dc
.SetTextForeground(wxSCHEME_COLOUR(m_scheme
, SHADOW_HIGHLIGHT
));
2203 dc
.SetTextBackground(wxSCHEME_COLOUR(m_scheme
, CONTROL
));
2204 dc
.SetPen(*wxTRANSPARENT_PEN
);
2205 dc
.DrawRectangle(rectInt
);
2209 void wxWin32Renderer::DrawSliderTicks(wxDC
& dc
,
2212 wxOrientation orient
,
2216 int WXUNUSED(flags
),
2219 /* show ticks geometry
2234 if (end
== start
) return;
2236 bool transpose
= (orient
== wxVERTICAL
);
2237 bool left
= ((style
& wxSL_AUTOTICKS
) != 0) &
2238 (((style
& wxSL_TOP
) != 0) & !transpose
|
2239 ((style
& wxSL_LEFT
) != 0) & transpose
|
2240 ((style
& wxSL_BOTH
) != 0));
2241 bool right
= ((style
& wxSL_AUTOTICKS
) != 0) &
2242 (((style
& wxSL_BOTTOM
) != 0) & !transpose
|
2243 ((style
& wxSL_RIGHT
) != 0) & transpose
|
2244 ((style
& wxSL_BOTH
) != 0));
2246 // default thumb size
2247 wxSize sizeThumb
= GetSliderThumbSize (rect
, 0, orient
);
2248 wxCoord defaultLen
= (transpose
? sizeThumb
.x
: sizeThumb
.y
);
2250 // normal thumb size
2251 sizeThumb
= GetSliderThumbSize (rect
, lenThumb
, orient
);
2252 wxCoord widthThumb
= (transpose
? sizeThumb
.y
: sizeThumb
.x
);
2254 wxRect rectShaft
= GetSliderShaftRect (rect
, lenThumb
, orient
, style
);
2256 wxCoord x1
, x2
, y1
, y2
, y3
, y4
, len
;
2257 x1
= (transpose
? rectShaft
.y
: rectShaft
.x
) + widthThumb
/2;
2258 x2
= (transpose
? rectShaft
.GetBottom() : rectShaft
.GetRight()) - widthThumb
/2;
2259 y1
= (transpose
? rectShaft
.x
: rectShaft
.y
) - defaultLen
/2;
2260 y2
= (transpose
? rectShaft
.GetRight() : rectShaft
.GetBottom()) + defaultLen
/2;
2261 y3
= (transpose
? rect
.x
: rect
.y
);
2262 y4
= (transpose
? rect
.GetRight() : rect
.GetBottom());
2265 dc
.SetPen(m_penBlack
);
2267 int range
= end
- start
;
2268 for ( int n
= 0; n
< range
; n
+= step
) {
2269 wxCoord x
= x1
+ (len
*n
) / range
;
2271 if (left
& (y1
> y3
)) {
2272 DrawLine(dc
, x
, y1
, x
, y3
, orient
== wxVERTICAL
);
2274 if (right
& (y4
> y2
)) {
2275 DrawLine(dc
, x
, y2
, x
, y4
, orient
== wxVERTICAL
);
2278 // always draw the line at the end position
2279 if (left
& (y1
> y3
)) {
2280 DrawLine(dc
, x2
, y1
, x2
, y3
, orient
== wxVERTICAL
);
2282 if (right
& (y4
> y2
)) {
2283 DrawLine(dc
, x2
, y2
, x2
, y4
, orient
== wxVERTICAL
);
2287 #endif // wxUSE_SLIDER
2291 // ----------------------------------------------------------------------------
2293 // ----------------------------------------------------------------------------
2295 // wxWin32MenuGeometryInfo: the wxMenuGeometryInfo used by wxWin32Renderer
2296 class WXDLLEXPORT wxWin32MenuGeometryInfo
: public wxMenuGeometryInfo
2299 virtual wxSize
GetSize() const { return m_size
; }
2301 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
2302 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
2304 wxCoord
GetItemHeight() const { return m_heightItem
; }
2307 // the total size of the menu
2310 // the offset of the start of the menu item label
2313 // the offset of the start of the accel label
2316 // the height of a normal (not separator) item
2317 wxCoord m_heightItem
;
2319 friend wxMenuGeometryInfo
*
2320 wxWin32Renderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
2323 // FIXME: all constants are hardcoded but shouldn't be
2324 static const wxCoord MENU_LEFT_MARGIN
= 9;
2325 static const wxCoord MENU_RIGHT_MARGIN
= 18;
2326 static const wxCoord MENU_VERT_MARGIN
= 3;
2328 // the margin around bitmap/check marks (on each side)
2329 static const wxCoord MENU_BMP_MARGIN
= 2;
2331 // the margin between the labels and accel strings
2332 static const wxCoord MENU_ACCEL_MARGIN
= 8;
2334 // the separator height in pixels: in fact, strangely enough, the real height
2335 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
2337 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
2339 // the size of the standard checkmark bitmap
2340 static const wxCoord MENU_CHECK_SIZE
= 9;
2342 void wxWin32Renderer::DrawMenuBarItem(wxDC
& dc
,
2343 const wxRect
& rectOrig
,
2344 const wxString
& label
,
2348 wxRect rect
= rectOrig
;
2351 wxDCTextColourChanger
colChanger(dc
);
2353 if ( flags
& wxCONTROL_SELECTED
)
2355 colChanger
.Set(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
2357 const wxColour colBg
= wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
);
2360 dc
.DrawRectangle(rect
);
2363 // don't draw the focus rect around menu bar items
2364 DrawLabel(dc
, label
, rect
, flags
& ~wxCONTROL_FOCUSED
,
2365 wxALIGN_CENTRE
, indexAccel
);
2368 void wxWin32Renderer::DrawMenuItem(wxDC
& dc
,
2370 const wxMenuGeometryInfo
& gi
,
2371 const wxString
& label
,
2372 const wxString
& accel
,
2373 const wxBitmap
& bitmap
,
2377 const wxWin32MenuGeometryInfo
& geometryInfo
=
2378 (const wxWin32MenuGeometryInfo
&)gi
;
2383 rect
.width
= geometryInfo
.GetSize().x
;
2384 rect
.height
= geometryInfo
.GetItemHeight();
2386 // draw the selected item specially
2387 wxDCTextColourChanger
colChanger(dc
);
2388 if ( flags
& wxCONTROL_SELECTED
)
2390 colChanger
.Set(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
2392 const wxColour colBg
= wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
);
2395 dc
.DrawRectangle(rect
);
2398 // draw the bitmap: use the bitmap provided or the standard checkmark for
2399 // the checkable items
2400 wxBitmap bmp
= bitmap
;
2401 if ( !bmp
.Ok() && (flags
& wxCONTROL_CHECKED
) )
2403 bmp
= GetIndicator(IndicatorType_Menu
, flags
);
2408 rect
.SetRight(geometryInfo
.GetLabelOffset());
2409 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
2413 rect
.x
= geometryInfo
.GetLabelOffset();
2414 rect
.SetRight(geometryInfo
.GetAccelOffset());
2416 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
2418 // draw the accel string
2419 rect
.x
= geometryInfo
.GetAccelOffset();
2420 rect
.SetRight(geometryInfo
.GetSize().x
);
2422 // NB: no accel index here
2423 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
2425 // draw the submenu indicator
2426 if ( flags
& wxCONTROL_ISSUBMENU
)
2428 rect
.x
= geometryInfo
.GetSize().x
- MENU_RIGHT_MARGIN
;
2429 rect
.width
= MENU_RIGHT_MARGIN
;
2431 ArrowStyle arrowStyle
;
2432 if ( flags
& wxCONTROL_DISABLED
)
2433 arrowStyle
= flags
& wxCONTROL_SELECTED
? Arrow_InvertedDisabled
2435 else if ( flags
& wxCONTROL_SELECTED
)
2436 arrowStyle
= Arrow_Inverted
;
2438 arrowStyle
= Arrow_Normal
;
2440 DrawArrow(dc
, rect
, Arrow_Right
, arrowStyle
);
2444 void wxWin32Renderer::DrawMenuSeparator(wxDC
& dc
,
2446 const wxMenuGeometryInfo
& geomInfo
)
2448 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
2451 wxSize
wxWin32Renderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
2453 wxSize size
= sizeText
;
2455 // FIXME: menubar height is configurable under Windows
2462 wxMenuGeometryInfo
*wxWin32Renderer::GetMenuGeometry(wxWindow
*win
,
2463 const wxMenu
& menu
) const
2465 // prepare the dc: for now we draw all the items with the system font
2467 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
2469 // the height of a normal item
2470 wxCoord heightText
= dc
.GetCharHeight();
2475 // the max length of label and accel strings: the menu width is the sum of
2476 // them, even if they're for different items (as the accels should be
2479 // the max length of the bitmap is never 0 as Windows always leaves enough
2480 // space for a check mark indicator
2481 wxCoord widthLabelMax
= 0,
2483 widthBmpMax
= MENU_LEFT_MARGIN
;
2485 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
2487 node
= node
->GetNext() )
2489 // height of this item
2492 wxMenuItem
*item
= node
->GetData();
2493 if ( item
->IsSeparator() )
2495 h
= MENU_SEPARATOR_HEIGHT
;
2497 else // not separator
2502 dc
.GetTextExtent(item
->GetLabel(), &widthLabel
, NULL
);
2503 if ( widthLabel
> widthLabelMax
)
2505 widthLabelMax
= widthLabel
;
2509 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
2510 if ( widthAccel
> widthAccelMax
)
2512 widthAccelMax
= widthAccel
;
2515 const wxBitmap
& bmp
= item
->GetBitmap();
2518 wxCoord widthBmp
= bmp
.GetWidth();
2519 if ( widthBmp
> widthBmpMax
)
2520 widthBmpMax
= widthBmp
;
2522 //else if ( item->IsCheckable() ): no need to check for this as
2523 // MENU_LEFT_MARGIN is big enough to show the check mark
2526 h
+= 2*MENU_VERT_MARGIN
;
2528 // remember the item position and height
2529 item
->SetGeometry(height
, h
);
2534 // bundle the metrics into a struct and return it
2535 wxWin32MenuGeometryInfo
*gi
= new wxWin32MenuGeometryInfo
;
2537 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
2538 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
2539 if ( widthAccelMax
> 0 )
2541 // if we actually have any accesl, add a margin
2542 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
2545 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
2547 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
2548 gi
->m_size
.y
= height
;
2553 #endif // wxUSE_MENUS
2557 // ----------------------------------------------------------------------------
2559 // ----------------------------------------------------------------------------
2561 void wxWin32Renderer::DrawStatusField(wxDC
& dc
,
2563 const wxString
& label
,
2569 if ( flags
& wxCONTROL_SIZEGRIP
)
2571 // draw the size grip: it is a normal rect except that in the lower
2572 // right corner we have several bands which may be used for dragging
2573 // the status bar corner
2575 // each band consists of 4 stripes: m_penHighlight, double
2576 // m_penDarkGrey and transparent one
2577 wxCoord x2
= rect
.GetRight(),
2578 y2
= rect
.GetBottom();
2580 // draw the upper left part of the rect normally
2581 if (style
!= wxSB_FLAT
)
2583 if (style
== wxSB_RAISED
)
2584 dc
.SetPen(m_penHighlight
);
2586 dc
.SetPen(m_penDarkGrey
);
2587 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(), rect
.GetLeft(), y2
);
2588 dc
.DrawLine(rect
.GetLeft() + 1, rect
.GetTop(), x2
, rect
.GetTop());
2591 // draw the grey stripes of the grip
2593 wxCoord ofs
= WIDTH_STATUSBAR_GRIP_BAND
- 1;
2594 for ( n
= 0; n
< NUM_STATUSBAR_GRIP_BANDS
; n
++, ofs
+= WIDTH_STATUSBAR_GRIP_BAND
)
2596 dc
.DrawLine(x2
- ofs
+ 1, y2
- 1, x2
, y2
- ofs
);
2597 dc
.DrawLine(x2
- ofs
, y2
- 1, x2
, y2
- ofs
- 1);
2600 // draw the white stripes
2601 dc
.SetPen(m_penHighlight
);
2602 ofs
= WIDTH_STATUSBAR_GRIP_BAND
+ 1;
2603 for ( n
= 0; n
< NUM_STATUSBAR_GRIP_BANDS
; n
++, ofs
+= WIDTH_STATUSBAR_GRIP_BAND
)
2605 dc
.DrawLine(x2
- ofs
+ 1, y2
- 1, x2
, y2
- ofs
);
2608 // draw the remaining rect boundaries
2609 if (style
!= wxSB_FLAT
)
2611 if (style
== wxSB_RAISED
)
2612 dc
.SetPen(m_penDarkGrey
);
2614 dc
.SetPen(m_penHighlight
);
2615 ofs
-= WIDTH_STATUSBAR_GRIP_BAND
;
2616 dc
.DrawLine(x2
, rect
.GetTop(), x2
, y2
- ofs
+ 1);
2617 dc
.DrawLine(rect
.GetLeft(), y2
, x2
- ofs
+ 1, y2
);
2623 rectIn
.width
-= STATUSBAR_GRIP_SIZE
;
2625 // this will prevent the standard version from drawing any borders
2629 wxStdRenderer::DrawStatusField(dc
, rect
, label
, flags
, style
);
2632 #endif // wxUSE_STATUSBAR
2634 // ----------------------------------------------------------------------------
2636 // ----------------------------------------------------------------------------
2638 void wxWin32Renderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
2639 wxBitmap
* WXUNUSED(bmpFocus
),
2640 wxBitmap
*bmpPressed
,
2641 wxBitmap
*bmpDisabled
)
2643 static const wxCoord widthCombo
= 16;
2644 static const wxCoord heightCombo
= 17;
2650 bmpNormal
->Create(widthCombo
, heightCombo
);
2651 dcMem
.SelectObject(*bmpNormal
);
2652 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2653 Arrow_Down
, Arrow_Normal
);
2658 bmpPressed
->Create(widthCombo
, heightCombo
);
2659 dcMem
.SelectObject(*bmpPressed
);
2660 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2661 Arrow_Down
, Arrow_Pressed
);
2666 bmpDisabled
->Create(widthCombo
, heightCombo
);
2667 dcMem
.SelectObject(*bmpDisabled
);
2668 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2669 Arrow_Down
, Arrow_Disabled
);
2673 // ----------------------------------------------------------------------------
2675 // ----------------------------------------------------------------------------
2677 void wxWin32Renderer::DrawArrowBorder(wxDC
& dc
, wxRect
*rect
, bool isPressed
)
2681 DrawRect(dc
, rect
, m_penDarkGrey
);
2683 // the arrow is usually drawn inside border of width 2 and is offset by
2684 // another pixel in both directions when it's pressed - as the border
2685 // in this case is more narrow as well, we have to adjust rect like
2693 DrawAntiSunkenBorder(dc
, rect
);
2697 void wxWin32Renderer::DrawArrow(wxDC
& dc
,
2702 ArrowStyle arrowStyle
;
2703 if ( flags
& wxCONTROL_PRESSED
)
2705 // can't be pressed and disabled
2706 arrowStyle
= Arrow_Pressed
;
2710 arrowStyle
= flags
& wxCONTROL_DISABLED
? Arrow_Disabled
: Arrow_Normal
;
2713 DrawArrowButton(dc
, rect
, GetArrowDirection(dir
), arrowStyle
);
2716 void wxWin32Renderer::DrawArrow(wxDC
& dc
,
2718 ArrowDirection arrowDir
,
2719 ArrowStyle arrowStyle
)
2721 const wxBitmap
& bmp
= m_bmpArrows
[arrowStyle
][arrowDir
];
2723 // under Windows the arrows always have the same size so just centre it in
2724 // the provided rectangle
2725 wxCoord x
= rect
.x
+ (rect
.width
- bmp
.GetWidth()) / 2,
2726 y
= rect
.y
+ (rect
.height
- bmp
.GetHeight()) / 2;
2728 // Windows does it like this...
2729 if ( arrowDir
== Arrow_Left
)
2733 dc
.DrawBitmap(bmp
, x
, y
, true /* use mask */);
2736 void wxWin32Renderer::DrawArrowButton(wxDC
& dc
,
2737 const wxRect
& rectAll
,
2738 ArrowDirection arrowDir
,
2739 ArrowStyle arrowStyle
)
2741 wxRect rect
= rectAll
;
2742 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), rect
);
2743 DrawArrowBorder(dc
, &rect
, arrowStyle
== Arrow_Pressed
);
2744 DrawArrow(dc
, rect
, arrowDir
, arrowStyle
);
2747 void wxWin32Renderer::DrawScrollbarThumb(wxDC
& dc
,
2748 wxOrientation
WXUNUSED(orient
),
2750 int WXUNUSED(flags
))
2752 // we don't use the flags, the thumb never changes appearance
2753 wxRect rectThumb
= rect
;
2754 DrawArrowBorder(dc
, &rectThumb
);
2755 DrawBackground(dc
, wxNullColour
, rectThumb
);
2758 void wxWin32Renderer::DrawScrollbarShaft(wxDC
& dc
,
2759 wxOrientation
WXUNUSED(orient
),
2760 const wxRect
& rectBar
,
2763 wxColourScheme::StdColour col
= flags
& wxCONTROL_PRESSED
2764 ? wxColourScheme::SCROLLBAR_PRESSED
2765 : wxColourScheme::SCROLLBAR
;
2766 DrawBackground(dc
, m_scheme
->Get(col
), rectBar
);
2769 // ----------------------------------------------------------------------------
2771 // ----------------------------------------------------------------------------
2773 /* Copyright (c) Julian Smart */
2774 static char *error_xpm
[]={
2775 /* columns rows colors chars-per-pixel */
2852 " $oooooooooooo%& ",
2853 " *=-ooooooooooooo;: ",
2854 " *oooooooooooooooooo> ",
2855 " =ooooooooooooooooooo, ",
2856 " $-ooooooooooooooooooo<1 ",
2857 " .oooooo2334ooo533oooooo6 ",
2858 " +ooooooo789oo2883oooooo0q ",
2859 " oooooooo2w83o78eoooooooor ",
2860 " toooooooooy88u884oooooooori ",
2861 " Xooooooooooe888poooooooooas ",
2862 " ooooooooooo4889doooooooooof ",
2863 " ooooooooooo588w2oooooooooofi ",
2864 " oooooooooodw8887oooooooooofi ",
2865 " goooooooooh8w588jooooooookli ",
2866 " tooooooooz885op8wdooooooorix ",
2867 " oooooood98cood98cooooooori ",
2868 " @oooooop8w2ooo5885ooooovbi ",
2869 " n%ooooooooooooooooooooomiM ",
2870 " &;oooooooooooooooooooNBiV ",
2871 " :ooooooooooooooooooCZiA ",
2872 " nSooooooooooooooooCDiF ",
2873 " nG<oooooooooooooNZiiH ",
2874 " 160ooooooooovmBiFH ",
2875 " nqrraoookrrbiiA ",
2882 /* Copyright (c) Julian Smart */
2883 static char *info_xpm
[]={
2884 /* columns rows colors chars-per-pixel */
2906 " ..XXXXXXXXXXXXX.. ",
2907 " .XXXXXXXXXXXXXXXXX. ",
2908 " .XXXXXXXXoO+XXXXXXXX. ",
2909 " .XXXXXXXXX@#OXXXXXXXXX. ",
2910 " .XXXXXXXXXX$@oXXXXXXXXXX. ",
2911 " .XXXXXXXXXXXXXXXXXXXXXXX.% ",
2912 " .XXXXXXXXX&*=-XXXXXXXXXX.%% ",
2913 ".XXXXXXXXXX;:#>XXXXXXXXXXX.% ",
2914 ".XXXXXXXXXXX;#+XXXXXXXXXXX.% ",
2915 ".XXXXXXXXXXX;#+XXXXXXXXXXX.%% ",
2916 " .XXXXXXXXXX;#+XXXXXXXXXX.%%% ",
2917 " .XXXXXXXXXX;#+XXXXXXXXXX.%%% ",
2918 " .XXXXXXXXXX;#+XXXXXXXXXX.%% ",
2919 " .XXXXXXXX*-##+XXXXXXXX.%%% ",
2920 " .XXXXXXXXXXXXXXXXXXX.%%%% ",
2921 " .XXXXXXXXXXXXXXXXX.%%%% ",
2922 " ..XXXXXXXXXXXXX..%%%% ",
2923 " %...XXXXXXXX..%%%%% ",
2924 " %%%..XXXXXX.%%%%% ",
2938 /* Copyright (c) Julian Smart */
2939 static char *question_xpm
[]={
2940 /* columns rows colors chars-per-pixel */
2961 " ..XXXXXXXXXXXXX.. ",
2962 " .XXXXXXoO++@XXXXXX. ",
2963 " .XXXXXXO#$$$$#%XXXXX. ",
2964 " .XXXXXX@$$#&&#$#oXXXXX. ",
2965 " .XXXXXXX*$$%XX%$$=XXXXXX. ",
2966 " .XXXXXXX+-;XXXX$$-XXXXXX.: ",
2967 " .XXXXXXXXXXXXX+$$&XXXXXX.:: ",
2968 ".XXXXXXXXXXXXo;$$*oXXXXXXX.: ",
2969 ".XXXXXXXXXXXo*$$*oXXXXXXXX.: ",
2970 ".XXXXXXXXXXX+$$*oXXXXXXXXX.:: ",
2971 " .XXXXXXXXXX-$$oXXXXXXXXX.::: ",
2972 " .XXXXXXXXXXX--XXXXXXXXXX.::: ",
2973 " .XXXXXXXXXXXXXXXXXXXXXXX.:: ",
2974 " .XXXXXXXXX-$$XXXXXXXXX.::: ",
2975 " .XXXXXXXX-$$XXXXXXXX.:::: ",
2976 " .XXXXXXXO++XXXXXXX.:::: ",
2977 " ..XXXXXXXXXXXXX..:::: ",
2978 " :...XXXXXXXX..::::: ",
2979 " :::..XXXXXX.::::: ",
2993 /* Copyright (c) Julian Smart */
2994 static char *warning_xpm
[]={
2995 /* columns rows colors chars-per-pixel */
3021 " ..XXXXO@#XXX... ",
3022 " ...XXXXO@#XXXX.. ",
3023 " ..XXXXXO@#XXXX... ",
3024 " ...XXXXXo@OXXXXX.. ",
3025 " ...XXXXXXo@OXXXXXX.. ",
3026 " ..XXXXXXX$@OXXXXXX... ",
3027 " ...XXXXXXXX@XXXXXXXX.. ",
3028 " ...XXXXXXXXXXXXXXXXXX... ",
3029 " ..XXXXXXXXXXOXXXXXXXXX.. ",
3030 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
3031 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
3032 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
3033 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
3034 " .............................. ",
3035 " .............................. ",
3042 wxBitmap
wxWin32ArtProvider::CreateBitmap(const wxArtID
& id
,
3043 const wxArtClient
& WXUNUSED(client
),
3044 const wxSize
& WXUNUSED(size
))
3046 if ( id
== wxART_INFORMATION
)
3047 return wxBitmap(info_xpm
);
3048 if ( id
== wxART_ERROR
)
3049 return wxBitmap(error_xpm
);
3050 if ( id
== wxART_WARNING
)
3051 return wxBitmap(warning_xpm
);
3052 if ( id
== wxART_QUESTION
)
3053 return wxBitmap(question_xpm
);
3054 return wxNullBitmap
;
3060 // ----------------------------------------------------------------------------
3061 // text control geometry
3062 // ----------------------------------------------------------------------------
3065 wxWin32Renderer::GetTextTotalArea(const wxTextCtrl
*text
,
3066 const wxRect
& rect
) const
3068 wxRect rectTotal
= wxStdRenderer::GetTextTotalArea(text
, rect
);
3070 // this is strange but it's what Windows does
3077 wxWin32Renderer::GetTextClientArea(const wxTextCtrl
*text
,
3079 wxCoord
*extraSpaceBeyond
) const
3081 wxRect rectText
= rect
;
3083 // undo GetTextTotalArea()
3084 if ( rectText
.height
> 0 )
3087 return wxStdRenderer::GetTextClientArea(text
, rect
, extraSpaceBeyond
);
3090 #endif // wxUSE_TEXTCTRL
3092 // ----------------------------------------------------------------------------
3094 // ----------------------------------------------------------------------------
3096 void wxWin32Renderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
3099 if ( wxDynamicCast(window
, wxScrollBar
) )
3101 // we only set the width of vert scrollbars and height of the
3103 if ( window
->GetWindowStyle() & wxSB_HORIZONTAL
)
3104 size
->y
= m_sizeScrollbarArrow
.y
;
3106 size
->x
= m_sizeScrollbarArrow
.x
;
3108 // skip border width adjustments, they don't make sense for us
3111 #endif // wxUSE_SCROLLBAR
3114 if ( wxDynamicCast(window
, wxBitmapButton
) )
3118 #endif // wxUSE_BMPBUTTON
3119 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
3122 || wxDynamicCast(window
, wxButton
)
3123 # endif // wxUSE_BUTTON
3124 # if wxUSE_TOGGLEBTN
3125 || wxDynamicCast(window
, wxToggleButton
)
3126 # endif // wxUSE_TOGGLEBTN
3129 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
3131 // TODO: don't harcode all this
3132 size
->x
+= 3*window
->GetCharWidth();
3134 wxCoord heightBtn
= (11*(window
->GetCharHeight() + 8))/10;
3135 if ( size
->y
< heightBtn
- 8 )
3136 size
->y
= heightBtn
;
3141 // for compatibility with other ports, the buttons default size is never
3142 // less than the standard one, but not when display not PDAs.
3143 if (wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA
)
3145 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
3147 wxSize szDef
= wxButton::GetDefaultSize();
3148 if ( size
->x
< szDef
.x
)
3153 // no border width adjustments for buttons
3156 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
3158 wxStdRenderer::AdjustSize(size
, window
);
3161 wxBitmap
wxWin32Renderer::GetFrameButtonBitmap(FrameButtonType type
)
3163 wxBitmap
& bmp
= m_bmpFrameButtons
[type
];
3166 bmp
= wxBitmap(ms_xpmFrameButtons
[type
]);
3172 // ============================================================================
3174 // ============================================================================
3176 // ----------------------------------------------------------------------------
3177 // wxWin32InputHandler
3178 // ----------------------------------------------------------------------------
3180 bool wxWin32InputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
3181 const wxKeyEvent
& WXUNUSED(event
),
3182 bool WXUNUSED(pressed
))
3187 bool wxWin32InputHandler::HandleMouse(wxInputConsumer
*control
,
3188 const wxMouseEvent
& event
)
3190 // clicking on the control gives it focus
3191 if ( event
.ButtonDown() )
3193 wxWindow
*win
= control
->GetInputWindow();
3195 if ( (wxWindow::FindFocus() != control
->GetInputWindow()) &&
3196 win
->AcceptsFocus() )
3209 // ----------------------------------------------------------------------------
3210 // wxWin32ScrollBarInputHandler
3211 // ----------------------------------------------------------------------------
3213 wxWin32ScrollBarInputHandler::
3214 wxWin32ScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
3215 : wxStdScrollBarInputHandler(renderer
, handler
)
3217 m_scrollPaused
= false;
3221 bool wxWin32ScrollBarInputHandler::OnScrollTimer(wxScrollBar
*scrollbar
,
3222 const wxControlAction
& action
)
3224 // stop if went beyond the position of the original click (this can only
3225 // happen when we scroll by pages)
3227 if ( action
== wxACTION_SCROLL_PAGE_DOWN
)
3229 stop
= m_renderer
->HitTestScrollbar(scrollbar
, m_ptStartScrolling
)
3230 != wxHT_SCROLLBAR_BAR_2
;
3232 else if ( action
== wxACTION_SCROLL_PAGE_UP
)
3234 stop
= m_renderer
->HitTestScrollbar(scrollbar
, m_ptStartScrolling
)
3235 != wxHT_SCROLLBAR_BAR_1
;
3240 StopScrolling(scrollbar
);
3242 scrollbar
->Refresh();
3247 return wxStdScrollBarInputHandler::OnScrollTimer(scrollbar
, action
);
3250 bool wxWin32ScrollBarInputHandler::HandleMouse(wxInputConsumer
*control
,
3251 const wxMouseEvent
& event
)
3253 // remember the current state
3254 bool wasDraggingThumb
= m_htLast
== wxHT_SCROLLBAR_THUMB
;
3256 // do process the message
3257 bool rc
= wxStdScrollBarInputHandler::HandleMouse(control
, event
);
3259 // analyse the changes
3260 if ( !wasDraggingThumb
&& (m_htLast
== wxHT_SCROLLBAR_THUMB
) )
3262 // we just started dragging the thumb, remember its initial position to
3263 // be able to restore it if the drag is cancelled later
3264 m_eventStartDrag
= event
;
3270 bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer
*control
,
3271 const wxMouseEvent
& event
)
3273 // we don't highlight scrollbar elements, so there is no need to process
3274 // mouse move events normally - only do it while mouse is captured (i.e.
3275 // when we're dragging the thumb or pressing on something)
3276 if ( !m_winCapture
)
3279 if ( event
.Entering() )
3281 // we're not interested in this at all
3285 wxScrollBar
*scrollbar
= wxStaticCast(control
->GetInputWindow(), wxScrollBar
);
3287 if ( m_scrollPaused
)
3289 // check if the mouse returned to its original location
3291 if ( event
.Leaving() )
3297 ht
= m_renderer
->HitTestScrollbar(scrollbar
, event
.GetPosition());
3298 if ( ht
== m_htLast
)
3300 // yes it did, resume scrolling
3301 m_scrollPaused
= false;
3302 if ( m_timerScroll
)
3304 // we were scrolling by line/page, restart timer
3305 m_timerScroll
->Start(m_interval
);
3307 Press(scrollbar
, true);
3309 else // we were dragging the thumb
3311 // restore its last location
3312 HandleThumbMove(scrollbar
, m_eventLastDrag
);
3318 else // normal case, scrolling hasn't been paused
3320 // if we're scrolling the scrollbar because the arrow or the shaft was
3321 // pressed, check that the mouse stays on the same scrollbar element
3324 // Always let thumb jump back if we leave the scrollbar
3325 if ( event
.Moving() )
3327 ht
= m_renderer
->HitTestScrollbar(scrollbar
, event
.GetPosition());
3329 else // event.Leaving()
3334 // Jump back only if we get far away from it
3335 wxPoint pos
= event
.GetPosition();
3336 if (scrollbar
->HasFlag( wxVERTICAL
))
3338 if (pos
.x
> -40 && pos
.x
< scrollbar
->GetSize().x
+40)
3343 if (pos
.y
> -40 && pos
.y
< scrollbar
->GetSize().y
+40)
3346 ht
= m_renderer
->HitTestScrollbar(scrollbar
, pos
);
3349 // if we're dragging the thumb and the mouse stays in the scrollbar, it
3350 // is still ok - we only want to catch the case when the mouse leaves
3351 // the scrollbar here
3352 if ( m_htLast
== wxHT_SCROLLBAR_THUMB
&& ht
!= wxHT_NOWHERE
)
3354 ht
= wxHT_SCROLLBAR_THUMB
;
3357 if ( ht
!= m_htLast
)
3359 // what were we doing? 2 possibilities: either an arrow/shaft was
3360 // pressed in which case we have a timer and so we just stop it or
3361 // we were dragging the thumb
3362 if ( m_timerScroll
)
3365 m_interval
= m_timerScroll
->GetInterval();
3366 m_timerScroll
->Stop();
3367 m_scrollPaused
= true;
3369 // unpress the arrow
3370 Press(scrollbar
, false);
3372 else // we were dragging the thumb
3374 // remember the current thumb position to be able to restore it
3375 // if the mouse returns to it later
3376 m_eventLastDrag
= event
;
3378 // and restore the original position (before dragging) of the
3380 HandleThumbMove(scrollbar
, m_eventStartDrag
);
3387 return wxStdInputHandler::HandleMouseMove(control
, event
);
3390 #endif // wxUSE_SCROLLBAR
3394 // ----------------------------------------------------------------------------
3395 // wxWin32CheckboxInputHandler
3396 // ----------------------------------------------------------------------------
3398 bool wxWin32CheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
3399 const wxKeyEvent
& event
,
3404 wxControlAction action
;
3405 int keycode
= event
.GetKeyCode();
3409 action
= wxACTION_CHECKBOX_TOGGLE
;
3413 case WXK_NUMPAD_SUBTRACT
:
3414 action
= wxACTION_CHECKBOX_CHECK
;
3418 case WXK_NUMPAD_ADD
:
3419 case WXK_NUMPAD_EQUAL
:
3420 action
= wxACTION_CHECKBOX_CLEAR
;
3424 if ( !action
.IsEmpty() )
3426 control
->PerformAction(action
);
3435 #endif // wxUSE_CHECKBOX
3439 // ----------------------------------------------------------------------------
3440 // wxWin32TextCtrlInputHandler
3441 // ----------------------------------------------------------------------------
3443 bool wxWin32TextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
3444 const wxKeyEvent
& event
,
3447 // handle only MSW-specific text bindings here, the others are handled in
3451 int keycode
= event
.GetKeyCode();
3453 wxControlAction action
;
3454 if ( keycode
== WXK_DELETE
&& event
.ShiftDown() )
3456 action
= wxACTION_TEXT_CUT
;
3458 else if ( keycode
== WXK_INSERT
)
3460 if ( event
.ControlDown() )
3461 action
= wxACTION_TEXT_COPY
;
3462 else if ( event
.ShiftDown() )
3463 action
= wxACTION_TEXT_PASTE
;
3466 if ( action
!= wxACTION_NONE
)
3468 control
->PerformAction(action
);
3474 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
3477 #endif // wxUSE_TEXTCTRL
3481 // ----------------------------------------------------------------------------
3482 // wxWin32StatusBarInputHandler
3483 // ----------------------------------------------------------------------------
3485 wxWin32StatusBarInputHandler::
3486 wxWin32StatusBarInputHandler(wxInputHandler
*handler
)
3487 : wxStdInputHandler(handler
)
3492 bool wxWin32StatusBarInputHandler::IsOnGrip(wxWindow
*statbar
,
3493 const wxPoint
& pt
) const
3495 if ( statbar
->HasFlag(wxST_SIZEGRIP
) &&
3496 statbar
->GetParent()->HasFlag(wxRESIZE_BORDER
) )
3499 parentTLW
= wxDynamicCast(statbar
->GetParent(), wxTopLevelWindow
);
3501 wxCHECK_MSG( parentTLW
, false,
3502 _T("the status bar should be a child of a TLW") );
3504 // a maximized window can't be resized anyhow
3505 if ( !parentTLW
->IsMaximized() )
3507 // VZ: I think that the standard Windows behaviour is to only
3508 // show the resizing cursor when the mouse is on top of the
3509 // grip itself but apparently different Windows versions behave
3510 // differently (?) and it seems a better UI to allow resizing
3511 // the status bar even when the mouse is above the grip
3512 wxSize sizeSbar
= statbar
->GetSize();
3514 int diff
= sizeSbar
.x
- pt
.x
;
3515 return diff
>= 0 && diff
< (wxCoord
)STATUSBAR_GRIP_SIZE
;
3522 bool wxWin32StatusBarInputHandler::HandleMouse(wxInputConsumer
*consumer
,
3523 const wxMouseEvent
& event
)
3525 if ( event
.Button(1) )
3527 if ( event
.ButtonDown(1) )
3529 wxWindow
*statbar
= consumer
->GetInputWindow();
3531 if ( IsOnGrip(statbar
, event
.GetPosition()) )
3533 wxTopLevelWindow
*tlw
= wxDynamicCast(statbar
->GetParent(),
3537 tlw
->PerformAction(wxACTION_TOPLEVEL_RESIZE
,
3538 wxHT_TOPLEVEL_BORDER_SE
);
3540 statbar
->SetCursor(m_cursorOld
);
3548 return wxStdInputHandler::HandleMouse(consumer
, event
);
3551 bool wxWin32StatusBarInputHandler::HandleMouseMove(wxInputConsumer
*consumer
,
3552 const wxMouseEvent
& event
)
3554 wxWindow
*statbar
= consumer
->GetInputWindow();
3556 bool isOnGrip
= IsOnGrip(statbar
, event
.GetPosition());
3557 if ( isOnGrip
!= m_isOnGrip
)
3559 m_isOnGrip
= isOnGrip
;
3562 m_cursorOld
= statbar
->GetCursor();
3563 statbar
->SetCursor(wxCURSOR_SIZENWSE
);
3567 statbar
->SetCursor(m_cursorOld
);
3571 return wxStdInputHandler::HandleMouseMove(consumer
, event
);
3574 #endif // wxUSE_STATUSBAR
3576 // ----------------------------------------------------------------------------
3577 // wxWin32FrameInputHandler
3578 // ----------------------------------------------------------------------------
3580 class wxWin32SystemMenuEvtHandler
: public wxEvtHandler
3583 wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler
*handler
);
3585 void Attach(wxInputConsumer
*consumer
);
3589 DECLARE_EVENT_TABLE()
3590 void OnSystemMenu(wxCommandEvent
&event
);
3591 void OnCloseFrame(wxCommandEvent
&event
);
3592 void OnClose(wxCloseEvent
&event
);
3594 wxWin32FrameInputHandler
*m_inputHnd
;
3595 wxTopLevelWindow
*m_wnd
;
3597 wxAcceleratorTable m_oldAccelTable
;
3601 wxWin32SystemMenuEvtHandler::
3602 wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler
*handler
)
3604 m_inputHnd
= handler
;
3608 void wxWin32SystemMenuEvtHandler::Attach(wxInputConsumer
*consumer
)
3610 wxASSERT_MSG( m_wnd
== NULL
, _T("can't attach the handler twice!") );
3612 m_wnd
= wxStaticCast(consumer
->GetInputWindow(), wxTopLevelWindow
);
3613 m_wnd
->PushEventHandler(this);
3616 // VS: This code relies on using generic implementation of
3617 // wxAcceleratorTable in wxUniv!
3618 wxAcceleratorTable table
= *m_wnd
->GetAcceleratorTable();
3619 m_oldAccelTable
= table
;
3620 table
.Add(wxAcceleratorEntry(wxACCEL_ALT
, WXK_SPACE
, wxID_SYSTEM_MENU
));
3621 table
.Add(wxAcceleratorEntry(wxACCEL_ALT
, WXK_F4
, wxID_CLOSE_FRAME
));
3622 m_wnd
->SetAcceleratorTable(table
);
3626 void wxWin32SystemMenuEvtHandler::Detach()
3631 m_wnd
->SetAcceleratorTable(m_oldAccelTable
);
3633 m_wnd
->RemoveEventHandler(this);
3638 BEGIN_EVENT_TABLE(wxWin32SystemMenuEvtHandler
, wxEvtHandler
)
3639 EVT_MENU(wxID_SYSTEM_MENU
, wxWin32SystemMenuEvtHandler::OnSystemMenu
)
3640 EVT_MENU(wxID_CLOSE_FRAME
, wxWin32SystemMenuEvtHandler::OnCloseFrame
)
3641 EVT_CLOSE(wxWin32SystemMenuEvtHandler::OnClose
)
3644 void wxWin32SystemMenuEvtHandler::OnSystemMenu(wxCommandEvent
&WXUNUSED(event
))
3647 wxAcceleratorTable table
= *m_wnd
->GetAcceleratorTable();
3648 m_wnd
->SetAcceleratorTable(wxNullAcceleratorTable
);
3652 m_inputHnd
->PopupSystemMenu(m_wnd
);
3653 #endif // wxUSE_MENUS
3656 m_wnd
->SetAcceleratorTable(table
);
3660 void wxWin32SystemMenuEvtHandler::OnCloseFrame(wxCommandEvent
&WXUNUSED(event
))
3662 m_wnd
->PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
3663 wxTOPLEVEL_BUTTON_CLOSE
);
3666 void wxWin32SystemMenuEvtHandler::OnClose(wxCloseEvent
&event
)
3673 wxWin32FrameInputHandler::wxWin32FrameInputHandler(wxInputHandler
*handler
)
3674 : wxStdInputHandler(handler
)
3676 m_menuHandler
= new wxWin32SystemMenuEvtHandler(this);
3679 wxWin32FrameInputHandler::~wxWin32FrameInputHandler()
3681 if ( m_menuHandler
)
3683 m_menuHandler
->Detach();
3684 delete m_menuHandler
;
3688 bool wxWin32FrameInputHandler::HandleMouse(wxInputConsumer
*consumer
,
3689 const wxMouseEvent
& event
)
3691 if ( event
.LeftDClick() || event
.LeftDown() || event
.RightDown() )
3693 wxTopLevelWindow
*tlw
=
3694 wxStaticCast(consumer
->GetInputWindow(), wxTopLevelWindow
);
3696 long hit
= tlw
->HitTest(event
.GetPosition());
3698 if ( event
.LeftDClick() && hit
== wxHT_TOPLEVEL_TITLEBAR
)
3700 tlw
->PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
3701 tlw
->IsMaximized() ? wxTOPLEVEL_BUTTON_RESTORE
3702 : wxTOPLEVEL_BUTTON_MAXIMIZE
);
3705 else if ( tlw
->GetWindowStyle() & wxSYSTEM_MENU
)
3707 if ( (event
.LeftDown() && hit
== wxHT_TOPLEVEL_ICON
) ||
3708 (event
.RightDown() &&
3709 (hit
== wxHT_TOPLEVEL_TITLEBAR
||
3710 hit
== wxHT_TOPLEVEL_ICON
)) )
3713 PopupSystemMenu(tlw
);
3714 #endif // wxUSE_MENUS
3720 return wxStdInputHandler::HandleMouse(consumer
, event
);
3725 void wxWin32FrameInputHandler::PopupSystemMenu(wxTopLevelWindow
*window
) const
3729 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
3730 menu
.Append(wxID_RESTORE_FRAME
, _("&Restore"));
3731 menu
.Append(wxID_MOVE_FRAME
, _("&Move"));
3732 if ( window
->GetWindowStyle() & wxRESIZE_BORDER
)
3733 menu
.Append(wxID_RESIZE_FRAME
, _("&Size"));
3734 if ( wxSystemSettings::HasFeature(wxSYS_CAN_ICONIZE_FRAME
) )
3735 menu
.Append(wxID_ICONIZE_FRAME
, _("Mi&nimize"));
3736 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
3737 menu
.Append(wxID_MAXIMIZE_FRAME
, _("Ma&ximize"));
3738 menu
.AppendSeparator();
3739 menu
.Append(wxID_CLOSE_FRAME
, _("Close\tAlt-F4"));
3741 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
3743 if ( window
->IsMaximized() )
3745 menu
.Enable(wxID_MAXIMIZE_FRAME
, false);
3746 menu
.Enable(wxID_MOVE_FRAME
, false);
3747 if ( window
->GetWindowStyle() & wxRESIZE_BORDER
)
3748 menu
.Enable(wxID_RESIZE_FRAME
, false);
3751 menu
.Enable(wxID_RESTORE_FRAME
, false);
3754 window
->PopupMenu(&menu
, wxPoint(0, 0));
3757 #endif // wxUSE_MENUS
3759 bool wxWin32FrameInputHandler::HandleActivation(wxInputConsumer
*consumer
,
3762 if ( consumer
->GetInputWindow()->GetWindowStyle() & wxSYSTEM_MENU
)
3764 // always detach if active frame changed:
3765 m_menuHandler
->Detach();
3769 m_menuHandler
->Attach(consumer
);
3773 return wxStdInputHandler::HandleActivation(consumer
, activated
);