[Scummvm-cvs-logs] SF.net SVN: scummvm:[41582] tools/branches/gsoc2009-gui

Remere at users.sourceforge.net Remere at users.sourceforge.net
Tue Jun 16 13:03:53 CEST 2009


Revision: 41582
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41582&view=rev
Author:   Remere
Date:     2009-06-16 11:03:53 +0000 (Tue, 16 Jun 2009)

Log Message:
-----------
*Start of GUI for tools, requires wxWidgets 2.8.8 to compile. ONLY for looks right now, there is no functionality. For some nice graphics, make sure working directory is gui. You need to setup the project manually (so far).

Added Paths:
-----------
    tools/branches/gsoc2009-gui/gui/
    tools/branches/gsoc2009-gui/gui/main.cpp
    tools/branches/gsoc2009-gui/gui/main.h
    tools/branches/gsoc2009-gui/gui/media/
    tools/branches/gsoc2009-gui/gui/media/logo.jpg
    tools/branches/gsoc2009-gui/gui/media/tile.gif

Added: tools/branches/gsoc2009-gui/gui/main.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/main.cpp	                        (rev 0)
+++ tools/branches/gsoc2009-gui/gui/main.cpp	2009-06-16 11:03:53 UTC (rev 41582)
@@ -0,0 +1,253 @@
+/* gui_main.cpp - Main entry point for the tool GUI
+ * Copyright (C) 2009 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+	#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+	#include "wx/wx.h"
+#endif
+
+#include <wx/statline.h>
+
+#include "main.h"
+
+class ScummVMToolsApp : public wxApp
+{
+	virtual bool OnInit();
+};
+
+IMPLEMENT_APP(ScummVMToolsApp)
+
+bool ScummVMToolsApp::OnInit()
+{
+	ScummToolsFrame *frame = new ScummToolsFrame(wxT("ScummVM Tools"), wxDefaultPosition, wxSize(600,400));
+	frame->SetMinSize(wxSize(600, 400));
+	frame->Show(true);
+	SetTopWindow(frame);
+	return true;
+}
+
+BEGIN_EVENT_TABLE(ScummToolsFrame, wxFrame)
+END_EVENT_TABLE()
+
+ScummToolsFrame::ScummToolsFrame(const wxString &title, const wxPoint &pos, const wxSize& size)
+		: wxFrame((wxFrame *)NULL, -1, title, pos, size)
+{
+	// We need a parent frame for correct background color (default frame looks 'disabled' in the background)
+	wxPanel *main = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxT("Wizard Main Panel"));
+
+
+	wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+	
+	// Add the top header, it's sweet!
+	sizer->Add(new Header(main), wxSizerFlags(0).Expand());
+
+	// Pane that holds the wizard window
+	_wizardpane = new wxPanel(main);
+	sizer->Add(_wizardpane, wxSizerFlags(1).Expand().Border());
+
+	// Add a spacer line
+	// We split it in two parts over a panel to have a small text there
+	wxPanel *linepanel = new wxPanel(main, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxT("Wizard Line Panel"));
+	wxSizer *linesizer = new wxBoxSizer(wxHORIZONTAL);
+	
+	wxStaticText *linetext = new wxStaticText(linepanel, wxID_ANY, wxT("ScummVM Tools"));
+	linesizer->Add(linetext, wxSizerFlags());
+	linetext->Disable();
+
+	wxStaticLine *line = new wxStaticLine(
+			linepanel, wxID_ANY, 
+			wxDefaultPosition, wxSize(300, 1), 
+			wxBORDER_SIMPLE | wxLI_HORIZONTAL, wxT("Line Spacer")
+		);
+	line->Disable();
+	linesizer->Add(line, wxSizerFlags(1).Center());
+
+	linepanel->SetSizer(linesizer);
+	
+	// Add the line to the main panel
+	sizer->Add(linepanel, wxSizerFlags().Expand().Center().Border());
+
+	// Buttons on the bottom
+	_buttons = new WizardButtons(main, linetext);
+	sizer->Add(_buttons, wxSizerFlags().Border().Right());
+	
+	// We create the intro page once the window is setup
+	wxSizer *panesizer = new wxBoxSizer(wxVERTICAL);
+	panesizer->Add(new IntroPage(_wizardpane, _buttons), wxSizerFlags(1).Expand());
+	_wizardpane->SetSizerAndFit(panesizer);
+
+
+	main->SetSizer(sizer);
+}
+
+void ScummToolsFrame::SwitchPage(WizardPage *nextPage) {
+	
+}
+
+WizardButtons::WizardButtons(wxWindow *parent, wxStaticText *linetext)
+	: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxT("Wizard Button Panel")),
+	  _linetext(linetext)
+{
+	wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
+
+	_prev = new wxButton(this, wxID_ANY, wxT("< Back"));
+	_prev->SetSize(80, -1);
+	sizer->Add(_prev, wxSizerFlags().Center().ReserveSpaceEvenIfHidden());
+
+	_next = new wxButton(this, wxID_ANY, wxT("Next >"));
+	_next->SetSize(80, -1);
+	sizer->Add(_next, wxSizerFlags().Center().ReserveSpaceEvenIfHidden());
+
+	sizer->AddSpacer(10);
+
+	_cancel = new wxButton(this, wxID_ANY, wxT("Cancel"));
+	_cancel->SetSize(80, -1);
+	sizer->Add(_cancel, wxSizerFlags().Center().ReserveSpaceEvenIfHidden());
+
+	SetSizerAndFit(sizer);
+}
+
+void WizardButtons::enableNext(bool enable) {
+	_next->Enable(enable);
+}
+
+void WizardButtons::enablePrevious(bool enable) {
+	_next->Enable(enable);
+}
+
+void WizardButtons::showFinish(bool show) {
+	if(show)
+		_next->SetLabel(wxT("Finish!"));
+	else
+		_next->SetLabel(wxT("Next >"));
+}
+
+void WizardButtons::showPrevious(bool show) {
+	if(show)
+		_prev->Show();
+	else
+		_prev->Hide();
+}
+
+BEGIN_EVENT_TABLE(Header, wxPanel)
+	EVT_PAINT(Header::onPaint)
+END_EVENT_TABLE()
+
+Header::Header(wxWindow *parent)
+	: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(400, 118), wxBORDER_NONE, wxT("Wizard Splash"))
+{
+	// Disable warnings in this function
+	wxLogNull nulllog;
+
+	// Add support for loading .jpg images
+	if(wxImage::FindHandler(wxT("jpg")) == NULL)
+		wxImage::AddHandler(new wxJPEGHandler);
+	if(wxImage::FindHandler(wxT("gif")) == NULL)
+		wxImage::AddHandler(new wxGIFHandler);
+
+	// Load image files
+	_logo.LoadFile(wxT("media/logo.jpg"), wxBITMAP_TYPE_JPEG);
+	_tile.LoadFile(wxT("media/tile.gif"), wxBITMAP_TYPE_GIF);
+
+	// Load font
+	_font = wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false);
+}
+
+void Header::onPaint(wxPaintEvent &evt) {
+	wxPaintDC dc(this);
+
+	int w, h;
+	this->GetSize(&w, &h);
+	
+	if(_logo.IsOk() == false || _tile.IsOk() == false) {
+		// If we couldn't load the images, use orange instead!
+		dc.SetBackground(wxBrush(wxColor(213, 114, 0)));
+		dc.Clear();
+
+		// Draw lighter stripe below, looks good
+		dc.SetPen(wxPen(*wxBLACK, 0, wxTRANSPARENT));
+		dc.SetBrush(wxBrush(wxColor(245, 228, 156)));
+		dc.DrawRectangle(0, 90, w, h - 90);
+	} else {
+		// We got some good-looking images! Draw them!
+		int x = 0;
+		dc.DrawBitmap(_logo, x, 0);
+		x += _logo.GetWidth();
+
+		while(x < w) {
+			dc.DrawBitmap(_tile, x, 0);
+			x += _tile.GetWidth();
+		}
+	}
+	
+	dc.SetFont(_font);
+	dc.DrawText(wxT("Extraction & Compression Wizard"), 290, 70);
+}
+
+
+WizardPage::WizardPage(wxWindow *parent, WizardButtons *buttons)
+	: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxT("Wizard Page")),
+	  _nextPage(NULL),
+	  _prevPage(NULL),
+	  _buttons(buttons)
+{
+}
+
+void WizardPage::SetAlignedSizer(wxSizer *sizer) {
+	wxSizer *topsizer = new wxBoxSizer(wxHORIZONTAL);
+	topsizer->AddSpacer(100);
+	topsizer->Add(sizer);
+	SetSizer(topsizer);
+}
+
+IntroPage::IntroPage(wxWindow *parent, WizardButtons *buttons)
+	: WizardPage(parent, buttons)
+{
+	wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+	sizer->AddSpacer(15);
+
+	sizer->Add(new wxStaticText(this, wxID_ANY, 
+		wxT("Welcome to the ScummVM extraction and compression utility.")));
+	sizer->Add(new wxStaticText(this, wxID_ANY,
+		wxT("Please select what you want to do, or drop a file or folder on this window for automatic .")));
+	
+	wxString choices[] = {
+		wxT("Extract from game data files"),
+		wxT("Compress audio files")
+	};
+
+	_options = new wxRadioBox(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 2, choices, 1, wxRA_SPECIFY_COLS | wxBORDER_NONE);
+	sizer->Add(_options);
+	_options->SetSelection(0);
+
+	SetAlignedSizer(sizer);
+
+	_buttons->showPrevious(false);
+	_buttons->enableNext(true);
+}
+


Property changes on: tools/branches/gsoc2009-gui/gui/main.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: tools/branches/gsoc2009-gui/gui/main.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/main.h	                        (rev 0)
+++ tools/branches/gsoc2009-gui/gui/main.h	2009-06-16 11:03:53 UTC (rev 41582)
@@ -0,0 +1,131 @@
+/* gui_main.h - Main window classes for the tool GUI
+ * Copyright (C) 2009 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef GUI_MAIN_H
+#define GUI_MAIN_H
+
+#include <wx/wx.h>
+
+class WizardButtons;
+class WizardPage;
+
+// Application top window
+
+class ScummToolsFrame : public wxFrame
+{
+public:
+	ScummToolsFrame(const wxString &title, const wxPoint &pos, const wxSize &size);
+
+	// Switches to this page and resets the buttons
+	void SwitchPage(WizardPage *nextPage);
+
+private:
+	wxPanel *_wizardpane;
+	WizardButtons *_buttons;
+
+	DECLARE_EVENT_TABLE()
+};
+
+// This panel contains the "Next", "Previous" and "Abort" buttons
+// Convenient interface as you don't need to create buttons
+// with long, awkward calls
+
+class WizardButtons : public wxPanel {
+public:
+	WizardButtons(wxWindow *parent, wxStaticText *linetext);
+
+	// Set the label of the line above the buttons, can display some useful info here
+	void setLineLabel(wxString label);
+
+	// Enables (ie. makes clickable) the next button (or finish for the last page)
+	void enableNext(bool enable);
+	void enableFinish(bool enable) {enableNext(enable);}
+	// Enables the previous button, shows it if hidden
+	void enablePrevious(bool enable);
+	// Display the previous button, it is invisible by default
+	void showPrevious(bool show);
+	// Changes 'next' into 'finish'
+	void showFinish(bool show);
+
+protected:
+	wxButton *_next;
+	wxButton *_prev;
+	wxButton *_cancel;
+	wxStaticText *_linetext;
+};
+
+// The header at the top of the window
+// Tries to load media/logo.gif and media/tiled.gif
+// If unavailable, it will simply be orange/brigt orange
+
+class Header : public wxPanel
+{
+public:
+	Header(wxWindow *parent);
+
+	void onPaint(wxPaintEvent &evt);
+protected:
+	wxFont _font;
+	wxBitmap _logo;
+	wxBitmap _tile;
+
+	DECLARE_EVENT_TABLE()
+};
+
+// Wizard Page
+// A page in the extraction wizard
+// This class is responsible for almost everything!
+
+class WizardPage : public wxPanel
+{
+public:
+	WizardPage(wxWindow *parent, WizardButtons *buttons);
+
+	// This adds an offset (about 100px) to the left of the sizer
+	// to center the text somewhat, before adding it to the panel
+	void SetAlignedSizer(wxSizer *sizer);
+
+protected:
+	WizardPage *_nextPage;
+	WizardPage *_prevPage;
+	WizardButtons *_buttons;
+};
+
+// Introduction page, with options to extract/compress
+
+class IntroPage : public WizardPage
+{
+public:
+	IntroPage(wxWindow *parent, WizardButtons *buttons);
+
+protected:
+	wxRadioBox *_options;
+};
+
+class TestPage : public WizardPage
+{
+public:
+	TestPage(wxWindow *parent, WizardButtons *buttons);
+};
+
+
+#endif


Property changes on: tools/branches/gsoc2009-gui/gui/main.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: tools/branches/gsoc2009-gui/gui/media/logo.jpg
===================================================================
(Binary files differ)


Property changes on: tools/branches/gsoc2009-gui/gui/media/logo.jpg
___________________________________________________________________
Added: svn:mime-type
   + image/jpeg

Added: tools/branches/gsoc2009-gui/gui/media/tile.gif
===================================================================
(Binary files differ)


Property changes on: tools/branches/gsoc2009-gui/gui/media/tile.gif
___________________________________________________________________
Added: svn:mime-type
   + image/gif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list