-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcbTerminalViewManagerLayout.cpp
More file actions
109 lines (87 loc) · 2.95 KB
/
cbTerminalViewManagerLayout.cpp
File metadata and controls
109 lines (87 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/***************************************************************
* Name: cbTerminalViewManagerLayout
* Purpose: Implements the cbTerminalViewManagerBase
* interface to make the cbTerminalView panel
* managed by the layout.
* Author: Jerome ANTOINE
* Created: 2007-07-19
* Copyright: Jerome ANTOINE
* Copyright: Christo Joseph
* License: GPL
**************************************************************/
#include <sdk.h> // Code::Blocks SDK
#ifndef CB_PRECOMP
#include "globals.h"
#include "manager.h"
#include "sdk_events.h"
#endif
#include "cbTerminalViewManagerLayout.hpp"
#include "cbTerminalView.hpp"
cbTerminalViewManagerLayout::~cbTerminalViewManagerLayout()
{
}
void cbTerminalViewManagerLayout::AddViewToManager()
{
if ( m_IsManaged == false )
{
// Docking event creation
CodeBlocksDockEvent evt(cbEVT_ADD_DOCK_WINDOW);
evt.name = _T("cbTerminal");
evt.title = _("Terminal");
evt.pWindow = (wxWindow*)m_pcbTerminalView;
evt.desiredSize.Set(800, 200);
evt.floatingSize.Set(600, 200);
evt.minimumSize.Set( 30, 40 );
evt.stretch = true;
evt.dockSide = CodeBlocksDockEvent::dsBottom;
evt.shown = true;
// Adds view to layout manager
Manager::Get()->ProcessEvent(evt);
m_IsManaged = true;
m_IsShown = true;
}
}
void cbTerminalViewManagerLayout::RemoveViewFromManager()
{
if ( m_IsManaged == true )
{
// Undocking event creation
CodeBlocksDockEvent evt(cbEVT_REMOVE_DOCK_WINDOW);
evt.pWindow = (wxWindow*)m_pcbTerminalView;
evt.shown = false;
// Removes view from layout manager
Manager::Get()->ProcessEvent(evt);
m_IsManaged = false;
m_IsShown = false;
// We need to delete this to make it behave like the notebook.
delete m_pcbTerminalView;
m_pcbTerminalView = nullptr;
}
}
bool cbTerminalViewManagerLayout::ShowView(uint32_t flags)
{
const bool show = ((flags & ShowViewFlags::Show) == ShowViewFlags::Show);
if ((m_IsManaged == false) || (show == IsViewShown()))
return false;
wxWindow *focused = nullptr;
if ((flags & ShowViewFlags::PreserveFocus) == ShowViewFlags::PreserveFocus)
focused = wxWindow::FindFocus();
CodeBlocksDockEvent evt(show ? cbEVT_SHOW_DOCK_WINDOW : cbEVT_HIDE_DOCK_WINDOW);
evt.pWindow = (wxWindow*)m_pcbTerminalView;
evt.shown = show;
Manager::Get()->ProcessEvent(evt);
if (focused)
focused->SetFocus();
m_IsShown = show;
return true;
}
bool cbTerminalViewManagerLayout::IsViewShown()
{
// m_IsShown is not sufficient because user can close the view with the close cross
// so we use IsWindowReallyShown to give correct result.
return m_IsShown && IsWindowReallyShown((wxWindow*)m_pcbTerminalView);
}
void cbTerminalViewManagerLayout::Raise()
{
m_pcbTerminalView->GetParent()->Raise();
}