-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcbTerminalViewManagerMessagesNotebook.cpp
More file actions
120 lines (100 loc) · 3.48 KB
/
cbTerminalViewManagerMessagesNotebook.cpp
File metadata and controls
120 lines (100 loc) · 3.48 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
110
111
112
113
114
115
116
117
118
119
120
/***************************************************************
* Name: cbTerminalViewManagerMessagesNotebook
* Purpose: Implements the cbTerminalViewManagerBase
* interface to make the cbTerminalView panel
* managed by the Messages notebook.
* 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 "configmanager.h"
#include "manager.h"
#endif
#include "cbTerminalView.hpp"
#include "cbTerminalViewManagerMessagesNotebook.hpp"
cbTerminalViewManagerMessagesNotebook::~cbTerminalViewManagerMessagesNotebook()
{
delete m_Bitmap;
}
void cbTerminalViewManagerMessagesNotebook::AddViewToManager()
{
if ( m_IsManaged == false )
{
// Creates log image
wxString prefix(ConfigManager::GetDataFolder()+"/cbTerminal.zip#zip:/");
#if wxCHECK_VERSION(3, 1, 6)
m_Bitmap = new wxBitmapBundle(cbLoadBitmap(prefix+"terminal-16.png"));
#else
const int uiSize = Manager::Get()->GetImageSize(Manager::UIComponent::InfoPaneNotebooks);
prefix << wxString::Format("%dx%d/", uiSize, uiSize);
m_Bitmap = new wxBitmap(cbLoadBitmap(prefix+"findf.png", wxBITMAP_TYPE_PNG));
#endif
// Adds log to C::B Messages notebook
CodeBlocksLogEvent evtShow(cbEVT_ADD_LOG_WINDOW, m_pcbTerminalView,
wxString(_T("Terminal")), m_Bitmap);
Manager::Get()->ProcessEvent(evtShow);
CodeBlocksLogEvent evtSwitch(cbEVT_SWITCH_TO_LOG_WINDOW, m_pcbTerminalView);
Manager::Get()->ProcessEvent(evtSwitch);
// Status update
m_IsManaged = true;
m_IsShown = true;
}
}
void cbTerminalViewManagerMessagesNotebook::RemoveViewFromManager()
{
if ( m_IsManaged == true )
{
// Status update
m_IsManaged = false;
m_IsShown = false;
// Removes cbTerminal panel from C::B Messages notebook
// Reparent call to avoid m_pcbTerminalView deletion
CodeBlocksLogEvent evt(cbEVT_REMOVE_LOG_WINDOW, m_pcbTerminalView);
Manager::Get()->ProcessEvent(evt);
m_pcbTerminalView = nullptr;
delete m_Bitmap;
m_Bitmap = nullptr;
}
}
bool cbTerminalViewManagerMessagesNotebook::ShowView(uint32_t flags)
{
// m_IsManaged is updated in called methods
const bool show = ((flags & ShowViewFlags::Show) == ShowViewFlags::Show);
if (show)
{
if (m_IsManaged == true)
{
wxWindow *focused = nullptr;
if ((flags & ShowViewFlags::PreserveFocus) == ShowViewFlags::PreserveFocus)
focused = wxWindow::FindFocus();
CodeBlocksLogEvent evtShow(cbEVT_SHOW_LOG_MANAGER);
Manager::Get()->ProcessEvent(evtShow);
CodeBlocksLogEvent evtSwitch(cbEVT_SWITCH_TO_LOG_WINDOW, m_pcbTerminalView);
Manager::Get()->ProcessEvent(evtSwitch);
m_IsShown = true;
if (focused)
focused->SetFocus();
}
else
{
AddViewToManager();
}
}
else
{
RemoveViewFromManager();
}
return true;
}
bool cbTerminalViewManagerMessagesNotebook::IsViewShown()
{
return m_IsShown && IsWindowReallyShown((wxWindow*)m_pcbTerminalView);
}
void cbTerminalViewManagerMessagesNotebook::Raise()
{
m_pcbTerminalView->GetParent()->GetParent()->Raise();
}