5 * Created by Toshi Nagata on 09/07/15.
6 * Copyright 2009 Toshi Nagata. All rights reserved.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation version 2 of the License.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
18 #include "ProgressFrame.h"
21 #include "wx/stattext.h"
26 #include <Carbon/Carbon.h>
29 BEGIN_EVENT_TABLE(ProgressFrame, wxFrame)
30 // EVT_TEXT_ENTER(-1, ConsoleFrame::OnEnterPressed)
31 // EVT_CHAR(ConsoleFrame::OnChar)
32 // EVT_RICHTEXT_RETURN(-1, ConsoleFrame::OnEnterPressed)
35 ProgressFrame::ProgressFrame(const wxString &title, const wxString &mes):
36 wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION)
38 // Vertical sizer containing (1) message text, (2) progress gauge, (3) note text
39 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
41 m_messageText = new wxStaticText(this, -1, wxT("Message"), wxDefaultPosition, wxSize(240, 40), wxST_NO_AUTORESIZE);
42 sizer->Add(m_messageText, 0, wxALL | wxEXPAND, 10); // Can expand horizontally
44 m_progressGauge = new wxGauge(this, -1, 10000, wxDefaultPosition, wxSize(240, 24), wxGA_HORIZONTAL);
45 sizer->Add(m_progressGauge, 0, wxALL | wxEXPAND, 10);
47 wxStaticText *noteText = new wxStaticText(this, -1, wxT("Press ESC to interrupt"), wxDefaultPosition, wxSize(240, 20), wxALIGN_CENTRE | wxST_NO_AUTORESIZE);
48 /* wxFont smallFont(noteText->GetFont());
49 int size = smallFont.GetPointSize();
56 smallFont.SetPointSize(size);
57 noteText->SetFont(smallFont); */
58 noteText->SetFont(*wxSMALL_FONT);
59 sizer->Add(noteText, 0, wxALL | wxEXPAND, 10);
62 m_progressGauge->Pulse();
63 m_messageText->SetLabel(mes);
68 this->SetSizerAndFit(sizer);
73 // ::SetWindowModality(((WindowRef)MacGetWindowRef()), kWindowModalityAppModal, NULL);
77 ProgressFrame::~ProgressFrame()
82 ProgressFrame::SetProgressMessage(const wxString &mes)
84 m_messageText->SetLabel(mes);
86 m_progressGauge->Pulse();
91 ProgressFrame::SetProgressValue(double value)
95 m_progressGauge->Pulse();
97 m_progressGauge->SetValue((int)(value * 10000));
102 ProgressFrame::SetInterruptValue(int value)
104 m_interruptValue = value;
108 ProgressFrame::CheckInterrupt()
110 if (this != NULL && m_interruptValue) {
111 int save = m_interruptValue;
112 m_interruptValue = 0;
120 wxWindow *activeWin = NULL;
124 // activeWin = GetMainFrame()->GetActiveChild();
125 ::wxSafeYield(activeWin);
128 if (::wxGetKeyState(WXK_ESCAPE))