forked from graysonbridges/Lab12
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawBST.cpp
More file actions
91 lines (70 loc) · 1.86 KB
/
DrawBST.cpp
File metadata and controls
91 lines (70 loc) · 1.86 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
#include "wx/wx.h"
#include "wx/sizer.h"
#include "DrawPanel.h"
#include "ImageLoader.h"
#include "Circle.h"
#include "Line.h"
#include "BinarySearchTree.h"
#include "BinaryTreeIterator.h"
#include "DrawPanel.h"
#include "CD.h"
using CSC2110::CD;
#include "ListArray.h"
using CSC2110::ListArray;
#include "ListArrayIterator.h"
using CSC2110::ListArrayIterator;
#include <iostream>
using namespace std;
class MyApp: public wxApp
{
bool OnInit();
wxFrame* frame;
DrawPanel* drawPane;
public:
};
IMPLEMENT_APP(MyApp)
//int main(int argc, char** argv)
bool MyApp::OnInit()
{
ListArray<CD>* cds = CD::readCDs("cds.txt");
int num_items = cds->size();
cout << num_items << endl;
ListArrayIterator<CD>* iter = cds->iterator();
BinarySearchTree<CD>* bst = new BinarySearchTree<CD>(&CD::compare_items, &CD::compare_keys);
while(iter->hasNext())
{
CD* cd = iter->next();
bst->insert(cd);
}
delete iter;
delete cds;
//BinarySearchTree<CD>* min = bst->minimizeComplete();
BinarySearchTree<CD>* min = bst->minimize();
delete bst;
bst = min;
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
frame = new wxFrame((wxFrame *)NULL, -1, wxT("BST Min Height"), wxPoint(500,500), wxSize(1100,600));
drawPane = new DrawPanel((wxFrame*) frame, bst);
sizer->Add(drawPane, 1, wxEXPAND);
frame->SetSizer(sizer);
frame->SetAutoLayout(true);
frame->Show();
return true;
/*
GTK mess...
Gtk::Main kit(argc, argv);
Gtk::Window win;
win.set_title("BST!");
win.set_position(Gtk::WIN_POS_CENTER);
//the size of the window
int width = 1000;
int height = 500;
win.set_size_request(width, height);
win.set_resizable(false);
DrawPanel pnl(width, height, bst); //needs to know its own dimensions
win.add(pnl);
win.show_all_children();
Gtk::Main::run(win);
*/
// return 0;
}