/*************************************************************************** * Copyright (C) 2007 by Torben Nielsen * * torben@t-hoerup.dk * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "trayicon.h" #include #include "wxcputhrottleframe.h" enum { Menu_Quit = 100, Menu_About, Menu_Increase, Menu_Decrease, Menu_ShowDialog }; BEGIN_EVENT_TABLE(TrayIcon, wxTaskBarIcon) EVT_MENU(Menu_Quit, TrayIcon::OnQuit) EVT_MENU(Menu_About, TrayIcon::OnAbout) EVT_MENU(Menu_ShowDialog, TrayIcon::OnShowDialog) EVT_MENU(Menu_Increase, TrayIcon::OnIncrease) EVT_MENU(Menu_Decrease, TrayIcon::OnDecrease) EVT_TASKBAR_LEFT_DOWN(TrayIcon::OnLeftClick) END_EVENT_TABLE() TrayIcon::TrayIcon(wxCpuThrottleFrame* parent) : wxTaskBarIcon(), mParent(parent) { } TrayIcon::~TrayIcon() { } wxMenu* TrayIcon::CreatePopupMenu() { wxMenu* menu = new wxMenu(); menu->Append(Menu_ShowDialog, wxT("Show/hide dialog") ); menu->Append(Menu_Increase, wxT("Increase throttle") ); menu->Append(Menu_Decrease, wxT("Decrease throttle") ); menu->Append(Menu_About, wxT("About wxCpuThrottle")); menu->AppendSeparator(); menu->Append(Menu_Quit, wxT("Quit application"), wxT("Terminates wxCpuThrottle") ); if (!mParent->GetWritable()) { menu->Enable(Menu_Increase, false); menu->Enable(Menu_Decrease, false); } return menu; } void TrayIcon::OnQuit( wxCommandEvent& event ) { mParent->OnQuit(/*event*/); } void TrayIcon::OnAbout( wxCommandEvent& WXUNUSED( event ) ) { wxMessageBox( wxT( "wxCpuThrottle by TOU" ), wxT( "About Hello World" ), wxOK | wxICON_INFORMATION, 0 ); } void TrayIcon::OnShowDialog( wxCommandEvent& event ) { ShowDialog(); } void TrayIcon::OnLeftClick(wxTaskBarIconEvent& WXUNUSED(event) ) { ShowDialog(); } void TrayIcon::OnIncrease( wxCommandEvent& WXUNUSED( event ) ) { AcpiParser* parser = mParent->GetParser(); int current = parser->GetCurrentState(); if (current < parser->GetStateCount() -1) parser->SetState( current +1 ); } void TrayIcon::OnDecrease( wxCommandEvent& WXUNUSED( event ) ) { AcpiParser* parser = mParent->GetParser(); int current = parser->GetCurrentState(); if ( current > 0) parser->SetState( current - 1 ); } void TrayIcon::ShowDialog() { mParent->SetPosition(); mParent->Show( !mParent->IsShown() ); if (mParent->IsIconized()) mParent->Iconize( false ); }