7 QemuUIMenuBar::QemuUIMenuBar() : wxMenuBar(){
8 this->Append(CreateFileMenu(), _("&File"));
9 this->Append(CreateViewMenu(), _("&View"));
10 this->Append(CreateVMMenu(), _("V&M"));
11 this->Append(CreatePowerMenu(), _("&Power"));
12 this->Append(CreateWindowMenu(),_("&Windows"));
13 this->Append(CreateHelpMenu(), _("&Help"));
16 wxMenu
*QemuUIMenuBar::CreateFileMenu(){
17 this->filemenu
= new wxMenu();
28 _("Open an existing VM")
37 filemenu
->AppendSeparator();
42 _("Quit this program")
45 return this->filemenu
;
48 wxMenu
*QemuUIMenuBar::CreateViewMenu(){
49 this->viewmenu
= new wxMenu();
54 _("Show start screen")
57 viewmenu
->AppendCheckItem(
60 _("Toggle fullscreen mode")
63 wxMenu
*toolbarmenu
= new wxMenu();
64 toolbarmenu
->AppendCheckItem(
69 toolbarmenu
->Check(QEMU_TOGGLE_TOOLBAR
,true);
70 toolbarmenu
->AppendSeparator();
71 toolbarmenu
->AppendRadioItem(QEMU_TOOLBAR_ICONS
,_("Icons"));
72 toolbarmenu
->AppendRadioItem(QEMU_TOOLBAR_TEXT
,_("Text"));
73 toolbarmenu
->AppendRadioItem(QEMU_TOOLBAR_BOTH
,_("Both"));
74 toolbarmenu
->Check(QEMU_TOOLBAR_BOTH
,true);
80 _("Toolbar related settings")
83 viewmenu
->AppendCheckItem(
84 QEMU_TOGGLE_STATUSBAR
,
86 _("Toggle status bar")
88 viewmenu
->Check(QEMU_TOGGLE_STATUSBAR
,true);
90 return this->viewmenu
;
93 wxMenu
* QemuUIMenuBar::CreateVMMenu(){
94 this->vmmenu
= new wxMenu();
95 vmmenu
->Append(QEMU_VM_SEND_CTRL_ALT_DEL
,_("Send Ctrl+Alt+Del"));
96 vmmenu
->Append(QEMU_VM_SETTINGS
,_("Settings"));
101 wxMenu
* QemuUIMenuBar::CreatePowerMenu(){
102 this->powermenu
= new wxMenu();
103 powermenu
->Append(QEMU_VM_START
,_("Power on"));
104 powermenu
->Append(QEMU_VM_SHUTDOWN
,_("Power off"));
105 powermenu
->Append(QEMU_VM_PAUSE
,_("Pause"));
106 powermenu
->Append(QEMU_VM_RESET
,_("Reset"));
107 return this->powermenu
;
110 wxMenu
* QemuUIMenuBar::CreateWindowMenu(){
111 this->windowmenu
= new wxMenu();
112 windowmenu
->AppendSeparator();
115 _("&Next Window\tCtrl+TAB")
119 _("&Previous Window\tCtrl+Shift+Tab")
121 return this->windowmenu
;
124 wxMenu
*QemuUIMenuBar::CreateHelpMenu(){
125 this->helpmenu
= new wxMenu();
128 _("&Documentation\tF1"),
129 _("Show Qemu documentation")
134 _("Show about dialog")
136 return this->helpmenu
;
139 void QemuUIMenuBar::Disable(){
140 powermenu
->Enable(QEMU_VM_START
,false);
141 powermenu
->Enable(QEMU_VM_PAUSE
,false);
142 powermenu
->Enable(QEMU_VM_SHUTDOWN
,false);
143 powermenu
->Enable(QEMU_VM_RESET
,false);
144 vmmenu
->Enable(QEMU_VM_SETTINGS
,false);
145 vmmenu
->Enable(QEMU_VM_SEND_CTRL_ALT_DEL
,false);
148 void QemuUIMenuBar::Settings(bool state
){
149 vmmenu
->Enable(QEMU_VM_SETTINGS
,state
);
152 void QemuUIMenuBar::SendCtrlAltDel(bool state
){
153 vmmenu
->Enable(QEMU_VM_SEND_CTRL_ALT_DEL
,state
);
156 void QemuUIMenuBar::PowerOn(bool state
){
157 powermenu
->Enable(QEMU_VM_START
,state
);
160 void QemuUIMenuBar::Pause(bool state
){
161 powermenu
->Enable(QEMU_VM_PAUSE
,state
);
164 void QemuUIMenuBar::PowerOff(bool state
){
165 powermenu
->Enable(QEMU_VM_SHUTDOWN
,state
);
168 void QemuUIMenuBar::Reset(bool state
){
169 powermenu
->Enable(QEMU_VM_RESET
,state
);
172 void QemuUIMenuBar::EnableToolbar(bool value
){
173 viewmenu
->Enable(QEMU_TOOLBAR_TEXT
,value
);
174 viewmenu
->Enable(QEMU_TOOLBAR_ICONS
,value
);
175 viewmenu
->Enable(QEMU_TOOLBAR_BOTH
,value
);
178 void QemuUIMenuBar::CheckFavorites(bool value
){
179 viewmenu
->Check(QEMU_SPLIT
,value
);
182 void QemuUIMenuBar::UpdateWindowMenu(const size_t posOld
,const size_t posNew
){
183 wxMenuItem
*item
= windowmenu
->FindItemByPosition(posOld
);
185 windowmenu
->Remove(item
);
186 windowmenu
->Insert(posNew
,item
);
190 void QemuUIMenuBar::RemoveWindowMenuEntry(const size_t pos
){
191 wxMenuItem
*item
= windowmenu
->FindItemByPosition(pos
);
193 windowmenu
->Remove(item
);
195 CheckWindowMenuEntry(pos
> 0 ? pos
- 1 : 0);
199 void QemuUIMenuBar::InsertWindowMenuEntry(const size_t pos
,const wxString
& title
){
200 /* there seem to be a problem in wxwidgets which occurs
201 * when radio items are removed and then later back added
202 * so this is an ugly workaround. All items are removed
203 * and then back added.
205 * see also my post to wx-dev
206 * http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi?5:mss:76732:200608:mfgbpjnmoondkdinmimb
208 const int count
= windowmenu
->GetMenuItemCount();
209 wxMenuItem
*tmp
[count
];
210 for(int i
= count
- 1; i
>= 0; i
--){
211 tmp
[i
] = windowmenu
->FindItemByPosition(i
);
212 windowmenu
->Remove(tmp
[i
]);
215 wxMenuItem *workaround = windowmenu->Append(-1,wxEmptyString);
216 windowmenu->Remove(workaround);
219 const int id
= wxNewId();
220 wxMenuItem
*item
= new wxMenuItem(windowmenu
,id
,title
,wxEmptyString
,
222 // this evalutes to false on windows, and thus the menuentries do not
223 // respond to user events.
225 GetParent()->Connect(
227 wxEVT_COMMAND_MENU_SELECTED
,
228 wxCommandEventHandler(QemuMainFrame::OnChangeWindow
)
232 for(int i
= 0; i
< count
; i
++){
234 windowmenu
->Append(item
);
236 windowmenu
->Append(tmp
[i
]);
240 void QemuUIMenuBar::AppendWindowMenuEntry(const wxString
& title
){
241 // subtract 3 because of the separator and
242 // the 2 standard menu items
243 const int pos
= windowmenu
->GetMenuItemCount() - 3;
244 InsertWindowMenuEntry(pos
,title
);
247 void QemuUIMenuBar::PrependWindowMenuEntry(const wxString
& title
){
248 InsertWindowMenuEntry(0,title
);
251 void QemuUIMenuBar::CheckWindowMenuEntry(size_t pos
){
252 // return if there are no entries available
253 // check for 3 because of the separator and the
254 // 2 standard menu items which are allways there
255 const size_t count
= windowmenu
->GetMenuItemCount();
260 wxMenuItem
*item
= windowmenu
->FindItemByPosition(pos
);
265 int QemuUIMenuBar::GetCheckedWindowMenuEntry(){
266 for(int i
= 0; i
< windowmenu
->GetMenuItemCount() - 3; i
++){
267 wxMenuItem
*item
= windowmenu
->FindItemByPosition(i
);
268 if(item
->IsChecked())
273 wxMenu
* QemuUIMenuBar::GetFileMenu(){
274 return this->filemenu
;
277 void QemuUIMenuBar::UpdateFileHistory(const size_t fileHistoryCount
){
278 wxMenuItem
*separator
= NULL
;
279 for(int i
= filemenu
->GetMenuItemCount() - 1; i
>= 0; i
--){
280 separator
= filemenu
->FindItemByPosition(i
);
281 if(separator
->GetKind() == wxITEM_SEPARATOR
){
282 filemenu
->Remove(separator
);
285 if(fileHistoryCount
> 0){
286 filemenu
->InsertSeparator(filemenu
->GetMenuItemCount() - fileHistoryCount
- 1);
288 wxMenuItem
*exit
= filemenu
->Remove(QEMU_QUIT
);
289 filemenu
->AppendSeparator();
290 filemenu
->Append(exit
);