aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2018-10-24 22:00:05 -0700
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit49b8281ce3590642673db3fca67f7c94d5f710c1 (patch)
tree17931db3855a022e4046f2ea194202e45f5a69c1 /engines
parent3d8626081ce6a03d533009e07699b397f70b834b (diff)
downloadscummvm-rg350-49b8281ce3590642673db3fca67f7c94d5f710c1.tar.gz
scummvm-rg350-49b8281ce3590642673db3fca67f7c94d5f710c1.tar.bz2
scummvm-rg350-49b8281ce3590642673db3fca67f7c94d5f710c1.zip
GLK: Window rearrangement methods
Diffstat (limited to 'engines')
-rw-r--r--engines/gargoyle/glk.cpp20
-rw-r--r--engines/gargoyle/glk.h4
-rw-r--r--engines/gargoyle/window_pair.cpp81
-rw-r--r--engines/gargoyle/window_pair.h4
-rw-r--r--engines/gargoyle/windows.cpp8
-rw-r--r--engines/gargoyle/windows.h14
6 files changed, 118 insertions, 13 deletions
diff --git a/engines/gargoyle/glk.cpp b/engines/gargoyle/glk.cpp
index 26b8349d75..4dc5e53ee2 100644
--- a/engines/gargoyle/glk.cpp
+++ b/engines/gargoyle/glk.cpp
@@ -25,6 +25,7 @@
#include "gargoyle/streams.h"
#include "gargoyle/string.h"
#include "gargoyle/windows.h"
+#include "gargoyle/window_pair.h"
namespace Gargoyle {
@@ -86,14 +87,21 @@ void Glk::glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr)
// TODO
}
-void Glk::glk_window_set_arrangement(winid_t win, glui32 method,
- glui32 size, winid_t keywin) {
- // TODO
+void Glk::glk_window_set_arrangement(winid_t win, glui32 method, glui32 size, winid_t keywin) {
+ if (!win) {
+ warning("window_set_arrangement: invalid ref");
+ } else {
+ win->setArrangement(method, size, keywin);
+ }
}
-void Glk::glk_window_get_arrangement(winid_t win, glui32 *methodptr,
- glui32 *sizeptr, winid_t *keywinptr) {
- // TODO
+void Glk::glk_window_get_arrangement(winid_t win, glui32 *method,
+ glui32 *size, winid_t *keyWin) {
+ if (!win) {
+ warning("window_get_arrangement: invalid ref");
+ } else {
+ win->getArrangement(method, size, keyWin);
+ }
}
winid_t Glk::glk_window_iterate(winid_t win, glui32 *rockptr) {
diff --git a/engines/gargoyle/glk.h b/engines/gargoyle/glk.h
index 0029ecf24f..5a822f8480 100644
--- a/engines/gargoyle/glk.h
+++ b/engines/gargoyle/glk.h
@@ -75,8 +75,8 @@ public:
glui32 *heightptr);
void glk_window_set_arrangement(winid_t win, glui32 method,
glui32 size, winid_t keywin);
- void glk_window_get_arrangement(winid_t win, glui32 *methodptr,
- glui32 *sizeptr, winid_t *keywinptr);
+ void glk_window_get_arrangement(winid_t win, glui32 *method,
+ glui32 *size, winid_t *keywin);
winid_t glk_window_iterate(winid_t win, glui32 *rockptr);
glui32 glk_window_get_rock(winid_t win);
glui32 glk_window_get_type(winid_t win);
diff --git a/engines/gargoyle/window_pair.cpp b/engines/gargoyle/window_pair.cpp
index 7a11597680..b8d593e02e 100644
--- a/engines/gargoyle/window_pair.cpp
+++ b/engines/gargoyle/window_pair.cpp
@@ -124,4 +124,85 @@ void PairWindow::redraw() {
// TODO
}
+void PairWindow::getArrangement(glui32 *method, glui32 *size, Window **keyWin) {
+ glui32 val = _dir | _division;
+ if (!_wBorder)
+ val |= winmethod_NoBorder;
+
+ if (size)
+ *size = _size;
+ if (keyWin) {
+ if (_key)
+ *keyWin = _key;
+ else
+ *keyWin = nullptr;
+ }
+
+ if (method)
+ *method = val;
+}
+
+void PairWindow::setArrangement(glui32 method, glui32 size, Window *keyWin) {
+ glui32 newDir;
+ bool newVertical, newBackward;
+
+ if (_key) {
+ Window *wx;
+ PairWindow *pairWin = dynamic_cast<PairWindow *>(_key);
+
+ if (pairWin) {
+ warning("setArrangement: keywin cannot be a Pair");
+ return;
+ }
+
+ for (wx = _key; wx; wx = wx->_parent) {
+ if (wx == this)
+ break;
+ }
+ if (wx == nullptr) {
+ warning("setArrangement: keywin must be a descendant");
+ return;
+ }
+ }
+
+ newDir = method & winmethod_DirMask;
+ newVertical = (newDir == winmethod_Left || newDir == winmethod_Right);
+ newBackward = (newDir == winmethod_Left || newDir == winmethod_Above);
+ if (!keyWin)
+ keyWin = _key;
+
+ if ((newVertical && !_vertical) || (!newVertical && _vertical)) {
+ if (!_vertical)
+ warning("setArrangement: split must stay horizontal");
+ else
+ warning("setArrangement: split must stay vertical");
+ return;
+ }
+
+ if (keyWin && dynamic_cast<BlankWindow *>(keyWin)
+ && (method & winmethod_DivisionMask) == winmethod_Fixed) {
+ warning("setArrangement: a Blank window cannot have a fixed size");
+ return;
+ }
+
+ if ((newBackward && !_backward) || (!newBackward && _backward)) {
+ // switch the children
+ Window *tmpWin = _child1;
+ _child1 = _child2;
+ _child2 = tmpWin;
+ }
+
+ // set up everything else
+ _dir = newDir;
+ _division = method & winmethod_DivisionMask;
+ _key = keyWin;
+ _size = size;
+ _wBorder = ((method & winmethod_BorderMask) == winmethod_Border);
+
+ _vertical = (_dir == winmethod_Left || _dir == winmethod_Right);
+ _backward = (_dir == winmethod_Left || _dir == winmethod_Above);
+
+ _windows->rearrange();
+}
+
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/window_pair.h b/engines/gargoyle/window_pair.h
index b25b324199..8e80f79f59 100644
--- a/engines/gargoyle/window_pair.h
+++ b/engines/gargoyle/window_pair.h
@@ -57,6 +57,10 @@ public:
* Redraw the window
*/
virtual void redraw() override;
+
+ virtual void getArrangement(glui32 *method, glui32 *size, Window **keyWin) override;
+
+ virtual void setArrangement(glui32 method, glui32 size, Window *keyWin) override;
};
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/windows.cpp b/engines/gargoyle/windows.cpp
index 42db6f72f6..53feed2f28 100644
--- a/engines/gargoyle/windows.cpp
+++ b/engines/gargoyle/windows.cpp
@@ -471,6 +471,14 @@ void Window::acceptReadChar(glui32 arg) {
warning("acceptReadChar:: window does not support keyboard input");
}
+void Window::getArrangement(glui32 *method, glui32 *size, Window **keyWin) {
+ warning("getArrangement: not a Pair window");
+}
+
+void Window::setArrangement(glui32 method, glui32 size, Window *keyWin) {
+ warning("setArrangement: not a Pair window");
+}
+
bool Window::checkTerminator(glui32 ch) {
if (ch == keycode_Escape)
return true;
diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h
index f52bbdd155..1e4dfd85d4 100644
--- a/engines/gargoyle/windows.h
+++ b/engines/gargoyle/windows.h
@@ -98,11 +98,6 @@ private:
*/
PairWindow *newPairWindow(glui32 method, Window *key, glui32 size);
- /**
- * Rearrange windows
- */
- void rearrange();
-
void refocus(Window *win);
Window *iterateTreeOrder(Window *win);
@@ -158,6 +153,11 @@ public:
void clearClaimSelect() { _claimSelect = false; }
+ /**
+ * Rearrange windows
+ */
+ void rearrange();
+
void redraw();
void redrawRect(const Common::Rect &r);
@@ -366,6 +366,10 @@ public:
virtual void acceptReadChar(glui32 arg);
+ virtual void getArrangement(glui32 *method, glui32 *size, Window **keyWin);
+
+ virtual void setArrangement(glui32 method, glui32 size, Window *keyWin);
+
int acceptScroll(glui32 arg);
};
typedef Window *winid_t;