aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2018-10-25 19:49:10 -0700
committerPaul Gilbert2018-12-08 19:05:59 -0800
commitb231dee01a92f263c95311d68657f01b003141ca (patch)
tree8d9e55889b9c342b92cfed5be29c9d39666a345f /engines
parente14424c2b944ae9a9c5ce34158bd5e7e361ee994 (diff)
downloadscummvm-rg350-b231dee01a92f263c95311d68657f01b003141ca.tar.gz
scummvm-rg350-b231dee01a92f263c95311d68657f01b003141ca.tar.bz2
scummvm-rg350-b231dee01a92f263c95311d68657f01b003141ca.zip
GLK: More window glk methods
Diffstat (limited to 'engines')
-rw-r--r--engines/gargoyle/glk.cpp72
-rw-r--r--engines/gargoyle/window_graphics.cpp22
-rw-r--r--engines/gargoyle/window_graphics.h9
-rw-r--r--engines/gargoyle/window_text_buffer.cpp11
-rw-r--r--engines/gargoyle/window_text_buffer.h4
-rw-r--r--engines/gargoyle/windows.cpp16
-rw-r--r--engines/gargoyle/windows.h8
7 files changed, 106 insertions, 36 deletions
diff --git a/engines/gargoyle/glk.cpp b/engines/gargoyle/glk.cpp
index c309f727ae..8f9df2393f 100644
--- a/engines/gargoyle/glk.cpp
+++ b/engines/gargoyle/glk.cpp
@@ -21,7 +21,9 @@
*/
#include "gargoyle/glk.h"
+#include "gargoyle/conf.h"
#include "gargoyle/events.h"
+#include "gargoyle/picture.h"
#include "gargoyle/streams.h"
#include "gargoyle/string.h"
#include "gargoyle/windows.h"
@@ -169,11 +171,27 @@ winid_t Glk::glk_window_get_sibling(winid_t win) {
}
void Glk::glk_window_clear(winid_t win) {
- // TODO
+ if (!win) {
+ warning("window_clear: invalid ref");
+ } else if (win->_lineRequest || win->_lineRequestUni) {
+ if (g_conf->_safeClicks && _events->_forceClick) {
+ glk_cancel_line_event(win, NULL);
+ _events->_forceClick = false;
+
+ win->clear();
+ } else {
+ warning("window_clear: window has pending line request");
+ return;
+ }
+ }
}
void Glk::glk_window_move_cursor(winid_t win, glui32 xpos, glui32 ypos) {
- // TODO
+ if (!win) {
+ warning("window_move_cursor: invalid ref");
+ } else {
+ win->moveCursor(Common::Point(xpos, ypos));
+ }
}
strid_t Glk::glk_window_get_stream(winid_t win) {
@@ -583,8 +601,14 @@ glui32 Glk::glk_buffer_canon_normalize_uni(glui32 *buf, glui32 len, glui32 numch
#ifdef GLK_MODULE_IMAGE
glui32 Glk::glk_image_draw(winid_t win, glui32 image, glsi32 val1, glsi32 val2) {
- // TODO
- return 0;
+/*
+ if (!win) {
+ warning("image_draw: invalid ref");
+ } else if (g_conf->_graphics) {
+ win->imageDraw(image, val1, val2, );
+ }
+ */
+ return false;
}
glui32 Glk::glk_image_draw_scaled(winid_t win, glui32 image,
@@ -594,22 +618,44 @@ glui32 Glk::glk_image_draw_scaled(winid_t win, glui32 image,
}
glui32 Glk::glk_image_get_info(glui32 image, glui32 *width, glui32 *height) {
- // TODO
- return 0;
+ if (!g_conf->_graphics)
+ return false;
+
+ Picture *pic = Picture::load(image);
+ if (!pic)
+ return false;
+
+ if (width)
+ *width = pic->w;
+ if (height)
+ *height = pic->h;
+
+ return true;
}
void Glk::glk_window_flow_break(winid_t win) {
- // TODO
+ if (!win) {
+ warning("window_erase_rect: invalid ref");
+ } else {
+ win->flowBreak();
+ }
}
-void Glk::glk_window_erase_rect(winid_t win,
- glsi32 left, glsi32 top, glui32 width, glui32 height) {
- // TODO
+void Glk::glk_window_erase_rect(winid_t win, glsi32 left, glsi32 top, glui32 width, glui32 height) {
+ if (!win) {
+ warning("window_erase_rect: invalid ref");
+ } else {
+ win->eraseRect(false, Common::Rect(left, top, left + width, top + height));
+ }
}
-void Glk::glk_window_fill_rect(winid_t win, glui32 color,
- glsi32 left, glsi32 top, glui32 width, glui32 height) {
- // TODO
+void Glk::glk_window_fill_rect(winid_t win, glui32 color, glsi32 left, glsi32 top,
+ glui32 width, glui32 height) {
+ if (!win) {
+ warning("window_fill_rect: invalid ref");
+ } else {
+ win->eraseRect(color, Common::Rect(left, top, left + width, top + height));
+ }
}
void Glk::glk_window_set_background_color(winid_t win, glui32 color) {
diff --git a/engines/gargoyle/window_graphics.cpp b/engines/gargoyle/window_graphics.cpp
index 0ec2beef18..0ea587616e 100644
--- a/engines/gargoyle/window_graphics.cpp
+++ b/engines/gargoyle/window_graphics.cpp
@@ -120,9 +120,8 @@ glui32 GraphicsWindow::drawPicture(glui32 image, glsi32 xpos, glsi32 ypos, int s
return true;
}
-void GraphicsWindow::eraseRect(int whole, glsi32 x0, glsi32 y0, glui32 width, glui32 height) {
- int x1 = x0 + width;
- int y1 = y0 + height;
+void GraphicsWindow::eraseRect(bool whole, const Common::Rect &box) {
+ int x0 = box.left, y0 = box.top, x1 = box.right, y1 = box.bottom;
int hx0, hx1, hy0, hy1;
if (whole) {
@@ -153,10 +152,9 @@ void GraphicsWindow::eraseRect(int whole, glsi32 x0, glsi32 y0, glui32 width, gl
touch();
}
-void GraphicsWindow::fillRect(glui32 color, glsi32 x0, glsi32 y0, glui32 width, glui32 height) {
+void GraphicsWindow::fillRect(glui32 color, const Common::Rect &box) {
unsigned char col[3];
- int x1 = x0 + width;
- int y1 = y0 + height;
+ int x0 = box.left, y0 = box.top, x1 = box.right, y1 = box.bottom;
int hx0, hx1, hy0, hy1;
col[0] = (color >> 16) & 0xff;
@@ -184,12 +182,6 @@ void GraphicsWindow::fillRect(glui32 color, glsi32 x0, glsi32 y0, glui32 width,
touch();
}
-void GraphicsWindow::setBackgroundColor(glui32 color) {
- _bgnd[0] = (color >> 16) & 0xff;
- _bgnd[1] = (color >> 8) & 0xff;
- _bgnd[2] = (color >> 0) & 0xff;
-}
-
void GraphicsWindow::drawPicture(Picture *src, int x0, int y0, int width, int height, glui32 linkval) {
int dx1, dy1, x1, y1, sx0, sy0, sx1, sy1;
int hx0, hx1, hy0, hy1;
@@ -249,4 +241,10 @@ void GraphicsWindow::getSize(glui32 *width, glui32 *height) const {
*height = _bbox.height();
}
+void GraphicsWindow::setBackgroundColor(glui32 color) {
+ _bgnd[0] = (color >> 16) & 0xff;
+ _bgnd[1] = (color >> 8) & 0xff;
+ _bgnd[2] = (color >> 0) & 0xff;
+}
+
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/window_graphics.h b/engines/gargoyle/window_graphics.h
index 166b03a4f2..8c2724e2ec 100644
--- a/engines/gargoyle/window_graphics.h
+++ b/engines/gargoyle/window_graphics.h
@@ -35,9 +35,6 @@ class GraphicsWindow : public Window {
private:
void touch();
- void eraseRect(int whole, glsi32 x0, glsi32 y0, glui32 width, glui32 height);
- void fillRect(glui32 color, glsi32 x0, glsi32 y0, glui32 width, glui32 height);
- void setBackgroundColor(glui32 color);
void drawPicture(Picture *src, int x0, int y0, int width, int height, glui32 linkval);
public:
unsigned char _bgnd[3];
@@ -89,7 +86,13 @@ public:
*/
virtual void redraw() override;
+ virtual void eraseRect(bool whole, const Common::Rect &box) override;
+
+ virtual void fillRect(glui32 color, const Common::Rect &box) override;
+
virtual void getSize(glui32 *width, glui32 *height) const override;
+
+ virtual void setBackgroundColor(glui32 color) override;
};
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/window_text_buffer.cpp b/engines/gargoyle/window_text_buffer.cpp
index c428dac516..05705cc454 100644
--- a/engines/gargoyle/window_text_buffer.cpp
+++ b/engines/gargoyle/window_text_buffer.cpp
@@ -296,12 +296,6 @@ glui32 TextBufferWindow::drawPicture(glui32 image, glui32 align, glui32 scaled,
return error;
}
-bool TextBufferWindow::flowBreak() {
- while (_ladjn || _radjn)
- putCharUni('\n');
- return true;
-}
-
void TextBufferWindow::putText(const char *buf, int len, int pos, int oldlen) {
int diff = len - oldlen;
@@ -1640,6 +1634,11 @@ void TextBufferWindow::getSize(glui32 *width, glui32 *height) const {
*height = (_bbox.height() - g_conf->_tMarginY * 2) / g_conf->_cellH;
}
+void TextBufferWindow::flowBreak() {
+ while (_ladjn || _radjn)
+ putCharUni('\n');
+}
+
/*--------------------------------------------------------------------------*/
TextBufferWindow::TextBufferRow::TextBufferRow() : _len(0), _newLine(0), _dirty(false),
diff --git a/engines/gargoyle/window_text_buffer.h b/engines/gargoyle/window_text_buffer.h
index 774bd66221..be9ffcbd74 100644
--- a/engines/gargoyle/window_text_buffer.h
+++ b/engines/gargoyle/window_text_buffer.h
@@ -66,8 +66,6 @@ private:
*/
void putTextUni(const glui32 *buf, int len, int pos, int oldlen);
- bool flowBreak();
-
void acceptLine(glui32 keycode);
/**
@@ -221,6 +219,8 @@ public:
virtual void requestHyperlinkEvent() override { _hyperRequest = true; }
virtual void cancelCharEvent() override { _charRequest = _charRequestUni = false; }
+
+ virtual void flowBreak() override;
};
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/windows.cpp b/engines/gargoyle/windows.cpp
index cc23e477d8..2f2008c626 100644
--- a/engines/gargoyle/windows.cpp
+++ b/engines/gargoyle/windows.cpp
@@ -487,6 +487,22 @@ void Window::requestCharEventUni() {
warning("requestCharEventUni: window does not support keyboard input");
}
+void Window::flowBreak() {
+ warning("flowBreak: not a text buffer window");
+}
+
+void Window::eraseRect(bool whole, const Common::Rect &box) {
+ warning("eraseRect: not a graphics window");
+}
+
+void Window::fillRect(glui32 color, const Common::Rect &box) {
+ warning("fillRect: not a graphics window");
+}
+
+void Window::setBackgroundColor(glui32 color) {
+ warning("setBackgroundColor: not a graphics window");
+}
+
void Window::setTerminatorsLineEvent(glui32 *keycodes, glui32 count) {
if (dynamic_cast<TextBufferWindow *>(this) || dynamic_cast<TextGridWindow *>(this)) {
delete _lineTerminatorsBase;
diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h
index b7d701f1f9..03ab1b0b30 100644
--- a/engines/gargoyle/windows.h
+++ b/engines/gargoyle/windows.h
@@ -390,6 +390,14 @@ public:
virtual void requestMouseEvent() {}
virtual void requestHyperlinkEvent() {}
+
+ virtual void flowBreak();
+
+ virtual void eraseRect(bool whole, const Common::Rect &box);
+
+ virtual void fillRect(glui32 color, const Common::Rect &box);
+
+ virtual void setBackgroundColor(glui32 color);
};
typedef Window *winid_t;