1 /////////////////////////////////////////////////////////////////////////////
3 // Author: Vaclav Slavik
5 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // ============================================================================
11 // ============================================================================
13 // ----------------------------------------------------------------------------
15 // ----------------------------------------------------------------------------
18 #pragma implementation "univtoplevel.h"
21 // For compilers that support precompilation, includes "wx.h".
22 #include "wx/wxprec.h"
31 #include "wx/dcclient.h"
32 #include "wx/settings.h"
35 #include "wx/toplevel.h"
36 #include "wx/univ/renderer.h"
37 #include "wx/bitmap.h"
39 #include "wx/cshelp.h"
40 #include "wx/evtloop.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 BEGIN_EVENT_TABLE(wxTopLevelWindow
, wxTopLevelWindowNative
)
48 WX_EVENT_TABLE_INPUT_CONSUMER(wxTopLevelWindow
)
49 EVT_NC_PAINT(wxTopLevelWindow::OnNcPaint
)
50 EVT_MENU_RANGE(wxID_CLOSE_FRAME
, wxID_RESTORE_FRAME
, wxTopLevelWindow::OnSystemMenu
)
53 WX_FORWARD_TO_INPUT_CONSUMER(wxTopLevelWindow
)
55 // ============================================================================
57 // ============================================================================
59 int wxTopLevelWindow::ms_drawDecorations
= -1;
60 int wxTopLevelWindow::ms_canIconize
= -1;
62 void wxTopLevelWindow::Init()
69 bool wxTopLevelWindow::Create(wxWindow
*parent
,
71 const wxString
& title
,
77 // init them to avoid compiler warnings
81 if ( ms_drawDecorations
== -1 )
84 !wxSystemSettings::HasFeature(wxSYS_CAN_DRAW_FRAME_DECORATIONS
)
85 || wxGetEnv(wxT("WXDECOR"), NULL
);
86 // FIXME -- wxUniv should provide a way to force non-native decorations!
87 // $WXDECOR is just a hack in absence of better wxUniv solution
90 if ( ms_canIconize
== -1 )
92 ms_canIconize
= wxSystemSettings::HasFeature(wxSYS_CAN_ICONIZE_FRAME
);
95 if ( ms_drawDecorations
)
97 CreateInputHandler(wxINP_HANDLER_TOPLEVEL
);
100 exstyleOrig
= GetExtraStyle();
101 style
&= ~(wxCAPTION
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
102 wxSYSTEM_MENU
| wxRESIZE_BORDER
| wxFRAME_TOOL_WINDOW
|
104 style
= wxSIMPLE_BORDER
;
105 SetExtraStyle(exstyleOrig
&
106 ~(wxFRAME_EX_CONTEXTHELP
| wxDIALOG_EX_CONTEXTHELP
));
109 if ( !wxTopLevelWindowNative::Create(parent
, id
, title
, pos
,
113 if ( ms_drawDecorations
)
115 m_windowStyle
= styleOrig
;
116 m_exStyle
= exstyleOrig
;
122 bool wxTopLevelWindow::ShowFullScreen(bool show
, long style
)
124 if ( show
== IsFullScreen() ) return FALSE
;
126 if ( ms_drawDecorations
)
130 m_fsSavedStyle
= m_windowStyle
;
131 if ( style
& wxFULLSCREEN_NOBORDER
)
132 m_windowStyle
|= wxSIMPLE_BORDER
;
133 if ( style
& wxFULLSCREEN_NOCAPTION
)
134 m_windowStyle
&= ~wxCAPTION
;
138 m_windowStyle
= m_fsSavedStyle
;
142 return wxTopLevelWindowNative::ShowFullScreen(show
, style
);
145 long wxTopLevelWindow::GetDecorationsStyle() const
149 if ( m_windowStyle
& wxCAPTION
)
151 style
|= wxTOPLEVEL_TITLEBAR
| wxTOPLEVEL_BUTTON_CLOSE
;
152 if ( (m_windowStyle
& wxMINIMIZE_BOX
) && ms_canIconize
)
153 style
|= wxTOPLEVEL_BUTTON_ICONIZE
;
154 if ( m_windowStyle
& wxMAXIMIZE_BOX
)
157 style
|= wxTOPLEVEL_BUTTON_RESTORE
;
159 style
|= wxTOPLEVEL_BUTTON_MAXIMIZE
;
162 if ( m_exStyle
& (wxFRAME_EX_CONTEXTHELP
| wxDIALOG_EX_CONTEXTHELP
))
163 style
|= wxTOPLEVEL_BUTTON_HELP
;
166 if ( (m_windowStyle
& (wxSIMPLE_BORDER
| wxNO_BORDER
)) == 0 )
167 style
|= wxTOPLEVEL_BORDER
;
168 if ( m_windowStyle
& (wxRESIZE_BORDER
| wxTHICK_FRAME
) )
169 style
|= wxTOPLEVEL_RESIZEABLE
;
172 style
|= wxTOPLEVEL_MAXIMIZED
;
173 if ( GetIcon().Ok() )
174 style
|= wxTOPLEVEL_ICON
;
176 style
|= wxTOPLEVEL_ACTIVE
;
181 void wxTopLevelWindow::RefreshTitleBar()
183 wxNcPaintEvent
event(GetId());
184 event
.SetEventObject(this);
185 GetEventHandler()->ProcessEvent(event
);
188 // ----------------------------------------------------------------------------
189 // client area handling
190 // ----------------------------------------------------------------------------
192 wxPoint
wxTopLevelWindow::GetClientAreaOrigin() const
194 if ( ms_drawDecorations
)
197 wxTopLevelWindowNative::DoGetClientSize(&w
, &h
);
198 wxRect rect
= wxRect(wxTopLevelWindowNative::GetClientAreaOrigin(),
200 rect
= m_renderer
->GetFrameClientArea(rect
,
201 GetDecorationsStyle());
202 return rect
.GetPosition();
206 return wxTopLevelWindowNative::GetClientAreaOrigin();
210 void wxTopLevelWindow::DoGetClientSize(int *width
, int *height
) const
212 if ( ms_drawDecorations
)
215 wxTopLevelWindowNative::DoGetClientSize(&w
, &h
);
216 wxRect rect
= wxRect(wxTopLevelWindowNative::GetClientAreaOrigin(),
218 rect
= m_renderer
->GetFrameClientArea(rect
,
219 GetDecorationsStyle());
223 *height
= rect
.height
;
226 wxTopLevelWindowNative::DoGetClientSize(width
, height
);
229 void wxTopLevelWindow::DoSetClientSize(int width
, int height
)
231 if ( ms_drawDecorations
)
233 wxSize size
= m_renderer
->GetFrameTotalSize(wxSize(width
, height
),
234 GetDecorationsStyle());
235 wxTopLevelWindowNative::DoSetClientSize(size
.x
, size
.y
);
238 wxTopLevelWindowNative::DoSetClientSize(width
, height
);
241 void wxTopLevelWindow::OnNcPaint(wxPaintEvent
& event
)
243 if ( !ms_drawDecorations
|| !m_renderer
)
247 // get the window rect
249 wxSize size
= GetSize();
253 rect
.height
= size
.y
;
256 m_renderer
->DrawFrameTitleBar(dc
, rect
,
257 GetTitle(), m_titlebarIcon
,
258 GetDecorationsStyle(),
264 long wxTopLevelWindow::HitTest(const wxPoint
& pt
) const
267 wxTopLevelWindowNative::DoGetClientSize(&w
, &h
);
268 wxRect
rect(wxTopLevelWindowNative::GetClientAreaOrigin(), wxSize(w
, h
));
270 return m_renderer
->HitTestFrame(rect
, pt
+GetClientAreaOrigin(), GetDecorationsStyle());
273 int wxTopLevelWindow::GetMinWidth() const
275 if ( ms_drawDecorations
)
277 return wxMax(wxTopLevelWindowNative::GetMinWidth(),
278 m_renderer
->GetFrameMinSize(GetDecorationsStyle()).x
);
281 return wxTopLevelWindowNative::GetMinWidth();
284 int wxTopLevelWindow::GetMinHeight() const
286 if ( ms_drawDecorations
)
288 return wxMax(wxTopLevelWindowNative::GetMinHeight(),
289 m_renderer
->GetFrameMinSize(GetDecorationsStyle()).y
);
292 return wxTopLevelWindowNative::GetMinHeight();
295 // ----------------------------------------------------------------------------
297 // ----------------------------------------------------------------------------
299 void wxTopLevelWindow::SetIcon(const wxIcon
& icon
)
301 wxTopLevelWindowNative::SetIcon(icon
);
303 if ( ms_drawDecorations
&& m_renderer
)
305 wxSize size
= m_renderer
->GetFrameIconSize();
307 if ( !icon
.Ok() || size
.x
== -1 )
308 m_titlebarIcon
= icon
;
312 bmp1
.CopyFromIcon(icon
);
314 m_titlebarIcon
= wxNullIcon
;
315 else if ( bmp1
.GetWidth() == size
.x
&& bmp1
.GetHeight() == size
.y
)
316 m_titlebarIcon
= icon
;
319 wxImage img
= bmp1
.ConvertToImage();
320 img
.Rescale(size
.x
, size
.y
);
321 m_titlebarIcon
.CopyFromBitmap(wxBitmap(img
));
327 // ----------------------------------------------------------------------------
328 // interactive manipulation
329 // ----------------------------------------------------------------------------
331 #define wxINTERACTIVE_RESIZE_DIR \
332 (wxINTERACTIVE_RESIZE_W | wxINTERACTIVE_RESIZE_E | \
333 wxINTERACTIVE_RESIZE_S | wxINTERACTIVE_RESIZE_N)
335 struct wxInteractiveMoveData
337 wxTopLevelWindowBase
*m_window
;
338 wxEventLoop
*m_evtLoop
;
343 wxSize m_minSize
, m_maxSize
;
347 class wxInteractiveMoveHandler
: public wxEvtHandler
350 wxInteractiveMoveHandler(wxInteractiveMoveData
& data
) : m_data(data
) {}
353 DECLARE_EVENT_TABLE()
354 void OnMouseMove(wxMouseEvent
& event
);
355 void OnMouseDown(wxMouseEvent
& event
);
356 void OnMouseUp(wxMouseEvent
& event
);
357 void OnKeyDown(wxKeyEvent
& event
);
359 wxInteractiveMoveData
& m_data
;
362 BEGIN_EVENT_TABLE(wxInteractiveMoveHandler
, wxEvtHandler
)
363 EVT_MOTION(wxInteractiveMoveHandler::OnMouseMove
)
364 EVT_LEFT_DOWN(wxInteractiveMoveHandler::OnMouseDown
)
365 EVT_LEFT_UP(wxInteractiveMoveHandler::OnMouseUp
)
366 EVT_KEY_DOWN(wxInteractiveMoveHandler::OnKeyDown
)
370 static inline LINKAGEMODE
371 void wxApplyResize(wxInteractiveMoveData
& data
, const wxPoint
& diff
)
373 if ( data
.m_flags
& wxINTERACTIVE_RESIZE_W
)
375 data
.m_rect
.x
+= diff
.x
;
376 data
.m_rect
.width
-= diff
.x
;
378 else if ( data
.m_flags
& wxINTERACTIVE_RESIZE_E
)
380 data
.m_rect
.width
+= diff
.x
;
382 if ( data
.m_flags
& wxINTERACTIVE_RESIZE_N
)
384 data
.m_rect
.y
+= diff
.y
;
385 data
.m_rect
.height
-= diff
.y
;
387 else if ( data
.m_flags
& wxINTERACTIVE_RESIZE_S
)
389 data
.m_rect
.height
+= diff
.y
;
392 if ( data
.m_minSize
.x
!= -1 && data
.m_rect
.width
< data
.m_minSize
.x
)
394 if ( data
.m_flags
& wxINTERACTIVE_RESIZE_W
)
395 data
.m_rect
.x
-= data
.m_minSize
.x
- data
.m_rect
.width
;
396 data
.m_rect
.width
= data
.m_minSize
.x
;
398 if ( data
.m_maxSize
.x
!= -1 && data
.m_rect
.width
> data
.m_maxSize
.x
)
400 if ( data
.m_flags
& wxINTERACTIVE_RESIZE_W
)
401 data
.m_rect
.x
-= data
.m_minSize
.x
- data
.m_rect
.width
;
402 data
.m_rect
.width
= data
.m_maxSize
.x
;
404 if ( data
.m_minSize
.y
!= -1 && data
.m_rect
.height
< data
.m_minSize
.y
)
406 if ( data
.m_flags
& wxINTERACTIVE_RESIZE_N
)
407 data
.m_rect
.y
-= data
.m_minSize
.y
- data
.m_rect
.height
;
408 data
.m_rect
.height
= data
.m_minSize
.y
;
410 if ( data
.m_maxSize
.y
!= -1 && data
.m_rect
.height
> data
.m_maxSize
.y
)
412 if ( data
.m_flags
& wxINTERACTIVE_RESIZE_N
)
413 data
.m_rect
.y
-= data
.m_minSize
.y
- data
.m_rect
.height
;
414 data
.m_rect
.height
= data
.m_maxSize
.y
;
418 void wxInteractiveMoveHandler::OnMouseMove(wxMouseEvent
& event
)
420 if ( m_data
.m_flags
& wxINTERACTIVE_WAIT_FOR_INPUT
)
423 else if ( m_data
.m_flags
& wxINTERACTIVE_MOVE
)
425 wxPoint diff
= wxGetMousePosition() - m_data
.m_pos
;
426 m_data
.m_rect
= m_data
.m_rectOrig
;
427 m_data
.m_rect
.Offset(diff
);
428 m_data
.m_window
->Move(m_data
.m_rect
.GetPosition());
431 else if ( m_data
.m_flags
& wxINTERACTIVE_RESIZE
)
433 wxPoint diff
= wxGetMousePosition() - m_data
.m_pos
;
434 m_data
.m_rect
= m_data
.m_rectOrig
;
435 wxApplyResize(m_data
, diff
);
436 m_data
.m_window
->SetSize(m_data
.m_rect
);
440 void wxInteractiveMoveHandler::OnMouseDown(wxMouseEvent
& event
)
442 if ( m_data
.m_flags
& wxINTERACTIVE_WAIT_FOR_INPUT
)
444 m_data
.m_evtLoop
->Exit();
448 void wxInteractiveMoveHandler::OnKeyDown(wxKeyEvent
& event
)
452 switch ( event
.GetKeyCode() )
454 case WXK_UP
: diff
= wxPoint(0, -16); break;
455 case WXK_DOWN
: diff
= wxPoint(0, 16); break;
456 case WXK_LEFT
: diff
= wxPoint(-16, 0); break;
457 case WXK_RIGHT
: diff
= wxPoint(16, 0); break;
459 m_data
.m_window
->SetSize(m_data
.m_rectOrig
);
460 m_data
.m_evtLoop
->Exit();
463 m_data
.m_evtLoop
->Exit();
469 if ( m_data
.m_flags
& wxINTERACTIVE_WAIT_FOR_INPUT
)
471 m_data
.m_flags
&= ~wxINTERACTIVE_WAIT_FOR_INPUT
;
472 if ( m_data
.m_sizingCursor
)
475 m_data
.m_sizingCursor
= FALSE
;
478 if ( m_data
.m_flags
& wxINTERACTIVE_MOVE
)
480 m_data
.m_pos
= m_data
.m_window
->GetPosition() +
481 wxPoint(m_data
.m_window
->GetSize().x
/2, 8);
487 if ( m_data
.m_flags
& wxINTERACTIVE_MOVE
)
489 m_data
.m_rect
.Offset(diff
);
490 m_data
.m_window
->Move(m_data
.m_rect
.GetPosition());
491 warp
= wxPoint(m_data
.m_window
->GetSize().x
/2, 8);
493 else /* wxINTERACTIVE_RESIZE */
495 if ( !(m_data
.m_flags
&
496 (wxINTERACTIVE_RESIZE_N
| wxINTERACTIVE_RESIZE_S
)) )
500 m_data
.m_flags
|= wxINTERACTIVE_RESIZE_N
;
501 m_data
.m_pos
.y
= m_data
.m_window
->GetPosition().y
;
503 else if ( diff
.y
> 0 )
505 m_data
.m_flags
|= wxINTERACTIVE_RESIZE_S
;
506 m_data
.m_pos
.y
= m_data
.m_window
->GetPosition().y
+
507 m_data
.m_window
->GetSize().y
;
510 if ( !(m_data
.m_flags
&
511 (wxINTERACTIVE_RESIZE_W
| wxINTERACTIVE_RESIZE_E
)) )
515 m_data
.m_flags
|= wxINTERACTIVE_RESIZE_W
;
516 m_data
.m_pos
.x
= m_data
.m_window
->GetPosition().x
;
518 else if ( diff
.x
> 0 )
520 m_data
.m_flags
|= wxINTERACTIVE_RESIZE_E
;
521 m_data
.m_pos
.x
= m_data
.m_window
->GetPosition().x
+
522 m_data
.m_window
->GetSize().x
;
526 wxApplyResize(m_data
, diff
);
527 m_data
.m_window
->SetSize(m_data
.m_rect
);
529 if ( m_data
.m_flags
& wxINTERACTIVE_RESIZE_W
)
531 else if ( m_data
.m_flags
& wxINTERACTIVE_RESIZE_E
)
532 warp
.x
= m_data
.m_window
->GetSize().x
-1;
534 warp
.x
= wxGetMousePosition().x
- m_data
.m_window
->GetPosition().x
;
536 if ( m_data
.m_flags
& wxINTERACTIVE_RESIZE_N
)
538 else if ( m_data
.m_flags
& wxINTERACTIVE_RESIZE_S
)
539 warp
.y
= m_data
.m_window
->GetSize().y
-1;
541 warp
.y
= wxGetMousePosition().y
- m_data
.m_window
->GetPosition().y
;
544 warp
-= m_data
.m_window
->GetClientAreaOrigin();
545 m_data
.m_window
->WarpPointer(warp
.x
, warp
.y
);
549 void wxInteractiveMoveHandler::OnMouseUp(wxMouseEvent
& event
)
551 m_data
.m_evtLoop
->Exit();
555 void wxTopLevelWindow::InteractiveMove(int flags
)
557 wxASSERT_MSG( !((flags
& wxINTERACTIVE_MOVE
) && (flags
& wxINTERACTIVE_RESIZE
)),
558 wxT("can't move and resize window at the same time") );
560 wxASSERT_MSG( !(flags
& wxINTERACTIVE_RESIZE
) ||
561 (flags
& wxINTERACTIVE_WAIT_FOR_INPUT
) ||
562 (flags
& wxINTERACTIVE_RESIZE_DIR
),
563 wxT("direction of resizing not specified") );
565 wxInteractiveMoveData data
;
571 if ( flags
& wxINTERACTIVE_WAIT_FOR_INPUT
)
573 wxCursor
sizingCursor(wxCURSOR_SIZING
);
574 wxBeginBusyCursor(&sizingCursor
);
575 data
.m_sizingCursor
= TRUE
;
579 data
.m_sizingCursor
= FALSE
;
581 data
.m_window
= this;
582 data
.m_evtLoop
= &loop
;
583 data
.m_flags
= flags
;
584 data
.m_rect
= data
.m_rectOrig
= GetRect();
585 data
.m_pos
= wxGetMousePosition();
586 data
.m_minSize
= wxSize(GetMinWidth(), GetMinHeight());
587 data
.m_maxSize
= wxSize(GetMaxWidth(), GetMaxHeight());
589 wxEvtHandler
*handler
= new wxInteractiveMoveHandler(data
);
590 this->PushEventHandler(handler
);
596 this->RemoveEventHandler(handler
);
599 if ( data
.m_sizingCursor
)
603 // ----------------------------------------------------------------------------
605 // ----------------------------------------------------------------------------
607 void wxTopLevelWindow::ClickTitleBarButton(long button
)
611 case wxTOPLEVEL_BUTTON_CLOSE
:
615 case wxTOPLEVEL_BUTTON_ICONIZE
:
619 case wxTOPLEVEL_BUTTON_MAXIMIZE
:
623 case wxTOPLEVEL_BUTTON_RESTORE
:
627 case wxTOPLEVEL_BUTTON_HELP
:
630 wxContextHelp
contextHelp(this);
636 wxFAIL_MSG(wxT("incorrect button specification"));
640 bool wxTopLevelWindow::PerformAction(const wxControlAction
& action
,
642 const wxString
& strArg
)
644 bool isActive
= numArg
!= 0;
646 if ( action
== wxACTION_TOPLEVEL_ACTIVATE
)
648 if ( m_isActive
!= isActive
)
650 m_isActive
= isActive
;
656 else if ( action
== wxACTION_TOPLEVEL_BUTTON_PRESS
)
658 m_pressedButton
= numArg
;
663 else if ( action
== wxACTION_TOPLEVEL_BUTTON_RELEASE
)
670 else if ( action
== wxACTION_TOPLEVEL_BUTTON_CLICK
)
674 ClickTitleBarButton(numArg
);
678 else if ( action
== wxACTION_TOPLEVEL_MOVE
)
680 InteractiveMove(wxINTERACTIVE_MOVE
);
684 else if ( action
== wxACTION_TOPLEVEL_RESIZE
)
686 int flags
= wxINTERACTIVE_RESIZE
;
687 if ( numArg
& wxHT_TOPLEVEL_BORDER_N
)
688 flags
|= wxINTERACTIVE_RESIZE_N
;
689 if ( numArg
& wxHT_TOPLEVEL_BORDER_S
)
690 flags
|= wxINTERACTIVE_RESIZE_S
;
691 if ( numArg
& wxHT_TOPLEVEL_BORDER_W
)
692 flags
|= wxINTERACTIVE_RESIZE_W
;
693 if ( numArg
& wxHT_TOPLEVEL_BORDER_E
)
694 flags
|= wxINTERACTIVE_RESIZE_E
;
695 InteractiveMove(flags
);
703 void wxTopLevelWindow::OnSystemMenu(wxCommandEvent
& event
)
707 switch (event
.GetId())
709 case wxID_CLOSE_FRAME
:
710 ret
= PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
711 wxTOPLEVEL_BUTTON_CLOSE
);
713 case wxID_MOVE_FRAME
:
714 InteractiveMove(wxINTERACTIVE_MOVE
| wxINTERACTIVE_WAIT_FOR_INPUT
);
716 case wxID_RESIZE_FRAME
:
717 InteractiveMove(wxINTERACTIVE_RESIZE
| wxINTERACTIVE_WAIT_FOR_INPUT
);
719 case wxID_MAXIMIZE_FRAME
:
720 ret
= PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
721 wxTOPLEVEL_BUTTON_MAXIMIZE
);
723 case wxID_ICONIZE_FRAME
:
724 ret
= PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
725 wxTOPLEVEL_BUTTON_ICONIZE
);
727 case wxID_RESTORE_FRAME
:
728 ret
= PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
,
729 wxTOPLEVEL_BUTTON_RESTORE
);
741 // ============================================================================
742 // wxStdFrameInputHandler: handles focus, resizing and titlebar buttons clicks
743 // ============================================================================
745 wxStdFrameInputHandler::wxStdFrameInputHandler(wxInputHandler
*inphand
)
746 : wxStdInputHandler(inphand
)
751 m_borderCursorOn
= FALSE
;
754 bool wxStdFrameInputHandler::HandleMouse(wxInputConsumer
*consumer
,
755 const wxMouseEvent
& event
)
757 // the button has 2 states: pressed and normal with the following
758 // transitions between them:
760 // normal -> left down -> capture mouse and go to pressed state
761 // pressed -> left up inside -> generate click -> go to normal
762 // outside ------------------>
764 // the other mouse buttons are ignored
765 if ( event
.Button(1) )
767 if ( event
.ButtonDown(1) )
769 wxTopLevelWindow
*w
= wxStaticCast(consumer
->GetInputWindow(), wxTopLevelWindow
);
770 long hit
= w
->HitTest(event
.GetPosition());
772 if ( hit
& wxHT_TOPLEVEL_ANY_BUTTON
)
775 m_winCapture
->CaptureMouse();
778 consumer
->PerformAction(wxACTION_TOPLEVEL_BUTTON_PRESS
, m_winPressed
);
781 else if ( (hit
& wxHT_TOPLEVEL_TITLEBAR
) && !w
->IsMaximized() )
783 consumer
->PerformAction(wxACTION_TOPLEVEL_MOVE
);
786 else if ( (consumer
->GetInputWindow()->GetWindowStyle() & wxRESIZE_BORDER
)
787 && (hit
& wxHT_TOPLEVEL_ANY_BORDER
) )
789 consumer
->PerformAction(wxACTION_TOPLEVEL_RESIZE
, hit
);
798 m_winCapture
->ReleaseMouse();
801 if ( m_winHitTest
== m_winPressed
)
803 consumer
->PerformAction(wxACTION_TOPLEVEL_BUTTON_CLICK
, m_winPressed
);
807 //else: the mouse was released outside the window, this doesn't
812 return wxStdInputHandler::HandleMouse(consumer
, event
);
815 bool wxStdFrameInputHandler::HandleMouseMove(wxInputConsumer
*consumer
,
816 const wxMouseEvent
& event
)
818 if ( event
.GetEventObject() == m_winCapture
)
820 long hit
= m_winCapture
->HitTest(event
.GetPosition());
822 if ( hit
!= m_winHitTest
)
824 if ( hit
!= m_winPressed
)
825 consumer
->PerformAction(wxACTION_TOPLEVEL_BUTTON_RELEASE
, m_winPressed
);
827 consumer
->PerformAction(wxACTION_TOPLEVEL_BUTTON_PRESS
, m_winPressed
);
833 else if ( consumer
->GetInputWindow()->GetWindowStyle() & wxRESIZE_BORDER
)
835 wxTopLevelWindow
*win
= wxStaticCast(consumer
->GetInputWindow(),
837 long hit
= win
->HitTest(event
.GetPosition());
839 if ( hit
!= m_winHitTest
)
843 if ( m_borderCursorOn
)
845 m_borderCursorOn
= FALSE
;
846 win
->SetCursor(m_origCursor
);
849 if ( hit
& wxHT_TOPLEVEL_ANY_BORDER
)
851 m_borderCursorOn
= TRUE
;
856 case wxHT_TOPLEVEL_BORDER_N
:
857 case wxHT_TOPLEVEL_BORDER_S
:
858 cur
= wxCursor(wxCURSOR_SIZENS
);
860 case wxHT_TOPLEVEL_BORDER_W
:
861 case wxHT_TOPLEVEL_BORDER_E
:
862 cur
= wxCursor(wxCURSOR_SIZEWE
);
864 case wxHT_TOPLEVEL_BORDER_NE
:
865 case wxHT_TOPLEVEL_BORDER_SW
:
866 cur
= wxCursor(wxCURSOR_SIZENESW
);
868 case wxHT_TOPLEVEL_BORDER_NW
:
869 case wxHT_TOPLEVEL_BORDER_SE
:
870 cur
= wxCursor(wxCURSOR_SIZENWSE
);
873 m_borderCursorOn
= FALSE
;
876 if ( m_borderCursorOn
)
878 m_origCursor
= win
->GetCursor();
885 return wxStdInputHandler::HandleMouseMove(consumer
, event
);
888 bool wxStdFrameInputHandler::HandleActivation(wxInputConsumer
*consumer
,
891 if ( m_borderCursorOn
)
893 consumer
->GetInputWindow()->SetCursor(m_origCursor
);
894 m_borderCursorOn
= FALSE
;
896 consumer
->PerformAction(wxACTION_TOPLEVEL_ACTIVATE
, activated
);