added namespace GUI

svn-id: r11255
This commit is contained in:
Max Horn 2003-11-10 23:40:48 +00:00
parent 5c2a3da7f2
commit 22c22d1e81
37 changed files with 166 additions and 44 deletions

View file

@ -183,7 +183,7 @@ static void launcherDialog(GameDetector &detector, OSystem *system) {
system->set_palette(dummy_palette, 0, 16); system->set_palette(dummy_palette, 0, 16);
LauncherDialog dlg(detector); GUI::LauncherDialog dlg(detector);
dlg.runModal(); dlg.runModal();
} }

View file

@ -41,7 +41,7 @@ Debugger<T>::Debugger() {
_isAttached = false; _isAttached = false;
_errStr = NULL; _errStr = NULL;
_firstTime = true; _firstTime = true;
_debuggerDialog = new ConsoleDialog(1.0, 0.67F); _debuggerDialog = new GUI::ConsoleDialog(1.0, 0.67F);
_debuggerDialog->setInputCallback(debuggerInputCallback, this); _debuggerDialog->setInputCallback(debuggerInputCallback, this);
_debuggerDialog->setCompletionCallback(debuggerCompletionCallback, this); _debuggerDialog->setCompletionCallback(debuggerCompletionCallback, this);
} }
@ -339,7 +339,7 @@ void Debugger<T>::DCmd_Register(const char *cmdname, DebugProc pointer) {
// Console handler // Console handler
#if USE_CONSOLE #if USE_CONSOLE
template <class T> template <class T>
bool Debugger<T>::debuggerInputCallback(ConsoleDialog *console, const char *input, void *refCon) { bool Debugger<T>::debuggerInputCallback(GUI::ConsoleDialog *console, const char *input, void *refCon) {
Debugger *debugger = (Debugger *)refCon; Debugger *debugger = (Debugger *)refCon;
return debugger->RunCommand(input); return debugger->RunCommand(input);
@ -347,7 +347,7 @@ bool Debugger<T>::debuggerInputCallback(ConsoleDialog *console, const char *inpu
template <class T> template <class T>
bool Debugger<T>::debuggerCompletionCallback(ConsoleDialog *console, const char *input, char*& completion, void *refCon) { bool Debugger<T>::debuggerCompletionCallback(GUI::ConsoleDialog *console, const char *input, char*& completion, void *refCon) {
Debugger *debugger = (Debugger *)refCon; Debugger *debugger = (Debugger *)refCon;
return debugger->TabComplete(input, completion); return debugger->TabComplete(input, completion);

View file

@ -21,7 +21,9 @@
#ifndef COMMON_DEBUGGER_H #ifndef COMMON_DEBUGGER_H
#define COMMON_DEBUGGER_H #define COMMON_DEBUGGER_H
class ConsoleDialog; namespace GUI {
class ConsoleDialog;
};
namespace Common { namespace Common {
@ -71,7 +73,7 @@ private:
bool _isAttached; bool _isAttached;
char *_errStr; char *_errStr;
bool _firstTime; bool _firstTime;
ConsoleDialog *_debuggerDialog; GUI::ConsoleDialog *_debuggerDialog;
protected: protected:
void detach(); void detach();
@ -87,8 +89,8 @@ protected:
void DCmd_Register(const char *cmdname, DebugProc pointer); void DCmd_Register(const char *cmdname, DebugProc pointer);
#if USE_CONSOLE #if USE_CONSOLE
static bool debuggerInputCallback(ConsoleDialog *console, const char *input, void *refCon); static bool debuggerInputCallback(GUI::ConsoleDialog *console, const char *input, void *refCon);
static bool debuggerCompletionCallback(ConsoleDialog *console, const char *input, char*& completion, void *refCon); static bool debuggerCompletionCallback(GUI::ConsoleDialog *console, const char *input, char*& completion, void *refCon);
#endif #endif
}; };

View file

@ -19,9 +19,12 @@
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "EditTextWidget.h" #include "gui/EditTextWidget.h"
#include "dialog.h" #include "gui/dialog.h"
#include "newgui.h" #include "gui/newgui.h"
namespace GUI {
EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text) EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text)
: StaticTextWidget(boss, x, y - 1, w, h + 2, text, kTextAlignLeft), _backupString(text) { : StaticTextWidget(boss, x, y - 1, w, h + 2, text, kTextAlignLeft), _backupString(text) {
@ -214,3 +217,5 @@ bool EditTextWidget::adjustOffset() {
return false; return false;
} }
} // End of namespace GUI

View file

@ -21,10 +21,12 @@
#ifndef EDITTEXTWIDGET_H #ifndef EDITTEXTWIDGET_H
#define EDITTEXTWIDGET_H #define EDITTEXTWIDGET_H
#include "widget.h" #include "gui/widget.h"
#include "common/str.h" #include "common/str.h"
#include "common/list.h" #include "common/list.h"
namespace GUI {
/* EditTextWidget */ /* EditTextWidget */
class EditTextWidget : public StaticTextWidget { class EditTextWidget : public StaticTextWidget {
typedef Common::StringList StringList; typedef Common::StringList StringList;
@ -53,4 +55,6 @@ protected:
bool adjustOffset(); bool adjustOffset();
}; };
} // End of namespace GUI
#endif #endif

View file

@ -19,12 +19,14 @@
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "ListWidget.h" #include "gui/ListWidget.h"
#include "ScrollBarWidget.h" #include "gui/ScrollBarWidget.h"
#include "dialog.h" #include "gui/dialog.h"
#include "newgui.h" #include "gui/newgui.h"
namespace GUI {
ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h) ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h)
: Widget(boss, x, y, w - kScrollBarWidth, h), CommandSender(boss) { : Widget(boss, x, y, w - kScrollBarWidth, h), CommandSender(boss) {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE; _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
@ -349,3 +351,5 @@ void ListWidget::abortEditMode() {
draw(); draw();
} }
} }
} // End of namespace GUI

View file

@ -21,10 +21,12 @@
#ifndef LISTWIDGET_H #ifndef LISTWIDGET_H
#define LISTWIDGET_H #define LISTWIDGET_H
#include "widget.h" #include "gui/widget.h"
#include "common/str.h" #include "common/str.h"
#include "common/list.h" #include "common/list.h"
namespace GUI {
class ScrollBarWidget; class ScrollBarWidget;
enum NumberingMode { enum NumberingMode {
@ -92,4 +94,6 @@ protected:
void scrollToCurrent(); void scrollToCurrent();
}; };
} // End of namespace GUI
#endif #endif

View file

@ -19,11 +19,13 @@
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "PopUpWidget.h" #include "gui/PopUpWidget.h"
#include "dialog.h" #include "gui/dialog.h"
#include "newgui.h" #include "gui/newgui.h"
#include "base/engine.h" #include "base/engine.h"
namespace GUI {
#define UP_DOWN_BOX_HEIGHT 10 #define UP_DOWN_BOX_HEIGHT 10
// Little up/down arrow // Little up/down arrow
@ -337,3 +339,5 @@ void PopUpWidget::drawWidget(bool hilite) {
gui->drawString(_entries[_selectedItem].name, x+2, _y+3, w-6, !isEnabled() ? gui->_color : gui->_textcolor, align); gui->drawString(_entries[_selectedItem].name, x+2, _y+3, w-6, !isEnabled() ? gui->_color : gui->_textcolor, align);
} }
} }
} // End of namespace GUI

