51 #include <wx/settings.h>
56 #import <AppKit/NSWindow.h>
82 : m_ParentWindow(parent),
83 m_WindowManager(manager),
88 m_ActiveDragContainer(
NULL),
103 for(
size_t i = 0;
i < conts.size();
i++ ) {
175 if(
tree.FindByFingerprint(fingerprint)) {
186 wxPoint pos = panel_rc.GetLeftTop();
187 pos += wxPoint(40, 40);
200 client.GetWindow()->SetFocus();
265 full_node->Link(*
new TNode(*full_node));
268 full_node->SetFingerprint(p);
269 full_node->GetClone()->SetFingerprint(p);
353 wxWindow* window =
client.GetWindow();
355 wxWindow* parent = window->GetParent();
384 client->GetWindow()->SetFocus();
387 wxRect winloc =
client->GetWindow()->GetRect();
388 wxPoint scrpnt =
client->GetWindow()->GetScreenPosition();
390 Info <<
"Client location is "
391 "(" << winloc.x <<
"/" << scrpnt.x <<
", " << winloc.y <<
"/" << scrpnt.y <<
")"
392 "[" << winloc.width <<
", " << winloc.height <<
"]"
412 for( ;w->GetParent(); w = w->GetParent()) {
433 wxWindow* window =
dynamic_cast<wxWindow*
>(&dockable);
452 OnDrag( dockable, sc_mouse_pos );
510 const wxPoint& sc_mouse_pos)
516 OnDrag( dockable, sc_mouse_pos );
528 wxWindow* target =
NULL;
545 dock_client = &dockable;
550 wxWindow* window =
dynamic_cast<wxWindow*
>(dock_client);
561 frame->SetWindowStyleFlag(frame->GetWindowStyleFlag()&~wxFRAME_FLOAT_ON_PARENT);
568 full_node->GetWindow()->SetFocus();
572 wxWindow* w = target;
573 if (target->GetParent() !=
NULL)
574 w = target->GetParent();
576 bool is_main_window =
false;
585 is_main_window =
false;
587 is_main_window =
true;
589 if (is_main_window) {
593 static int drop_count = 0;
643 frame_cont->Reparent(frame);
681 wxWindow* window =
dynamic_cast<wxWindow*
>(&dockable);
684 wxWindow* focused = wxWindow::FindFocus();
685 wxWindow* w = focused;
697 wxPoint sc_origin = window->GetScreenPosition();
705 wxPoint pos = panel_rc.GetLeftTop();
707 pos += wxPoint(40, 40);
709 wxSize
size = panel_rc.GetSize();
732 full_node->Link(*
new TNode(*full_node));
735 full_node->SetFingerprint(p);
736 full_node->GetClone()->SetFingerprint(p);
744 wxPoint sc_new_origin = window->GetScreenPosition();
745 wxPoint frame_pos = frame->GetScreenPosition();
747 wxPoint
delta = sc_origin - sc_new_origin;
749 frame->Move(frame_pos);
762 size = frame->ClientToWindowSize(
size);
763 frame->SetSize(
size);
788 sc_mouse_pos.y < menubar_height)) {
789 if (pos.y +
delta.y > menubar_height && pos.y +
delta.y < maxy) {
799 if (pos.y < menubar_height)
800 pos.y = menubar_height;
826 if(cont != dragged_cont) {
829 if(rc.Contains(sc_mouse_pos)) {
852 OnDrag(frame, sc_mouse_pos);
859 WM_POST(
"CDockManager::OnFloatingPaneEndMove");
871 wxMenu* menu =
new wxMenu();
902 int code =
event.GetKeyCode();
903 if(
code == WXK_ESCAPE) {
906 wxPoint sc_mouse = wxGetMousePosition();
918 int code =
event.GetKeyCode();
920 wxPoint sc_mouse = wxGetMousePosition();
946 vector<IWMClient*> clients;
967 TContainers::iterator it;
969 for (it=cont_copy.begin(); it!=cont_copy.end(); ++it) {
986 TContainers::iterator it;
987 bool overlap =
false;
998 if (
f->GetRect().Intersects(
r))
1012 if(frame && active) {
1019 TContainers::iterator it =
1049 vector<CRef<CUser_object> > descrs;
1055 descrs.push_back(contDesc);
1067 if (contDesc) descrs.push_back(contDesc);
1078 if (!
object.GetType().IsStr() ||
object.GetType().GetStr() !=
kLayoutTag2) {
1085 videoId =
object.GetField(
kVideoIdTag).GetData().GetStr();
1086 const vector<CRef<CUser_object> >& descrs =
1088 for (
size_t i = 0;
i < descrs.size(); ++
i) {
1092 }
NCBI_CATCH(
"CDockManager::x_ReadLayout()");
1099 vector<CRef<CDockContainerDescr> > descrs;
1105 if (descrs.empty()) {
1106 LOG_POST(
Error <<
"Failed to read layout: " <<
"Empty layout");
1110 vector<IWMClient*> allClients;
1114 vector<IWMClient*> clients;
1116 allClients.insert(allClients.end(), clients.begin(), clients.end());
1118 ITERATE(vector<IWMClient*>, it, clients)
1125 descrs.erase(descrs.begin());
1129 mainFrame->SetSize(mainDescr->GetRect());
1133 if (mainDescr->GetMaximized() && !mainFrame->IsMaximized())
1134 mainFrame->Maximize();
1140 ITERATE(vector<IWMClient*>, it, allClients)
1166 vector<CRef<CDockContainerDescr> > descrs;
1172 if (descrs.empty()) {
1173 LOG_POST(
Error <<
"Failed to read layout: " <<
"Empty layout");
1180 (*it)->GetTree()->DepthFirstForEach(finder);
1186 descrs.erase(descrs.begin());
static CDockContainerDescr * FromUserObject(const objects::CUser_object &obj)
CDockLayoutTree * GetTree()
CDockContainer is a window that hosts docked windows.
bool HasDefaultPositionFor(const TFingerprint &fingerprint)
void OnBeginDragOver(const wxPoint &sc_mouse_pt)
bool IsRootWindow(wxWindow *window)
EDockEffect OnEndDragOver(wxWindow *&target)
CRef< TNode > RemoveWindow(IDockableWindow &dockable, ERemoveAction action)
CFloatingFrame * GetDockFrame()
returns floating frame hosting this container
void ApplyLayout(CDockLayoutTree &tree)
bool NeedToSavePositions()
void AddClientToDefaultLocation(IWMClient &client)
wxWindow * GetRootWindow()
returns window representing the root of the layout hosted by the container
void GetAllClients(vector< IWMClient * > &clients)
void SetFullTree(CDockLayoutTree &full_tree)
initialize the container with the layout tree
void OnDragOver(const wxPoint &sc_mouse_pt)
objects::CUser_object * SaveLayout(wxFrame *mainFrame)
void AddClient(CRef< TNode > full_client, EDockEffect effect, wxWindow *target_w)
void AddClientToCentralPane(CRef< TNode > full_client)
CRef< CDockLayoutTree > DisconnectTrees()
void ActivateClients(vector< IWMClient * > &clients)
bool HasNoWMClients()
returns true if Dock Container does not have any IWMClients as children
CNode - a node in layout tree corresponding to a window.
TFingerprint GetFingerprint() const
CDockLayoutTree - represents hierarchical layout in a Dock Container as a tree where nodes correspond...
void x_MoveDragFrame(const wxPoint &sc_mouse_pos)
objects::CUser_object * SaveLayout()
produces Memento describing the current window layout (including all clients)
void OnFloatingPaneBeginMove(CFloatingFrame &frame, const wxPoint &sc_mouse_pos)
void Restore(IWMClient &client)
TDescrMRUList m_DeadFrameDescrs
void MoveToMainTab(IWMClient &client)
moves the given client into the Main Tab Control ("Reset")
void OnKeyDown(wxKeyEvent &event)
vector< IWMClient * > TClients
CDockLayoutTree::CNode TNode
void OnKeyUp(wxKeyEvent &event)
wxWindow * GetTopAppWindow()
CDockContainer * m_ActiveDragContainer
bool OnDockPanelCommand(CDockPanel &panel, TCmdID cmd)
CWindowManager & GetWindowManager()
void OnBeginDrag(IDockableWindow &dockable, const wxPoint &sc_mouse_pos)
void OnFloatingFrameActivateEvent(CFloatingFrame *frame, bool active)
void OnFrameClosePressed(CFloatingFrame *frame)
CWindowManager & m_WindowManager
void x_DestroyFrameAndContainer(CDockContainer *cont)
Destroys a Docking Container togather with its Floating Frame.
bool x_ReadLayout(const objects::CUser_object &object, vector< CRef< CDockContainerDescr > > &descriptors, string &videoId)
IDockManagerKeyHook * m_FrameHook
wxFrame * MoveToFloatingFrame(IWMClient &client)
wxMenu * GetDockPanelMenu(CDockPanel &panel)
CFloatingFrame * x_CreateFrameAndContainer(const wxPoint &pos, const wxSize &size, CDockLayoutTree *tree)
Creates a new top-level Floating Frame and a Dock Container that will be hosted in the frame.
void AddToDefaultLocation(IWMClient &client, bool bFloat)
vector< CDockContainer * > TContainers
CDockContainer * GetMainContainer()
CMinPanelContainer * GetMinPanelContainer()
static CDockPanel * x_GetDockPanel(IWMClient &client)
bool OnDrag(IDockableWindow &dockable, const wxPoint &sc_mouse_pos)
void Remove(IWMClient &client)
void OnTabClosePressed(const vector< IWMClient * > &clients)
void LoadLayout(const objects::CUser_object &object, IWMClientFactory &factory)
creates a new window layout based on the given Memento instantiates the clients as needed using the g...
CFloatingFrame * m_DragFrame
CDockContainer * x_GetActiveContainerByPos(const wxPoint &sc_mouse_pos)
IDockableWindow * m_DragClient
TContainers m_Containers
A list of all Dock containers, the first container in the list is the main one.
CMinPanelContainer * m_MinContainer
holds minimized IWMClients
void ActivateClients(TClients &clients)
void OnEndDrag(IDockableWindow &dockable, EDragResult result, const wxPoint &sc_mouse_pos)
void OnCloseDockable(IDockableWindow &dockable)
wxWindow * m_FocusedChild
wxWindow & m_ParentWindow
a window that hosts the main dock container
bool IsInMainTab(IWMClient &client) const
CDockManager(CWindowManager &manager, wxWindow &parent)
for debugging purpose
void Minimize(IWMClient &client)
void SetKeyboardHook(wxFrame *frame)
void OnFloatingPaneEndMove(CFloatingFrame &frame, CDockManager::EDragResult result, const wxPoint &sc_mouse_pos)
void RaiseFloatingInZOrder()
bool IsMinimized(IWMClient &client) const
void OnMove(wxMoveEvent &event)
void OnFloatingPaneMoving(CFloatingFrame &frame, const wxPoint &sc_mouse_pos)
CFloatingFrame * x_MoveToFloatingFrame(IDockableWindow &dockable, bool shift)
bool IsFloating(IWMClient &client) const
void ApplyLayout(const objects::CUser_object &object)
CDockPanel - a container with a title bar (caption) hosting a single client window (IWMClient).
void RemoveClient(wxWindow *new_parent)
disconnect the client and re-parent it to the given window
virtual wxSize ClientToWindowSize(const wxSize &size) const
virtual CDockContainer * GetDockContainer()
virtual CDockContainer * GetDockContainer()
virtual void SetDockContainer(CDockContainer *dock_cont)
list< CRef< CDockContainerDescr > > TItems
const TItems & GetItems() const
void SetItems(const TItems &items)
void RemoveClient(CDockPanel &panel)
bool HasClient(CDockPanel &panel) const
void AddClient(CDockPanel &panel)
CUICommandRegistry is a centralized registry where all application commands should be registered.
static CUICommandRegistry & GetInstance()
the main instance associated with the application
wxMenuItem * AppendMenuItem(wxMenu &menu, TCmdID cmd_id) const
CUser_object & AddField(const string &label, const string &value, EParseField parse=eParse_String)
add a data field to the user object that holds a given value
CWindowManager - component controlling windowing of client windows.
wxFrame * GetMainWindow()
bool OnCloseClientsRequest(const TClients &clients)
bool OnCaptionPanelCommand(CDockPanel &panel, TCmdID cmd)
virtual bool AddClient(IWMClient &client, bool bFloat)
adds the client to the Main Tabbed Pane
string GetNewFloatingFrameTitle()
void operator()(CDockLayoutTree::CNode &node)
FClientFinder(set< string > &views)
virtual void ForwardKeyEventsTo(CDockManager *manager)=0
IDockableWindow - repersents a window that can be docked in Dock Manager.
virtual CDockContainer * GetDockContainer()=0
IWMClientFactory - IWMClient factory.
virtual IWMClient * CreateClient(const TFingerprint &fingerprint, wxWindow *parent)=0
creates a client by fingerprint returns NULL if fingerprint is not recognized.
CFingerprint identifies an instance of IWMClient and is used for labeling layout positions.
const string GetId() const
IWClient - abstract Window Manager client.
virtual wxWindow * GetWindow()=0
returns a pointer to the wxWindow representing the client
virtual CFingerprint GetFingerprint() const =0
returns a fingerprint identifying the client
virtual bool IsAForm() const
returns true if client is a Form - wants to be sized to its client area (like a dialog)
iterator_bool insert(const value_type &val)
static const char * kLayoutTag2
static const char * kVideoIdTag
static const char * kContainersTag
Saving and Loading layouts.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define REVERSE_ITERATE(Type, Var, Cont)
ITERATE macro to reverse sequence through container elements.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
#define NCBI_CATCH(message)
Catch CExceptions as well This macro is deprecated - use *_X or *_XX variant instead of it.
void Info(CExceptionArgs_Base &args)
@ eCmdReCreate
tool tip parent window about to dock
@ eCmdSuspend
tool tip window parent moves
@ eCmdDockMainWindow
tool tip parent window finished docking
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void SetType(TType &value)
Assign a value to Type data member.
const struct ncbi::grid::netcache::search::fields::SIZE size
Int4 delta(size_t dimension_, const Int4 *score_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
double f(double x_, const double &y_)
static CNamedPipeClient * client
void GetMacDragWindowBounds(wxTopLevelWindow *win, int &menubar_height, int &maxy, int &maxx)
Returns window boundaries for mac (top menubar width and max height)
wxString ToWxString(const string &s)
string GetVideoId()
Returns id of video configuration to be used for saving settings.
void BroadcastCommandToChildWindows(wxWindow *window, int cmd_id, int cmd_data=0)
Sends command event with id 'cmd_id' to window and all its children.
wxRect GetScreenRect(const wxWindow &win)