-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainframe.cpp
executable file
·171 lines (150 loc) · 5.89 KB
/
mainframe.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "zoomsrc.h"
#include "ZoomSrc.xpm"
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
EVT_MENU(ZoomSrc_Close, MainFrame::OnClose)
EVT_MENU(ZoomSrc_About, MainFrame::OnAbout)
EVT_MENU(ZoomSrc_Open, MainFrame::OnOpen)
EVT_MENU(ZoomSrc_MatchBracket, MainFrame::OnMatchBracket)
EVT_MENU(ZoomSrc_Away, MainFrame::OnAway)
EVT_MENU(ZoomSrc_Into, MainFrame::OnInto)
EVT_MENU(ZoomSrc_Larger, MainFrame::OnLarger)
EVT_MENU(ZoomSrc_Smaller, MainFrame::OnSmaller)
EVT_MENU(ZoomSrc_Swap, MainFrame::OnSwap)
EVT_MENU(ZoomSrc_ShowAll, MainFrame::OnShowAll)
EVT_MENU(ZoomSrc_GotoView, MainFrame::OnGotoView)
EVT_MENU(ZoomSrc_Prefs, MainFrame::OnPrefs)
// EVT_MENU(ZoomSrc_Indent, MainFrame::OnIndent)
// EVT_MENU(ZoomSrc_Undent, MainFrame::OnUndent)
//EVT_MENU(ZoomSrc_Move, MyFrame::OnCaretMove)
END_EVENT_TABLE()
/*
void MainFrame::OnClose( wxCommandEvent& WXUNUSED(event) ){
Close(true); // true is to force the frame to close
}
*/
void MainFrame::OnPrefs(wxCommandEvent& event){
PrefsDlg p(m_editpanel);
p.ShowModal();
}
void MainFrame::OnGotoView(wxCommandEvent& event){
//wxMenuItem *mi = (wxMenuItem *) event.GetEventObject();
//wxString str;
wxMenuItemList& mil = menuGo->GetMenuItems();
for(int i = menuGoOffset; i < mil.GetCount(); i++){
if(mil[i]->IsChecked()) {
//str = mil[i]->GetItemLabel();
m_editpanel->GotoView(i - menuGoOffset -1);
break;
}
}
//str.Printf( _T("Menu %d"), event.GetInt());
//wxMessageBox(str);
}
void MainFrame::OnClose(wxCommandEvent& event){
Close(true);
}
void MainFrame::OnShowAll(wxCommandEvent& event){
m_editpanel->ShowAll();
}
void MainFrame::OnSwap(wxCommandEvent& event){
m_editpanel->Swap();
}
void MainFrame::OnOpen(wxCommandEvent& event ){
wxString filename = wxFileSelector(_T("Choose a file to open"));
if( ! filename.empty() ) {
//delete m_editpanel;
//m_editpanel->LoadFile(filename);
//m_editpanel->SetSize(300,300);
Refresh();
}
}
void MainFrame::Load( wxString& filename ){
// m_editpanel->LoadFile(filename);
// Refresh();
}
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size) {
// set the frame icon
SetIcon(wxICON(ZoomSrc));
SetTransparent( 0xF0 );
// create a menu bar
menuFile = new wxMenu;
/*
menuFile->Append(Caret_SetBlinkTime, _T("&Blink time...\tCtrl-B"));
menuFile->Append(Caret_SetFontSize, _T("&Font size...\tCtrl-S"));
menuFile->Append(Caret_Move, _T("&Move caret\tCtrl-C"));
menuFile->AppendSeparator();
*/
menuFile->Append(ZoomSrc_New, _T("&New\tCtrl-N"), _T("New file") );
menuFile->Append(ZoomSrc_Open, _T("&Open...\tCtrl-O"), _T("Open a file from disk") );
menuFile->AppendSeparator();
menuFile->Append(ZoomSrc_Close, _T("&Close\tCtrl-W"), _T("Close the current file") );
menuFile->Append(ZoomSrc_Save, _T("&Save\tCtrl-S"), _T("Save changes to the current file") );
menuFile->Append(ZoomSrc_SaveAs, _T("Save &As...\tCtrl-Shift-S"), _T("Save to another file") );
menuFile->AppendSeparator();
menuFile->Append(ZoomSrc_About, _T("&About..."), _T("Show about dialog"));
menuFile->AppendSeparator();
menuFile->Append(ZoomSrc_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
menuEdit = new wxMenu;
menuEdit->Append(ZoomSrc_Undo, _T("&Undo\tCtrl-Z"), _T("Undo the last command"));
menuEdit->Append(ZoomSrc_Redo, _T("&Redo\tCtrl-Y"), _T("Redo the recently undone command"));
menuEdit->AppendSeparator();
menuEdit->Append(ZoomSrc_Cut, _T("Cu&t\tCtrl-X"), _T("Cut the selected text"));
menuEdit->Append(ZoomSrc_Copy, _T("&Copy\tCtrl-C"), _T("Copy the selected text"));
menuEdit->Append(ZoomSrc_Paste, _T("&Paste\tCtrl-V"), _T("Paste at the insertion point"));
menuEdit->AppendSeparator();
menuEdit->Append(ZoomSrc_Delete,_T("&Delete\tCtrl-D"),_T("Delete current line") );
//menuEdit->Append(ZoomSrc_SelectAll,_T("Select &All\tCtrl-A"),_T("Extend selection") );
menuEdit->Append(ZoomSrc_MatchBracket,_T("Match &Bracket\tCtrl-B"),_T("Go to the matching bracket") );
menuEdit->Append(ZoomSrc_Indent, _T("Indent\tTab"), _T("") );
menuEdit->Append(ZoomSrc_Undent, _T("Undent\tShift+Tab"), _T("") );
menuEdit->AppendSeparator();
menuEdit->Append(ZoomSrc_Prefs, _T("Preferences...\tCtrl-,"), _T("Bring up the options panel") );
menuView = new wxMenu;
menuView->Append(ZoomSrc_Smaller, _T("Smaller\tCtrl--"), _T("Reduce the small view text size") );
menuView->Append(ZoomSrc_Larger, _T("Larger\tCtrl-="), _T("Increase the small view text size") );
menuGo = NULL;
RebuildGo();
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, _T("&File"));
menuBar->Append(menuEdit, _T("&Edit"));
menuBar->Append(menuView, _T("&View"));
menuBar->Append(menuGo, _T("&Go") );
SetMenuBar(menuBar);
m_editpanel = new EditPanel(this, _T("zoomsrc.h"));
/*
#if wxUSE_STATUSBAR
// create a status bar just for fun (by default with 1 pane only)
CreateStatusBar(2);
SetStatusText(_T("ZoomSrc ready."));
#endif // wxUSE_STATUSBAR
*/
}
void MainFrame::RebuildGo(){
if(menuGo != NULL) delete menuGo;
menuGo = new wxMenu;
menuGo->Append(ZoomSrc_Away, _T("Away\tCtrl-Up"), _T("Move away from the current position") );
menuGo->Append(ZoomSrc_Into, _T("Into\tCtrl-Down"), _T("Move away from the current position") );
menuGo->AppendSeparator();
menuGo->Append(ZoomSrc_Swap, _T("Swap\tCtrl-U"), _T("Switch to the other open file") );
menuGo->Append(ZoomSrc_ShowAll, _T("Show all\tCtrl-A"), _T("Show all source views") );
menuGoOffset = menuGo->GetMenuItemCount();
}
void MainFrame::OnAway(wxCommandEvent& event){
m_editpanel->Away();
}
void MainFrame::OnInto(wxCommandEvent& event){
m_editpanel->Into();
}
void MainFrame::OnLarger(wxCommandEvent& event){
m_editpanel->Larger();
}
void MainFrame::OnSmaller(wxCommandEvent& event){
m_editpanel->Smaller();
}
void MainFrame::OnMatchBracket(wxCommandEvent& event){
m_editpanel->MatchBracket();
}
void MainFrame::OnAbout(wxCommandEvent& event){
wxMessageBox( _T("ZoomSrc Copyright © D. Casey Tucker 2008") );
}