[Scummvm-cvs-logs] CVS: scummex descumm.h,1.2,1.3 image.cpp,1.10,1.11 image.h,1.7,1.8 resource.cpp,1.14,1.15 resource.h,1.7,1.8 scummex.cpp,1.18,1.19 scummex.h,1.10,1.11 scummsys.h,1.1.1.1,1.2 sound.h,1.3,1.4 wxwindows.cpp,1.14,1.15 wxwindows.h,1.5,1.6

Max Horn fingolfin at users.sourceforge.net
Mon Sep 22 17:48:16 CEST 2003


Update of /cvsroot/scummvm/scummex
In directory sc8-pr-cvs1:/tmp/cvs-serv16396

Modified Files:
	descumm.h image.cpp image.h resource.cpp resource.h 
	scummex.cpp scummex.h scummsys.h sound.h wxwindows.cpp 
	wxwindows.h 
Log Message:
cleanup, cleanup, and lots of bug fixes (like, those _gui variables were never inited... nobody noticed because the class had no member vars... still this was pure evil.. and it would be really nice if there was some design work behind the whole thing (like GUI_wxWindows vs. MainWindow, which have no clear distribution of responsibilities - both act upon the same (global!) data. Evil. Using the MVC model would be nice)

Index: descumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/descumm.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- descumm.h	19 Sep 2003 19:57:07 -0000	1.2
+++ descumm.h	23 Sep 2003 00:47:23 -0000	1.3
@@ -113,8 +113,6 @@
 
 class DeScumm {
 private:
-	GUI_wxWindows *_gui;
-
 	char *strecpy(char *buf, const char *src);
 	int get_curoffs();
 	int get_byte();

Index: image.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/image.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- image.cpp	22 Sep 2003 21:31:18 -0000	1.10
+++ image.cpp	23 Sep 2003 00:47:23 -0000	1.11
@@ -109,16 +109,16 @@
 int Image::drawBoxes(BlockTable *_blockTable, int id, File& _input, int newWindow) {
 	int nBox, RMHDindex, width, height, v8 = 0;
 
-	RMHDindex = _resource->findBlock(0, _blockTable, id, "RMHD", "-1");
+	RMHDindex = _resource->findBlock(0, _blockTable, id, "RMHD", NULL);
 	width = _blockTable[RMHDindex].width;
 	height = _blockTable[RMHDindex].height;
 
 	if (newWindow == 0) {
-		if ( _resource->findBlock(0, _blockTable, id, "IMAG", "-1") != -1) {
+		if ( _resource->findBlock(0, _blockTable, id, "IMAG", NULL) != -1) {
 			v8 = 1;
-			id = _resource->findBlock(1, _blockTable, id, "BOXD", "-1");
+			id = _resource->findBlock(1, _blockTable, id, "BOXD", NULL);
 		} else {
-			id = _resource->findBlock(0, _blockTable, id, "BOXD", "-1");
+			id = _resource->findBlock(0, _blockTable, id, "BOXD", NULL);
 		}
 	}
 	
@@ -182,7 +182,7 @@
 	int x = 0, y = 0;
 	byte *dst, *dstorg, *chunk_buffer;
 
-	index = _resource->findBlock(0, _blockTable, id, "NPAL", "AHDR", "-1");
+	index = _resource->findBlock(0, _blockTable, id, "NPAL", "AHDR", NULL);
 	if (_blockTable[index].blockTypeID == AHDR) {
 		_input.seek(_blockTable[index].offset + 14, SEEK_SET);
 	} else {
@@ -236,11 +236,11 @@
 	int RMHDindex, CLUTindex, SMAPindex, TRNSindex;
 	
 	if (_blockTable[id].blockTypeID == BM) {
-		RMHDindex = _resource->findBlock(0, _blockTable, id, "HD", "-1");
+		RMHDindex = _resource->findBlock(0, _blockTable, id, "HD", NULL);
 	} else if (_blockTable[id-1].blockTypeID == IMHD) {
 		RMHDindex = id-1;
 	} else {
-		RMHDindex = _resource->findBlock(0, _blockTable, id, "RMHD", "-1");
+		RMHDindex = _resource->findBlock(0, _blockTable, id, "RMHD", NULL);
 	}
 	_width = _blockTable[RMHDindex].width;
 	_height = _blockTable[RMHDindex].height;
@@ -248,13 +248,13 @@
 	_gui->DisplayImage("Room Image", _width, _height, IMAGE_BOXES);
 	
 	if (_blockTable[id].blockTypeID != BM) {
-		TRNSindex = _resource->findBlock(0, _blockTable, id, "TRNS", "-1");
+		TRNSindex = _resource->findBlock(0, _blockTable, id, "TRNS", NULL);
 		_transp = _blockTable[TRNSindex].trans;
-		CLUTindex = _resource->findBlock(0, _blockTable, id, "CLUT", "APAL", "NPAL", "-1");
+		CLUTindex = _resource->findBlock(0, _blockTable, id, "CLUT", "APAL", "NPAL", NULL);
 		_input.seek(_blockTable[CLUTindex].offset + 8, SEEK_SET);
 	} else {
 		_transp = 260;
-		CLUTindex = _resource->findBlock(0, _blockTable, id, "PA", "-1");
+		CLUTindex = _resource->findBlock(0, _blockTable, id, "PA", NULL);
 		_input.seek(_blockTable[CLUTindex].offset + 8, SEEK_SET);
 	}
 
@@ -265,13 +265,13 @@
 	}
 	
 	if (_blockTable[id].blockTypeID != BM) {
-		SMAPindex = _resource->findBlock(1, _blockTable, id, "SMAP", "-1");
+		SMAPindex = _resource->findBlock(1, _blockTable, id, "SMAP", NULL);
 	} else {
 		SMAPindex = id;
 	}
 
 	if (_blockTable[id].blockTypeID == IMAG) {
-		SMAPindex = _resource->findBlock(1, _blockTable, SMAPindex, "OFFS", "-1");
+		SMAPindex = _resource->findBlock(1, _blockTable, SMAPindex, "OFFS", NULL);
 	}
 
 	_offsets = new uint32[_width/8];
@@ -301,18 +301,18 @@
 {
 	int RMHDindex, CLUTindex, SMAPindex, TRNSindex;
 
-	RMHDindex = _resource->findBlock(1, _blockTable, id, "IMHD", "-1");
+	RMHDindex = _resource->findBlock(1, _blockTable, id, "IMHD", NULL);
 	
 	_width = _blockTable[RMHDindex].width;
 	_height = _blockTable[RMHDindex].height;
 	
 	_gui->DisplayImage("Object", _width, _height);
 	
-	TRNSindex = _resource->findBlock(0, _blockTable, id, "TRNS", "-1");
+	TRNSindex = _resource->findBlock(0, _blockTable, id, "TRNS", NULL);
 
 	_transp = _blockTable[TRNSindex].trans;
 	
-	CLUTindex = _resource->findBlock(0, _blockTable, id, "CLUT", "APAL", "NPAL", "-1");
+	CLUTindex = _resource->findBlock(0, _blockTable, id, "CLUT", "APAL", "NPAL", NULL);
 
 	_input.seek(_blockTable[CLUTindex].offset + 8, SEEK_SET);
 
@@ -322,7 +322,7 @@
 		_rgbTable[j].blue = _input.readByte();	// blue
 	}
 	
-	SMAPindex = _resource->findBlock(1, _blockTable, id, "SMAP", "-1");
+	SMAPindex = _resource->findBlock(1, _blockTable, id, "SMAP", NULL);
 
 	_offsets = new uint32[_width/8];
 	

Index: image.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/image.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- image.h	22 Sep 2003 18:25:16 -0000	1.7
+++ image.h	23 Sep 2003 00:47:23 -0000	1.8
@@ -49,7 +49,6 @@
 	int _width;
 	int _height;
 	Resource *_resource;
-	GUI_wxWindows *_gui;
 	Codec37Decoder _codec37;
 	Codec47Decoder _codec47;
 

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/resource.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- resource.cpp	22 Sep 2003 19:47:58 -0000	1.14
+++ resource.cpp	23 Sep 2003 00:47:23 -0000	1.15
@@ -877,13 +877,13 @@
 
 	va_start(arg_ptr, id);
 
-	while (strcmp(test = (va_arg(arg_ptr, char *)) , "-1")) {
+	while ((test = (va_arg(arg_ptr, char *)))) {
 		id = tempid;
 		if (direction == 0) {
 			id -= 1;
 			while (id >= 0) {
 				if(strstr(test, _blockTable[id].blockName)) {
-					return id;
+					goto the_end;
 				}
 				id--;
 			}
@@ -891,16 +891,18 @@
 
 		if (direction == 1) {
 			id += 1;
+			// FIXME: Loop till infinity?? that can hardly be correct
 			while (1) {
 				if(strstr(test, _blockTable[id].blockName)) {
-					return id;
+					goto the_end;
 				}
 				id++;
 			}
 		}
 	}
 	
+the_end:
 	va_end(arg_ptr);
-	return -1;
+	return test ? id : -1;
 }
 

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/resource.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- resource.h	22 Sep 2003 19:47:58 -0000	1.7
+++ resource.h	23 Sep 2003 00:47:23 -0000	1.8
@@ -210,7 +210,6 @@
 
 class Resource {
 private:
-	GUI_wxWindows *_gui;
 	int stopflag;	
 public:
 	Resource();

Index: scummex.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummex.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- scummex.cpp	22 Sep 2003 23:43:29 -0000	1.18
+++ scummex.cpp	23 Sep 2003 00:47:23 -0000	1.19
@@ -26,9 +26,9 @@
 #include "descumm.h"
 
 ScummEX::ScummEX() {
-    _image = new Image();
-    _sound = new Sound();
-    _resource = new Resource();
+	_image = new Image();	// FIXME - where is this deleted?
+	_sound = new Sound();
+	_resource = new Resource();
 }
 
 void ScummEX::getFileType(const char *filename) {
@@ -45,7 +45,7 @@
 	sprintf(buf, "ScummEX - %s", filename);
 	_gui->SetTitle(buf);
 
-	_gui->EnableToolbarTool(ID_Close);
+	_gui->EnableToolbarTool(wxID_CLOSE);
 	_gui->EnableToolbarTool(ID_FileInfo);
 
 	_input.read(&tag, 4);
@@ -104,7 +104,7 @@
 	}
 
 	_gui->SetTitle("ScummEX");
-	_gui->DisableToolbarTool(ID_Close);
+	_gui->DisableToolbarTool(wxID_CLOSE);
 	_gui->DisableToolbarTool(ID_FileInfo);
 	_gui->DisplayDialog("Unknown file type!", "Error");
 }
@@ -257,37 +257,37 @@
 
 void ScummEX::paletteDraw()
 {
-	_image = new Image();
+	_image = new Image();	// FIXME - where is this deleted?
 	_image->drawPalette(_blockTable, _blockId, _input);
 }
 
 void ScummEX::bgDraw()
 {
-	_image = new Image();
+	_image = new Image();	// FIXME - where is this deleted?
 	_image->drawBG(_input, _blockTable, _blockId);
 }
 
 void ScummEX::SmushFrameDraw()
 {
-	_image = new Image();
+	_image = new Image();	// FIXME - where is this deleted?
 	_image->drawSmushFrame(_blockTable, _blockId, _input);
 }
 
 void ScummEX::objectDraw()
 {
-	_image = new Image();
+	_image = new Image();	// FIXME - where is this deleted?
 	_image->drawObject(_input, _blockTable, _blockId);
 }
 
 void ScummEX::boxesDraw()
 {
-	_image = new Image();
+	_image = new Image();	// FIXME - where is this deleted?
 	_image->drawBoxes(_blockTable, _blockId, _input);
 }
 
 void ScummEX::boxesDrawOverlay()
 {
-	_image = new Image();
+	_image = new Image();	// FIXME - where is this deleted?
 	_image->drawBoxes(_blockTable, _blockId, _input, 0);
 }
 
@@ -411,6 +411,6 @@
 	ScummEX *_scummex;
 	_scummex = new ScummEX();
 
-    return 0;
+	return 0;
 
 }*/

Index: scummex.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummex.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- scummex.h	22 Sep 2003 23:43:29 -0000	1.10
+++ scummex.h	23 Sep 2003 00:47:23 -0000	1.11
@@ -41,7 +41,6 @@
 	Image *_image;
 	Sound *_sound;
 	Resource *_resource;
-	GUI_wxWindows *_gui;
 
 public:
 	int _scummVersion;

Index: scummsys.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummsys.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- scummsys.h	18 Sep 2003 16:26:58 -0000	1.1.1.1
+++ scummsys.h	23 Sep 2003 00:47:23 -0000	1.2
@@ -285,17 +285,4 @@
 	}
 #endif
 
-
-/* Initialized operator new */
-// FIXME - get rid of these new/delete overrides!!! They conflict with the
-// Standard C++ library, and they are only there to support lazy programmers anyway.
-#ifndef __PALM_OS__
-void * operator new(size_t size);
-void operator delete(void *ptr);
-// Temporary hack until we fully remove the new/delete operators:
-// Since 'new' now returns a memory block inited to 0xE7E7E7E7 we might
-// get some invocations of free() with that param. We check for those here.
-// That allows us to set a debugger breakpoint to catch it.
-#endif
-
 #endif

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/sound.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sound.h	21 Sep 2003 00:45:16 -0000	1.3
+++ sound.h	23 Sep 2003 00:47:23 -0000	1.4
@@ -40,7 +40,6 @@
 private:
 	Mixer *_mixer;
 	Resource *_resource;
-	GUI_wxWindows *_gui;
 
 	static int32 Sound::compDecode(byte * src, byte * dst);
 

Index: wxwindows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- wxwindows.cpp	22 Sep 2003 19:47:59 -0000	1.14
+++ wxwindows.cpp	23 Sep 2003 00:47:23 -0000	1.15
@@ -25,56 +25,61 @@
 #include "scummex.h"
 #include "icons.h"
 
-wxTreeItemId iter[11], itemid;
-wxTreeCtrl *tree;
+wxTreeItemId iter[11];
+wxTreeCtrl *tree = 0;
 wxStaticText *TypeLabel, *OffsetLabel, *SizeLabel, *DescriptionLabel;
 wxStaticText *SpecLabel[6];
-wxButton *SpecButton1, *SpecButton2;
-MainWindow *frame;
-ImageWindow *imageFrame;
-ScummEX *_scummex;
-wxImage *image;
-const char *file, *filename;
-wxTextCtrl *hexdata;
-wxToolBar *ToolBar;
+wxButton *SpecButton1 = 0, *SpecButton2 = 0;
+ScummEX *_scummex = 0;
+wxImage *image = 0;
+const char *g_filename = 0;
+wxTextCtrl *hexdata = 0;
+wxToolBar *ToolBar = 0;
+
+GUI_wxWindows *_gui = 0;
+
 
 IMPLEMENT_APP(GUI_wxWindows)
 
-GUI_wxWindows::GUI_wxWindows() {
+GUI_wxWindows::GUI_wxWindows()
+	: _mainWindow(0), _imageWindow(0) {
 	_scummex = new ScummEX();
+	_gui = this; // FIXME - ugly quick workaround for previously broken code
 }
 
 bool GUI_wxWindows::OnInit()
 {
-	frame = new MainWindow("ScummEX", wxPoint(-1,-1),
+printf("GUI_wxWindows::OnInit\n");
+	_mainWindow = new MainWindow("ScummEX", wxPoint(-1,-1),
                 wxSize(640,480));
 
-	frame->Connect( ID_Quit, wxEVT_COMMAND_MENU_SELECTED,
+	_mainWindow->Connect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &MainWindow::OnQuit );
-	frame->Connect( ID_About, wxEVT_COMMAND_MENU_SELECTED,
+	_mainWindow->Connect( wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &MainWindow::OnAbout );
-	frame->Connect( ID_Open, wxEVT_COMMAND_MENU_SELECTED,
+	_mainWindow->Connect( wxID_OPEN, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &MainWindow::OnOpen );
-	frame->Connect( ID_Browse, wxEVT_COMMAND_BUTTON_CLICKED,
+	_mainWindow->Connect( ID_Browse, wxEVT_COMMAND_BUTTON_CLICKED,
 		(wxObjectEventFunction) &MainWindow::OnOpen );
-	frame->Connect( ID_View, wxEVT_COMMAND_MENU_SELECTED,
+	_mainWindow->Connect( ID_View, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &ScummEX::fileView );
-	frame->Connect( ID_Dump, wxEVT_COMMAND_MENU_SELECTED,
+	_mainWindow->Connect( ID_Dump, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &GUI_wxWindows::BlockDump );
-	frame->Connect( Tree, wxEVT_COMMAND_TREE_SEL_CHANGING,
+	_mainWindow->Connect( Tree, wxEVT_COMMAND_TREE_SEL_CHANGING,
 		(wxObjectEventFunction) &MainWindow::OnSelChanged );
-	frame->Connect( ID_Help, wxEVT_COMMAND_MENU_SELECTED,
+	_mainWindow->Connect( wxID_HELP, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &MainWindow::OnHelp );
-	frame->Connect( ID_FileInfo, wxEVT_COMMAND_MENU_SELECTED,
+	_mainWindow->Connect( ID_FileInfo, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &ScummEX::FileInfo );
 		
-	frame->Show(TRUE);
-	SetTopWindow(frame);
+	_mainWindow->Show(TRUE);
+	SetTopWindow(_mainWindow);
 	return TRUE;
 }
 
 void GUI_wxWindows::SetTitle(char *title) {
-	frame->SetTitle(title);
+printf("GUI_wxWindows::SetTitle(%s)\n", title);
+	_mainWindow->SetTitle(title);
 }
 
 void MainWindow::OnHelp(wxCommandEvent& WXUNUSED(event)) {
@@ -108,7 +113,7 @@
 	"The Curse of Monkey Island"
 	};
 	
-	wxSingleChoiceDialog *dialog = new wxSingleChoiceDialog(frame, "Please select the correct game", "Scumm version selection", 22, games, NULL, wxOK|wxCANCEL|wxCENTRE, wxDefaultPosition);
+	wxSingleChoiceDialog *dialog = new wxSingleChoiceDialog(_mainWindow, "Please select the correct game", "Scumm version selection", 22, games, NULL, wxOK|wxCANCEL|wxCENTRE, wxDefaultPosition);
 	if (dialog->ShowModal() == wxID_OK) {
 		choice = dialog->GetSelection();
 		switch (choice) {
@@ -151,7 +156,7 @@
 	char msg[512];
 	const char *fname;
 	const char *fpath;
-	wxFileName *filename = new wxFileName(file);
+	wxFileName *filename = new wxFileName(g_filename);
 	
 	fname = filename->GetFullName();
 	fpath = filename->GetFullPath();
@@ -162,40 +167,40 @@
 	strcat(msg, buf);
 	sprintf(buf, "XOR byte: \t %d (0x%02X)\n", encbyte, encbyte);
 	strcat(msg, buf);
-	wxMessageBox(msg, "File Info", wxOK, frame);
+	wxMessageBox(msg, "File Info", wxOK, _mainWindow);
 }
 
 void GUI_wxWindows::BlockDump() {
-    wxFileDialog *dialog = new wxFileDialog(frame, "Please select an output file.", "", "",
-        "*",
-        wxSAVE);
+	wxFileDialog *dialog = new wxFileDialog(_mainWindow, "Please select an output file.", "", "",
+		"*",
+		wxSAVE);
 	if (dialog->ShowModal() == wxID_OK) {
-		filename = (const char*)dialog->GetPath();
+		const char *filename = (const char*)dialog->GetPath();
 		_scummex->FileDump(filename);
 	}
-
+	
 }
-
+	
 void GUI_wxWindows::SaveSOU() {
-    wxFileDialog *dialog = new wxFileDialog(frame, "Please select an output file.", "", "",
-        "*",
-        wxSAVE);
+	wxFileDialog *dialog = new wxFileDialog(_mainWindow, "Please select an output file.", "", "",
+		"*",
+		wxSAVE);
 	if (dialog->ShowModal() == wxID_OK) {
-		filename = (const char*)dialog->GetPath();
+		const char *filename = (const char*)dialog->GetPath();
 		_scummex->iMUSEDump(filename);
 	}
-
+	
 }
-
+	
 void GUI_wxWindows::SaveiMUSE() {
-    wxFileDialog *dialog = new wxFileDialog(frame, "Please select an output file.", "", "",
-        "*",
-        wxSAVE);
+	wxFileDialog *dialog = new wxFileDialog(_mainWindow, "Please select an output file.", "", "",
+		"*",
+		wxSAVE);
 	if (dialog->ShowModal() == wxID_OK) {
-		filename = (const char*)dialog->GetPath();
+		const char *filename = (const char*)dialog->GetPath();
 		_scummex->iMUSEDump(filename);
 	}
-
+	
 }
 
 void GUI_wxWindows::PutPixel(int x, int y, int red, int green, int blue) {
@@ -203,40 +208,40 @@
 }
 
 void GUI_wxWindows::SaveImage() {
-    wxFileDialog *dialog = new wxFileDialog(imageFrame, "Please select an output file.", "", "",
-        "*",
-        wxSAVE);
+	wxFileDialog *dialog = new wxFileDialog(_imageWindow, "Please select an output file.", "", "",
+		"*",
+		wxSAVE);
 	if (dialog->ShowModal() == wxID_OK) {
-		filename = (const char*)dialog->GetPath();
+		const char *filename = (const char*)dialog->GetPath();
 		image->SaveFile(filename, wxBITMAP_TYPE_BMP);
 	}
 }
 
 void GUI_wxWindows::DisplayImage(char* title, int width, int height, byte flags) {
-	imageFrame = new ImageWindow(title, wxPoint(-1,-1), wxSize(width, height), flags);
+	_imageWindow = new ImageWindow(_mainWindow, title, wxPoint(-1,-1), wxSize(width, height), flags);
 
-	imageFrame->Connect( Viewer_Quit, wxEVT_COMMAND_MENU_SELECTED,
+	_imageWindow->Connect( Viewer_Quit, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &ImageWindow::OnQuit );
-	imageFrame->Connect( ID_BMP, wxEVT_COMMAND_MENU_SELECTED,
+	_imageWindow->Connect( ID_BMP, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &GUI_wxWindows::SaveImage );
-	imageFrame->Connect( ID_Boxes, wxEVT_COMMAND_MENU_SELECTED,
+	_imageWindow->Connect( ID_Boxes, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &ScummEX::boxesDrawOverlay );
-	imageFrame->Connect( ID_ImageWindow, wxEVT_CLOSE_WINDOW,
+	_imageWindow->Connect( ID_ImageWindow, wxEVT_CLOSE_WINDOW,
 		(wxObjectEventFunction) &ImageWindow::OnQuit );
 }
 
 void GUI_wxWindows::DrawImage() {
-	imageFrame->DrawImage();
+	_imageWindow->DrawImage();
 }
 
 void GUI_wxWindows::UpdateImage() {
 	wxBitmap bitmap = wxBitmap(image);
-	imageFrame->_sbmp->SetBitmap(bitmap);
-	imageFrame->Refresh();
+	_imageWindow->_sbmp->SetBitmap(bitmap);
+	_imageWindow->Refresh();
 }
 
-ImageWindow::ImageWindow(const wxString& title, const wxPoint& pos, const wxSize& size, byte flags)
-	: wxFrame(frame,ID_ImageWindow,title,pos,size, wxDEFAULT_FRAME_STYLE & (wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION))
+ImageWindow::ImageWindow(MainWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, byte flags)
+	: wxFrame(parent,ID_ImageWindow,title,pos,size, wxDEFAULT_FRAME_STYLE & (wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION))
 {
 	wxMenuBar *menuBar = new wxMenuBar;
 	wxMenu *menuFile = new wxMenu;
@@ -282,7 +287,7 @@
 
 void GUI_wxWindows::DisplayViewer(char *title, int width, int height, char *text) {
 
-	ViewerWindow *viewerFrame = new ViewerWindow(title, text, wxPoint(50,50), wxSize(width, height));
+	ViewerWindow *viewerFrame = new ViewerWindow(_mainWindow, title, text, wxPoint(50,50), wxSize(width, height));
 
 	viewerFrame->Connect( Viewer_Quit, wxEVT_COMMAND_MENU_SELECTED,
 		(wxObjectEventFunction) &ViewerWindow::OnQuit );
@@ -294,8 +299,8 @@
 	hexdata->AppendText(text);
 }
 
-ViewerWindow::ViewerWindow(const wxString& title, const wxString& text, const wxPoint& pos, const wxSize& size)
-	: wxFrame(frame, ID_ViewerWindow, title, pos, size)
+ViewerWindow::ViewerWindow(MainWindow *parent, const wxString& title, const wxString& text, const wxPoint& pos, const wxSize& size)
+	: wxFrame(parent, ID_ViewerWindow, title, pos, size)
 {
 	wxMenuBar *menuBar = new wxMenuBar;
 	wxMenu *menuFile = new wxMenu;
@@ -320,7 +325,7 @@
 }
 
 void GUI_wxWindows::DisplayDialog(char *message, char *title) {
-	wxMessageBox(message, title, wxOK, frame);
+	wxMessageBox(message, title, wxOK, _mainWindow);
 }
 
 void GUI_wxWindows::EnableToolbarTool(int tool) {
@@ -421,15 +426,16 @@
 
 void GUI_wxWindows::add_tree_elements(char *itemName, int blockid, int level, int type) {
 
+	wxTreeItemId itemid;
 	assert(level <= 10);
 	itemid = iter[level] = tree->AppendItem(iter[level-1], itemName, -1, -1, new TreeItemData(blockid, type));
 
 	if (type < 200) {
-			tree->SetItemImage(itemid, blocksInfo[type].iconid);
-			tree->SetItemImage(itemid, blocksInfo[type].iconid, wxTreeItemIcon_Selected);
+		tree->SetItemImage(itemid, blocksInfo[type].iconid);
+		tree->SetItemImage(itemid, blocksInfo[type].iconid, wxTreeItemIcon_Selected);
 	} else {
-			tree->SetItemImage(itemid, oldBlocksInfo[type-200].iconid);
-			tree->SetItemImage(itemid, oldBlocksInfo[type-200].iconid, wxTreeItemIcon_Selected);
+		tree->SetItemImage(itemid, oldBlocksInfo[type-200].iconid);
+		tree->SetItemImage(itemid, oldBlocksInfo[type-200].iconid, wxTreeItemIcon_Selected);
 	}
 	
 	if (blockid == 1) {
@@ -499,13 +505,13 @@
 	wxMenuBar *menuBar = new wxMenuBar;
 	wxMenu *menuFile = new wxMenu;
 	
-	wxMenuItem *OpenItem = new wxMenuItem(menuFile, ID_Open, "Open", "Open resource file", wxITEM_NORMAL, NULL );
+	wxMenuItem *OpenItem = new wxMenuItem(menuFile, wxID_OPEN, "Open...", "Open resource file", wxITEM_NORMAL, NULL );
 	OpenItem->SetBitmap(OpenIcon);
 	menuFile->Append(OpenItem);
 	
 	menuFile->AppendSeparator();
 	
-	wxMenuItem *QuitItem = new wxMenuItem(menuFile, ID_Quit, "Exit", "Exit ScummEX", wxITEM_NORMAL, NULL );
+	wxMenuItem *QuitItem = new wxMenuItem(menuFile, wxID_EXIT, "Exit", "Exit ScummEX", wxITEM_NORMAL, NULL );
 	QuitItem->SetBitmap(ExitIcon);
 	menuFile->Append(QuitItem);
 
@@ -519,8 +525,8 @@
 	menuBar->Append(menuTools, "&Tools");
 
 	wxMenu *menuHelp = new wxMenu;
-	menuHelp->Append(ID_Help, "Contents");
-	menuHelp->Append(ID_About,"About...");
+	menuHelp->Append(wxID_HELP, "Contents");
+	menuHelp->Append(wxID_ABOUT,"About...");
 	menuBar->Append(menuHelp, "&Help");
 	
 	SetMenuBar(menuBar);
@@ -531,21 +537,21 @@
 	
 	ToolBar->SetToolBitmapSize(wxSize(16, 16));
 	
-	ToolBar->AddTool(ID_Open, "Open", OpenIcon, wxNullBitmap, wxITEM_NORMAL, "Open", "Open resource file", NULL);
-	ToolBar->AddTool(ID_Close, "Close", CloseIcon, wxNullBitmap, wxITEM_NORMAL, "Close", "Close resource file", NULL);
-	ToolBar->EnableTool(ID_Close, FALSE);
+	ToolBar->AddTool(wxID_OPEN, "Open...", OpenIcon, wxNullBitmap, wxITEM_NORMAL, "Open...", "Open resource file", NULL);
+	ToolBar->AddTool(wxID_CLOSE, "Close", CloseIcon, wxNullBitmap, wxITEM_NORMAL, "Close", "Close resource file", NULL);
+	ToolBar->EnableTool(wxID_CLOSE, FALSE);
 	ToolBar->AddTool(ID_FileInfo, "File Info", FileIcon, wxNullBitmap, wxITEM_NORMAL, "File Info", "Show File Info", NULL);
 	ToolBar->EnableTool(ID_FileInfo, FALSE);
-	ToolBar->AddTool(ID_Quit, "Exit", ExitIcon, wxNullBitmap, wxITEM_NORMAL, "Exit", "Exit ScummEX", NULL);
+	ToolBar->AddTool(wxID_EXIT, "Exit", ExitIcon, wxNullBitmap, wxITEM_NORMAL, "Exit", "Exit ScummEX", NULL);
 	ToolBar->AddSeparator();
 	ToolBar->AddTool(ID_Dump, "File Dump", SaveIcon, wxNullBitmap, wxITEM_NORMAL, "File Dump", "Dump block to disk", NULL);
 	ToolBar->EnableTool(ID_Dump, FALSE);
-	ToolBar->AddTool(ID_View, "Hex Viewer", HexIcon, wxNullBitmap, wxITEM_NORMAL, "Hex Viewer", "View block as hex", NULL);
+	ToolBar->AddTool(ID_View, "Hex Viewer...", HexIcon, wxNullBitmap, wxITEM_NORMAL, "Hex Viewer...", "View block as hex", NULL);
 	ToolBar->EnableTool(ID_View, FALSE);
-	ToolBar->AddTool(Button_Options, "Options", OptionsIcon, wxNullBitmap, wxITEM_NORMAL, "Options", "Options", NULL);
+	ToolBar->AddTool(Button_Options, "Options...", OptionsIcon, wxNullBitmap, wxITEM_NORMAL, "Options...", "Options", NULL);
 	ToolBar->EnableTool(Button_Options, FALSE);
 	ToolBar->AddSeparator();
-	ToolBar->AddTool(ID_Help, "Help", HelpIcon, wxNullBitmap, wxITEM_NORMAL, "Help", "View help", NULL);
+	ToolBar->AddTool(wxID_HELP, "Help", HelpIcon, wxNullBitmap, wxITEM_NORMAL, "Help", "View help", NULL);
 	ToolBar->Realize();
 	
 	panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, "panel");
@@ -847,8 +853,8 @@
 	searchpanel->SetAutoLayout( true );
 	searchpanel->SetSizer( SearchPanelSizer );	
 	
-    	panel->SetAutoLayout( TRUE );
-    	panel->SetSizer( RootSizer );
+	panel->SetAutoLayout( TRUE );
+	panel->SetSizer( RootSizer );
 
 	CreateStatusBar();
 	SetStatusText("Ready.");
@@ -871,18 +877,21 @@
 
 void MainWindow::OnOpen(wxCommandEvent& WXUNUSED(event))
 {
-    wxFileDialog *dialog = new wxFileDialog(frame, "Please select an input file.", "", "",
-        "All Supported Files|*|Main Resource Files|*.001;*.la1;*.la2;*.lab;*.lfl;*.lec;*.sm1|Directory Files|*.000;*.la0;*.lfl;*.sm0",
-        wxOPEN);
+	wxFileDialog *dialog = new wxFileDialog(this, "Please select an input file.", "", "",
+		"All Supported Files|*|"
+		"Main Resource Files|*.001;*.la1;*.la2;*.lab;*.lfl;*.lec;*.sm1|"
+		"Directory Files|*.000;*.la0;*.lfl;*.sm0",
+		wxOPEN);
 	if (dialog->ShowModal() == wxID_OK) {
-		file = (const char*)dialog->GetPath();
+		g_filename = (const char*)dialog->GetPath();
 		tree->DeleteChildren(iter[0]);
-		_scummex->getFileType(file);
+		_scummex->getFileType(g_filename);
 	}
 }
 
 void MainWindow::OnSelChanged(wxTreeEvent& event) {
-	int itemid, itemtype;
+	wxTreeItemId itemid;
+	int itemtype;
 	bool val1, val2;
 	itemid = event.GetItem();
 	TreeItemData *item = (TreeItemData *)tree->GetItemData(itemid);

Index: wxwindows.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- wxwindows.h	22 Sep 2003 18:25:16 -0000	1.5
+++ wxwindows.h	23 Sep 2003 00:47:23 -0000	1.6
@@ -69,17 +69,19 @@
 
 	void DrawImage();
 	void OnQuit(wxCommandEvent& event);
-	ImageWindow(const wxString& title, const wxPoint& pos, const wxSize& size, byte flags);
+	ImageWindow(MainWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, byte flags);
 };
 
 class ViewerWindow : public wxFrame {
 public:
 	void OnQuit(wxCommandEvent& event);
-	ViewerWindow(const wxString& title, const wxString& text, const wxPoint& pos, const wxSize& size);
+	ViewerWindow(MainWindow *parent, const wxString& title, const wxString& text, const wxPoint& pos, const wxSize& size);
 };
 
 class GUI_wxWindows : public wxApp {
 private:
+	MainWindow *_mainWindow;
+	ImageWindow *_imageWindow;
 
 public:
 	GUI_wxWindows();
@@ -115,10 +117,7 @@
 		
 enum
 {
-	ID_Quit=1,
-	ID_About,
-	ID_Open,
-	ID_Browse,
+	ID_Browse = 1,
 	ID_SoundStop,
 	ID_Dump,
 	ID_View,
@@ -130,7 +129,6 @@
 	Button_Save,
 	Button_Options,
 	ID_Help,
-	ID_Close,
 	ID_FileInfo,
 	ID_Hex,
 	ID_ImageWindow,
@@ -139,5 +137,7 @@
 	ID_Boxes,
 	Tree
 };
+
+extern GUI_wxWindows *_gui;
 
 #endif





More information about the Scummvm-git-logs mailing list