Debian Codegraph @

CodeLite/progress_dialog.cpp

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : progress_dialog.cpp
6 //
7 // -------------------------------------------------------------------------
8 // A
9 // _____ _ _ _ _
10 // / __ \ | | | | (_) |
11 // | / \/ ___ __| | ___| | _| |_ ___
12 // | | / _ \ / _ |/ _ \ | | | __/ _ )
13 // | \__/\ (_) | (_| | __/ |___| | || __/
14 // \____/\___/ \__,_|\___\_____/_|\__\___|
15 //
16 // F i l e
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25
26 #include "progress_dialog.h"
27 #if wxUSE_GUI
28 #ifdef __WXMSW__
29
30 clProgressDlg::clProgressDlg(wxWindow* parent, const wxString& title, const wxString& msg, int maxValue)
31 : clProgressDlgBase(parent)
32 {
33 SetSizeHints(600, -1);
34 SetTitle(title);
35 m_staticLabel->SetLabel(msg);
36 m_gauge->SetRange(maxValue);
37 GetSizer()->Fit(this);
38 CenterOnParent();
39 Show();
40 wxYieldIfNeeded();
41 }
42
43 clProgressDlg::~clProgressDlg() {}
44
45 bool clProgressDlg::Update(int value, const wxString& msg)
46 {
47 m_staticLabel->SetLabel(msg);
48 m_gauge->SetValue(value);
49
50 if(value % 20 == 0) { wxSafeYield(this, true); }
51 return true;
52 }
53
54 bool clProgressDlg::Pulse(const wxString& msg)
55 {
56 int curval = m_gauge->GetValue();
57 m_gauge->SetValue(curval + 1);
58 if(!msg.IsEmpty()) m_staticLabel->SetLabel(msg);
59 return true;
60 }
61
62 #else // UNIX
63
64 clProgressDlg::clProgressDlg(wxWindow* parent, const wxString& title, const wxString& msg, int maxValue)
65 : wxProgressDialog(title, msg, maxValue, NULL, wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_AUTO_HIDE)
66 {
67 SetSizeHints(400, -1);
68 GetSizer()->Fit(this);
69 CenterOnScreen();
70 }
71
72 clProgressDlg::~clProgressDlg() {}
73
74 bool clProgressDlg::Update(int value, const wxString& msg) { return wxProgressDialog::Update(value, msg, NULL); }
75
76 bool clProgressDlg::Pulse(const wxString& msg) { return wxProgressDialog::Pulse(msg, NULL); }
77 #endif // #if wxUSE_GUI
78 #endif