View file

@ -21,10 +21,12 @@
#ifndef POPUPWIDGET_H #ifndef POPUPWIDGET_H
#define POPUPWIDGET_H #define POPUPWIDGET_H
#include "widget.h" #include "gui/widget.h"
#include "common/str.h" #include "common/str.h"
#include "common/list.h" #include "common/list.h"
namespace GUI {
enum { enum {
kPopUpItemSelectedCmd = 'POPs' kPopUpItemSelectedCmd = 'POPs'
}; };
@ -69,4 +71,6 @@ protected:
void drawWidget(bool hilite); void drawWidget(bool hilite);
}; };
} // End of namespace GUI
#endif #endif

View file

@ -20,10 +20,12 @@
#include "stdafx.h" #include "stdafx.h"
#include "ScrollBarWidget.h" #include "ScrollBarWidget.h"
#include "dialog.h" #include "gui/dialog.h"
#include "newgui.h" #include "gui/newgui.h"
namespace GUI {
/* /*
* TODO: * TODO:
* - Auto-repeat: if user clicks & holds on one of the arrows, then after a * - Auto-repeat: if user clicks & holds on one of the arrows, then after a
@ -245,3 +247,5 @@ void ScrollBarWidget::drawWidget(bool hilite) {
gui->hLine(_x + 2, y + 2, _x + _w-3, color); gui->hLine(_x + 2, y + 2, _x + _w-3, color);
} }
} }
} // End of namespace GUI

View file

@ -21,7 +21,9 @@
#ifndef SCROLLBARWIDGET_H #ifndef SCROLLBARWIDGET_H
#define SCROLLBARWIDGET_H #define SCROLLBARWIDGET_H
#include "widget.h" #include "gui/widget.h"
namespace GUI {
enum { enum {
kScrollBarWidth = 9 kScrollBarWidth = 9
@ -77,5 +79,6 @@ protected:
void checkBounds(int old_pos); void checkBounds(int old_pos);
}; };
} // End of namespace GUI
#endif #endif

View file

@ -24,6 +24,8 @@
#include "gui/dialog.h" #include "gui/dialog.h"
#include "gui/newgui.h" #include "gui/newgui.h"
namespace GUI {
enum { enum {
kTabHeight = 15, kTabHeight = 15,
@ -148,3 +150,5 @@ Widget *TabWidget::findWidget(int x, int y) {
return Widget::findWidgetInChain(_firstWidget, x, y - kTabHeight); return Widget::findWidgetInChain(_firstWidget, x, y - kTabHeight);
} }
} }
} // End of namespace GUI

View file

@ -25,6 +25,8 @@
#include "common/str.h" #include "common/str.h"
#include "common/list.h" #include "common/list.h"
namespace GUI {
class TabWidget : public Widget { class TabWidget : public Widget {
typedef Common::String String; typedef Common::String String;
struct Tab { struct Tab {
@ -66,4 +68,6 @@ protected:
virtual Widget *findWidget(int x, int y); virtual Widget *findWidget(int x, int y);
}; };
} // End of namespace GUI
#endif #endif

View file

@ -24,6 +24,8 @@
#include "gui/newgui.h" #include "gui/newgui.h"
#include "gui/widget.h" #include "gui/widget.h"
namespace GUI {
AboutDialog::AboutDialog() AboutDialog::AboutDialog()
: Dialog(10, 20, 300, 144) { : Dialog(10, 20, 300, 144) {
addButton((_w - kButtonWidth) / 2, 120, "OK", kCloseCmd, '\r'); // Close dialog - FIXME addButton((_w - kButtonWidth) / 2, 120, "OK", kCloseCmd, '\r'); // Close dialog - FIXME
@ -48,3 +50,4 @@ AboutDialog::AboutDialog()
new StaticTextWidget(this, 10, 105, _w - 20, kLineHeight, "Broken Sword Games (C) Revolution", kTextAlignCenter); new StaticTextWidget(this, 10, 105, _w - 20, kLineHeight, "Broken Sword Games (C) Revolution", kTextAlignCenter);
} }
} // End of namespace GUI

View file

@ -23,9 +23,13 @@
#include "dialog.h" #include "dialog.h"
namespace GUI {
class AboutDialog : public Dialog { class AboutDialog : public Dialog {
public: public:
AboutDialog(); AboutDialog();
}; };
} // End of namespace GUI
#endif #endif

View file

@ -25,6 +25,8 @@
#include "backends/fs/fs.h" #include "backends/fs/fs.h"
namespace GUI {
/* We want to use this as a general directory selector at some point... possible uses /* We want to use this as a general directory selector at some point... possible uses
* - to select the data dir for a game * - to select the data dir for a game
* - to select the place where save games are stored * - to select the place where save games are stored
@ -155,3 +157,4 @@ void BrowserDialog::updateListing() {
draw(); draw();
} }
} // End of namespace GUI

View file

@ -25,12 +25,14 @@
#include "common/str.h" #include "common/str.h"
#include "common/list.h" #include "common/list.h"
class ListWidget;
class StaticTextWidget;
class FilesystemNode; class FilesystemNode;
class FSList; class FSList;
namespace GUI {
class ListWidget;
class StaticTextWidget;
class BrowserDialog : public Dialog { class BrowserDialog : public Dialog {
typedef Common::String String; typedef Common::String String;
typedef Common::StringList StringList; typedef Common::StringList StringList;
@ -54,4 +56,6 @@ protected:
void updateListing(); void updateListing();
}; };
} // End of namespace GUI
#endif #endif

View file

@ -19,9 +19,11 @@
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "chooser.h" #include "gui/chooser.h"
#include "newgui.h" #include "gui/newgui.h"
#include "ListWidget.h" #include "gui/ListWidget.h"
namespace GUI {
enum { enum {
kChooseCmd = 'Chos' kChooseCmd = 'Chos'
@ -61,3 +63,5 @@ void ChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
Dialog::handleCommand(sender, cmd, data); Dialog::handleCommand(sender, cmd, data);
} }
} }
} // End of namespace GUI

View file

@ -25,6 +25,8 @@
#include "common/list.h" #include "common/list.h"
#include "gui/dialog.h" #include "gui/dialog.h"
namespace GUI {
class ButtonWidget; class ButtonWidget;
class ListWidget; class ListWidget;
@ -45,4 +47,6 @@ public:
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
}; };
} // End of namespace GUI
#endif #endif

View file

@ -20,11 +20,13 @@
#include "stdafx.h" #include "stdafx.h"
#include "gui/console.h" #include "gui/console.h"
#include "ScrollBarWidget.h" #include "gui/ScrollBarWidget.h"
#include "base/engine.h" #include "base/engine.h"
namespace GUI {
#define PROMPT ") " #define PROMPT ") "
/* TODO: /* TODO:
@ -528,3 +530,5 @@ void ConsoleDialog::scrollToCurrent() {
updateScrollBar(); updateScrollBar();
} }
} }
} // End of namespace GUI

View file

@ -26,6 +26,8 @@
#include <stdarg.h> #include <stdarg.h>
namespace GUI {
enum { enum {
kBufferSize = 32768, kBufferSize = 32768,
kLineBufferSize = 256, kLineBufferSize = 256,
@ -123,4 +125,6 @@ protected:
void historyScroll(int direction); void historyScroll(int direction);
}; };
} // End of namespace GUI
#endif #endif

View file

@ -25,6 +25,8 @@
#include "dialog.h" #include "dialog.h"
#include "widget.h" #include "widget.h"
namespace GUI {
/* /*
* TODO list * TODO list
* - add some sense of the window being "active" (i.e. in front) or not. If it * - add some sense of the window being "active" (i.e. in front) or not. If it
@ -269,3 +271,5 @@ Widget *Dialog::findWidget(int x, int y) {
ButtonWidget *Dialog::addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey) { ButtonWidget *Dialog::addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey) {
return new ButtonWidget(this, x, y, kButtonWidth, 16, label, cmd, hotkey); return new ButtonWidget(this, x, y, kButtonWidth, 16, label, cmd, hotkey);
} }
} // End of namespace GUI

View file

@ -26,6 +26,8 @@
#include "gui/object.h" #include "gui/object.h"
namespace GUI {
class NewGui; class NewGui;
class ButtonWidget; class ButtonWidget;
@ -81,4 +83,6 @@ protected:
int getResult() const { return _result; } int getResult() const { return _result; }
}; };
} // End of namespace GUI
#endif #endif

View file

@ -46,6 +46,8 @@
using Common::ConfigManager; using Common::ConfigManager;
namespace GUI {
enum { enum {
kStartCmd = 'STRT', kStartCmd = 'STRT',
kAboutCmd = 'ABOU', kAboutCmd = 'ABOU',
@ -511,7 +513,7 @@ void LauncherDialog::editGame(int item) {
} }
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
int item = _list->getSelected(); int item = _list->getSelected();
switch (cmd) { switch (cmd) {
case kAddGameCmd: case kAddGameCmd:
@ -569,3 +571,5 @@ void LauncherDialog::updateButtons() {
_removeButton->draw(); _removeButton->draw();
} }
} }
} // End of namespace GUI

View file

@ -25,8 +25,11 @@
#include "common/str.h" #include "common/str.h"
#include "common/list.h" #include "common/list.h"
class BrowserDialog;
class GameDetector; class GameDetector;
namespace GUI {
class BrowserDialog;
class ListWidget; class ListWidget;
class LauncherDialog : public Dialog { class LauncherDialog : public Dialog {
@ -55,4 +58,6 @@ protected:
void editGame(int item); void editGame(int item);
}; };
} // End of namespace GUI
#endif #endif

View file

@ -25,6 +25,8 @@
#include "gui/newgui.h" #include "gui/newgui.h"
#include "gui/widget.h" #include "gui/widget.h"
namespace GUI {
enum { enum {
kOkCmd = 'OK ', kOkCmd = 'OK ',
kCancelCmd = 'CNCL' kCancelCmd = 'CNCL'
@ -162,3 +164,5 @@ void TimedMessageDialog::handleTickle() {
if (g_system->get_msecs() > _timer) if (g_system->get_msecs() > _timer)
close(); close();
} }
} // End of namespace GUI

View file

@ -28,6 +28,8 @@ namespace Common {
class StringList; class StringList;
} }
namespace GUI {
/** /**
* Simple message dialog ("alert box"): presents a text message in a dialog with up to two buttons. * Simple message dialog ("alert box"): presents a text message in a dialog with up to two buttons.
*/ */
@ -56,5 +58,6 @@ protected:
uint32 _timer; uint32 _timer;
}; };
} // End of namespace GUI
#endif #endif

