Hugin trunk 0.1
Loading...
Searching...
No Matches
BatchTrayIcon.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
11/*
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
16 *
17 * This software is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public
23 * License along with this software. If not, see
24 * <http://www.gnu.org/licenses/>.
25 *
26 */
27
28#include "BatchTrayIcon.h"
29#include <wx/app.h>
30#include <wx/menu.h>
31#include "PTBatcherGUI.h"
32
33enum
34{
42};
43
55
56// Overridables
58{
59 wxMenu* menu = new wxMenu;
60 menu->Append(ID_SHOWGUI,_("&Show window"));
61 menu->AppendSeparator();
62 bool isRunning=wxGetApp().GetFrame()->IsRunning();
63 menu->Append(ID_START,_("Start batch"));
64 menu->Enable(ID_START,!isRunning);
65 if(wxGetApp().GetFrame()->IsPaused())
66 {
67 menu->Append(ID_PAUSE,_("Continue batch"));
68 }
69 else
70 {
71 menu->Append(ID_PAUSE,_("Pause batch"));
72 };
73 menu->Enable(ID_PAUSE,isRunning);
74 menu->Append(ID_STOP,_("Stop batch"));
75 menu->Enable(ID_STOP,isRunning);
76 menu->AppendSeparator();
77 menu->Append(ID_ADDPROJECT,_("Add project to stitching queue..."));
78 menu->Append(ID_ADDPROJECTASSISTANT,_("Add project to assistant queue..."));
79#ifndef __WXMAC_OSX__
80 /*Mac has built-in quit menu*/
81 menu->AppendSeparator();
82 menu->Append(ID_EXIT, _("E&xit"));
83#endif
84 return menu;
85}
86
87void BatchTaskBarIcon::OnShowGUI(wxCommandEvent& e)
88{
89 wxGetApp().GetFrame()->Show(true);
90 wxGetApp().GetFrame()->Iconize(false);
91 wxGetApp().GetFrame()->UpdateBatchVerboseStatus();
92};
93
94void BatchTaskBarIcon::OnStartBatch(wxCommandEvent& e)
95{
96 wxCommandEvent ev(wxEVT_COMMAND_TOOL_CLICKED ,XRCID("tool_start"));
97 wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(ev);
98};
99
100void BatchTaskBarIcon::OnPauseBatch(wxCommandEvent& e)
101{
102 wxCommandEvent ev(wxEVT_COMMAND_TOOL_CLICKED ,XRCID("tool_pause"));
103 wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(ev);
104};
105
106void BatchTaskBarIcon::OnStopBatch(wxCommandEvent& e)
107{
108 wxCommandEvent ev(wxEVT_COMMAND_TOOL_CLICKED ,XRCID("tool_cancel"));
109 wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(ev);
110};
111
112void BatchTaskBarIcon::OnAddProject(wxCommandEvent& e)
113{
114 wxCommandEvent ev(wxEVT_COMMAND_MENU_SELECTED ,XRCID("menu_add"));
115 wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(ev);
116};
117
119{
120 wxCommandEvent ev(wxEVT_COMMAND_MENU_SELECTED ,XRCID("menu_add_assistant"));
121 wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(ev);
122};
123
124void BatchTaskBarIcon::OnExit(wxCommandEvent& e)
125{
126 wxCommandEvent ev(wxEVT_COMMAND_MENU_SELECTED ,XRCID("menu_exit"));
127 wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(ev);
128};
129
135
136#if defined __WXMSW__ && wxUSE_TASKBARICON_BALLOONS
137// wxMSW, version 2.9 offers a native balloon for the traybar notification
138// we need to implement a own version for the other systems
139#else
140enum
141{
143};
144//declaration of the balloon tool tip
145
148{
149 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK));
151
152 wxStaticText* title = new wxStaticText(this, -1, sTitle);
154 titleFont.SetWeight(wxFONTWEIGHT_BOLD);
155 title->SetFont(titleFont);
156 title->SetBackgroundColour(GetBackgroundColour());
157 mainSizer->Add(title,0,wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
158 wxStaticText* text = new wxStaticText(this, -1, sMessage);
159 text->SetBackgroundColour(GetBackgroundColour());
160 mainSizer->Add(text,1,wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 5);
162 mainSizer->SetSizeHints( this );
163
164 m_timer = new wxTimer(this,TIMER_BALLOON);
165 // here, we try to align the frame to the right bottom corner
166 Center();
167 int iX = 0, iY = 0;
168 GetPosition( &iX, &iY );
169 iX = (iX * 2) - 2;
170 iY = (iY * 2) - 2;
171 Move( iX, iY );
175}
176
181
184{
185 Destroy();
186}
187
189{
190 Destroy();
191};
192
194{
195 Destroy();
196};
197
200{
201 Show(false);
202 Show(true);
204}
205#endif
@ ID_STOP
@ ID_SHOWGUI
@ ID_ADDPROJECTASSISTANT
@ ID_START
@ ID_PAUSE
@ ID_EXIT
@ ID_ADDPROJECT
@ TIMER_BALLOON
definition of tray/task bar icon for PTBatcherGUI
Batch processor for Hugin with GUI.
void OnShowGUI(wxCommandEvent &e)
handler to open window
void OnPauseBatch(wxCommandEvent &e)
handler to pause batch
void OnStartBatch(wxCommandEvent &e)
handler to start batch
BatchTaskBarIcon(wxTaskBarIconType iconType=wxTBI_DEFAULT_TYPE)
void OnLeftButtonDClick(wxTaskBarIconEvent &)
handler if double clicked on taskbar icon, opens window
virtual wxMenu * CreatePopupMenu()
creates the popup menu
void OnAddProjectToAssistant(wxCommandEvent &e)
handler to adding a project to assistant queue
void OnExit(wxCommandEvent &e)
handler to exit PTBatcherGUI
void OnAddProject(wxCommandEvent &e)
handler to adding a project to stitching queue
void OnStopBatch(wxCommandEvent &e)
handler to stop batch
void OnClick(wxMouseEvent &e)
click on the balloon
void showBalloon(unsigned int iTimeout)
display the baloon and run the timer
void OnTimerTick(wxTimerEvent &e)
timer to close window
wxTimer * m_timer
virtual ~TaskBarBalloon()
void OnKeyDown(wxKeyEvent &e)
key down event in the balloon
TaskBarBalloon(wxString sTitle, wxString sMessage)
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41