/
TabBrowser.cpp
executable file
·101 lines (89 loc) · 2.65 KB
/
TabBrowser.cpp
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
/*
* MojoMerge -- A cross-platform compare-and-merge utility.
* Copyright (C) 2007 Ryan C. Gordon and Gregory S. Read.
*
* Please refer to LICENSE.txt in the root directory of the source
* distribution for licensing details.
*/
/* TabBrowser.cpp - Implementation for the TabBrowser class
*
*/
#include "TabBrowser.h"
#include "Identifiers.h"
using namespace MojoMerge;
TabBrowser::TabBrowser(wxWindow *Container)
{
// Initialize member variables
Notebook = NULL;
BoxSizer = NULL;
NotebookSizer = NULL;
// Container can't be NULL
assert(Container);
// Create our panel window where the tab control will be placed
Create(Container, ID_TAB_BROWSER_PANEL);
// Create new notebook control
Notebook = new wxNotebook(this, ID_TAB_BROWSER_NOTEBOOK, wxDefaultPosition,
wxDefaultSize, wxCLIP_CHILDREN);
// Create the notebook sizer
NotebookSizer = new wxNotebookSizer(Notebook);
// Create our box sizer
BoxSizer = new wxBoxSizer(wxVERTICAL);
// Our new objects can't be NULL
assert(Notebook);
assert(BoxSizer);
assert(NotebookSizer);
// Add the notebook sizer to the sizer object
BoxSizer->Add(NotebookSizer, 1, wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 0);
// Initialize sizer stuff so that the browser will take up
// the entire panel.
this->SetAutoLayout(true);
this->SetSizer(BoxSizer);
BoxSizer->Fit(this);
BoxSizer->SetSizeHints(this);
// Show the notebook control
Notebook->Show();
// Show this panel control
Show();
}
void TabBrowser::AddWindow(TabWindow *Window)
{
Window->Initialize(Notebook);
Notebook->AddPage(Window, Window->GetName(), true);
}
void TabBrowser::RemoveActiveWindow()
{
// Get current page
int Page = Notebook->GetSelection();
// Delete the currently active page if it exists
if(Page != -1)
Notebook->DeletePage(Page);
}
TabWindow *TabBrowser::GetActiveWindow()
{
TabWindow *CurrentPage;
int Page;
Page = Notebook->GetSelection();
// There must be a valid page selected
if(Page == -1)
CurrentPage = NULL;
else
{
// Return the window to the caller
CurrentPage = (TabWindow *)Notebook->GetPage(Page);
assert(CurrentPage);
}
return CurrentPage;
}
void TabBrowser::UpdateNameForActiveWindow()
{
TabWindow *CurrentPage;
int Page;
Page = Notebook->GetSelection();
// There must be a valid page selected
assert(Page != -1);
// Return the window to the caller
CurrentPage = (TabWindow *)Notebook->GetPage(Page);
// Page object must be valid
assert(CurrentPage);
Notebook->SetPageText(Page, CurrentPage->GetName());
}