aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wage/macwindow.cpp11
-rw-r--r--engines/wage/macwindow.h11
-rw-r--r--engines/wage/macwindowmanager.cpp46
-rw-r--r--engines/wage/macwindowmanager.h17
4 files changed, 80 insertions, 5 deletions
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index a745755c07..99d0ad061c 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -49,7 +49,7 @@
namespace Wage {
-MacWindow::MacWindow(WindowType type) : _type(type) {
+MacWindow::MacWindow(bool scrollable, int id) : _scrollable(scrollable), _id(id) {
_active = false;
_borderIsDirty = true;
}
@@ -69,9 +69,16 @@ void MacWindow::resize(int w, int h) {
_surface.free();
_surface.create(w, h, Graphics::PixelFormat::createFormatCLUT8());
+
+ _dims.setWidth(w);
+ _dims.setHeight(h);
+}
+
+void MacWindow::move(int x, int y) {
+ _dims.moveTo(x, y);
}
-void MacWindow::draw(Graphics::Surface *g, int x, int y) {
+void MacWindow::draw(Graphics::Surface *g) {
if (_borderIsDirty)
drawBorder();
}
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index 4efdbd0a0f..44f25b6101 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -58,10 +58,12 @@ enum WindowType {
};
class MacWindow {
- MacWindow(WindowType type);
+public:
+ MacWindow(bool scrollable, int id);
~MacWindow();
+ void move(int x, int y);
void resize(int w, int h);
- void draw(Graphics::Surface *g, int x, int y);
+ void draw(Graphics::Surface *g);
void setActive(bool active);
Graphics::ManagedSurface *getSurface() { return &_surface; }
@@ -71,9 +73,12 @@ private:
private:
Graphics::ManagedSurface _surface;
Graphics::ManagedSurface _borderSurface;
- WindowType _type;
+ bool _scrollable;
+ int _id;
bool _active;
bool _borderIsDirty;
+
+ Common::Rect _dims;
};
} // End of namespace Wage
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 02e47a148e..5717361527 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -45,14 +45,60 @@
*
*/
+#include "common/list.h"
+#include "common/array.h"
+
+#include "graphics/surface.h"
+#include "wage/macwindow.h"
#include "wage/macwindowmanager.h"
namespace Wage {
MacWindowManager::MacWindowManager() {
+ _lastId = 0;
+ _activeWindow = -1;
}
MacWindowManager::~MacWindowManager() {
+ for (uint i = 0; i < _lastId; i++)
+ delete _windows[i];
+}
+
+int MacWindowManager::add(bool scrollable) {
+ MacWindow *w = new MacWindow(scrollable, _lastId);
+
+ _windows.push_back(w);
+ _windowStack.push_back(w);
+
+ _activeWindow = _lastId;
+
+ _lastId++;
+
+ return _activeWindow;
+}
+
+void MacWindowManager::setActive(int id) {
+ if (_activeWindow == id)
+ return;
+
+ if (_activeWindow != -1)
+ _windows[_activeWindow]->setActive(false);
+
+ _windows[id]->setActive(true);
+
+ _windowStack.remove(_windows[id]);
+ _windowStack.push_back(_windows[id]);
+
+ _fullRefresh = true;
+}
+
+void MacWindowManager::draw(Graphics::Surface *g) {
+ if (_fullRefresh) {
+ for (Common::List<MacWindow *>::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++)
+ (*it)->draw(g);
+ } else {
+ _windowStack.back()->draw(g);
+ }
}
} // End of namespace Wage
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index eaec462d5d..0c35356863 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -50,9 +50,26 @@
namespace Wage {
+class MacWindow;
+
class MacWindowManager {
+public:
MacWindowManager();
~MacWindowManager();
+
+ int add(bool scrollable);
+ void setActive(int id);
+
+ void draw(Graphics::Surface *g);
+
+private:
+ Common::List<MacWindow *> _windowStack;
+ Common::Array<MacWindow *> _windows;
+
+ int _lastId;
+ int _activeWindow;
+
+ bool _fullRefresh;
};
} // End of namespace Wage