~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/src/batchbuild.h

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
 
3
 * http://www.gnu.org/licenses/gpl-3.0.html
 
4
 */
 
5
 
 
6
#include <scrollingdialog.h>
 
7
#include <manager.h>
 
8
#include <configmanager.h>
 
9
#include <pluginmanager.h>
 
10
#include <cbplugin.h>
 
11
#include <globals.h>
 
12
 
 
13
// Custom window to shutdown the app when closed.
 
14
// used for batch builds only.
 
15
class BatchLogWindow : public wxScrollingDialog
 
16
{
 
17
    public:
 
18
        BatchLogWindow(wxWindow *parent, const wxChar *title)
 
19
            : wxScrollingDialog(parent, -1, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)
 
20
        {
 
21
            wxSize size;
 
22
            size.SetWidth(Manager::Get()->GetConfigManager(_T("message_manager"))->ReadInt(_T("/batch_build_log/width"), wxDefaultSize.GetWidth()));
 
23
            size.SetHeight(Manager::Get()->GetConfigManager(_T("message_manager"))->ReadInt(_T("/batch_build_log/height"), wxDefaultSize.GetHeight()));
 
24
            SetSize(size);
 
25
        }
 
26
        void EndModal(int retCode)
 
27
        {
 
28
            // allowed to close?
 
29
            // find compiler plugin
 
30
            PluginsArray arr = Manager::Get()->GetPluginManager()->GetCompilerOffers();
 
31
            if (arr.GetCount() != 0)
 
32
            {
 
33
                cbCompilerPlugin* compiler = static_cast<cbCompilerPlugin*>(arr[0]);
 
34
                if (compiler && compiler->IsRunning())
 
35
                {
 
36
                    if (cbMessageBox(_("The build is in progress. Are you sure you want to abort it?"),
 
37
                                    _("Abort build?"),
 
38
                                    wxICON_QUESTION | wxYES_NO, this) == wxID_YES)
 
39
                    {
 
40
                        compiler->KillProcess();
 
41
                        while (compiler->IsRunning())
 
42
                        {
 
43
                            wxMilliSleep(100);
 
44
                            Manager::Yield();
 
45
                        }
 
46
                    }
 
47
                    return;
 
48
                }
 
49
            }
 
50
 
 
51
            Manager::Get()->GetConfigManager(_T("message_manager"))->Write(_T("/batch_build_log/width"), (int)GetSize().GetWidth());
 
52
            Manager::Get()->GetConfigManager(_T("message_manager"))->Write(_T("/batch_build_log/height"), (int)GetSize().GetHeight());
 
53
            wxScrollingDialog::EndModal(retCode);
 
54
        }
 
55
};