1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/themes/win32.cpp
3 // Purpose: wxUniversal theme implementing Win32-like LNF
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #include "wx/univ/theme.h"
34 #include "wx/window.h"
36 #include "wx/dcmemory.h"
37 #include "wx/dcclient.h"
39 #include "wx/button.h"
40 #include "wx/bmpbuttn.h"
41 #include "wx/listbox.h"
42 #include "wx/checklst.h"
43 #include "wx/combobox.h"
44 #include "wx/scrolbar.h"
45 #include "wx/slider.h"
46 #include "wx/textctrl.h"
47 #include "wx/toolbar.h"
48 #include "wx/statusbr.h"
51 // for COLOR_* constants
52 #include "wx/msw/private.h"
55 #include "wx/settings.h"
56 #include "wx/toplevel.h"
60 #include "wx/notebook.h"
61 #include "wx/spinbutt.h"
62 #include "wx/artprov.h"
63 #include "wx/tglbtn.h"
65 #include "wx/univ/scrtimer.h"
66 #include "wx/univ/stdrend.h"
67 #include "wx/univ/inpcons.h"
68 #include "wx/univ/inphand.h"
69 #include "wx/univ/colschem.h"
71 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
75 static const int BORDER_THICKNESS
= 2;
77 static const size_t NUM_STATUSBAR_GRIP_BANDS
= 3;
78 static const size_t WIDTH_STATUSBAR_GRIP_BAND
= 4;
79 static const size_t STATUSBAR_GRIP_SIZE
=
80 WIDTH_STATUSBAR_GRIP_BAND
*NUM_STATUSBAR_GRIP_BANDS
;
82 static const wxCoord SLIDER_MARGIN
= 6; // margin around slider
83 static const wxCoord SLIDER_THUMB_LENGTH
= 18;
84 static const wxCoord SLIDER_TICK_LENGTH
= 6;
86 // wxWin32Renderer: draw the GUI elements in Win32 style
87 // ----------------------------------------------------------------------------
89 class wxWin32Renderer
: public wxStdRenderer
93 wxWin32Renderer(const wxColourScheme
*scheme
);
95 // reimplement the renderer methods which are different for this theme
96 virtual void DrawLabel(wxDC
& dc
,
97 const wxString
& label
,
100 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
102 wxRect
*rectBounds
= NULL
);
103 virtual void DrawButtonLabel(wxDC
& dc
,
104 const wxString
& label
,
105 const wxBitmap
& image
,
108 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
110 wxRect
*rectBounds
= NULL
);
111 virtual void DrawButtonBorder(wxDC
& dc
,
114 wxRect
*rectIn
= NULL
);
116 virtual void DrawArrow(wxDC
& dc
,
120 virtual void DrawScrollbarThumb(wxDC
& dc
,
121 wxOrientation orient
,
124 virtual void DrawScrollbarShaft(wxDC
& dc
,
125 wxOrientation orient
,
130 virtual void DrawToolBarButton(wxDC
& dc
,
131 const wxString
& label
,
132 const wxBitmap
& bitmap
,
137 #endif // wxUSE_TOOLBAR
140 virtual void DrawTab(wxDC
& dc
,
143 const wxString
& label
,
144 const wxBitmap
& bitmap
= wxNullBitmap
,
146 int indexAccel
= -1);
147 #endif // wxUSE_NOTEBOOK
150 virtual void DrawSliderShaft(wxDC
& dc
,
153 wxOrientation orient
,
156 wxRect
*rectShaft
= NULL
);
157 virtual void DrawSliderThumb(wxDC
& dc
,
159 wxOrientation orient
,
162 virtual void DrawSliderTicks(wxDC
& dc
,
165 wxOrientation orient
,
171 #endif // wxUSE_SLIDER
174 virtual void DrawMenuBarItem(wxDC
& dc
,
176 const wxString
& label
,
178 int indexAccel
= -1);
179 virtual void DrawMenuItem(wxDC
& dc
,
181 const wxMenuGeometryInfo
& geometryInfo
,
182 const wxString
& label
,
183 const wxString
& accel
,
184 const wxBitmap
& bitmap
= wxNullBitmap
,
186 int indexAccel
= -1);
187 virtual void DrawMenuSeparator(wxDC
& dc
,
189 const wxMenuGeometryInfo
& geomInfo
);
190 #endif // wxUSE_MENUS
193 virtual void DrawStatusField(wxDC
& dc
,
195 const wxString
& label
,
196 int flags
= 0, int style
= 0);
197 #endif // wxUSE_STATUSBAR
199 virtual void GetComboBitmaps(wxBitmap
*bmpNormal
,
201 wxBitmap
*bmpPressed
,
202 wxBitmap
*bmpDisabled
);
204 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
205 virtual bool AreScrollbarsInsideBorder() const;
207 virtual wxSize
GetScrollbarArrowSize() const
208 { return m_sizeScrollbarArrow
; }
210 virtual wxSize
GetCheckBitmapSize() const
211 { return wxSize(13, 13); }
212 virtual wxSize
GetRadioBitmapSize() const
213 { return wxSize(12, 12); }
214 virtual wxCoord
GetCheckItemMargin() const
218 virtual wxSize
GetToolBarButtonSize(wxCoord
*separator
) const
219 { if ( separator
) *separator
= 5; return wxSize(16, 15); }
220 virtual wxSize
GetToolBarMargin() const
221 { return wxSize(4, 4); }
222 #endif // wxUSE_TOOLBAR
225 virtual wxRect
GetTextTotalArea(const wxTextCtrl
*text
,
226 const wxRect
& rect
) const;
227 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
229 wxCoord
*extraSpaceBeyond
) const;
230 #endif // wxUSE_TEXTCTRL
233 virtual wxSize
GetTabIndent() const { return wxSize(2, 2); }
234 virtual wxSize
GetTabPadding() const { return wxSize(6, 5); }
235 #endif // wxUSE_NOTEBOOK
239 virtual wxCoord
GetSliderDim() const { return SLIDER_THUMB_LENGTH
+ 2*BORDER_THICKNESS
; }
240 virtual wxCoord
GetSliderTickLen() const { return SLIDER_TICK_LENGTH
; }
241 virtual wxRect
GetSliderShaftRect(const wxRect
& rect
,
243 wxOrientation orient
,
244 long style
= 0) const;
245 virtual wxSize
GetSliderThumbSize(const wxRect
& rect
,
247 wxOrientation orient
) const;
248 #endif // wxUSE_SLIDER
250 virtual wxSize
GetProgressBarStep() const { return wxSize(16, 32); }
253 virtual wxSize
GetMenuBarItemSize(const wxSize
& sizeText
) const;
254 virtual wxMenuGeometryInfo
*GetMenuGeometry(wxWindow
*win
,
255 const wxMenu
& menu
) const;
256 #endif // wxUSE_MENUS
259 // overridden wxStdRenderer methods
260 virtual void DrawFrameWithLabel(wxDC
& dc
,
261 const wxString
& label
,
262 const wxRect
& rectFrame
,
263 const wxRect
& rectText
,
268 virtual void DrawCheckItemBitmap(wxDC
& dc
,
269 const wxBitmap
& bitmap
,
274 // draw the border used for scrollbar arrows
275 void DrawArrowBorder(wxDC
& dc
, wxRect
*rect
, bool isPressed
= false);
277 // public DrawArrow()s helper
278 void DrawArrow(wxDC
& dc
, const wxRect
& rect
,
279 ArrowDirection arrowDir
, ArrowStyle arrowStyle
);
281 // DrawArrowButton is used by DrawScrollbar and DrawComboButton
282 void DrawArrowButton(wxDC
& dc
, const wxRect
& rect
,
283 ArrowDirection arrowDir
,
284 ArrowStyle arrowStyle
);
286 // draw a normal or transposed line (useful for using the same code fo both
287 // horizontal and vertical widgets)
288 void DrawLine(wxDC
& dc
,
289 wxCoord x1
, wxCoord y1
,
290 wxCoord x2
, wxCoord y2
,
291 bool transpose
= false)
294 dc
.DrawLine(y1
, x1
, y2
, x2
);
296 dc
.DrawLine(x1
, y1
, x2
, y2
);
299 // get the standard check/radio button bitmap
300 wxBitmap
GetIndicator(IndicatorType indType
, int flags
);
301 virtual wxBitmap
GetCheckBitmap(int flags
)
302 { return GetIndicator(IndicatorType_Check
, flags
); }
303 virtual wxBitmap
GetRadioBitmap(int flags
)
304 { return GetIndicator(IndicatorType_Radio
, flags
); }
306 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType type
);
309 // Fill the arguments with true or false if this slider has labels on
310 // left/right side (or top/bottom for horizontal sliders) respectively
312 void GetSliderLabelsSides(wxOrientation orient
, long style
,
313 bool *left
, bool *right
)
315 // should we draw ticks at all?
316 if ( !(style
& wxSL_AUTOTICKS
) )
323 // should we draw them on both sides?
324 if ( style
& wxSL_BOTH
)
331 // we draw them on one side only, determine which one
332 if ( ((style
& wxSL_TOP
) && (orient
== wxHORIZONTAL
)) ||
333 ((style
& wxSL_LEFT
) && (orient
== wxVERTICAL
)) )
338 else if ( ((style
& wxSL_BOTTOM
) && (orient
== wxHORIZONTAL
)) ||
339 ((style
& wxSL_RIGHT
) && (orient
== wxVERTICAL
)) )
346 wxFAIL_MSG( "inconsistent wxSlider flags" );
352 #endif // wxUSE_SLIDER
355 // the sizing parameters (TODO make them changeable)
356 wxSize m_sizeScrollbarArrow
;
358 // the checked and unchecked bitmaps for DrawCheckItemBitmap()
359 wxBitmap m_bmpCheckBitmaps
[IndicatorStatus_Max
];
361 // the bitmaps returned by GetIndicator()
362 wxBitmap m_bmpIndicators
[IndicatorType_Max
]
363 [IndicatorState_MaxMenu
]
364 [IndicatorStatus_Max
];
367 wxBitmap m_bmpFrameButtons
[FrameButton_Max
];
369 // standard defaults for the above bitmaps
370 static const char **ms_xpmChecked
[IndicatorStatus_Max
];
371 static const char **ms_xpmIndicators
[IndicatorType_Max
]
372 [IndicatorState_MaxMenu
]
373 [IndicatorStatus_Max
];
374 static const char **ms_xpmFrameButtons
[FrameButton_Max
];
376 // first row is for the normal state, second - for the disabled
377 wxBitmap m_bmpArrows
[Arrow_StateMax
][Arrow_Max
];
380 // ----------------------------------------------------------------------------
381 // wxWin32InputHandler and derived classes: process the keyboard and mouse
382 // messages according to Windows standards
383 // ----------------------------------------------------------------------------
385 class wxWin32InputHandler
: public wxInputHandler
388 wxWin32InputHandler() { }
390 virtual bool HandleKey(wxInputConsumer
*control
,
391 const wxKeyEvent
& event
,
393 virtual bool HandleMouse(wxInputConsumer
*control
,
394 const wxMouseEvent
& event
);
398 class wxWin32ScrollBarInputHandler
: public wxStdScrollBarInputHandler
401 wxWin32ScrollBarInputHandler(wxRenderer
*renderer
,
402 wxInputHandler
*handler
);
404 virtual bool HandleMouse(wxInputConsumer
*control
,
405 const wxMouseEvent
& event
);
406 virtual bool HandleMouseMove(wxInputConsumer
*control
,
407 const wxMouseEvent
& event
);
409 virtual bool OnScrollTimer(wxScrollBar
*scrollbar
,
410 const wxControlAction
& action
);
413 virtual void Highlight(wxScrollBar
* WXUNUSED(scrollbar
),
416 // we don't highlight anything
419 // the first and last event which caused the thumb to move
420 wxMouseEvent m_eventStartDrag
,
423 // have we paused the scrolling because the mouse moved?
426 // we remember the interval of the timer to be able to restart it
429 #endif // wxUSE_SCROLLBAR
432 class wxWin32CheckboxInputHandler
: public wxStdInputHandler
435 wxWin32CheckboxInputHandler(wxInputHandler
*handler
)
436 : wxStdInputHandler(handler
) { }
438 virtual bool HandleKey(wxInputConsumer
*control
,
439 const wxKeyEvent
& event
,
442 #endif // wxUSE_CHECKBOX
445 class wxWin32TextCtrlInputHandler
: public wxStdInputHandler
448 wxWin32TextCtrlInputHandler(wxInputHandler
*handler
)
449 : wxStdInputHandler(handler
) { }
451 virtual bool HandleKey(wxInputConsumer
*control
,
452 const wxKeyEvent
& event
,
455 #endif // wxUSE_TEXTCTRL
457 class wxWin32StatusBarInputHandler
: public wxStdInputHandler
460 wxWin32StatusBarInputHandler(wxInputHandler
*handler
);
462 virtual bool HandleMouse(wxInputConsumer
*consumer
,
463 const wxMouseEvent
& event
);
465 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
466 const wxMouseEvent
& event
);
469 // is the given point over the statusbar grip?
470 bool IsOnGrip(wxWindow
*statbar
, const wxPoint
& pt
) const;
473 // the cursor we had replaced with the resize one
474 wxCursor m_cursorOld
;
476 // was the mouse over the grip last time we checked?
480 class wxWin32SystemMenuEvtHandler
;
482 class wxWin32FrameInputHandler
: public wxStdInputHandler
485 wxWin32FrameInputHandler(wxInputHandler
*handler
);
486 virtual ~wxWin32FrameInputHandler();
488 virtual bool HandleMouse(wxInputConsumer
*control
,
489 const wxMouseEvent
& event
);
491 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
494 void PopupSystemMenu(wxTopLevelWindow
*window
) const;
495 #endif // wxUSE_MENUS
498 // was the mouse over the grip last time we checked?
499 wxWin32SystemMenuEvtHandler
*m_menuHandler
;
502 // ----------------------------------------------------------------------------
503 // wxWin32ColourScheme: uses (default) Win32 colours
504 // ----------------------------------------------------------------------------
506 class wxWin32ColourScheme
: public wxColourScheme
509 virtual wxColour
Get(StdColour col
) const;
510 virtual wxColour
GetBackground(wxWindow
*win
) const;
513 // ----------------------------------------------------------------------------
514 // wxWin32ArtProvider
515 // ----------------------------------------------------------------------------
517 class wxWin32ArtProvider
: public wxArtProvider
520 virtual wxBitmap
CreateBitmap(const wxArtID
& id
,
521 const wxArtClient
& client
,
525 // ----------------------------------------------------------------------------
527 // ----------------------------------------------------------------------------
529 WX_DEFINE_ARRAY_PTR(wxInputHandler
*, wxArrayHandlers
);
531 class wxWin32Theme
: public wxTheme
535 virtual ~wxWin32Theme();
537 virtual wxRenderer
*GetRenderer();
538 virtual wxArtProvider
*GetArtProvider();
539 virtual wxInputHandler
*GetInputHandler(const wxString
& control
,
540 wxInputConsumer
*consumer
);
541 virtual wxColourScheme
*GetColourScheme();
544 wxWin32Renderer
*m_renderer
;
546 wxWin32ArtProvider
*m_artProvider
;
548 // the names of the already created handlers and the handlers themselves
549 // (these arrays are synchronized)
550 wxSortedArrayString m_handlerNames
;
551 wxArrayHandlers m_handlers
;
553 wxWin32ColourScheme
*m_scheme
;
555 WX_DECLARE_THEME(win32
)
558 // ----------------------------------------------------------------------------
560 // ----------------------------------------------------------------------------
562 // frame buttons bitmaps
563 static const char *frame_button_close_xpm
[] = {
578 static const char *frame_button_help_xpm
[] = {
593 static const char *frame_button_maximize_xpm
[] = {
608 static const char *frame_button_minimize_xpm
[] = {
623 static const char *frame_button_restore_xpm
[] = {
638 const char **wxWin32Renderer::ms_xpmFrameButtons
[FrameButton_Max
] =
640 frame_button_close_xpm
,
641 frame_button_minimize_xpm
,
642 frame_button_maximize_xpm
,
643 frame_button_restore_xpm
,
644 frame_button_help_xpm
,
649 static const char *checked_menu_xpm
[] = {
650 /* columns rows colors chars-per-pixel */
666 static const char *selected_checked_menu_xpm
[] = {
667 /* columns rows colors chars-per-pixel */
683 static const char *disabled_checked_menu_xpm
[] = {
684 /* columns rows colors chars-per-pixel */
701 static const char *selected_disabled_checked_menu_xpm
[] = {
702 /* columns rows colors chars-per-pixel */
718 // checkbox and radiobox bitmaps below
720 static const char *checked_xpm
[] = {
721 /* columns rows colors chars-per-pixel */
744 static const char *pressed_checked_xpm
[] = {
745 /* columns rows colors chars-per-pixel */
767 static const char *pressed_disabled_checked_xpm
[] = {
768 /* columns rows colors chars-per-pixel */
790 static const char *checked_item_xpm
[] = {
791 /* columns rows colors chars-per-pixel */
812 static const char *unchecked_xpm
[] = {
813 /* columns rows colors chars-per-pixel */
836 static const char *pressed_unchecked_xpm
[] = {
837 /* columns rows colors chars-per-pixel */
859 static const char *unchecked_item_xpm
[] = {
860 /* columns rows colors chars-per-pixel */
880 static const char *undetermined_xpm
[] = {
881 /* columns rows colors chars-per-pixel */
904 static const char *pressed_undetermined_xpm
[] = {
905 /* columns rows colors chars-per-pixel */
928 static const char *checked_radio_xpm
[] = {
929 /* columns rows colors chars-per-pixel */
952 static const char *pressed_checked_radio_xpm
[] = {
953 /* columns rows colors chars-per-pixel */
976 static const char *pressed_disabled_checked_radio_xpm
[] = {
977 /* columns rows colors chars-per-pixel */
1000 static const char *unchecked_radio_xpm
[] = {
1001 /* columns rows colors chars-per-pixel */
1024 static const char *pressed_unchecked_radio_xpm
[] = {
1025 /* columns rows colors chars-per-pixel */
1048 const char **wxWin32Renderer::ms_xpmIndicators
[IndicatorType_Max
]
1049 [IndicatorState_MaxMenu
]
1050 [IndicatorStatus_Max
] =
1055 { checked_xpm
, unchecked_xpm
, undetermined_xpm
},
1058 { pressed_checked_xpm
, pressed_unchecked_xpm
, pressed_undetermined_xpm
},
1061 { pressed_disabled_checked_xpm
, pressed_unchecked_xpm
, pressed_disabled_checked_xpm
},
1067 { checked_radio_xpm
, unchecked_radio_xpm
, NULL
},
1070 { pressed_checked_radio_xpm
, pressed_unchecked_radio_xpm
, NULL
},
1073 { pressed_disabled_checked_radio_xpm
, pressed_unchecked_radio_xpm
, NULL
},
1079 { checked_menu_xpm
, NULL
, NULL
},
1082 { selected_checked_menu_xpm
, NULL
, NULL
},
1085 { disabled_checked_menu_xpm
, NULL
, NULL
},
1087 // disabled selected state
1088 { selected_disabled_checked_menu_xpm
, NULL
, NULL
},
1092 const char **wxWin32Renderer::ms_xpmChecked
[IndicatorStatus_Max
] =
1098 // ============================================================================
1100 // ============================================================================
1102 WX_IMPLEMENT_THEME(wxWin32Theme
, win32
, wxTRANSLATE("Win32 theme"));
1104 // ----------------------------------------------------------------------------
1106 // ----------------------------------------------------------------------------
1108 wxWin32Theme::wxWin32Theme()
1112 m_artProvider
= NULL
;
1115 wxWin32Theme::~wxWin32Theme()
1119 delete m_artProvider
;
1122 wxRenderer
*wxWin32Theme::GetRenderer()
1126 m_renderer
= new wxWin32Renderer(GetColourScheme());
1132 wxArtProvider
*wxWin32Theme::GetArtProvider()
1134 if ( !m_artProvider
)
1136 m_artProvider
= new wxWin32ArtProvider
;
1139 return m_artProvider
;
1143 wxWin32Theme::GetInputHandler(const wxString
& control
,
1144 wxInputConsumer
*consumer
)
1146 wxInputHandler
*handler
= NULL
;
1147 int n
= m_handlerNames
.Index(control
);
1148 if ( n
== wxNOT_FOUND
)
1150 static wxWin32InputHandler s_handlerDef
;
1152 wxInputHandler
* const
1153 handlerStd
= consumer
->DoGetStdInputHandler(&s_handlerDef
);
1155 // create a new handler
1156 if ( control
== wxINP_HANDLER_TOPLEVEL
)
1158 static wxWin32FrameInputHandler
s_handler(handlerStd
);
1160 handler
= &s_handler
;
1163 else if ( control
== wxINP_HANDLER_CHECKBOX
)
1165 static wxWin32CheckboxInputHandler
s_handler(handlerStd
);
1167 handler
= &s_handler
;
1169 #endif // wxUSE_CHECKBOX
1171 else if ( control
== wxINP_HANDLER_SCROLLBAR
)
1173 static wxWin32ScrollBarInputHandler
1174 s_handler(GetRenderer(), handlerStd
);
1176 handler
= &s_handler
;
1178 #endif // wxUSE_SCROLLBAR
1180 else if ( control
== wxINP_HANDLER_STATUSBAR
)
1182 static wxWin32StatusBarInputHandler
s_handler(handlerStd
);
1184 handler
= &s_handler
;
1186 #endif // wxUSE_STATUSBAR
1188 else if ( control
== wxINP_HANDLER_TEXTCTRL
)
1190 static wxWin32TextCtrlInputHandler
s_handler(handlerStd
);
1192 handler
= &s_handler
;
1194 #endif // wxUSE_TEXTCTRL
1195 else // no special handler for this control
1197 handler
= handlerStd
;
1200 n
= m_handlerNames
.Add(control
);
1201 m_handlers
.Insert(handler
, n
);
1203 else // we already have it
1205 handler
= m_handlers
[n
];
1211 wxColourScheme
*wxWin32Theme::GetColourScheme()
1215 m_scheme
= new wxWin32ColourScheme
;
1220 // ============================================================================
1221 // wxWin32ColourScheme
1222 // ============================================================================
1224 wxColour
wxWin32ColourScheme::GetBackground(wxWindow
*win
) const
1227 if ( win
->UseBgCol() )
1229 // use the user specified colour
1230 col
= win
->GetBackgroundColour();
1233 if ( !win
->ShouldInheritColours() )
1236 wxTextCtrl
*text
= wxDynamicCast(win
, wxTextCtrl
);
1237 #endif // wxUSE_TEXTCTRL
1239 wxListBox
* listBox
= wxDynamicCast(win
, wxListBox
);
1240 #endif // wxUSE_LISTBOX
1249 if ( !win
->IsEnabled() ) // not IsEditable()
1255 // doesn't depend on the state
1260 #endif // wxUSE_TEXTCTRL
1263 col
= Get(CONTROL
); // Most controls should be this colour, not WINDOW
1267 int flags
= win
->GetStateFlags();
1269 // the colour set by the user should be used for the normal state
1270 // and for the states for which we don't have any specific colours
1271 if ( !col
.IsOk() || (flags
& wxCONTROL_PRESSED
) != 0 )
1274 if ( wxDynamicCast(win
, wxScrollBar
) )
1275 col
= Get(flags
& wxCONTROL_PRESSED
? SCROLLBAR_PRESSED
1278 #endif // wxUSE_SCROLLBAR
1286 wxColour
wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col
) const
1290 // use the system colours under Windows
1291 #if defined(__WXMSW__)
1292 case WINDOW
: return wxColour(GetSysColor(COLOR_WINDOW
));
1294 case CONTROL_PRESSED
:
1295 case CONTROL_CURRENT
:
1296 case CONTROL
: return wxColour(GetSysColor(COLOR_BTNFACE
));
1298 case CONTROL_TEXT
: return wxColour(GetSysColor(COLOR_BTNTEXT
));
1300 #if defined(COLOR_3DLIGHT)
1301 case SCROLLBAR
: return wxColour(GetSysColor(COLOR_3DLIGHT
));
1303 case SCROLLBAR
: return wxColour(0xe0e0e0);
1305 case SCROLLBAR_PRESSED
: return wxColour(GetSysColor(COLOR_BTNTEXT
));
1307 case HIGHLIGHT
: return wxColour(GetSysColor(COLOR_HIGHLIGHT
));
1308 case HIGHLIGHT_TEXT
: return wxColour(GetSysColor(COLOR_HIGHLIGHTTEXT
));
1310 #if defined(COLOR_3DDKSHADOW)
1311 case SHADOW_DARK
: return wxColour(GetSysColor(COLOR_3DDKSHADOW
));
1313 case SHADOW_DARK
: return wxColour(GetSysColor(COLOR_3DHADOW
));
1316 case CONTROL_TEXT_DISABLED
:
1317 case SHADOW_HIGHLIGHT
: return wxColour(GetSysColor(COLOR_BTNHIGHLIGHT
));
1319 case SHADOW_IN
: return wxColour(GetSysColor(COLOR_BTNFACE
));
1321 case CONTROL_TEXT_DISABLED_SHADOW
:
1322 case SHADOW_OUT
: return wxColour(GetSysColor(COLOR_BTNSHADOW
));
1324 case TITLEBAR
: return wxColour(GetSysColor(COLOR_INACTIVECAPTION
));
1325 case TITLEBAR_ACTIVE
: return wxColour(GetSysColor(COLOR_ACTIVECAPTION
));
1326 case TITLEBAR_TEXT
: return wxColour(GetSysColor(COLOR_INACTIVECAPTIONTEXT
));
1327 case TITLEBAR_ACTIVE_TEXT
: return wxColour(GetSysColor(COLOR_CAPTIONTEXT
));
1329 case DESKTOP
: return wxColour(0x808000);
1330 case FRAME
: return wxColour(GetSysColor(COLOR_APPWORKSPACE
));
1332 // use the standard Windows colours elsewhere
1333 case WINDOW
: return *wxWHITE
;
1335 case CONTROL_PRESSED
:
1336 case CONTROL_CURRENT
:
1337 case CONTROL
: return wxColour(0xc0c0c0);
1339 case CONTROL_TEXT
: return *wxBLACK
;
1341 case SCROLLBAR
: return wxColour(0xe0e0e0);
1342 case SCROLLBAR_PRESSED
: return *wxBLACK
;
1344 case HIGHLIGHT
: return wxColour(0x800000);
1345 case HIGHLIGHT_TEXT
: return wxColour(0xffffff);
1347 case SHADOW_DARK
: return *wxBLACK
;
1349 case CONTROL_TEXT_DISABLED
:return wxColour(0xe0e0e0);
1350 case SHADOW_HIGHLIGHT
: return wxColour(0xffffff);
1352 case SHADOW_IN
: return wxColour(0xc0c0c0);
1354 case CONTROL_TEXT_DISABLED_SHADOW
:
1355 case SHADOW_OUT
: return wxColour(0x7f7f7f);
1357 case TITLEBAR
: return wxColour(0xaeaaae);
1358 case TITLEBAR_ACTIVE
: return wxColour(0x820300);
1359 case TITLEBAR_TEXT
: return wxColour(0xc0c0c0);
1360 case TITLEBAR_ACTIVE_TEXT
:return *wxWHITE
;
1362 case DESKTOP
: return wxColour(0x808000);
1363 case FRAME
: return wxColour(0x808080);
1366 case GAUGE
: return Get(HIGHLIGHT
);
1370 wxFAIL_MSG(wxT("invalid standard colour"));
1375 // ============================================================================
1377 // ============================================================================
1379 // ----------------------------------------------------------------------------
1381 // ----------------------------------------------------------------------------
1383 wxWin32Renderer::wxWin32Renderer(const wxColourScheme
*scheme
)
1384 : wxStdRenderer(scheme
)
1387 m_sizeScrollbarArrow
= wxSize(16, 16);
1389 // init the arrow bitmaps
1390 static const size_t ARROW_WIDTH
= 7;
1391 static const size_t ARROW_LENGTH
= 4;
1394 wxMemoryDC dcNormal
,
1397 for ( size_t n
= 0; n
< Arrow_Max
; n
++ )
1399 bool isVertical
= n
> Arrow_Right
;
1412 // disabled arrow is larger because of the shadow
1413 m_bmpArrows
[Arrow_Normal
][n
].Create(w
, h
);
1414 m_bmpArrows
[Arrow_Disabled
][n
].Create(w
+ 1, h
+ 1);
1416 dcNormal
.SelectObject(m_bmpArrows
[Arrow_Normal
][n
]);
1417 dcDisabled
.SelectObject(m_bmpArrows
[Arrow_Disabled
][n
]);
1419 dcNormal
.SetBackground(*wxWHITE_BRUSH
);
1420 dcDisabled
.SetBackground(*wxWHITE_BRUSH
);
1424 dcNormal
.SetPen(m_penBlack
);
1425 dcDisabled
.SetPen(m_penDarkGrey
);
1427 // calculate the position of the point of the arrow
1431 x1
= (ARROW_WIDTH
- 1)/2;
1432 y1
= n
== Arrow_Up
? 0 : ARROW_LENGTH
- 1;
1436 x1
= n
== Arrow_Left
? 0 : ARROW_LENGTH
- 1;
1437 y1
= (ARROW_WIDTH
- 1)/2;
1448 for ( size_t i
= 0; i
< ARROW_LENGTH
; i
++ )
1450 dcNormal
.DrawLine(x1
, y1
, x2
, y2
);
1451 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1458 if ( n
== Arrow_Up
)
1469 else // left or right arrow
1474 if ( n
== Arrow_Left
)
1487 // draw the shadow for the disabled one
1488 dcDisabled
.SetPen(m_penHighlight
);
1493 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1497 x1
= ARROW_LENGTH
- 1;
1498 y1
= (ARROW_WIDTH
- 1)/2 + 1;
1501 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1502 dcDisabled
.DrawLine(++x1
, y1
, x2
, ++y2
);
1507 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1511 x1
= ARROW_WIDTH
- 1;
1513 x2
= (ARROW_WIDTH
- 1)/2;
1515 dcDisabled
.DrawLine(x1
, y1
, x2
, y2
);
1516 dcDisabled
.DrawLine(++x1
, y1
, x2
, ++y2
);
1521 // create the inverted bitmap but only for the right arrow as we only
1522 // use it for the menus
1523 if ( n
== Arrow_Right
)
1525 m_bmpArrows
[Arrow_Inverted
][n
].Create(w
, h
);
1526 dcInverse
.SelectObject(m_bmpArrows
[Arrow_Inverted
][n
]);
1528 dcInverse
.Blit(0, 0, w
, h
,
1531 dcInverse
.SelectObject(wxNullBitmap
);
1533 mask
= new wxMask(m_bmpArrows
[Arrow_Inverted
][n
], *wxBLACK
);
1534 m_bmpArrows
[Arrow_Inverted
][n
].SetMask(mask
);
1536 m_bmpArrows
[Arrow_InvertedDisabled
][n
].Create(w
, h
);
1537 dcInverse
.SelectObject(m_bmpArrows
[Arrow_InvertedDisabled
][n
]);
1539 dcInverse
.Blit(0, 0, w
, h
,
1542 dcInverse
.SelectObject(wxNullBitmap
);
1544 mask
= new wxMask(m_bmpArrows
[Arrow_InvertedDisabled
][n
], *wxBLACK
);
1545 m_bmpArrows
[Arrow_InvertedDisabled
][n
].SetMask(mask
);
1548 dcNormal
.SelectObject(wxNullBitmap
);
1549 dcDisabled
.SelectObject(wxNullBitmap
);
1551 mask
= new wxMask(m_bmpArrows
[Arrow_Normal
][n
], *wxWHITE
);
1552 m_bmpArrows
[Arrow_Normal
][n
].SetMask(mask
);
1553 mask
= new wxMask(m_bmpArrows
[Arrow_Disabled
][n
], *wxWHITE
);
1554 m_bmpArrows
[Arrow_Disabled
][n
].SetMask(mask
);
1556 m_bmpArrows
[Arrow_Pressed
][n
] = m_bmpArrows
[Arrow_Normal
][n
];
1560 bool wxWin32Renderer::AreScrollbarsInsideBorder() const
1565 // ----------------------------------------------------------------------------
1567 // ----------------------------------------------------------------------------
1569 void wxWin32Renderer::DrawLabel(wxDC
& dc
,
1570 const wxString
& label
,
1577 // the underscores are not drawn for focused controls in wxMSW
1578 if ( flags
& wxCONTROL_FOCUSED
)
1583 if ( flags
& wxCONTROL_DISABLED
)
1585 // the combination of wxCONTROL_SELECTED and wxCONTROL_DISABLED
1586 // currently only can happen for a menu item and it seems that Windows
1587 // doesn't draw the shadow in this case, so we don't do it neither
1588 if ( flags
& wxCONTROL_SELECTED
)
1590 // just make the label text greyed out
1591 dc
.SetTextForeground(m_penDarkGrey
.GetColour());
1593 flags
&= ~wxCONTROL_DISABLED
;
1597 wxStdRenderer::DrawLabel(dc
, label
, rect
, flags
, alignment
,
1598 indexAccel
, rectBounds
);
1601 void wxWin32Renderer::DrawFrameWithLabel(wxDC
& dc
,
1602 const wxString
& label
,
1603 const wxRect
& rectFrame
,
1604 const wxRect
& rectText
,
1610 label2
<< wxT(' ') << label
<< wxT(' ');
1611 if ( indexAccel
!= -1 )
1613 // adjust it as we prepended a space
1617 wxStdRenderer::DrawFrameWithLabel(dc
, label2
, rectFrame
, rectText
,
1618 flags
, alignment
, indexAccel
);
1621 void wxWin32Renderer::DrawButtonLabel(wxDC
& dc
,
1622 const wxString
& label
,
1623 const wxBitmap
& image
,
1630 // the underscores are not drawn for focused controls in wxMSW
1631 if ( flags
& wxCONTROL_PRESSED
)
1636 wxStdRenderer::DrawButtonLabel(dc
, label
, image
, rect
, flags
, alignment
,
1637 indexAccel
, rectBounds
);
1640 void wxWin32Renderer::DrawButtonBorder(wxDC
& dc
,
1641 const wxRect
& rectTotal
,
1645 wxRect rect
= rectTotal
;
1647 wxPen
penOut(*wxBLACK
);
1648 if ( flags
& wxCONTROL_PRESSED
)
1650 // button pressed: draw a double border around it
1651 DrawRect(dc
, &rect
, penOut
);
1652 DrawRect(dc
, &rect
, m_penDarkGrey
);
1654 else // button not pressed
1656 if ( flags
& (wxCONTROL_FOCUSED
| wxCONTROL_ISDEFAULT
) )
1658 // button either default or focused (or both): add an extra border
1660 DrawRect(dc
, &rect
, penOut
);
1663 // now draw a normal button border
1664 DrawRaisedBorder(dc
, &rect
);
1671 // ----------------------------------------------------------------------------
1672 // (check)listbox items
1673 // ----------------------------------------------------------------------------
1675 void wxWin32Renderer::DrawCheckItemBitmap(wxDC
& dc
,
1676 const wxBitmap
& bitmap
,
1681 if ( bitmap
.IsOk() )
1685 else // use default bitmap
1687 IndicatorStatus i
= flags
& wxCONTROL_CHECKED
1688 ? IndicatorStatus_Checked
1689 : IndicatorStatus_Unchecked
;
1691 if ( !m_bmpCheckBitmaps
[i
].IsOk() )
1693 m_bmpCheckBitmaps
[i
] = wxBitmap(ms_xpmChecked
[i
]);
1696 bmp
= m_bmpCheckBitmaps
[i
];
1699 dc
.DrawBitmap(bmp
, rect
.x
, rect
.y
+ (rect
.height
- bmp
.GetHeight()) / 2 - 1,
1700 true /* use mask */);
1703 // ----------------------------------------------------------------------------
1704 // check/radio buttons
1705 // ----------------------------------------------------------------------------
1707 wxBitmap
wxWin32Renderer::GetIndicator(IndicatorType indType
, int flags
)
1709 IndicatorState indState
;
1710 IndicatorStatus indStatus
;
1711 GetIndicatorsFromFlags(flags
, indState
, indStatus
);
1713 wxBitmap
& bmp
= m_bmpIndicators
[indType
][indState
][indStatus
];
1716 const char **xpm
= ms_xpmIndicators
[indType
][indState
][indStatus
];
1719 // create and cache it
1720 bmp
= wxBitmap(xpm
);
1727 // ----------------------------------------------------------------------------
1729 // ----------------------------------------------------------------------------
1732 void wxWin32Renderer::DrawToolBarButton(wxDC
& dc
,
1733 const wxString
& label
,
1734 const wxBitmap
& bitmap
,
1735 const wxRect
& rectOrig
,
1740 if (style
== wxTOOL_STYLE_BUTTON
)
1742 wxRect rect
= rectOrig
;
1743 rect
.Deflate(BORDER_THICKNESS
);
1745 if ( flags
& wxCONTROL_PRESSED
)
1747 DrawBorder(dc
, wxBORDER_SUNKEN
, rect
, flags
);
1749 else if ( flags
& wxCONTROL_CURRENT
)
1751 DrawBorder(dc
, wxBORDER_RAISED
, rect
, flags
);
1754 if(tbarStyle
& wxTB_TEXT
)
1756 if(tbarStyle
& wxTB_HORIZONTAL
)
1758 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_CENTRE
);
1762 dc
.DrawLabel(label
, bitmap
, rect
, wxALIGN_LEFT
|wxALIGN_CENTER_VERTICAL
);
1767 int xpoint
= (rect
.GetLeft() + rect
.GetRight() + 1 - bitmap
.GetWidth()) / 2;
1768 int ypoint
= (rect
.GetTop() + rect
.GetBottom() + 1 - bitmap
.GetHeight()) / 2;
1769 dc
.DrawBitmap(bitmap
, xpoint
, ypoint
, bitmap
.GetMask() != NULL
);
1772 else if (style
== wxTOOL_STYLE_SEPARATOR
)
1774 // leave a small gap aroudn the line, also account for the toolbar
1776 if(rectOrig
.height
> rectOrig
.width
)
1779 DrawVerticalLine(dc
, rectOrig
.x
+ rectOrig
.width
/2,
1780 rectOrig
.y
+ 2*BORDER_THICKNESS
,
1781 rectOrig
.GetBottom() - BORDER_THICKNESS
);
1786 DrawHorizontalLine(dc
, rectOrig
.y
+ rectOrig
.height
/2,
1787 rectOrig
.x
+ 2*BORDER_THICKNESS
,
1788 rectOrig
.GetRight() - BORDER_THICKNESS
);
1791 // don't draw wxTOOL_STYLE_CONTROL
1793 #endif // wxUSE_TOOLBAR
1795 // ----------------------------------------------------------------------------
1797 // ----------------------------------------------------------------------------
1801 void wxWin32Renderer::DrawTab(wxDC
& dc
,
1802 const wxRect
& rectOrig
,
1804 const wxString
& label
,
1805 const wxBitmap
& bitmap
,
1809 #define SELECT_FOR_VERTICAL(X,Y) ( isVertical ? Y : X )
1810 #define REVERSE_FOR_VERTICAL(X,Y) \
1811 SELECT_FOR_VERTICAL(X,Y) \
1813 SELECT_FOR_VERTICAL(Y,X)
1815 wxRect rect
= rectOrig
;
1817 bool isVertical
= ( dir
== wxLEFT
) || ( dir
== wxRIGHT
);
1819 // the current tab is drawn indented (to the top for default case) and
1820 // bigger than the other ones
1821 const wxSize indent
= GetTabIndent();
1822 if ( flags
& wxCONTROL_SELECTED
)
1824 rect
.Inflate( SELECT_FOR_VERTICAL( indent
.x
, 0),
1825 SELECT_FOR_VERTICAL( 0, indent
.y
));
1829 wxFAIL_MSG(wxT("invaild notebook tab orientation"));
1836 rect
.height
+= indent
.y
;
1843 rect
.width
+= indent
.x
;
1848 // draw the text, image and the focus around them (if necessary)
1849 wxRect
rectLabel( REVERSE_FOR_VERTICAL(rect
.x
,rect
.y
),
1850 REVERSE_FOR_VERTICAL(rect
.width
,rect
.height
)
1852 rectLabel
.Deflate(1, 1);
1855 // draw it horizontally into memory and rotate for screen
1857 wxBitmap bitmapRotated
,
1858 bitmapMem( rectLabel
.x
+ rectLabel
.width
,
1859 rectLabel
.y
+ rectLabel
.height
);
1860 dcMem
.SelectObject(bitmapMem
);
1861 dcMem
.SetBackground(dc
.GetBackground());
1862 dcMem
.SetFont(dc
.GetFont());
1863 dcMem
.SetTextForeground(dc
.GetTextForeground());
1867 wxBitmap( wxImage( bitmap
.ConvertToImage() ).Rotate90(dir
==wxLEFT
) )
1870 #endif // wxUSE_IMAGE
1872 DrawButtonLabel(dcMem
, label
, bitmapRotated
, rectLabel
,
1873 flags
, wxALIGN_CENTRE
, indexAccel
);
1874 dcMem
.SelectObject(wxNullBitmap
);
1875 bitmapMem
= bitmapMem
.GetSubBitmap(rectLabel
);
1877 bitmapMem
= wxBitmap(wxImage(bitmapMem
.ConvertToImage()).Rotate90(dir
==wxRIGHT
));
1878 #endif // wxUSE_IMAGE
1879 dc
.DrawBitmap(bitmapMem
, rectLabel
.y
, rectLabel
.x
, false);
1883 DrawButtonLabel(dc
, label
, bitmap
, rectLabel
,
1884 flags
, wxALIGN_CENTRE
, indexAccel
);
1887 // now draw the tab border itself (maybe use DrawRoundedRectangle()?)
1888 static const wxCoord CUTOFF
= 2; // radius of the rounded corner
1889 wxCoord x
= SELECT_FOR_VERTICAL(rect
.x
,rect
.y
),
1890 y
= SELECT_FOR_VERTICAL(rect
.y
,rect
.x
),
1891 x2
= SELECT_FOR_VERTICAL(rect
.GetRight(),rect
.GetBottom()),
1892 y2
= SELECT_FOR_VERTICAL(rect
.GetBottom(),rect
.GetRight());
1894 // FIXME: all this code will break if the tab indent or the border width,
1895 // it is tied to the fact that both of them are equal to 2
1901 // left orientation looks like top but IsVertical makes x and y reversed
1903 // top is not vertical so use coordinates in written order
1904 dc
.SetPen(m_penHighlight
);
1905 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
),
1906 REVERSE_FOR_VERTICAL(x
, y
+ CUTOFF
));
1907 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
+ CUTOFF
),
1908 REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y
));
1909 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y
),
1910 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y
));
1912 dc
.SetPen(m_penBlack
);
1913 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
),
1914 REVERSE_FOR_VERTICAL(x2
, y
+ CUTOFF
));
1915 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
+ CUTOFF
),
1916 REVERSE_FOR_VERTICAL(x2
- CUTOFF
, y
));
1918 dc
.SetPen(m_penDarkGrey
);
1919 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y2
),
1920 REVERSE_FOR_VERTICAL(x2
- 1, y
+ CUTOFF
- 1));
1922 if ( flags
& wxCONTROL_SELECTED
)
1924 dc
.SetPen(m_penLightGrey
);
1926 // overwrite the part of the border below this tab
1927 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1),
1928 REVERSE_FOR_VERTICAL(x2
- 1, y2
+ 1));
1930 // and the shadow of the tab to the left of us
1931 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
+ CUTOFF
+ 1),
1932 REVERSE_FOR_VERTICAL(x
+ 1, y2
+ 1));
1937 // right orientation looks like bottom but IsVertical makes x and y reversed
1939 // bottom is not vertical so use coordinates in written order
1940 dc
.SetPen(m_penHighlight
);
1941 // we need to continue one pixel further to overwrite the corner of
1942 // the border for the selected tab
1943 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y
- (flags
& wxCONTROL_SELECTED
? 1 : 0)),
1944 REVERSE_FOR_VERTICAL(x
, y2
- CUTOFF
));
1945 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
, y2
- CUTOFF
),
1946 REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
));
1948 dc
.SetPen(m_penBlack
);
1949 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
),
1950 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y2
));
1951 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y
),
1952 REVERSE_FOR_VERTICAL(x2
, y2
- CUTOFF
));
1953 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
, y2
- CUTOFF
),
1954 REVERSE_FOR_VERTICAL(x2
- CUTOFF
, y2
));
1956 dc
.SetPen(m_penDarkGrey
);
1957 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ CUTOFF
, y2
- 1),
1958 REVERSE_FOR_VERTICAL(x2
- CUTOFF
+ 1, y2
- 1));
1959 dc
.DrawLine(REVERSE_FOR_VERTICAL(x2
- 1, y
),
1960 REVERSE_FOR_VERTICAL(x2
- 1, y2
- CUTOFF
+ 1));
1962 if ( flags
& wxCONTROL_SELECTED
)
1964 dc
.SetPen(m_penLightGrey
);
1966 // overwrite the part of the (double!) border above this tab
1967 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 1),
1968 REVERSE_FOR_VERTICAL(x2
- 1, y
- 1));
1969 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y
- 2),
1970 REVERSE_FOR_VERTICAL(x2
- 1, y
- 2));
1972 // and the shadow of the tab to the left of us
1973 dc
.DrawLine(REVERSE_FOR_VERTICAL(x
+ 1, y2
- CUTOFF
),
1974 REVERSE_FOR_VERTICAL(x
+ 1, y
- 1));
1979 #undef SELECT_FOR_VERTICAL
1980 #undef REVERSE_FOR_VERTICAL
1983 #endif // wxUSE_NOTEBOOK
1987 // ----------------------------------------------------------------------------
1989 // ----------------------------------------------------------------------------
1992 wxWin32Renderer::GetSliderThumbSize(const wxRect
& WXUNUSED(rect
),
1994 wxOrientation orient
) const
1997 wxCoord width
= wxMax (lenThumb
, SLIDER_THUMB_LENGTH
) / 2;
1998 wxCoord height
= wxMax (lenThumb
, SLIDER_THUMB_LENGTH
);
2000 if (orient
== wxHORIZONTAL
)
2014 wxRect
wxWin32Renderer::GetSliderShaftRect(const wxRect
& rectOrig
,
2016 wxOrientation orient
,
2020 GetSliderLabelsSides(orient
, style
, &left
, &right
);
2022 wxRect rect
= rectOrig
;
2024 wxSize sizeThumb
= GetSliderThumbSize (rect
, lenThumb
, orient
);
2026 if (orient
== wxHORIZONTAL
)
2028 rect
.x
+= SLIDER_MARGIN
;
2031 rect
.y
+= wxMax ((rect
.height
- 2*BORDER_THICKNESS
) / 2, sizeThumb
.y
/2);
2035 rect
.y
+= wxMax ((rect
.height
- 2*BORDER_THICKNESS
- sizeThumb
.y
/2), sizeThumb
.y
/2);
2039 rect
.y
+= sizeThumb
.y
/2;
2041 rect
.width
-= 2*SLIDER_MARGIN
;
2042 rect
.height
= 2*BORDER_THICKNESS
;
2044 else // == wxVERTICAL
2046 rect
.y
+= SLIDER_MARGIN
;
2049 rect
.x
+= wxMax ((rect
.width
- 2*BORDER_THICKNESS
) / 2, sizeThumb
.x
/2);
2053 rect
.x
+= wxMax ((rect
.width
- 2*BORDER_THICKNESS
- sizeThumb
.x
/2), sizeThumb
.x
/2);
2057 rect
.x
+= sizeThumb
.x
/2;
2059 rect
.width
= 2*BORDER_THICKNESS
;
2060 rect
.height
-= 2*SLIDER_MARGIN
;
2066 void wxWin32Renderer::DrawSliderShaft(wxDC
& dc
,
2067 const wxRect
& rectOrig
,
2069 wxOrientation orient
,
2074 /* show shaft geometry
2092 if (flags
& wxCONTROL_FOCUSED
)
2093 DrawFocusRect(NULL
, dc
, rectOrig
);
2095 wxRect rect
= GetSliderShaftRect(rectOrig
, lenThumb
, orient
, style
);
2097 if (rectShaft
) *rectShaft
= rect
;
2099 DrawSunkenBorder(dc
, &rect
);
2102 void wxWin32Renderer::DrawSliderThumb(wxDC
& dc
,
2104 wxOrientation orient
,
2108 /* show thumb geometry
2117 H D B where H is highlight colour
2131 The interior of this shape is filled with the hatched brush if the thumb
2135 DrawBackground(dc
, wxNullColour
, rect
, flags
);
2138 GetSliderLabelsSides(orient
, style
, &left
, &right
);
2140 bool isVertical
= orient
== wxVERTICAL
;
2142 wxCoord sizeArrow
= (isVertical
? rect
.height
: rect
.width
) / 2;
2143 wxCoord c
= ((isVertical
? rect
.height
: rect
.width
) - 2*sizeArrow
);
2145 wxCoord x1
, x2
, x3
, y1
, y2
, y3
, y4
;
2146 x1
= (isVertical
? rect
.y
: rect
.x
);
2147 x2
= (isVertical
? rect
.GetBottom() : rect
.GetRight());
2148 x3
= (x1
-1+c
) + sizeArrow
;
2149 y1
= (isVertical
? rect
.x
: rect
.y
);
2150 y2
= (isVertical
? rect
.GetRight() : rect
.GetBottom());
2151 y3
= (left
? (y1
-1+c
) + sizeArrow
: y1
);
2152 y4
= (right
? (y2
+1-c
) - sizeArrow
: y2
);
2154 dc
.SetPen(m_penBlack
);
2157 DrawLine(dc
, x3
+1-c
, y1
, x2
, y3
, isVertical
);
2159 DrawLine(dc
, x2
, y3
, x2
, y4
, isVertical
);
2162 DrawLine(dc
, x3
+1-c
, y2
, x2
, y4
, isVertical
);
2166 DrawLine(dc
, x1
, y2
, x2
, y2
, isVertical
);
2169 dc
.SetPen(m_penDarkGrey
);
2170 DrawLine(dc
, x2
-1, y3
+1, x2
-1, y4
-1, isVertical
);
2173 DrawLine(dc
, x3
+1-c
, y2
-1, x2
-1, y4
, isVertical
);
2177 DrawLine(dc
, x1
+1, y2
-1, x2
-1, y2
-1, isVertical
);
2180 dc
.SetPen(m_penHighlight
);
2183 DrawLine(dc
, x1
, y3
, x3
, y1
, isVertical
);
2184 DrawLine(dc
, x3
+1-c
, y1
+1, x2
-1, y3
, isVertical
);
2188 DrawLine(dc
, x1
, y1
, x2
, y1
, isVertical
);
2190 DrawLine(dc
, x1
, y3
, x1
, y4
, isVertical
);
2193 DrawLine(dc
, x1
, y4
, x3
+c
, y2
+c
, isVertical
);
2196 if (flags
& wxCONTROL_PRESSED
)
2198 // TODO: MSW fills the entire area inside, not just the rect
2199 wxRect rectInt
= rect
;
2202 rectInt
.SetLeft(y3
);
2203 rectInt
.SetRight(y4
);
2208 rectInt
.SetBottom(y4
);
2212 static const char *stipple_xpm
[] = {
2213 /* columns rows colors chars-per-pixel */
2221 dc
.SetBrush(wxBrush(stipple_xpm
));
2223 dc
.SetTextForeground(wxSCHEME_COLOUR(m_scheme
, SHADOW_HIGHLIGHT
));
2224 dc
.SetTextBackground(wxSCHEME_COLOUR(m_scheme
, CONTROL
));
2225 dc
.SetPen(*wxTRANSPARENT_PEN
);
2226 dc
.DrawRectangle(rectInt
);
2230 void wxWin32Renderer::DrawSliderTicks(wxDC
& dc
,
2233 wxOrientation orient
,
2237 int WXUNUSED(flags
),
2240 /* show ticks geometry
2259 GetSliderLabelsSides(orient
, style
, &left
, &right
);
2261 bool isVertical
= orient
== wxVERTICAL
;
2263 // default thumb size
2264 wxSize sizeThumb
= GetSliderThumbSize (rect
, 0, orient
);
2265 wxCoord defaultLen
= (isVertical
? sizeThumb
.x
: sizeThumb
.y
);
2267 // normal thumb size
2268 sizeThumb
= GetSliderThumbSize (rect
, lenThumb
, orient
);
2269 wxCoord widthThumb
= (isVertical
? sizeThumb
.y
: sizeThumb
.x
);
2271 wxRect rectShaft
= GetSliderShaftRect (rect
, lenThumb
, orient
, style
);
2273 wxCoord x1
, x2
, y1
, y2
, y3
, y4
, len
;
2274 x1
= (isVertical
? rectShaft
.y
: rectShaft
.x
) + widthThumb
/2;
2275 x2
= (isVertical
? rectShaft
.GetBottom() : rectShaft
.GetRight()) - widthThumb
/2;
2276 y1
= (isVertical
? rectShaft
.x
: rectShaft
.y
) - defaultLen
/2;
2277 y2
= (isVertical
? rectShaft
.GetRight() : rectShaft
.GetBottom()) + defaultLen
/2;
2278 y3
= (isVertical
? rect
.x
: rect
.y
);
2279 y4
= (isVertical
? rect
.GetRight() : rect
.GetBottom());
2282 dc
.SetPen(m_penBlack
);
2284 int range
= end
- start
;
2285 for ( int n
= 0; n
< range
; n
+= step
)
2287 wxCoord x
= x1
+ (len
*n
) / range
;
2289 if (left
& (y1
> y3
))
2291 DrawLine(dc
, x
, y1
, x
, y3
, orient
== wxVERTICAL
);
2293 if (right
& (y4
> y2
))
2295 DrawLine(dc
, x
, y2
, x
, y4
, orient
== wxVERTICAL
);
2298 // always draw the line at the end position
2299 if (left
& (y1
> y3
))
2301 DrawLine(dc
, x2
, y1
, x2
, y3
, orient
== wxVERTICAL
);
2303 if (right
& (y4
> y2
))
2305 DrawLine(dc
, x2
, y2
, x2
, y4
, orient
== wxVERTICAL
);
2309 #endif // wxUSE_SLIDER
2313 // ----------------------------------------------------------------------------
2315 // ----------------------------------------------------------------------------
2317 // wxWin32MenuGeometryInfo: the wxMenuGeometryInfo used by wxWin32Renderer
2318 class WXDLLEXPORT wxWin32MenuGeometryInfo
: public wxMenuGeometryInfo
2321 virtual wxSize
GetSize() const { return m_size
; }
2323 wxCoord
GetLabelOffset() const { return m_ofsLabel
; }
2324 wxCoord
GetAccelOffset() const { return m_ofsAccel
; }
2326 wxCoord
GetItemHeight() const { return m_heightItem
; }
2329 // the total size of the menu
2332 // the offset of the start of the menu item label
2335 // the offset of the start of the accel label
2338 // the height of a normal (not separator) item
2339 wxCoord m_heightItem
;
2341 friend wxMenuGeometryInfo
*
2342 wxWin32Renderer::GetMenuGeometry(wxWindow
*, const wxMenu
&) const;
2345 // FIXME: all constants are hardcoded but shouldn't be
2346 static const wxCoord MENU_LEFT_MARGIN
= 9;
2347 static const wxCoord MENU_RIGHT_MARGIN
= 18;
2348 static const wxCoord MENU_VERT_MARGIN
= 3;
2350 // the margin around bitmap/check marks (on each side)
2351 static const wxCoord MENU_BMP_MARGIN
= 2;
2353 // the margin between the labels and accel strings
2354 static const wxCoord MENU_ACCEL_MARGIN
= 8;
2356 // the separator height in pixels: in fact, strangely enough, the real height
2357 // is 2 but Windows adds one extra pixel in the bottom margin, so take it into
2359 static const wxCoord MENU_SEPARATOR_HEIGHT
= 3;
2361 // the size of the standard checkmark bitmap
2362 static const wxCoord MENU_CHECK_SIZE
= 9;
2364 void wxWin32Renderer::DrawMenuBarItem(wxDC
& dc
,
2365 const wxRect
& rectOrig
,
2366 const wxString
& label
,
2370 wxRect rect
= rectOrig
;
2373 wxDCTextColourChanger
colChanger(dc
);
2375 if ( flags
& wxCONTROL_SELECTED
)
2377 colChanger
.Set(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
2379 const wxColour colBg
= wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
);
2382 dc
.DrawRectangle(rect
);
2385 // don't draw the focus rect around menu bar items
2386 DrawLabel(dc
, label
, rect
, flags
& ~wxCONTROL_FOCUSED
,
2387 wxALIGN_CENTRE
, indexAccel
);
2390 void wxWin32Renderer::DrawMenuItem(wxDC
& dc
,
2392 const wxMenuGeometryInfo
& gi
,
2393 const wxString
& label
,
2394 const wxString
& accel
,
2395 const wxBitmap
& bitmap
,
2399 const wxWin32MenuGeometryInfo
& geometryInfo
=
2400 (const wxWin32MenuGeometryInfo
&)gi
;
2405 rect
.width
= geometryInfo
.GetSize().x
;
2406 rect
.height
= geometryInfo
.GetItemHeight();
2408 // draw the selected item specially
2409 wxDCTextColourChanger
colChanger(dc
);
2410 if ( flags
& wxCONTROL_SELECTED
)
2412 colChanger
.Set(wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT_TEXT
));
2414 const wxColour colBg
= wxSCHEME_COLOUR(m_scheme
, HIGHLIGHT
);
2417 dc
.DrawRectangle(rect
);
2420 // draw the bitmap: use the bitmap provided or the standard checkmark for
2421 // the checkable items
2422 wxBitmap bmp
= bitmap
;
2423 if ( !bmp
.IsOk() && (flags
& wxCONTROL_CHECKED
) )
2425 bmp
= GetIndicator(IndicatorType_Menu
, flags
);
2430 rect
.SetRight(geometryInfo
.GetLabelOffset());
2431 wxControlRenderer::DrawBitmap(dc
, bmp
, rect
);
2435 rect
.x
= geometryInfo
.GetLabelOffset();
2436 rect
.SetRight(geometryInfo
.GetAccelOffset());
2438 DrawLabel(dc
, label
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
, indexAccel
);
2440 // draw the accel string
2441 rect
.x
= geometryInfo
.GetAccelOffset();
2442 rect
.SetRight(geometryInfo
.GetSize().x
);
2444 // NB: no accel index here
2445 DrawLabel(dc
, accel
, rect
, flags
, wxALIGN_CENTRE_VERTICAL
);
2447 // draw the submenu indicator
2448 if ( flags
& wxCONTROL_ISSUBMENU
)
2450 rect
.x
= geometryInfo
.GetSize().x
- MENU_RIGHT_MARGIN
;
2451 rect
.width
= MENU_RIGHT_MARGIN
;
2453 ArrowStyle arrowStyle
;
2454 if ( flags
& wxCONTROL_DISABLED
)
2455 arrowStyle
= flags
& wxCONTROL_SELECTED
? Arrow_InvertedDisabled
2457 else if ( flags
& wxCONTROL_SELECTED
)
2458 arrowStyle
= Arrow_Inverted
;
2460 arrowStyle
= Arrow_Normal
;
2462 DrawArrow(dc
, rect
, Arrow_Right
, arrowStyle
);
2466 void wxWin32Renderer::DrawMenuSeparator(wxDC
& dc
,
2468 const wxMenuGeometryInfo
& geomInfo
)
2470 DrawHorizontalLine(dc
, y
+ MENU_VERT_MARGIN
, 0, geomInfo
.GetSize().x
);
2473 wxSize
wxWin32Renderer::GetMenuBarItemSize(const wxSize
& sizeText
) const
2475 wxSize size
= sizeText
;
2477 // FIXME: menubar height is configurable under Windows
2484 wxMenuGeometryInfo
*wxWin32Renderer::GetMenuGeometry(wxWindow
*win
,
2485 const wxMenu
& menu
) const
2487 // prepare the dc: for now we draw all the items with the system font
2489 dc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
2491 // the height of a normal item
2492 wxCoord heightText
= dc
.GetCharHeight();
2497 // the max length of label and accel strings: the menu width is the sum of
2498 // them, even if they're for different items (as the accels should be
2501 // the max length of the bitmap is never 0 as Windows always leaves enough
2502 // space for a check mark indicator
2503 wxCoord widthLabelMax
= 0,
2505 widthBmpMax
= MENU_LEFT_MARGIN
;
2507 for ( wxMenuItemList::compatibility_iterator node
= menu
.GetMenuItems().GetFirst();
2509 node
= node
->GetNext() )
2511 // height of this item
2514 wxMenuItem
*item
= node
->GetData();
2515 if ( item
->IsSeparator() )
2517 h
= MENU_SEPARATOR_HEIGHT
;
2519 else // not separator
2524 dc
.GetTextExtent(item
->GetItemLabelText(), &widthLabel
, NULL
);
2525 if ( widthLabel
> widthLabelMax
)
2527 widthLabelMax
= widthLabel
;
2531 dc
.GetTextExtent(item
->GetAccelString(), &widthAccel
, NULL
);
2532 if ( widthAccel
> widthAccelMax
)
2534 widthAccelMax
= widthAccel
;
2537 const wxBitmap
& bmp
= item
->GetBitmap();
2540 wxCoord widthBmp
= bmp
.GetWidth();
2541 if ( widthBmp
> widthBmpMax
)
2542 widthBmpMax
= widthBmp
;
2544 //else if ( item->IsCheckable() ): no need to check for this as
2545 // MENU_LEFT_MARGIN is big enough to show the check mark
2548 h
+= 2*MENU_VERT_MARGIN
;
2550 // remember the item position and height
2551 item
->SetGeometry(height
, h
);
2556 // bundle the metrics into a struct and return it
2557 wxWin32MenuGeometryInfo
*gi
= new wxWin32MenuGeometryInfo
;
2559 gi
->m_ofsLabel
= widthBmpMax
+ 2*MENU_BMP_MARGIN
;
2560 gi
->m_ofsAccel
= gi
->m_ofsLabel
+ widthLabelMax
;
2561 if ( widthAccelMax
> 0 )
2563 // if we actually have any accesl, add a margin
2564 gi
->m_ofsAccel
+= MENU_ACCEL_MARGIN
;
2567 gi
->m_heightItem
= heightText
+ 2*MENU_VERT_MARGIN
;
2569 gi
->m_size
.x
= gi
->m_ofsAccel
+ widthAccelMax
+ MENU_RIGHT_MARGIN
;
2570 gi
->m_size
.y
= height
;
2575 #endif // wxUSE_MENUS
2579 // ----------------------------------------------------------------------------
2581 // ----------------------------------------------------------------------------
2583 void wxWin32Renderer::DrawStatusField(wxDC
& dc
,
2585 const wxString
& label
,
2591 if ( flags
& wxCONTROL_SIZEGRIP
)
2593 // draw the size grip: it is a normal rect except that in the lower
2594 // right corner we have several bands which may be used for dragging
2595 // the status bar corner
2597 // each band consists of 4 stripes: m_penHighlight, double
2598 // m_penDarkGrey and transparent one
2599 wxCoord x2
= rect
.GetRight(),
2600 y2
= rect
.GetBottom();
2602 // draw the upper left part of the rect normally
2603 if (style
!= wxSB_FLAT
)
2605 if (style
== wxSB_RAISED
)
2606 dc
.SetPen(m_penHighlight
);
2608 dc
.SetPen(m_penDarkGrey
);
2609 dc
.DrawLine(rect
.GetLeft(), rect
.GetTop(), rect
.GetLeft(), y2
);
2610 dc
.DrawLine(rect
.GetLeft() + 1, rect
.GetTop(), x2
, rect
.GetTop());
2613 // draw the grey stripes of the grip
2615 wxCoord ofs
= WIDTH_STATUSBAR_GRIP_BAND
- 1;
2616 for ( n
= 0; n
< NUM_STATUSBAR_GRIP_BANDS
; n
++, ofs
+= WIDTH_STATUSBAR_GRIP_BAND
)
2618 dc
.DrawLine(x2
- ofs
+ 1, y2
- 1, x2
, y2
- ofs
);
2619 dc
.DrawLine(x2
- ofs
, y2
- 1, x2
, y2
- ofs
- 1);
2622 // draw the white stripes
2623 dc
.SetPen(m_penHighlight
);
2624 ofs
= WIDTH_STATUSBAR_GRIP_BAND
+ 1;
2625 for ( n
= 0; n
< NUM_STATUSBAR_GRIP_BANDS
; n
++, ofs
+= WIDTH_STATUSBAR_GRIP_BAND
)
2627 dc
.DrawLine(x2
- ofs
+ 1, y2
- 1, x2
, y2
- ofs
);
2630 // draw the remaining rect boundaries
2631 if (style
!= wxSB_FLAT
)
2633 if (style
== wxSB_RAISED
)
2634 dc
.SetPen(m_penDarkGrey
);
2636 dc
.SetPen(m_penHighlight
);
2637 ofs
-= WIDTH_STATUSBAR_GRIP_BAND
;
2638 dc
.DrawLine(x2
, rect
.GetTop(), x2
, y2
- ofs
+ 1);
2639 dc
.DrawLine(rect
.GetLeft(), y2
, x2
- ofs
+ 1, y2
);
2645 rectIn
.width
-= STATUSBAR_GRIP_SIZE
;
2647 // this will prevent the standard version from drawing any borders
2651 wxStdRenderer::DrawStatusField(dc
, rect
, label
, flags
, style
);
2654 #endif // wxUSE_STATUSBAR
2656 // ----------------------------------------------------------------------------
2658 // ----------------------------------------------------------------------------
2660 void wxWin32Renderer::GetComboBitmaps(wxBitmap
*bmpNormal
,
2661 wxBitmap
* WXUNUSED(bmpFocus
),
2662 wxBitmap
*bmpPressed
,
2663 wxBitmap
*bmpDisabled
)
2665 static const wxCoord widthCombo
= 16;
2666 static const wxCoord heightCombo
= 17;
2672 bmpNormal
->Create(widthCombo
, heightCombo
);
2673 dcMem
.SelectObject(*bmpNormal
);
2674 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2675 Arrow_Down
, Arrow_Normal
);
2680 bmpPressed
->Create(widthCombo
, heightCombo
);
2681 dcMem
.SelectObject(*bmpPressed
);
2682 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2683 Arrow_Down
, Arrow_Pressed
);
2688 bmpDisabled
->Create(widthCombo
, heightCombo
);
2689 dcMem
.SelectObject(*bmpDisabled
);
2690 DrawArrowButton(dcMem
, wxRect(0, 0, widthCombo
, heightCombo
),
2691 Arrow_Down
, Arrow_Disabled
);
2695 // ----------------------------------------------------------------------------
2697 // ----------------------------------------------------------------------------
2699 void wxWin32Renderer::DrawArrowBorder(wxDC
& dc
, wxRect
*rect
, bool isPressed
)
2703 DrawRect(dc
, rect
, m_penDarkGrey
);
2705 // the arrow is usually drawn inside border of width 2 and is offset by
2706 // another pixel in both directions when it's pressed - as the border
2707 // in this case is more narrow as well, we have to adjust rect like
2715 DrawAntiSunkenBorder(dc
, rect
);
2719 void wxWin32Renderer::DrawArrow(wxDC
& dc
,
2724 ArrowStyle arrowStyle
;
2725 if ( flags
& wxCONTROL_PRESSED
)
2727 // can't be pressed and disabled
2728 arrowStyle
= Arrow_Pressed
;
2732 arrowStyle
= flags
& wxCONTROL_DISABLED
? Arrow_Disabled
: Arrow_Normal
;
2735 DrawArrowButton(dc
, rect
, GetArrowDirection(dir
), arrowStyle
);
2738 void wxWin32Renderer::DrawArrow(wxDC
& dc
,
2740 ArrowDirection arrowDir
,
2741 ArrowStyle arrowStyle
)
2743 const wxBitmap
& bmp
= m_bmpArrows
[arrowStyle
][arrowDir
];
2745 // under Windows the arrows always have the same size so just centre it in
2746 // the provided rectangle
2747 wxCoord x
= rect
.x
+ (rect
.width
- bmp
.GetWidth()) / 2,
2748 y
= rect
.y
+ (rect
.height
- bmp
.GetHeight()) / 2;
2750 // Windows does it like this...
2751 if ( arrowDir
== Arrow_Left
)
2755 dc
.DrawBitmap(bmp
, x
, y
, true /* use mask */);
2758 void wxWin32Renderer::DrawArrowButton(wxDC
& dc
,
2759 const wxRect
& rectAll
,
2760 ArrowDirection arrowDir
,
2761 ArrowStyle arrowStyle
)
2763 wxRect rect
= rectAll
;
2764 DrawBackground(dc
, wxSCHEME_COLOUR(m_scheme
, CONTROL
), rect
);
2765 DrawArrowBorder(dc
, &rect
, arrowStyle
== Arrow_Pressed
);
2766 DrawArrow(dc
, rect
, arrowDir
, arrowStyle
);
2769 void wxWin32Renderer::DrawScrollbarThumb(wxDC
& dc
,
2770 wxOrientation
WXUNUSED(orient
),
2772 int WXUNUSED(flags
))
2774 // we don't use the flags, the thumb never changes appearance
2775 wxRect rectThumb
= rect
;
2776 DrawArrowBorder(dc
, &rectThumb
);
2777 DrawBackground(dc
, wxNullColour
, rectThumb
);
2780 void wxWin32Renderer::DrawScrollbarShaft(wxDC
& dc
,
2781 wxOrientation
WXUNUSED(orient
),
2782 const wxRect
& rectBar
,
2785 wxColourScheme::StdColour col
= flags
& wxCONTROL_PRESSED
2786 ? wxColourScheme::SCROLLBAR_PRESSED
2787 : wxColourScheme::SCROLLBAR
;
2788 DrawBackground(dc
, m_scheme
->Get(col
), rectBar
);
2791 // ----------------------------------------------------------------------------
2793 // ----------------------------------------------------------------------------
2795 /* Copyright (c) Julian Smart */
2796 static const char *error_xpm
[]={
2797 /* columns rows colors chars-per-pixel */
2874 " $oooooooooooo%& ",
2875 " *=-ooooooooooooo;: ",
2876 " *oooooooooooooooooo> ",
2877 " =ooooooooooooooooooo, ",
2878 " $-ooooooooooooooooooo<1 ",
2879 " .oooooo2334ooo533oooooo6 ",
2880 " +ooooooo789oo2883oooooo0q ",
2881 " oooooooo2w83o78eoooooooor ",
2882 " toooooooooy88u884oooooooori ",
2883 " Xooooooooooe888poooooooooas ",
2884 " ooooooooooo4889doooooooooof ",
2885 " ooooooooooo588w2oooooooooofi ",
2886 " oooooooooodw8887oooooooooofi ",
2887 " goooooooooh8w588jooooooookli ",
2888 " tooooooooz885op8wdooooooorix ",
2889 " oooooood98cood98cooooooori ",
2890 " @oooooop8w2ooo5885ooooovbi ",
2891 " n%ooooooooooooooooooooomiM ",
2892 " &;oooooooooooooooooooNBiV ",
2893 " :ooooooooooooooooooCZiA ",
2894 " nSooooooooooooooooCDiF ",
2895 " nG<oooooooooooooNZiiH ",
2896 " 160ooooooooovmBiFH ",
2897 " nqrraoookrrbiiA ",
2904 /* Copyright (c) Julian Smart */
2905 static const char *info_xpm
[]={
2906 /* columns rows colors chars-per-pixel */
2928 " ..XXXXXXXXXXXXX.. ",
2929 " .XXXXXXXXXXXXXXXXX. ",
2930 " .XXXXXXXXoO+XXXXXXXX. ",
2931 " .XXXXXXXXX@#OXXXXXXXXX. ",
2932 " .XXXXXXXXXX$@oXXXXXXXXXX. ",
2933 " .XXXXXXXXXXXXXXXXXXXXXXX.% ",
2934 " .XXXXXXXXX&*=-XXXXXXXXXX.%% ",
2935 ".XXXXXXXXXX;:#>XXXXXXXXXXX.% ",
2936 ".XXXXXXXXXXX;#+XXXXXXXXXXX.% ",
2937 ".XXXXXXXXXXX;#+XXXXXXXXXXX.%% ",
2938 " .XXXXXXXXXX;#+XXXXXXXXXX.%%% ",
2939 " .XXXXXXXXXX;#+XXXXXXXXXX.%%% ",
2940 " .XXXXXXXXXX;#+XXXXXXXXXX.%% ",
2941 " .XXXXXXXX*-##+XXXXXXXX.%%% ",
2942 " .XXXXXXXXXXXXXXXXXXX.%%%% ",
2943 " .XXXXXXXXXXXXXXXXX.%%%% ",
2944 " ..XXXXXXXXXXXXX..%%%% ",
2945 " %...XXXXXXXX..%%%%% ",
2946 " %%%..XXXXXX.%%%%% ",
2960 /* Copyright (c) Julian Smart */
2961 static const char *question_xpm
[]={
2962 /* columns rows colors chars-per-pixel */
2983 " ..XXXXXXXXXXXXX.. ",
2984 " .XXXXXXoO++@XXXXXX. ",
2985 " .XXXXXXO#$$$$#%XXXXX. ",
2986 " .XXXXXX@$$#&&#$#oXXXXX. ",
2987 " .XXXXXXX*$$%XX%$$=XXXXXX. ",
2988 " .XXXXXXX+-;XXXX$$-XXXXXX.: ",
2989 " .XXXXXXXXXXXXX+$$&XXXXXX.:: ",
2990 ".XXXXXXXXXXXXo;$$*oXXXXXXX.: ",
2991 ".XXXXXXXXXXXo*$$*oXXXXXXXX.: ",
2992 ".XXXXXXXXXXX+$$*oXXXXXXXXX.:: ",
2993 " .XXXXXXXXXX-$$oXXXXXXXXX.::: ",
2994 " .XXXXXXXXXXX--XXXXXXXXXX.::: ",
2995 " .XXXXXXXXXXXXXXXXXXXXXXX.:: ",
2996 " .XXXXXXXXX-$$XXXXXXXXX.::: ",
2997 " .XXXXXXXX-$$XXXXXXXX.:::: ",
2998 " .XXXXXXXO++XXXXXXX.:::: ",
2999 " ..XXXXXXXXXXXXX..:::: ",
3000 " :...XXXXXXXX..::::: ",
3001 " :::..XXXXXX.::::: ",
3015 /* Copyright (c) Julian Smart */
3016 static const char *warning_xpm
[]={
3017 /* columns rows colors chars-per-pixel */
3043 " ..XXXXO@#XXX... ",
3044 " ...XXXXO@#XXXX.. ",
3045 " ..XXXXXO@#XXXX... ",
3046 " ...XXXXXo@OXXXXX.. ",
3047 " ...XXXXXXo@OXXXXXX.. ",
3048 " ..XXXXXXX$@OXXXXXX... ",
3049 " ...XXXXXXXX@XXXXXXXX.. ",
3050 " ...XXXXXXXXXXXXXXXXXX... ",
3051 " ..XXXXXXXXXXOXXXXXXXXX.. ",
3052 " ...XXXXXXXXXO@#XXXXXXXXX.. ",
3053 " ..XXXXXXXXXXX#XXXXXXXXXX... ",
3054 " ...XXXXXXXXXXXXXXXXXXXXXXX.. ",
3055 " ...XXXXXXXXXXXXXXXXXXXXXXXX... ",
3056 " .............................. ",
3057 " .............................. ",
3064 wxBitmap
wxWin32ArtProvider::CreateBitmap(const wxArtID
& id
,
3065 const wxArtClient
& WXUNUSED(client
),
3066 const wxSize
& WXUNUSED(size
))
3068 if ( id
== wxART_INFORMATION
)
3069 return wxBitmap(info_xpm
);
3070 if ( id
== wxART_ERROR
)
3071 return wxBitmap(error_xpm
);
3072 if ( id
== wxART_WARNING
)
3073 return wxBitmap(warning_xpm
);
3074 if ( id
== wxART_QUESTION
)
3075 return wxBitmap(question_xpm
);
3076 return wxNullBitmap
;
3082 // ----------------------------------------------------------------------------
3083 // text control geometry
3084 // ----------------------------------------------------------------------------
3087 wxWin32Renderer::GetTextTotalArea(const wxTextCtrl
*text
,
3088 const wxRect
& rect
) const
3090 wxRect rectTotal
= wxStdRenderer::GetTextTotalArea(text
, rect
);
3092 // this is strange but it's what Windows does
3099 wxWin32Renderer::GetTextClientArea(const wxTextCtrl
*text
,
3101 wxCoord
*extraSpaceBeyond
) const
3103 wxRect rectText
= rect
;
3105 // undo GetTextTotalArea()
3106 if ( rectText
.height
> 0 )
3109 return wxStdRenderer::GetTextClientArea(text
, rect
, extraSpaceBeyond
);
3112 #endif // wxUSE_TEXTCTRL
3114 // ----------------------------------------------------------------------------
3116 // ----------------------------------------------------------------------------
3118 void wxWin32Renderer::AdjustSize(wxSize
*size
, const wxWindow
*window
)
3121 if ( wxDynamicCast(window
, wxScrollBar
) )
3124 Don't adjust the size for a scrollbar as its DoGetBestClientSize
3125 already has the correct size set. Any size changes here would get
3126 added to the best size, making the scrollbar larger.
3127 Also skip border width adjustments, they don't make sense for us.
3131 #endif // wxUSE_SCROLLBAR
3134 if ( wxDynamicCast(window
, wxBitmapButton
) )
3138 #endif // wxUSE_BMPBUTTON
3139 #if wxUSE_BUTTON || wxUSE_TOGGLEBTN
3142 || wxDynamicCast(window
, wxButton
)
3143 # endif // wxUSE_BUTTON
3144 # if wxUSE_TOGGLEBTN
3145 || wxDynamicCast(window
, wxToggleButton
)
3146 # endif // wxUSE_TOGGLEBTN
3149 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
3151 // TODO: don't harcode all this
3152 size
->x
+= 3*window
->GetCharWidth();
3154 wxCoord heightBtn
= (11*(window
->GetCharHeight() + 8))/10;
3155 if ( size
->y
< heightBtn
- 8 )
3156 size
->y
= heightBtn
;
3161 // for compatibility with other ports, the buttons default size is never
3162 // less than the standard one, but not when display not PDAs.
3163 if (wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA
)
3165 if ( !(window
->GetWindowStyle() & wxBU_EXACTFIT
) )
3167 wxSize szDef
= wxButton::GetDefaultSize();
3168 if ( size
->x
< szDef
.x
)
3173 // no border width adjustments for buttons
3176 #endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
3178 wxStdRenderer::AdjustSize(size
, window
);
3181 wxBitmap
wxWin32Renderer::GetFrameButtonBitmap(FrameButtonType type
)
3183 wxBitmap
& bmp
= m_bmpFrameButtons
[type
];
3186 bmp
= wxBitmap(ms_xpmFrameButtons
[type
]);
3192 // ============================================================================
3194 // ============================================================================
3196 // ----------------------------------------------------------------------------
3197 // wxWin32InputHandler
3198 // ----------------------------------------------------------------------------
3200 bool wxWin32InputHandler::HandleKey(wxInputConsumer
* WXUNUSED(control
),
3201 const wxKeyEvent
& WXUNUSED(event
),
3202 bool WXUNUSED(pressed
))
3207 bool wxWin32InputHandler::HandleMouse(wxInputConsumer
*control
,
3208 const wxMouseEvent
& event
)
3210 // clicking on the control gives it focus
3211 if ( event
.ButtonDown() )
3213 wxWindow
* const win
= control
->GetInputWindow();
3215 if ( win
->CanAcceptFocus() && wxWindow::FindFocus() != win
)
3228 // ----------------------------------------------------------------------------
3229 // wxWin32ScrollBarInputHandler
3230 // ----------------------------------------------------------------------------
3232 wxWin32ScrollBarInputHandler::
3233 wxWin32ScrollBarInputHandler(wxRenderer
*renderer
, wxInputHandler
*handler
)
3234 : wxStdScrollBarInputHandler(renderer
, handler
)
3236 m_scrollPaused
= false;
3240 bool wxWin32ScrollBarInputHandler::OnScrollTimer(wxScrollBar
*scrollbar
,
3241 const wxControlAction
& action
)
3243 // stop if went beyond the position of the original click (this can only
3244 // happen when we scroll by pages)
3246 if ( action
== wxACTION_SCROLL_PAGE_DOWN
)
3248 stop
= scrollbar
->HitTestBar(m_ptStartScrolling
) != wxHT_SCROLLBAR_BAR_2
;
3250 else if ( action
== wxACTION_SCROLL_PAGE_UP
)
3252 stop
= scrollbar
->HitTestBar(m_ptStartScrolling
) != wxHT_SCROLLBAR_BAR_1
;
3257 StopScrolling(scrollbar
);
3259 scrollbar
->Refresh();
3264 return wxStdScrollBarInputHandler::OnScrollTimer(scrollbar
, action
);
3267 bool wxWin32ScrollBarInputHandler::HandleMouse(wxInputConsumer
*control
,
3268 const wxMouseEvent
& event
)
3270 // remember the current state
3271 bool wasDraggingThumb
= m_htLast
== wxHT_SCROLLBAR_THUMB
;
3273 // do process the message
3274 bool rc
= wxStdScrollBarInputHandler::HandleMouse(control
, event
);
3276 // analyse the changes
3277 if ( !wasDraggingThumb
&& (m_htLast
== wxHT_SCROLLBAR_THUMB
) )
3279 // we just started dragging the thumb, remember its initial position to
3280 // be able to restore it if the drag is cancelled later
3281 m_eventStartDrag
= event
;
3287 bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer
*control
,
3288 const wxMouseEvent
& event
)
3290 // we don't highlight scrollbar elements, so there is no need to process
3291 // mouse move events normally - only do it while mouse is captured (i.e.
3292 // when we're dragging the thumb or pressing on something)
3293 if ( !m_winCapture
)
3296 if ( event
.Entering() )
3298 // we're not interested in this at all
3302 wxScrollBar
*scrollbar
= wxStaticCast(control
->GetInputWindow(), wxScrollBar
);
3304 if ( m_scrollPaused
)
3306 // check if the mouse returned to its original location
3308 if ( event
.Leaving() )
3314 ht
= scrollbar
->HitTestBar(event
.GetPosition());
3315 if ( ht
== m_htLast
)
3317 // yes it did, resume scrolling
3318 m_scrollPaused
= false;
3319 if ( m_timerScroll
)
3321 // we were scrolling by line/page, restart timer
3322 m_timerScroll
->Start(m_interval
);
3324 Press(scrollbar
, true);
3326 else // we were dragging the thumb
3328 // restore its last location
3329 HandleThumbMove(scrollbar
, m_eventLastDrag
);
3335 else // normal case, scrolling hasn't been paused
3337 // if we're scrolling the scrollbar because the arrow or the shaft was
3338 // pressed, check that the mouse stays on the same scrollbar element
3341 // Always let thumb jump back if we leave the scrollbar
3342 if ( event
.Moving() )
3344 ht
= scrollbar
->HitTestBar(event
.GetPosition());
3346 else // event.Leaving()
3351 // Jump back only if we get far away from it
3352 wxPoint pos
= event
.GetPosition();
3353 if (scrollbar
->HasFlag( wxVERTICAL
))
3355 if (pos
.x
> -40 && pos
.x
< scrollbar
->GetSize().x
+40)
3360 if (pos
.y
> -40 && pos
.y
< scrollbar
->GetSize().y
+40)
3363 ht
= scrollbar
->HitTestBar(pos
);
3366 // if we're dragging the thumb and the mouse stays in the scrollbar, it
3367 // is still ok - we only want to catch the case when the mouse leaves
3368 // the scrollbar here
3369 if ( m_htLast
== wxHT_SCROLLBAR_THUMB
&& ht
!= wxHT_NOWHERE
)
3371 ht
= wxHT_SCROLLBAR_THUMB
;
3374 if ( ht
!= m_htLast
)
3376 // what were we doing? 2 possibilities: either an arrow/shaft was
3377 // pressed in which case we have a timer and so we just stop it or
3378 // we were dragging the thumb
3379 if ( m_timerScroll
)
3382 m_interval
= m_timerScroll
->GetInterval();
3383 m_timerScroll
->Stop();
3384 m_scrollPaused
= true;
3386 // unpress the arrow
3387 Press(scrollbar
, false);
3389 else // we were dragging the thumb
3391 // remember the current thumb position to be able to restore it
3392 // if the mouse returns to it later
3393 m_eventLastDrag
= event
;
3395 // and restore the original position (before dragging) of the
3397 HandleThumbMove(scrollbar
, m_eventStartDrag
);
3404 return wxStdInputHandler::HandleMouseMove(control
, event
);
3407 #endif // wxUSE_SCROLLBAR
3411 // ----------------------------------------------------------------------------
3412 // wxWin32CheckboxInputHandler
3413 // ----------------------------------------------------------------------------
3415 bool wxWin32CheckboxInputHandler::HandleKey(wxInputConsumer
*control
,
3416 const wxKeyEvent
& event
,
3421 wxControlAction action
;
3422 int keycode
= event
.GetKeyCode();
3426 action
= wxACTION_CHECKBOX_TOGGLE
;
3430 case WXK_NUMPAD_SUBTRACT
:
3431 action
= wxACTION_CHECKBOX_CHECK
;
3435 case WXK_NUMPAD_ADD
:
3436 case WXK_NUMPAD_EQUAL
:
3437 action
= wxACTION_CHECKBOX_CLEAR
;
3441 if ( !action
.IsEmpty() )
3443 control
->PerformAction(action
);
3452 #endif // wxUSE_CHECKBOX
3456 // ----------------------------------------------------------------------------
3457 // wxWin32TextCtrlInputHandler
3458 // ----------------------------------------------------------------------------
3460 bool wxWin32TextCtrlInputHandler::HandleKey(wxInputConsumer
*control
,
3461 const wxKeyEvent
& event
,
3464 // handle only MSW-specific text bindings here, the others are handled in
3468 int keycode
= event
.GetKeyCode();
3470 wxControlAction action
;
3471 if ( keycode
== WXK_DELETE
&& event
.ShiftDown() )
3473 action
= wxACTION_TEXT_CUT
;
3475 else if ( keycode
== WXK_INSERT
)
3477 if ( event
.ControlDown() )
3478 action
= wxACTION_TEXT_COPY
;
3479 else if ( event
.ShiftDown() )
3480 action
= wxACTION_TEXT_PASTE
;
3483 if ( action
!= wxACTION_NONE
)
3485 control
->PerformAction(action
);
3491 return wxStdInputHandler::HandleKey(control
, event
, pressed
);
3494 #endif // wxUSE_TEXTCTRL
3498 // ----------------------------------------------------------------------------
3499 // wxWin32StatusBarInputHandler
3500 // ----------------------------------------------------------------------------
3502 wxWin32StatusBarInputHandler::
3503 wxWin32StatusBarInputHandler(wxInputHandler
*handler
)
3504 : wxStdInputHandler(handler
)
3509 bool wxWin32StatusBarInputHandler::IsOnGrip(wxWindow
*statbar
,
3510 const wxPoint
& pt
) const
3512 if ( statbar
->HasFlag(wxST_SIZEGRIP
) &&
3513 statbar
->GetParent()->HasFlag(wxRESIZE_BORDER
) )
3516 parentTLW
= wxDynamicCast(statbar
->GetParent(), wxTopLevelWindow
);
3518 wxCHECK_MSG( parentTLW
, false,
3519 wxT("the status bar should be a child of a TLW") );
3521 // a maximized window can't be resized anyhow
3522 if ( !parentTLW
->IsMaximized() )
3524 // VZ: I think that the standard Windows behaviour is to only
3525 // show the resizing cursor when the mouse is on top of the
3526 // grip itself but apparently different Windows versions behave
3527 // differently (?) and it seems a better UI to allow resizing
3528 // the status bar even when the mouse is above the grip
3529 wxSize sizeSbar
= statbar
->GetSize();
3531 int diff
= sizeSbar
.x
- pt
.x
;
3532 return diff
>= 0 && diff
< (wxCoord
)STATUSBAR_GRIP_SIZE
;
3539 bool wxWin32StatusBarInputHandler::HandleMouse(wxInputConsumer
*consumer
,
3540 const wxMouseEvent
& event
)
3542 if ( event
.Button(1) )
3544 if ( event
.ButtonDown(1) )
3546 wxWindow
*statbar
= consumer
->GetInputWindow();
3548 if ( IsOnGrip(statbar
, event
.GetPosition()) )
3550 wxTopLevelWindow
*tlw
= wxDynamicCast(statbar
->GetParent(),
3554 tlw
->PerformAction(wxACTION_TOPLEVEL_RESIZE
,
3555 wxHT_TOPLEVEL_BORDER_SE
);
3557 statbar
->SetCursor(m_cursorOld
);
3565 return wxStdInputHandler::HandleMouse(consumer
, event
);
3568 bool wxWin32StatusBarInputHandler::HandleMouseMove(wxInputConsumer
*consumer
,
3569 const wxMouseEvent
& event
)
3571 wxWindow
*statbar
= consumer
->GetInputWindow();
3573 bool isOnGrip
= IsOnGrip(statbar
, event
.GetPosition());
3574 if ( isOnGrip
!= m_isOnGrip
)
3576 m_isOnGrip
= isOnGrip
;
3579 m_cursorOld
= statbar
->GetCursor();
3580 statbar
->SetCursor(wxCURSOR_SIZENWSE
);
3584 statbar
->SetCursor(m_cursorOld
);
3588 return wxStdInputHandler::HandleMouseMove(consumer
, event
);
3591 #endif // wxUSE_STATUSBAR
3593 // ----------------------------------------------------------------------------
3594 // wxWin32FrameInputHandler
3595 // ----------------------------------------------------------------------------
3597 class wxWin32SystemMenuEvtHandler
: public wxEvtHandler
3600 wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler
*handler
);
3602 void Attach(wxInputConsumer
*consumer
);
3606 DECLARE_EVENT_TABLE()
3607 void OnSystemMenu(wxCommandEvent
&event
);
3608 void OnCloseFrame(wxCommandEvent
&event
);
3609 void OnClose(wxCloseEvent
&event
);
3611 wxWin32FrameInputHandler
*m_inputHnd
;
3612 wxTopLevelWindow
*m_wnd
;
3614 wxAcceleratorTable m_oldAccelTable
;
3618 wxWin32SystemMenuEvtHandler::
3619 wxWin32SystemMenuEvtHandler(wxWin32FrameInputHandler
*handler
)
3621 m_inputHnd
= handler
;
3625 void wxWin32SystemMenuEvtHandler::Attach(wxInputConsumer
*consumer
)
3627 wxASSERT_MSG( m_wnd
== NULL
, wxT("can't attach the handler twice!") );
3629 m_wnd
= wxStaticCast(consumer
->GetInputWindow(), wxTopLevelWindow
);
3630 m_wnd
->PushEventHandler(this);
3633 // VS: This code relies on using generic implementation of
3634 // wxAcceleratorTable in wxUniv!
3635 wxAcceleratorTable table
= *m_wnd
->GetAcceleratorTable();
3636 m_oldAccelTable
= table
;
3637 table
.Add(wxAcceleratorEntry(wxACCEL_ALT
, WXK_SPACE
, wxID_SYSTEM_MENU
));
3638 table
.Add(wxAcceleratorEntry(wxACCEL_ALT
, WXK_F4
, wxID_CLOSE_FRAME
));
3639 m_wnd
->SetAcceleratorTable(table
);
3643 void wxWin32SystemMenuEvtHandler::Detach()
3648 m_wnd
->SetAcceleratorTable(m_oldAccelTable
);
3650 m_wnd
->RemoveEventHandler(this);
3655 BEGIN_EVENT_TABLE(wxWin32SystemMenuEvtHandler
, wxEvtHandler
)
3656 EVT_MENU(wxID_SYSTEM_MENU
, wxWin32SystemMenuEvtHandler::OnSystemMenu
)
3657 EVT_MENU(wxID_CLOSE_FRAME
, wxWin32SystemMenuEvtHandler::OnCloseFrame
)
3658 EVT_CLOSE(wxWin32SystemMenuEvtHandler::OnClose
)
3661 void wxWin32SystemMenuEvtHandler::OnSystemMenu(wxCommandEvent
&WXUNUSED(event
))
3664 wxAcceleratorTable table
= *m_wnd
->GetAcceleratorTable();
3665 m_wnd
->SetAcceleratorTable(wxNullAcceleratorTable
);
3669 m_inputHnd
->PopupSystemMenu(m_wnd
);
3670 #endif // wxUSE_MENUS
3673 m_wnd
->SetAcceleratorTable(table
);
3677 void wxWin32SystemMenuEvtHandler::OnCloseFrame(wxCommandEvent
&WXUNUSED(event
))
3679 m_wnd
->PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
3680 wxTOPLEVEL_BUTTON_CLOSE
);
3683 void wxWin32SystemMenuEvtHandler::OnClose(wxCloseEvent
&event
)
3690 wxWin32FrameInputHandler::wxWin32FrameInputHandler(wxInputHandler
*handler
)
3691 : wxStdInputHandler(handler
)
3693 m_menuHandler
= new wxWin32SystemMenuEvtHandler(this);
3696 wxWin32FrameInputHandler::~wxWin32FrameInputHandler()
3698 if ( m_menuHandler
)
3700 m_menuHandler
->Detach();
3701 delete m_menuHandler
;
3705 bool wxWin32FrameInputHandler::HandleMouse(wxInputConsumer
*consumer
,
3706 const wxMouseEvent
& event
)
3708 if ( event
.LeftDClick() || event
.LeftDown() || event
.RightDown() )
3710 wxTopLevelWindow
*tlw
=
3711 wxStaticCast(consumer
->GetInputWindow(), wxTopLevelWindow
);
3713 long hit
= tlw
->HitTest(event
.GetPosition());
3715 if ( event
.LeftDClick() && hit
== wxHT_TOPLEVEL_TITLEBAR
)
3717 tlw
->PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
3718 tlw
->IsMaximized() ? wxTOPLEVEL_BUTTON_RESTORE
3719 : wxTOPLEVEL_BUTTON_MAXIMIZE
);
3722 else if ( tlw
->GetWindowStyle() & wxSYSTEM_MENU
)
3724 if ( (event
.LeftDown() && hit
== wxHT_TOPLEVEL_ICON
) ||
3725 (event
.RightDown() &&
3726 (hit
== wxHT_TOPLEVEL_TITLEBAR
||
3727 hit
== wxHT_TOPLEVEL_ICON
)) )
3730 PopupSystemMenu(tlw
);
3731 #endif // wxUSE_MENUS
3737 return wxStdInputHandler::HandleMouse(consumer
, event
);
3742 void wxWin32FrameInputHandler::PopupSystemMenu(wxTopLevelWindow
*window
) const
3746 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
3747 menu
.Append(wxID_RESTORE_FRAME
, _("&Restore"));
3748 menu
.Append(wxID_MOVE_FRAME
, _("&Move"));
3749 if ( window
->GetWindowStyle() & wxRESIZE_BORDER
)
3750 menu
.Append(wxID_RESIZE_FRAME
, _("&Size"));
3751 if ( wxSystemSettings::HasFeature(wxSYS_CAN_ICONIZE_FRAME
) )
3752 menu
.Append(wxID_ICONIZE_FRAME
, _("Mi&nimize"));
3753 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
3754 menu
.Append(wxID_MAXIMIZE_FRAME
, _("Ma&ximize"));
3755 menu
.AppendSeparator();
3756 menu
.Append(wxID_CLOSE_FRAME
, _("&Close") + wxT("\t") + _("Alt+") + wxT("F4"));
3758 if ( window
->GetWindowStyle() & wxMAXIMIZE_BOX
)
3760 if ( window
->IsMaximized() )
3762 menu
.Enable(wxID_MAXIMIZE_FRAME
, false);
3763 menu
.Enable(wxID_MOVE_FRAME
, false);
3764 if ( window
->GetWindowStyle() & wxRESIZE_BORDER
)
3765 menu
.Enable(wxID_RESIZE_FRAME
, false);
3768 menu
.Enable(wxID_RESTORE_FRAME
, false);
3771 window
->PopupMenu(&menu
, wxPoint(0, 0));
3774 #endif // wxUSE_MENUS
3776 bool wxWin32FrameInputHandler::HandleActivation(wxInputConsumer
*consumer
,
3779 if ( consumer
->GetInputWindow()->GetWindowStyle() & wxSYSTEM_MENU
)
3781 // always detach if active frame changed:
3782 m_menuHandler
->Detach();
3786 m_menuHandler
->Attach(consumer
);
3790 return wxStdInputHandler::HandleActivation(consumer
, activated
);
3793 #endif // wxUSE_THEME_WIN32