forked from vslavik/diff-pdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.cpp
More file actions
118 lines (101 loc) · 3.23 KB
/
Copy pathbase.cpp
File metadata and controls
118 lines (101 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <wx/wxprec.h>
#include <wx/filename.h>
#include <wx/textfile.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "base.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
IMPLEMENT_APP(MainApp) // Initializes the MainApp class and tells our program
// to run it
bool MainApp::OnInit()
{
// Create an instance of our frame, or window
MainFrame *MainWin = new MainFrame(_T("diff-pdf"), wxPoint(1, 1), wxSize(400,300));
MainWin->Show(TRUE); // show the window
SetTopWindow(MainWin); // and finally, set it as the main window
return TRUE;
}
BEGIN_EVENT_TABLE ( MainFrame, wxFrame )
EVT_BUTTON ( BUTTON_Close, MainFrame::OnExit ) // Tell the OS to run MainFrame::OnExit when
EVT_BUTTON ( BUTTON_Open1, MainFrame::OnOpen )
EVT_BUTTON ( BUTTON_Open2, MainFrame::OnOpen2 )
END_EVENT_TABLE() // The button is pressed
MainFrame::MainFrame(const wxString &title, const wxPoint &pos, const wxSize
&size): wxFrame((wxFrame*)NULL, - 1, title, pos, size)
{
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(new wxButton(this, BUTTON_Open1, "Open File_1"), 0, 0, 0);
sizer->Add(new wxButton(this, BUTTON_Open2, "Open File_2"), 0, 0, 0);
sizer->Add(new wxButton(this, BUTTON_Close, "close"), 0, 0, 0);
SetSizer(sizer);
//HelloWorld = new wxButton(this, BUTTON_Hello, _T("close"),
// shows a button on this window
// wxDefaultPosition, wxDefaultSize, 0);
}
//
void MainFrame::OnExit( wxCommandEvent& event )
{
Close(TRUE); // Tells the OS to quit running this process
}
const char * filepath1;
const char * filepath2;
char * diff("./diff-pdf --view ");
char cmd[256];
void MainFrame::OnOpen( wxCommandEvent& event )
{
static const wxChar *FILETYPES = _T(
"pdf files|*.pdf|"
"PDF files|*.PDF|"
"All files|*.*"
);
wxFileDialog* openFileDialog =
new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
wxFD_OPEN, wxDefaultPosition);
if ( openFileDialog->ShowModal() == wxID_OK )
{
wxString path1;
path1.append( openFileDialog->GetDirectory() );
path1.append( wxFileName::GetPathSeparator() );
path1.append( openFileDialog->GetFilename() );
filepath1 = path1.mb_str(wxConvUTF8 );
printf("%s\n",filepath1);
strcpy( cmd, diff );
strcat( cmd, filepath1 );
}
}
void MainFrame::OnOpen2( wxCommandEvent& event )
{
static const wxChar *FILETYPES = _T(
"pdf files|*.pdf|"
"PDF files|*.PDF|"
"All files|*.*"
);
wxFileDialog* openFileDialog =
new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
wxFD_OPEN, wxDefaultPosition);
if ( openFileDialog->ShowModal() == wxID_OK )
{
wxString path2;
path2.append( openFileDialog->GetDirectory() );
path2.append( wxFileName::GetPathSeparator() );
path2.append( openFileDialog->GetFilename() );
filepath2 = path2.mb_str(wxConvUTF8 );
printf("%s\n",filepath2);
// char * diff("./diff-pdf --veiw ");
// char cmd[256];
// strcpy( cmd, diff );
// strcat( cmd, filepath1 );
strcat( cmd, " " );
strcat( cmd, filepath2 );
printf("%s\n", cmd);
system(cmd);
}
// const char * ss;
// ss << "./diff-pdf --view " << filepath1 << filepath2;
// system( ss.str().c_str() );
// system("./diff-pdf --view " + filepath1 + filepath2);
}