mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 16:03:24 +00:00
GRAPHICS: MACGUI: Implemented addWidget() to BaseMacWindow class
This commit is contained in:
parent
e3d7d53000
commit
7d81e1c14f
@ -45,19 +45,17 @@ enum {
|
||||
|
||||
static void cursorTimerHandler(void *refCon);
|
||||
|
||||
MacEditableText::MacEditableText(MacWindow *parent, int x, int y, int w, int h, Common::U32String s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
|
||||
MacWidget(parent, x, y, w, h, true), MacText(s, parent->_wm, macFont, fgcolor, bgcolor, maxWidth, textAlignment, interlinear) {
|
||||
MacEditableText::MacEditableText(int w, int h, MacWindowManager *wm, Common::U32String s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
|
||||
MacWidget(w, h, true), MacText(s, wm, macFont, fgcolor, bgcolor, maxWidth, textAlignment, interlinear) {
|
||||
|
||||
_parent = parent;
|
||||
_maxWidth = maxWidth;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
MacEditableText::MacEditableText(MacWindow *parent, int x, int y, int w, int h, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
|
||||
MacWidget(parent, x, y, w, h, true), MacText(s, parent->_wm, macFont, fgcolor, bgcolor, maxWidth, textAlignment, interlinear) {
|
||||
MacEditableText::MacEditableText(int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
|
||||
MacWidget(w, h, true), MacText(s, wm, macFont, fgcolor, bgcolor, maxWidth, textAlignment, interlinear) {
|
||||
|
||||
_parent = parent;
|
||||
_maxWidth = maxWidth;
|
||||
|
||||
init();
|
||||
|
@ -52,9 +52,9 @@ struct SelectedText {
|
||||
|
||||
class MacEditableText : public MacText, public MacWidget {
|
||||
public:
|
||||
MacEditableText(MacWindow *parent, int x, int y, int w, int h, Common::U32String s, const MacFont *font, int fgcolor, int bgcolor,
|
||||
MacEditableText(int w, int h, MacWindowManager *wm, Common::U32String s, const MacFont *font, int fgcolor, int bgcolor,
|
||||
int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0);
|
||||
MacEditableText(MacWindow *parent, int x, int y, int w, int h, const Common::String &s, const MacFont *font, int fgcolor, int bgcolor,
|
||||
MacEditableText(int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *font, int fgcolor, int bgcolor,
|
||||
int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0);
|
||||
// 0 pixels between the lines by default
|
||||
virtual ~MacEditableText();
|
||||
|
@ -24,14 +24,14 @@
|
||||
|
||||
namespace Graphics {
|
||||
|
||||
MacWidget::MacWidget(MacWindow *parent, int x, int y, int w, int h, bool focusable) :
|
||||
_focusable(focusable), _parent(parent) {
|
||||
MacWidget::MacWidget(int w, int h, bool focusable) :
|
||||
_focusable(focusable) {
|
||||
_contentIsDirty = true;
|
||||
|
||||
_dims.left = x;
|
||||
_dims.right = x + w;
|
||||
_dims.top = y;
|
||||
_dims.bottom = y + h;
|
||||
_dims.left = 0;
|
||||
_dims.right = w;
|
||||
_dims.top = 0;
|
||||
_dims.bottom = h;
|
||||
}
|
||||
|
||||
} // End of namespace Graphics
|
||||
|
@ -31,14 +31,14 @@ namespace Common {
|
||||
|
||||
namespace Graphics {
|
||||
|
||||
class MacWindow;
|
||||
class BaseMacWindow;
|
||||
class ManagedSurface;
|
||||
|
||||
class MacWidget {
|
||||
friend class MacEditableText;
|
||||
|
||||
public:
|
||||
MacWidget(MacWindow *parent, int x, int y, int w, int h, bool focusable);
|
||||
MacWidget(int w, int h, bool focusable);
|
||||
virtual ~MacWidget() {}
|
||||
|
||||
const Common::Rect &getDimensions() { return _dims; }
|
||||
@ -48,6 +48,7 @@ public:
|
||||
virtual bool draw(ManagedSurface *g, bool forceRedraw = false) = 0;
|
||||
virtual bool processEvent(Common::Event &event) = 0;
|
||||
virtual bool hasAllFocus() = 0;
|
||||
void setParent(BaseMacWindow *parent) { _parent = parent; }
|
||||
|
||||
protected:
|
||||
bool _focusable;
|
||||
@ -56,7 +57,7 @@ protected:
|
||||
Common::Rect _dims;
|
||||
|
||||
public:
|
||||
MacWindow *_parent;
|
||||
BaseMacWindow *_parent;
|
||||
};
|
||||
|
||||
} // End of namespace Graphics
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "graphics/macgui/macfontmanager.h"
|
||||
#include "graphics/macgui/macwindowmanager.h"
|
||||
#include "graphics/macgui/macwindow.h"
|
||||
#include "graphics/macgui/macwidget.h"
|
||||
#include "image/bmp.h"
|
||||
|
||||
namespace Graphics {
|
||||
@ -40,6 +41,22 @@ BaseMacWindow::BaseMacWindow(int id, bool editable, MacWindowManager *wm) :
|
||||
_type = kWindowUnknown;
|
||||
}
|
||||
|
||||
WidgetInfo::WidgetInfo(MacWidget *widget_, int x, int y) {
|
||||
widget = widget_;
|
||||
bbox = widget->getDimensions();
|
||||
bbox.moveTo(x, y);
|
||||
}
|
||||
|
||||
WidgetInfo::~WidgetInfo() {
|
||||
delete widget;
|
||||
}
|
||||
|
||||
void BaseMacWindow::addWidget(MacWidget *widget, int x, int y) {
|
||||
_widgets.push_back(new WidgetInfo(widget, x, y));
|
||||
|
||||
widget->setParent(this);
|
||||
}
|
||||
|
||||
MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, MacWindowManager *wm) :
|
||||
BaseMacWindow(id, editable, wm), _scrollable(scrollable), _resizable(resizable) {
|
||||
_active = false;
|
||||
|
@ -36,6 +36,7 @@ namespace Graphics {
|
||||
|
||||
class MacWindowManager;
|
||||
class MacWindowBorder;
|
||||
class MacWidget;
|
||||
|
||||
namespace MacWindowConstants {
|
||||
enum WindowType {
|
||||
@ -62,6 +63,14 @@ enum WindowClick {
|
||||
}
|
||||
using namespace MacWindowConstants;
|
||||
|
||||
struct WidgetInfo {
|
||||
Common::Rect bbox;
|
||||
MacWidget *widget;
|
||||
|
||||
WidgetInfo(MacWidget *widget_, int x, int y);
|
||||
~WidgetInfo();
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstract class that defines common functionality for all window classes.
|
||||
* It supports event callbacks and drawing.
|
||||
@ -150,6 +159,8 @@ public:
|
||||
*/
|
||||
void setCallback(bool (*callback)(WindowClick, Common::Event &, void *), void *data) { _callback = callback; _dataPtr = data; }
|
||||
|
||||
void addWidget(MacWidget *widget, int x, int y);
|
||||
|
||||
protected:
|
||||
int _id;
|
||||
WindowType _type;
|
||||
@ -164,6 +175,8 @@ protected:
|
||||
bool (*_callback)(WindowClick, Common::Event &, void *);
|
||||
void *_dataPtr;
|
||||
|
||||
Common::List<WidgetInfo *> _widgets;
|
||||
|
||||
public:
|
||||
MacWindowManager *_wm;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user