View file

@ -27,6 +27,8 @@
# include "palm.h" # include "palm.h"
#endif #endif
namespace GUI {
/* /*
* TODO list * TODO list
* - get a nicer font which contains diacrits (ŠšŸ§Žˆ etc.) * - get a nicer font which contains diacrits (ŠšŸ§Žˆ etc.)
@ -574,6 +576,8 @@ void NewGui::animateCursor() {
} }
} }
} // End of namespace GUI
#ifdef __PALM_OS__ #ifdef __PALM_OS__
#include "scumm_globals.h" #include "scumm_globals.h"

View file

@ -26,6 +26,8 @@
#include "common/str.h" #include "common/str.h"
#include "common/system.h" // For events #include "common/system.h" // For events
namespace GUI {
class Dialog; class Dialog;
#define hLine(x, y, x2, color) line(x, y, x2, y, color); #define hLine(x, y, x2, color) line(x, y, x2, y, color);
@ -147,4 +149,6 @@ public:
void addDirtyRect(int x, int y, int w, int h); void addDirtyRect(int x, int y, int w, int h);
}; };
} // End of namespace GUI
#endif #endif

View file

@ -21,6 +21,8 @@
#ifndef GUI_OBJECT_H #ifndef GUI_OBJECT_H
#define GUI_OBJECT_H #define GUI_OBJECT_H
namespace GUI {
class CommandReceiver; class CommandReceiver;
class CommandSender; class CommandSender;
@ -75,5 +77,6 @@ protected:
virtual void releaseFocus() = 0; virtual void releaseFocus() = 0;
}; };
} // End of namespace GUI
#endif #endif

View file

@ -36,6 +36,8 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
namespace GUI {
// TODO - allow changing options for: // TODO - allow changing options for:
// - the save path (use _browser!) // - the save path (use _browser!)
// - music & graphics driver (but see also the comments on EditGameDialog // - music & graphics driver (but see also the comments on EditGameDialog
@ -411,3 +413,5 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
OptionsDialog::handleCommand(sender, cmd, data); OptionsDialog::handleCommand(sender, cmd, data);
} }
} }
} // End of namespace GUI

View file

@ -25,9 +25,12 @@
#include "common/str.h" #include "common/str.h"
#include "common/list.h" #include "common/list.h"
class GameDetector;
namespace GUI {
class BrowserDialog; class BrowserDialog;
class CheckboxWidget; class CheckboxWidget;
class GameDetector;
class PopUpWidget; class PopUpWidget;
class SliderWidget; class SliderWidget;
class StaticTextWidget; class StaticTextWidget;
@ -105,4 +108,6 @@ protected:
StaticTextWidget *_savePath; StaticTextWidget *_savePath;
}; };
} // End of namespace GUI
#endif #endif

View file

@ -25,6 +25,8 @@
#include "gui/newgui.h" #include "gui/newgui.h"
namespace GUI {
Widget::Widget(GuiObject *boss, int x, int y, int w, int h) Widget::Widget(GuiObject *boss, int x, int y, int w, int h)
: GuiObject(x, y, w, h), _type(0), _boss(boss), : GuiObject(x, y, w, h), _type(0), _boss(boss),
_id(0), _flags(0), _hasFocus(false) { _id(0), _flags(0), _hasFocus(false) {
@ -260,3 +262,5 @@ int SliderWidget::valueToPos(int value) {
int SliderWidget::posToValue(int pos) { int SliderWidget::posToValue(int pos) {
return (pos) * (_valueMax - _valueMin) / (_w - _labelWidth - 4) + _valueMin; return (pos) * (_valueMax - _valueMin) / (_w - _labelWidth - 4) + _valueMin;
} }
} // End of namespace GUI

View file

@ -25,6 +25,8 @@
#include "common/str.h" #include "common/str.h"
#include "gui/object.h" #include "gui/object.h"
namespace GUI {
class Dialog; class Dialog;
enum { enum {
@ -206,5 +208,6 @@ protected:
int posToValue(int pos); int posToValue(int pos);
}; };
} // End of namespace GUI
#endif #endif

View file

@ -136,12 +136,6 @@ static ResString string_map_table_v5[] = {
#pragma mark - #pragma mark -
void ScummDialog::addResText(int x, int y, int w, int h, int resID) {
// Get the string
new StaticTextWidget(this, x, y, w, h, queryResString(resID), kTextAlignCenter);
}
const Common::String ScummDialog::queryResString(int stringno) { const Common::String ScummDialog::queryResString(int stringno) {
byte *result; byte *result;

View file

@ -30,7 +30,11 @@
#include "scumm/help.h" #include "scumm/help.h"
#endif #endif
class ListWidget; namespace GUI {
class ListWidget;
}
using namespace GUI; // FIXME: Bad style to use a using directive in a header
namespace Scumm { namespace Scumm {
@ -46,8 +50,6 @@ protected:
ScummEngine *_scumm; ScummEngine *_scumm;
void addResText(int x, int y, int w, int h, int resID);
// Query a string from the resources // Query a string from the resources
const String queryResString(int stringno); const String queryResString(int stringno);
}; };

View file

@ -32,7 +32,10 @@
#include "scumm/gfx.h" #include "scumm/gfx.h"
#include "scumm/script.h" #include "scumm/script.h"
class Dialog; namespace GUI {
class Dialog;
}
using GUI::Dialog;
class GameDetector; class GameDetector;
namespace Scumm { namespace Scumm {