NCBI C++ ToolKit
dock_frames.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: dock_frames.cpp 43821 2019-09-05 19:43:37Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  *
28  * File Description:
29  *
30  */
31 #include <ncbi_pch.hpp>
32 
33 
35 
40 
42 
43 #include <wx/dcclient.h>
44 #include <wx/settings.h>
45 
46 #if defined(__WXOSX_CARBON__) || defined(__WXMAC_CARBON__)
47 #include <Carbon/Carbon.h>
48 #endif
49 
50 
52 
53 
57 
58 static long kMarkersStyle = wxSTAY_ON_TOP | wxFRAME_TOOL_WINDOW |
59  wxFRAME_NO_TASKBAR | wxBORDER_NONE | wxFRAME_SHAPED;
60 
61 CDockMarkerWindow::CDockMarkerWindow(CDockContainer& dock_cont, wxWindow* parent)
62 : m_DockContainer(dock_cont),
63  m_BtnFrameColor(128, 128, 128),
64  m_BtnFillColor(224, 224, 224),
65  m_SetShape(true)
66 {
67  Create(parent, wxID_ANY, wxT("Dock Markers Window"),
68  wxPoint(6, 6), wxSize(666, 666), kMarkersStyle);
69 
70  // debugging code for GTK
71  //g_signal_connect (m_widget, "size_allocate", G_CALLBACK (gtk_frame_size_callback), this);
72 
73  SetBackgroundStyle(wxBG_STYLE_CUSTOM);
74  Enable(false);
75 
76  x_InitBitmaps();
77 }
78 
80 {
81  // prevent main window activation
82  SetWindowStyleFlag(GetWindowStyleFlag()&~wxFRAME_FLOAT_ON_PARENT);
83 }
84 
86 {
87  static bool initialized = false;
88 
90 
91  if( ! initialized) {
92  // Register images only once
93  provider->RegisterFileAlias(wxT("wm_dock_center"), wxT("wm_dock_center.png"));
94  provider->RegisterFileAlias(wxT("wm_dock_left"), wxT("wm_dock_left.png"));
95  provider->RegisterFileAlias(wxT("wm_dock_right"), wxT("wm_dock_right.png"));
96  provider->RegisterFileAlias(wxT("wm_dock_top"), wxT("wm_dock_top.png"));
97  provider->RegisterFileAlias(wxT("wm_dock_bottom"), wxT("wm_dock_bottom.png"));
98 
99  initialized = true;
100  }
101 
102  m_Bitmaps[0] = provider->GetBitmap(wxT("wm_dock_center"));
103  m_Bitmaps[1] = provider->GetBitmap(wxT("wm_dock_left"));
104  m_Bitmaps[2] = provider->GetBitmap(wxT("wm_dock_right"));
105  m_Bitmaps[3] = provider->GetBitmap(wxT("wm_dock_top"));
106  m_Bitmaps[4] = provider->GetBitmap(wxT("wm_dock_bottom"));
107 }
108 
109 
110 static int kBtnLength = 32;
111 static int kBtnWidth = 29;
112 static int kCenterSize = 88;
113 static int kCenterBtnSize = 25;
114 static int kCenterOffset = 4;
115 static int kBtnSpace = 10;
116 
118 {
119  if (!m_SetShape)
120  return;
121 
122  // make a cross-like region from the central pane
123 
124  // horizontal strip
125  wxRect rc(m_CenterRect);
126  int c_y = rc.y + rc.height / 2;
127  rc.y = c_y - kBtnWidth / 2;
128  rc.height = kBtnWidth - 1;
129 
130  // create a region that combines all rectangles
131  wxRegion rgn(rc);
132 
133  // vertical strip
134  rc = m_CenterRect;
135  int c_x = rc.x + rc.width / 2;
136  rc.x = c_x - kBtnWidth / 2;
137  rc.width = kBtnWidth - 1;
138  rgn.Union(rc);
139 
140  // add regions for the side markers
141  rgn.Union(m_LeftRect);
142  rgn.Union(m_RightRect);
143  rgn.Union(m_TopRect);
144  rgn.Union(m_BottomRect);
145 
146  rgn.Offset(-m_RootRect.GetPosition());
147 
148  m_ClipRegion = rgn;
149 
150  m_SetShape = false;
151 
152  SetShape(rgn);
153 }
154 
155 void CDockMarkerWindow::SetTargetRect(const wxRect& root_rc, const wxRect& target_rc)
156 {
157  if(m_RootRect != root_rc) {
158  wxSize size = ClientToWindowSize(root_rc.GetSize());
159  SetSize(wxRect(root_rc.GetPosition(), size));
160  }
161 
162  bool update = x_UpdateLayout(root_rc, target_rc);
163  if(update) {
164  m_SetShape = true;
165 
166  /// Cocoa doesn't refresh properly (visual artifacts) if we do not
167  // hide before (re)setting the shape.
168 #ifdef __WXOSX_COCOA__
169  Hide();
170 #endif
171 
172  if( ! IsShown()) {
173  // Mac (cocoa) is unhappy (at least in debug mode) if Show() is called before SetShape.
174 #ifdef __WXOSX_COCOA__
175  x_SetShape();
176  m_SetShape = true;
177 #endif
178  Show();
179  }
180  Refresh();
181  }
182  //WM_POST("CDockMarkerWindow::SetTargetRect m_CenterRect " << sToString(m_CenterRect));
183 }
184 
185 
186 bool CDockMarkerWindow::x_UpdateLayout(const wxRect& root_rc, const wxRect& target_rc)
187 {
188  //wxRect rc = GetRect();
189  //WM_POST(" CDockMarkerWindow::x_UpdateLayout() GetRect() " << sToString(rc));
190 
191  static const wxSize sz_btn_h(kBtnLength, kBtnWidth);
192  static const wxSize sz_btn_v(kBtnWidth, kBtnLength);
193 
194  bool root_changed = (m_RootRect != root_rc);
195 
196  if(root_changed) {
197  m_RootRect = root_rc;
198 
199  // update side buttons
200  int kRootMinSize = kBtnLength * 2 + kBtnWidth * 4;
201 
202  // layout side buttons
203  bool side_visible = (root_rc.height >= kRootMinSize && root_rc.width >= kRootMinSize);
204  if(side_visible) {
205  int c_x = root_rc.x + root_rc.width / 2;
206  int c_y = root_rc.y + root_rc.height / 2;
207 
208  m_LeftRect.x = root_rc.GetLeft() + kBtnSpace;
209  m_LeftRect.y = c_y - kBtnWidth / 2;
210  m_LeftRect.SetSize(sz_btn_h);
211 
213  m_RightRect.x = root_rc.GetRight() - kBtnSpace - kBtnLength;
214 
215  m_TopRect.x = c_x - kBtnWidth / 2;
216  m_TopRect.y = root_rc.GetTop() + kBtnSpace;
217  m_TopRect.SetSize(sz_btn_v);
218 
220  m_BottomRect.y = root_rc.GetBottom() - kBtnSpace - kBtnLength;
221  } else {
222  m_LeftRect = m_RightRect = m_TopRect = m_BottomRect = m_CenterRect = wxRect(0, 0, -1, -1);
223  }
224  }
225 
226  bool center_visible = (target_rc.width >= kCenterSize && target_rc.height >= kCenterSize);
227 
228  bool target_changed = (m_TargetRect != target_rc);
229  if(target_changed) {
230  m_TargetRect = target_rc;
231  // update central pane
232  if(center_visible) {
233  // central pane is visible
234  m_CenterRect.SetSize(wxSize(kCenterSize, kCenterSize));
235  m_CenterRect = m_CenterRect.CenterIn(target_rc);
236  } else {
237  m_CenterRect = wxRect(0, 0, -1, -1);
238  }
239  }
240 
241  if(root_changed || target_changed) {
242  // resolve possible clashes between side buttons and central pane
243  // hide clashing side buttons
244  wxSize sz_empty(-1, -1);
245 
246  // hide some of the buttons if there is not enough space
247  m_LeftRect.SetSize(m_CenterRect.Intersects(m_LeftRect) ? sz_empty : sz_btn_h);
248  m_RightRect.SetSize(m_CenterRect.Intersects(m_RightRect) ? sz_empty : sz_btn_h);
249  m_TopRect.SetSize(m_CenterRect.Intersects(m_TopRect) ? sz_empty : sz_btn_v);
250  m_BottomRect.SetSize(m_CenterRect.Intersects(m_BottomRect) ? sz_empty : sz_btn_v);
251 
252  // layout areas inside the central pane
253  if(center_visible) {
256 
257  // find the center of m_CenterRect
258  int c_x = m_CenterRect.x + m_CenterRect.width / 2;
259  int c_y = m_CenterRect.y + m_CenterRect.height / 2;
260 
262  m_CenterLeftRect.y = c_y - kBtnWidth / 2;
263  m_CenterLeftRect.SetSize(sz_btn_h);
264 
267  m_CenterRightRect.SetSize(sz_btn_h);
268 
269  m_CenterTopRect.x = c_x - kBtnWidth / 2;
271  m_CenterTopRect.SetSize(sz_btn_v);
272 
275  m_CenterBottomRect.SetSize(sz_btn_v);
276  }
277  }
278  return root_changed || target_changed;
279 }
280 
281 
282 void CDockMarkerWindow::OnPaint(wxPaintEvent& event)
283 {
284  wxPaintDC dc(this);
285 
286  // set origin so that we can draw in screen coordinates
287  wxPoint orig = ClientToScreen(wxPoint(0,0));
288 
289  if (orig != m_RootRect.GetPosition()) {
290  Move(GetPosition() + m_RootRect.GetPosition() - orig);
291  }
292 
293  x_SetShape();
294 
295 #ifdef __WXOSX_COCOA__
296  // On cocoa the central four-arrow drop hint may have the four non-button corners show up black if
297  // the clip region is not used to restrict the drawing. This has not happened consistently
298  // however, and seems to be similar to a wxWidgets defect that was fixed for 2.9.3, #13340
299 
300  // This has now been fixed in 2.9.3 (and leaving this in now causes corners to be clipped)
301  //dc.SetDeviceClippingRegion(m_ClipRegion);
302 #endif
303 
304  dc.SetDeviceOrigin(-m_RootRect.GetPosition().x, -m_RootRect.GetPosition().y);
305 
306  if( ! m_CenterRect.IsEmpty()) {
307  x_DrawButton(dc, m_CenterRect, 0);
308  }
309 
310  x_DrawButton(dc, m_LeftRect, 1);
311  x_DrawButton(dc, m_RightRect, 2);
312  x_DrawButton(dc, m_TopRect, 3);
313  x_DrawButton(dc, m_BottomRect, 4);
314 }
315 
316 void CDockMarkerWindow::x_DrawButton(wxDC& dc, const wxRect& btn_rc, int bmp_index)
317 {
318  if( ! btn_rc.IsEmpty()) {
319  wxBitmap& bmp = m_Bitmaps[bmp_index];
320  if(bmp.IsOk()) {
321  dc.DrawBitmap(bmp, btn_rc.x, btn_rc.y);
322  } else {
323  // error - no bitmap, draw a simple rectangle
324  wxPen pen(m_BtnFrameColor);
325  dc.SetPen(pen);
326 
327  wxBrush brush(m_BtnFillColor);
328  dc.SetBrush(brush);
329 
330  dc.DrawRectangle(btn_rc);
331  }
332  }
333 }
334 
335 
336 EDockEffect CDockMarkerWindow::HitTest(const wxPoint& screen_pt)
337 {
338  if(m_LeftRect.Contains(screen_pt)) {
339  return eSplitLeft;
340  }
341  if(m_RightRect.Contains(screen_pt)) {
342  return eSplitRight;
343  }
344  if(m_TopRect.Contains(screen_pt)) {
345  return eSplitTop;
346  }
347  if(m_BottomRect.Contains(screen_pt)) {
348  return eSplitBottom;
349  }
350 
351  if(m_CenterRect.Contains(screen_pt)) {
352  if(m_CenterLeftRect.Contains(screen_pt)) {
353  return eSplitTargetLeft;
354  }
355  if(m_CenterRightRect.Contains(screen_pt)) {
356  return eSplitTargetRight;
357  }
358  if(m_CenterTopRect.Contains(screen_pt)) {
359  return eSplitTargetTop;
360  }
361  if(m_CenterBottomRect.Contains(screen_pt)) {
362  return eSplitTargetBottom;
363  }
364  if(m_CenterTabRect.Contains(screen_pt)) {
365  return ePutInTab;
366  }
367  }
368  return eNoEffect;
369 }
370 
371 
372 
373 ///////////////////////////////////////////////////////////////////////////////
374 /// CFloatingFrame
375 
376 BEGIN_EVENT_TABLE(CFloatingFrame, CFloatingFrameBaseClass)
377  EVT_SIZE(CFloatingFrame::OnSize)
380  EVT_CLOSE(CFloatingFrame::OnClose)
381  EVT_IDLE(CFloatingFrame::OnIdle)
382  EVT_ACTIVATE(CFloatingFrame::OnActivate)
383  EVT_MOTION(CFloatingFrame::OnMotion)
384  EVT_KEY_DOWN(CFloatingFrame::OnKeyDown)
385  EVT_KEY_UP(CFloatingFrame::OnKeyUp)
387 
388 
390 
391 const static long kFloatFrameStyle =
392 #if defined(__WXMSW__)
393  wxRESIZE_BORDER | wxCAPTION | wxCLOSE_BOX |
394  wxFRAME_FLOAT_ON_PARENT | wxCLIP_CHILDREN ;
395 #elif defined(__WXOSX_COCOA__)
396  wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX |
397  wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT ;
398 #else
399  wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX |
400  wxFRAME_NO_TASKBAR;
401 #endif
402 
404  wxWindow* parent,
405  const wxPoint& pos,
406  const wxSize& size)
408  m_DockManager(&manager),
409  m_DockContainer(NULL)
410 {
411  // window shall not be created by base class, we must create here so that
412  // our version of MSWGetStyle() is called and we het a chance to modify
413  // the styles
414  Create(parent, wxID_ANY, wxEmptyString, pos, size, kFloatFrameStyle);
415 
416  m_moving = false;
417  m_solid_drag = true;
418 #ifdef __WXOSX_COCOA__
419  m_titlebar_move = false;
420 #endif
421 
422  // find out if the system supports solid window drag.
423  // on non-msw systems, this is assumed to be the case
424 #ifdef __WXMSW__
425  BOOL b = TRUE;
426  SystemParametersInfo(38 /*SPI_GETDRAGFULLWINDOWS*/, 0, &b, 0);
427  m_solid_drag = b ? true : false;
428 #endif
429 
430 #if defined(__WXOSX_CARBON__) || defined(__WXMAC_CARBON__)
431  // On mac, floating windows that display sticky tool tips have to have
432  // their window class set to kFloatingWindowClass (with some additional
433  // parent/child hierarchy stuff). So we have to do it for all floating
434  // otherwise windows with tip support will always be on top of windows
435  // without (on mac)
436  WindowGroupRef group_class = GetWindowGroupOfClass(kFloatingWindowClass);
437  SetWindowGroup((WindowRef)MacGetTopLevelWindowRef(), group_class);
438 #endif
439 
440  SetExtraStyle(wxWS_EX_PROCESS_IDLE);
441 
443 
444  cmd_reg.ApplyAccelerators( this );
445 }
446 
447 
449 {
450 }
451 
452 
454 {
455  m_DockContainer = dock_cont;
456 }
457 
458 
460 {
461  return m_DockContainer;
462 }
463 
465 {
468 
469  return CFloatingFrameBaseClass::Destroy();
470 }
471 
472 
473 #ifdef NCBI_OS_MSWIN
474 // we override these functions to modify windows styles before the window is
475 // created (WS_POPUP cannot be easily set after a window has been created).
476 WXDWORD CFloatingFrame::MSWGetStyle(long flags, WXDWORD *exstyle ) const
477 {
478  WXDWORD ms_styles = CFloatingFrameBaseClass::MSWGetStyle(flags, exstyle);
479  //ms_styles |= WS_POPUP;
480  //if(exstyle) {
481  //*exstyle |= WS_EX_OVERLAPPEDWINDOW;
482  //}
483  return ms_styles;
484 }
485 #endif
486 
487 
488 void CFloatingFrame::OnClose(wxCloseEvent& evt)
489 {
490  if(m_DockManager) {
492  }
493 }
494 
495 void CFloatingFrame::OnMovingEvent(wxMoveEvent& event)
496 {
497  //WM_POST("CFloatingFrame::OnMovingEvent()");
498 
499 // Cocoa doesn't send window-move events (EVT_MOVE/EVT_MOVING) when the user moves a window
500 // using the title bar. Since the window manager does the move, it doesn't require the
501 // app to be 'active' so you never have frozen windows. At the end of the move (when the
502 // mouse stops moving) we get an EVT_MOVE event. To get around this for drag and drop (where
503 // we need interactive updates), we must patch wxWidgets so that we also get a start-moving
504 // event as an initial EVT_MOVE. After that we can just look at the mouse position updates
505 // to get the windows position. The neecessary patch is:
506 /*
507 Index: osx/cocoa/nonownedwnd.mm
508 ===================================================================
509 --- osx/cocoa/nonownedwnd.mm (revision 69613)
510 +++ osx/cocoa/nonownedwnd.mm (working copy)
511 @@ -260,6 +260,7 @@
512  - (void)windowDidResignKey:(NSNotification *)notification;
513  - (void)windowDidBecomeKey:(NSNotification *)notification;
514  - (void)windowDidMove:(NSNotification *)notification;
515 +- (void)windowWillMove:(NSNotification *)notification;
516  - (BOOL)windowShouldClose:(id)window;
517  - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
518 
519 @@ -407,6 +408,19 @@
520  }
521  }
522 
523 +- (void)windowWillMove:(NSNotification *)notification
524 +{
525 + wxNSWindow* window = (wxNSWindow*) [notification object];
526 + wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
527 + if ( windowimpl )
528 + {
529 + wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
530 + if ( wxpeer )
531 + // Use a negative time to indicate this is the first move
532 + wxpeer->HandleMoved(-1.0);
533 + }
534 +}
535 +
536 */
537 
538 
539 #ifdef __WXOSX_COCOA__
540  if (event.GetTimestamp() < 0) {
541  m_move_start_mouse_pos = ::wxGetMousePosition();
542  m_titlebar_move = true;
543  }
544 #endif
545 
546  // Let child windows know parent has moved (for sticky tooltips)
548 
549  if( ! m_moving) { // this is the first move
550  //m_OrigMouseShift = ::wxGetMousePosition() - GetPosition();
551 
552  // Don't ask why, this is empirical knowledge.
553  m_OrigMouseShift = ::wxGetMousePosition() - event.GetPosition();
554 
555  //_TRACE( "OrigMouseShift: ( " << m_OrigMouseShift.x << ", " << m_OrigMouseShift.y << " )" );
556 
557  //LOG_POST( Info << "Orig Pos: ( " << GetPosition().x << ", " << GetPosition().y << " )" );
558  //LOG_POST( Info << "Orig Event pos: ( " << event.GetPosition().x << ", " << event.GetPosition().y << " )" );
559  } else {
560  //LOG_POST( Info << "----- Pos: ( " << GetPosition().x << ", " << GetPosition().y << " )" );
561  //LOG_POST( Info << "Event pos: ( " << event.GetPosition().x << ", " << event.GetPosition().y << " )" );
562  }
563 
564 
565  if ( ! m_solid_drag)
566  {
567  // systems without solid window dragging need to be
568  // handled slightly differently, due to the lack of
569  // the constant stream of EVT_MOVING events
570  if ( ! isMouseDown()) {
571  //WM_POST("CFloatingFrame::OnMovingEvent() - ! isMouseDown()");
572  return;
573  }
574  OnMoveStart();
575  OnMoving();
576  m_moving = true;
577  return;
578  }
579 
580  wxRect win_rect = GetRect();
581 
582 // Since cocoa doesn't update the windows rectangle (position) while moving via a tile-bar grab,
583 // we modify the position by adding mouse offset from the windows position at the beginning
584 // of the move
585 #ifdef __WXOSX_COCOA__
586  wxPoint pos = ::wxGetMousePosition();
587  wxPoint delta = pos - m_move_start_mouse_pos;
588  win_rect.Offset(delta);
589 #endif
590 
591  if (win_rect == m_last_rect) {
592  //WM_POST("CFloatingFrame::OnMovingEvent() - win_rect == m_last_rect");
593  return;
594  }
595 
596  // skip the first move event
597  if (m_last_rect.IsEmpty()) {
598  m_last_rect = win_rect;
599  //WM_POST("CFloatingFrame::OnMovingEvent() - skip the first move event");
600  return;
601  }
602 
603  // skip if moving too fast to avoid massive redraws and jumping hint windows
604  // but not for cocoa since it sometimes has jumps due to too few events
605 #ifndef __WXOSX_COCOA__
606  constexpr int kMaxMoveDelta = 30;
607 
608  if ((abs(win_rect.x - m_last_rect.x) > kMaxMoveDelta) ||
609  (abs(win_rect.y - m_last_rect.y) > kMaxMoveDelta))
610  {
613  m_last_rect = win_rect;
614  //WM_POST("CFloatingFrame::OnMovingEvent() - skip if moving too fast ");
615  return;
616  }
617 #endif
618 
619  // prevent frame redocking during resize
620  if (m_last_rect.GetSize() != win_rect.GetSize())
621  {
624  m_last_rect = win_rect;
625  //WM_POST("CFloatingFrame::OnMovingEvent() - prevent frame redocking during resize");
626  return;
627  }
628 
631  m_last_rect = win_rect;
632 
633  if ( ! isMouseDown()) {
634  //WM_POST("CFloatingFrame::OnMovingEvent() - ! isMouseDown()");
635  return;
636  }
637 
638  if ( ! m_moving) {
639  OnMoveStart();
640  m_moving = true;
641  }
642 
643  if (m_last3_rect.IsEmpty()) {
644  //WM_POST("CFloatingFrame::OnMovingEvent() - m_last3_rect.IsEmpty()");
645  return;
646  }
647 
648  OnMoving();
649 }
650 
651 
652 void CFloatingFrame::OnIdle(wxIdleEvent& event)
653 {
654  if (m_moving) {
655 
656  // Simulate window moving for Cocoa which (when using the title bar) does not normally send
657  // moving events
658 #ifdef __WXOSX_COCOA__
659  if (m_titlebar_move == true) {
660  wxPoint pos = ::wxGetMousePosition();
661  if (pos != m_prev_mouse_pos) {
662  m_prev_mouse_pos = pos;
663  wxMoveEvent dummy(pos, wxEVT_MOVING);
665  }
666  }
667 #endif
668  if ( ! isMouseDown()) {
669  m_moving = false;
670 #ifdef __WXOSX_COCOA__
671  m_titlebar_move = false;
672 #endif
673 
674  // if Esc has been pressed the offset most like is not the same,
675  // this is an workaround for wxWidgets feature request #1755061
676  wxPoint offset = ::wxGetMousePosition() - GetPosition();
677 
678  //_TRACE( Info << "Offset: ( " << offset.x << ", " << offset.y << " )" );
679 
680  int delta_x = (m_OrigMouseShift.x - offset.x);
681  int delta_y = (m_OrigMouseShift.y - offset.y);
682  int max_x = wxSystemSettings::GetMetric(wxSYS_DRAG_X) / 2;
683  int max_y = wxSystemSettings::GetMetric(wxSYS_DRAG_Y) / 2;
684  bool drop = abs(delta_x) <= max_x && abs(delta_y) <= max_y;
685 
686  OnMoveFinished(drop);
687  } else {
688  event.RequestMore();
689  }
690  }
691 }
692 
693 
695 {
696  //WM_POST("CFloatingFrame::OnMoveStart()");
697  if(m_DockManager) {
698  m_DockManager->OnFloatingPaneBeginMove(*this, wxGetMousePosition());
699  }
700 }
701 
702 
704 {
705  //WM_POST("CFloatingFrame::OnMoving()");
706  if(m_DockManager) {
707  m_DockManager->OnFloatingPaneMoving(*this, wxGetMousePosition());
708  }
709 }
710 
711 
713 {
714  //WM_POST("CFloatingFrame::OnMoveFinished() drop " << drop);
715  if(m_DockManager) {
716  wxPoint sc_mouse_pos = ::wxGetMousePosition();
719  m_DockManager->OnFloatingPaneEndMove(*this, result, sc_mouse_pos);
720  }
721 }
722 
723 void CFloatingFrame::OnActivate(wxActivateEvent& event)
724 {
725  bool active = event.GetActive();
726  //WM_POST("CFloatingFrame::OnActivate() " << this << " active " << active);
727 
728  // This messes up GTK which interleaves the activate message with the tool tip creation,
729  // which causes the unpinned tip to be deleted. Could make this GTK only, or fix the
730  // problem with special processing... (and windows...)
731 #if !defined(NCBI_OS_LINUX) && !defined(NCBI_OS_MSWIN)
732  //_TRACE("Suspend/ReCreate all via Activate.");
733  //BroadcastCommandToChildWindows(this, eCmdParentActivate);
734 #endif
735 
736  if(m_DockManager) {
738  }
739  event.Skip();
740 }
741 
742 
743 void CFloatingFrame::OnMotion(wxMouseEvent& evt)
744 {
745  //wxPoint pt = evt.GetPosition();
746 }
747 
748 
749 void CFloatingFrame::OnKeyDown(wxKeyEvent& event)
750 {
752 }
753 
754 
755 void CFloatingFrame::OnKeyUp(wxKeyEvent& event)
756 {
758 }
759 
760 
761 // utility function which determines the state of the mouse button
762 // (independent of having a wxMouseEvent handy) - ultimately a better
763 // mechanism for this should be found (possibly by adding the
764 // functionality to wxWidgets itself)
766 {
767  return wxGetMouseState().LeftIsDown();
768 }
769 
770 
#define static
unsigned dummy
Definition: block_cipher.h:0
CDockContainer is a window that hosts docked windows.
CDockManager & GetDockManager()
CDockManager CDockManager sends requests to Window Manager, Window Manager makes decisions about dele...
void OnFloatingPaneBeginMove(CFloatingFrame &frame, const wxPoint &sc_mouse_pos)
void OnKeyDown(wxKeyEvent &event)
void OnKeyUp(wxKeyEvent &event)
void OnFloatingFrameActivateEvent(CFloatingFrame *frame, bool active)
void OnFrameClosePressed(CFloatingFrame *frame)
void OnFloatingPaneEndMove(CFloatingFrame &frame, CDockManager::EDragResult result, const wxPoint &sc_mouse_pos)
void OnFloatingPaneMoving(CFloatingFrame &frame, const wxPoint &sc_mouse_pos)
CDockMarkerWindow - top level window with docking markers displayed on top of the application window.
Definition: dock_frames.hpp:62
wxColour m_BtnFillColor
Definition: dock_frames.hpp:88
wxRegion m_ClipRegion
Definition: dock_frames.hpp:90
void OnPaint(wxPaintEvent &event)
bool x_UpdateLayout(const wxRect &root_rc, const wxRect &target_rc)
virtual EDockEffect HitTest(const wxPoint &screen_pt)
determines whether a given position is inside one of the 9 markers and returns the corresponding dock...
wxBitmap m_Bitmaps[5]
Definition: dock_frames.hpp:86
void x_DrawButton(wxDC &dc, const wxRect &btn_rc, int index)
wxTopLevelWindow TParent
Definition: dock_frames.hpp:63
void SetTargetRect(const wxRect &root_rc, const wxRect &target_rc)
wxColour m_BtnFrameColor
Definition: dock_frames.hpp:87
virtual bool Destroy()
CDockManager * m_DockManager
virtual ~CFloatingFrame()
virtual CDockContainer * GetDockContainer()
void OnKeyUp(wxKeyEvent &event)
wxPoint m_OrigMouseShift
virtual void SetDockContainer(CDockContainer *dock_cont)
void OnMotion(wxMouseEvent &evt)
void OnIdle(wxIdleEvent &event)
virtual void OnMoveFinished(bool drop)
static bool isMouseDown()
virtual void OnMoving()
void OnKeyDown(wxKeyEvent &event)
virtual void OnMoveStart()
void OnActivate(wxActivateEvent &event)
void OnClose(wxCloseEvent &event)
CDockContainer * m_DockContainer
void OnMovingEvent(wxMoveEvent &event)
CFloatingFrame(CDockManager &manager, wxWindow *parent, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
static CUICommandRegistry & GetInstance()
the main instance associated with the application
Definition: ui_command.cpp:176
void ApplyAccelerators(wxWindow *frame)
apply accumulated accelerators to the specifed frame
Definition: ui_command.cpp:281
virtual void RegisterFileAlias(const wxArtID &anId, const wxArtClient &aClient, const wxSize &aSize, const wxString &aName, long aType=wxBITMAP_TYPE_ANY, int anIndex=-1)
static uch flags
static int kBtnSpace
IMPLEMENT_CLASS(CFloatingFrame, CFloatingFrameBaseClass) const static long kFloatFrameStyle
CFloatingFrame.
static int kBtnLength
static long kMarkersStyle
Definition: dock_frames.cpp:58
static int kCenterSize
static int kCenterOffset
static int kCenterBtnSize
static int kBtnWidth
#define CFloatingFrameBaseClass
CFloatingFrame - a top level floating frame that can host a Dock Container.
EDockEffect
EDockEffect.
Definition: dock_window.hpp:65
@ eSplitBottom
Definition: dock_window.hpp:70
@ eSplitTargetLeft
Definition: dock_window.hpp:71
@ ePutInTab
Definition: dock_window.hpp:75
@ eSplitLeft
Definition: dock_window.hpp:67
@ eSplitTargetBottom
Definition: dock_window.hpp:74
@ eNoEffect
Definition: dock_window.hpp:66
@ eSplitTargetRight
Definition: dock_window.hpp:72
@ eSplitTargetTop
Definition: dock_window.hpp:73
@ eSplitTop
Definition: dock_window.hpp:69
@ eSplitRight
Definition: dock_window.hpp:68
thread_local unique_ptr< FtaMsgPost > bmp
Definition: ftaerr.cpp:120
#define true
Definition: bool.h:35
int offset
Definition: replacements.h:160
int BOOL
Definition: sybdb.h:150
#define NULL
Definition: ncbistd.hpp:225
@ eCmdParentMove
Definition: command.hpp:117
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define wxCLOSE_BOX
Definition: gui.hpp:50
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
END_EVENT_TABLE()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
#define abs(a)
Definition: ncbi_heapmgr.c:130
#define TRUE
bool replacment for C indicating true.
Definition: ncbi_std.h:97
Int4 delta(size_t dimension_, const Int4 *score_)
static static static wxID_ANY
else result
Definition: token2.c:20
wxFileArtProvider * GetDefaultFileArtProvider()
Definition: wx_utils.cpp:334
void BroadcastCommandToChildWindows(wxWindow *window, int cmd_id, int cmd_data=0)
Sends command event with id 'cmd_id' to window and all its children.
Definition: wx_utils.cpp:1145
#define const
Definition: zconf.h:232
Modified on Fri May 24 14:53:01 2024 by modify_doxy.py rev. 669887