1 |
torben |
20 |
/*************************************************************************** |
2 |
|
|
* Copyright (C) 2007 by Torben Nielsen * |
3 |
|
|
* torben@t-hoerup.dk * |
4 |
|
|
* * |
5 |
|
|
* This program is free software; you can redistribute it and/or modify * |
6 |
|
|
* it under the terms of the GNU General Public License as published by * |
7 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
8 |
|
|
* (at your option) any later version. * |
9 |
|
|
* * |
10 |
|
|
* This program is distributed in the hope that it will be useful, * |
11 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
|
|
* GNU General Public License for more details. * |
14 |
|
|
* * |
15 |
|
|
* You should have received a copy of the GNU General Public License * |
16 |
|
|
* along with this program; if not, write to the * |
17 |
|
|
* Free Software Foundation, Inc., * |
18 |
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 |
|
|
***************************************************************************/ |
20 |
|
|
#include "trayicon.h" |
21 |
|
|
#include <wx/menu.h> |
22 |
|
|
|
23 |
|
|
#include "wxcputhrottleframe.h" |
24 |
|
|
|
25 |
|
|
enum |
26 |
|
|
{ |
27 |
|
|
Menu_Quit = 100, |
28 |
|
|
Menu_About, |
29 |
|
|
Menu_Increase, |
30 |
|
|
Menu_Decrease, |
31 |
|
|
Menu_ShowDialog |
32 |
|
|
}; |
33 |
|
|
|
34 |
|
|
BEGIN_EVENT_TABLE(TrayIcon, wxTaskBarIcon) |
35 |
|
|
EVT_MENU(Menu_Quit, TrayIcon::OnQuit) |
36 |
|
|
EVT_MENU(Menu_About, TrayIcon::OnAbout) |
37 |
|
|
EVT_MENU(Menu_ShowDialog, TrayIcon::OnShowDialog) |
38 |
|
|
EVT_MENU(Menu_Increase, TrayIcon::OnIncrease) |
39 |
|
|
EVT_MENU(Menu_Decrease, TrayIcon::OnDecrease) |
40 |
|
|
EVT_TASKBAR_LEFT_DOWN(TrayIcon::OnLeftClick) |
41 |
|
|
END_EVENT_TABLE() |
42 |
|
|
|
43 |
|
|
TrayIcon::TrayIcon(wxCpuThrottleFrame* parent) |
44 |
|
|
: wxTaskBarIcon(), |
45 |
|
|
mParent(parent) |
46 |
|
|
{ |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
|
50 |
|
|
TrayIcon::~TrayIcon() |
51 |
|
|
{ |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
|
55 |
|
|
wxMenu* TrayIcon::CreatePopupMenu() |
56 |
|
|
{ |
57 |
|
|
wxMenu* menu = new wxMenu(); |
58 |
|
|
|
59 |
|
|
menu->Append(Menu_ShowDialog, wxT("Show/hide dialog") ); |
60 |
|
|
menu->Append(Menu_Increase, wxT("Increase throttle") ); |
61 |
|
|
menu->Append(Menu_Decrease, wxT("Decrease throttle") ); |
62 |
|
|
menu->Append(Menu_About, wxT("About wxCpuThrottle")); |
63 |
|
|
menu->AppendSeparator(); |
64 |
|
|
menu->Append(Menu_Quit, wxT("Quit application"), wxT("Terminates wxCpuThrottle") ); |
65 |
|
|
|
66 |
|
|
|
67 |
|
|
return menu; |
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
void TrayIcon::OnQuit( wxCommandEvent& event ) |
71 |
|
|
{ |
72 |
|
|
mParent->OnQuit(event); |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
void TrayIcon::OnAbout( wxCommandEvent& WXUNUSED( event ) ) |
77 |
|
|
{ |
78 |
|
|
wxMessageBox( wxT( "wxCpuThrottle by TOU" ), |
79 |
|
|
wxT( "About Hello World" ), wxOK | wxICON_INFORMATION, 0 ); |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
void TrayIcon::OnShowDialog( wxCommandEvent& event ) |
83 |
|
|
{ |
84 |
torben |
21 |
mParent->SetPosition(); |
85 |
torben |
20 |
mParent->Show( !mParent->IsShown() ); |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
void TrayIcon::OnLeftClick(wxTaskBarIconEvent& WXUNUSED(event) ) |
89 |
|
|
{ |
90 |
torben |
21 |
mParent->SetPosition(); |
91 |
torben |
20 |
mParent->Show( !mParent->IsShown() ); |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
void TrayIcon::OnIncrease( wxCommandEvent& WXUNUSED( event ) ) |
95 |
|
|
{ |
96 |
|
|
} |
97 |
|
|
void TrayIcon::OnDecrease( wxCommandEvent& WXUNUSED( event ) ) |
98 |
|
|
{ |
99 |
|
|
} |