0
|
1 |
#include <wx/wx.h>
|
|
2 |
#include "MainWindow.hpp"
|
|
3 |
#include "PageList.hpp"
|
|
4 |
|
|
5 |
BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
1
|
6 |
EVT_MENU(ID_MENU_GENERATE, MainWindow::on_generate)
|
0
|
7 |
EVT_MENU(wxID_OPEN, MainWindow::on_open)
|
|
8 |
EVT_MENU(wxID_CLOSE, MainWindow::on_quit)
|
|
9 |
END_EVENT_TABLE()
|
|
10 |
|
|
11 |
MainWindow::MainWindow()
|
|
12 |
:wxFrame(0, wxID_ANY, _("wxDjvuMaker"), wxDefaultPosition,
|
|
13 |
wxSize(200,200))
|
|
14 |
{
|
|
15 |
create_menus();
|
|
16 |
|
|
17 |
wxBoxSizer *s = new wxBoxSizer(wxVERTICAL);
|
|
18 |
|
|
19 |
_pagelist = new PageList(this);
|
|
20 |
|
|
21 |
s->Add(_pagelist);
|
|
22 |
}
|
|
23 |
|
|
24 |
|
|
25 |
void
|
|
26 |
MainWindow::create_menus()
|
|
27 |
{
|
|
28 |
_menubar = new wxMenuBar();
|
|
29 |
_menufile = new wxMenu();
|
|
30 |
|
|
31 |
_menufile->Append(wxID_OPEN, _("&Open"));
|
|
32 |
_menufile->Append(wxID_CLOSE, _("&Quit"));
|
|
33 |
|
1
|
34 |
wxMenu *menuplay = new wxMenu();
|
|
35 |
menuplay->Append(ID_MENU_GENERATE, _("&Generate"));
|
|
36 |
|
0
|
37 |
_menubar->Append(_menufile, _("&File"));
|
1
|
38 |
_menubar->Append(menuplay, _("&Document"));
|
0
|
39 |
|
|
40 |
SetMenuBar(_menubar);
|
|
41 |
}
|
|
42 |
|
|
43 |
void
|
|
44 |
MainWindow::on_open(wxCommandEvent &event)
|
|
45 |
{
|
|
46 |
wxFileDialog fd(this, _("Add pages"), wxT(""),
|
|
47 |
wxT(""), wxT("*.jpg"), wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST
|
|
48 |
| wxFD_PREVIEW);
|
|
49 |
|
|
50 |
if (fd.ShowModal() == wxID_OK)
|
|
51 |
{
|
|
52 |
wxArrayString files;
|
|
53 |
fd.GetFilenames(files);
|
|
54 |
_pagelist->add_files(files);
|
|
55 |
}
|
|
56 |
}
|
|
57 |
|
|
58 |
void
|
|
59 |
MainWindow::on_quit(wxCommandEvent &event)
|
|
60 |
{
|
|
61 |
Close();
|
|
62 |
}
|
1
|
63 |
|
|
64 |
void
|
|
65 |
MainWindow::on_generate(wxCommandEvent &event)
|
|
66 |
{
|
|
67 |
_pagelist->generate(wxT("out.djvu"));
|
|
68 |
}
|