Skip to content

Latest commit

 

History

History
executable file
·
137 lines (115 loc) · 4.1 KB

CompareFolderPanel.cpp

File metadata and controls

executable file
·
137 lines (115 loc) · 4.1 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* CompareFolderPanel.cpp - Implementation of the CompareFolderPanel class
*
*/
#include "DataTypes.h"
#include "Identifiers.h"
#include "CompareFolderPanel.h"
#include "wx/filedlg.h"
#include "wx/treectrl.h"
#include "Application.h"
using namespace MojoMerge;
CompareFolderPanel::CompareFolderPanel(wxWindow *Parent)
{
// Set member defaults
VerticalSizer = NULL;
TopHorizontalSizer = NULL;
TextBox = NULL;
PickFolderButton = NULL;
// Create the window where all the controls will be placed
Create(Parent, ID_COMPARE_FILE_PANEL);
// Create sizers for arranging the button, combobox, and text controls
VerticalSizer = new wxBoxSizer(wxVERTICAL);
TopHorizontalSizer = new wxBoxSizer(wxHORIZONTAL);
// Create the file selection combo box
TextBox = new wxStaticText(this, ID_FOLDER_TEXT_BOX, wxT(""),
wxDefaultPosition, wxSize(20, 20), wxSUNKEN_BORDER |
wxST_NO_AUTORESIZE);
// Add it to the appropriate sizer
TopHorizontalSizer->Add(TextBox, 1, wxALIGN_CENTRE, 5);
// Create the pick file button
PickFolderButton = new wxButton(this, ID_PICK_FOLDER_BUTTON,
wxT("..."), wxDefaultPosition, wxSize(20, 20), 0);
// Add it to the appropriate sizer
TopHorizontalSizer->Add(PickFolderButton, 0, wxALIGN_CENTRE, 5);
// Add the horizontal sizer to the top of the vertical one
VerticalSizer->Add(TopHorizontalSizer, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5);
// Create the text control
TreeWindow = new wxTreeCtrl(this, ID_FOLDER_TREE_CTRL, wxDefaultPosition,
wxDefaultSize, wxTR_NO_BUTTONS);
// Add text control to sizer
VerticalSizer->Add(TreeWindow, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP, 5);
// Set parameters for sizers to they resize automagically
SetAutoLayout(true);
SetSizer(VerticalSizer);
VerticalSizer->Fit(this);
VerticalSizer->SetSizeHints(this);
}
CompareFolderPanel::~CompareFolderPanel()
{
// All other members are wxWindow based objects and are therefore cleaned
// up automatically upon deletion of their container.
}
void CompareFolderPanel::SetFolder()
{
// Prompt user for a file to open
Folder = wxDirSelector(wxT("Choose a folder to open"));
// Make sure the user didn't cancel
if(!Folder.IsEmpty())
{
TextBox->SetLabel(Folder);
}
}
wxString CompareFolderPanel::GetFolder()
{
// Return the name of the file
return Folder;
}
void CompareFolderPanel::OnPickFolderButton(wxCommandEvent& event)
{
// Let the user choose a file
SetFolder();
}
void CompareFolderPanel::Recompare(FolderHunk *FirstHunk,
DiffFileNumber FolderNumber)
{
/*Hunk *p; // Temporary hunk pointer
uint32 Start, End; // Start and end lines for hunks
// Make sure buffer is valid
if(Buffer)
{
// Clear all styling
FileTextEdit->MarkClearAll();
// Get first hunk in the list
p = FirstHunk;
// Loop through all hunks and mark changes appropriately
while(p)
{
// Get start and end of hunk for this file
Start = p->GetStart(FileNumber);
End = p->GetEnd(FileNumber);
// If End not specified, just highlight the start line
if(End == UNSPECIFIED)
FileTextEdit->MarkInsertAfterLine(Start);
// Else, set the end position appropriately
else
FileTextEdit->MarkChangedLine(Start, End);
// Go to the next hunk
p = p->GetNextHunk();
}
// Fixed a problem with highlighting (see function for more info)
FileTextEdit->BlankLineStyleBugHack();
// Set readonly back to true so user can't edit it
//FileTextEdit->SetReadOnly(true);
}
// Else, report the error
else
wxMessageBox(wxT("File could not be open!"), wxT("Error"), wxOK | wxICON_ERROR);*/
}
wxTreeCtrl *CompareFolderPanel::GetTreeWindow()
{
return TreeWindow;
}
// Event mappings for the file panel
BEGIN_EVENT_TABLE(CompareFolderPanel, wxPanel)
EVT_BUTTON(ID_PICK_FOLDER_BUTTON, CompareFolderPanel::OnPickFolderButton)
END_EVENT_TABLE()