/[projects]/wxCpuThrottle/src/trayicon.cpp
ViewVC logotype

Annotation of /wxCpuThrottle/src/trayicon.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (hide annotations) (download)
Fri Aug 10 18:12:36 2007 UTC (16 years, 9 months ago) by torben
File size: 3565 byte(s)
A lot of gui modifications, but now the application works as I want it to.

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 torben 25 if (!mParent->GetWritable())
67     {
68     menu->Enable(Menu_Increase, false);
69     menu->Enable(Menu_Decrease, false);
70     }
71 torben 20
72     return menu;
73     }
74    
75     void TrayIcon::OnQuit( wxCommandEvent& event )
76     {
77 torben 25 mParent->OnQuit(/*event*/);
78 torben 20 }
79    
80    
81     void TrayIcon::OnAbout( wxCommandEvent& WXUNUSED( event ) )
82     {
83     wxMessageBox( wxT( "wxCpuThrottle by TOU" ),
84     wxT( "About Hello World" ), wxOK | wxICON_INFORMATION, 0 );
85     }
86    
87     void TrayIcon::OnShowDialog( wxCommandEvent& event )
88     {
89 torben 25 ShowDialog();
90 torben 20 }
91    
92     void TrayIcon::OnLeftClick(wxTaskBarIconEvent& WXUNUSED(event) )
93     {
94 torben 25 ShowDialog();
95 torben 20 }
96    
97     void TrayIcon::OnIncrease( wxCommandEvent& WXUNUSED( event ) )
98     {
99 torben 25 AcpiParser* parser = mParent->GetParser();
100     int current = parser->GetCurrentState();
101    
102     if (current < parser->GetStateCount() -1)
103     parser->SetState( current +1 );
104     }
105    
106 torben 20 void TrayIcon::OnDecrease( wxCommandEvent& WXUNUSED( event ) )
107     {
108 torben 25 AcpiParser* parser = mParent->GetParser();
109     int current = parser->GetCurrentState();
110    
111     if ( current > 0)
112     parser->SetState( current - 1 );
113 torben 20 }
114 torben 25
115    
116    
117     void TrayIcon::ShowDialog()
118     {
119     mParent->SetPosition();
120     mParent->Show( !mParent->IsShown() );
121    
122     if (mParent->IsIconized())
123     mParent->Iconize( false );
124     }

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20