1 |
/*************************************************************************** |
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 |
|
21 |
#include "wxcputhrottleframe.h" |
22 |
|
23 |
#include "SysMetrix.xpm" |
24 |
|
25 |
BEGIN_EVENT_TABLE( wxCpuThrottleFrame, wxDialog ) |
26 |
EVT_CLOSE( wxCpuThrottleFrame::OnClose ) |
27 |
END_EVENT_TABLE() |
28 |
|
29 |
|
30 |
enum |
31 |
{ |
32 |
ID_SLIDER = 2000 |
33 |
}; |
34 |
|
35 |
wxCpuThrottleFrame::wxCpuThrottleFrame( ) |
36 |
: wxDialog(NULL, -1, wxT("wxCpuThrottle"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), |
37 |
mIcon(SysMetrix_xpm) |
38 |
{ |
39 |
mParser.ReadAcpiFile(); |
40 |
SetIcon(mIcon); |
41 |
|
42 |
mTrayIcon = new TrayIcon(this); |
43 |
mTrayIcon->SetIcon(mIcon,wxT("wxCpuThrottle") ); |
44 |
|
45 |
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL ); |
46 |
|
47 |
wxSlider* slider = new wxSlider(this, ID_SLIDER, mParser.GetCurrentState(), 0, mParser.GetStateCount()-1, wxDefaultPosition, wxSize(80,200), wxSL_VERTICAL|wxSL_AUTOTICKS|wxSL_LEFT|wxSL_LABELS); |
48 |
mainSizer->Add(slider, 1, wxEXPAND,0); |
49 |
|
50 |
|
51 |
SetSizer(mainSizer); |
52 |
mainSizer->SetSizeHints(this ); |
53 |
|
54 |
|
55 |
} |
56 |
|
57 |
void wxCpuThrottleFrame::OnQuit( wxCommandEvent& WXUNUSED( event ) ) |
58 |
{ |
59 |
delete mTrayIcon; |
60 |
mTrayIcon = 0; |
61 |
|
62 |
Close(TRUE); |
63 |
wxExit(); |
64 |
|
65 |
} |
66 |
|
67 |
void wxCpuThrottleFrame::OnClose( wxCloseEvent& WXUNUSED( event ) ) |
68 |
{ |
69 |
Show(false); |
70 |
} |
71 |
|
72 |
void wxCpuThrottleFrame::SetPosition() |
73 |
{ |
74 |
const int freeBorder = 20; |
75 |
wxSize screenSize = ::wxGetDisplaySize(); |
76 |
wxSize mySize = GetSize(); |
77 |
Move(screenSize.GetWidth()-mySize.GetWidth() - freeBorder, screenSize.GetHeight() - mySize.GetHeight() - freeBorder); |
78 |
} |