GRAPHICS: MACGUI: Further work on MacEditableText

This commit is contained in:
Eugene Sandulenko 2020-01-03 00:49:48 +01:00
parent c3c23c28a1
commit d9f6a0cf4d
4 changed files with 27 additions and 19 deletions

View File

@ -45,8 +45,8 @@ enum {
static void cursorTimerHandler(void *refCon);
MacEditableText::MacEditableText(Common::U32String s, MacWindow *parent, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
MacText(s, parent->_wm, macFont, fgcolor, bgcolor, maxWidth, textAlignment, interlinear), MacWidget(0, true, parent) {
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) {
_parent = parent;
_maxWidth = maxWidth;
@ -54,8 +54,8 @@ MacEditableText::MacEditableText(Common::U32String s, MacWindow *parent, const M
init();
}
MacEditableText::MacEditableText(const Common::String &s, MacWindow *parent, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
MacText(s, parent->_wm, macFont, fgcolor, bgcolor, maxWidth, textAlignment, interlinear), MacWidget(0, true, parent) {
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) {
_parent = parent;
_maxWidth = maxWidth;
@ -132,7 +132,7 @@ void MacEditableText::clearText() {
updateCursorPos();
}
void MacEditableText::setTextWindowFont(const MacFont *font) {
void MacEditableText::setTextFont(const MacFont *font) {
_font = font;
_fontRef = _wm->_fontMan->getFont(*font);
@ -140,7 +140,7 @@ void MacEditableText::setTextWindowFont(const MacFont *font) {
MacText::setDefaultFormatting(font->getId(), font->getSlant(), font->getSize(), 0, 0, 0);
}
const MacFont *MacEditableText::getTextWindowFont() {
const MacFont *MacEditableText::getTextFont() {
return _font;
}
@ -299,7 +299,8 @@ bool MacEditableText::processEvent(Common::Event &event) {
if (!_editable)
return false;
_wm->setActive(getId());
// Make the parent window active
_wm->setActive(_parent->getId());
if (event.kbd.flags & (Common::KBD_ALT | Common::KBD_CTRL | Common::KBD_META)) {
return false;

View File

@ -52,9 +52,9 @@ struct SelectedText {
class MacEditableText : public MacText, public MacWidget {
public:
MacEditableText(Common::U32String s, MacWindow *parent, const MacFont *font, int fgcolor, int bgcolor,
MacEditableText(MacWindow *parent, int x, int y, int w, int h, Common::U32String s, const MacFont *font, int fgcolor, int bgcolor,
int maxWidth = -1, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0);
MacEditableText(const Common::String &s, MacWindow *parent, const MacFont *font, int fgcolor, int bgcolor,
MacEditableText(MacWindow *parent, int x, int y, int w, int h, 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();
@ -65,8 +65,8 @@ public:
virtual bool draw(ManagedSurface *g, bool forceRedraw = false);
void setTextWindowFont(const MacFont *macFont);
const MacFont *getTextWindowFont();
void setTextFont(const MacFont *macFont);
const MacFont *getTextFont();
void appendText(Common::U32String str, const MacFont *macFont, bool skipAdd = false);
void appendText(const Common::String &str, const MacFont *macFont, bool skipAdd = false);

View File

@ -24,9 +24,14 @@
namespace Graphics {
MacWidget::MacWidget(int id, bool focusable, MacWindow *parent) :
_id(id), _focusable(focusable), _parent(parent) {
MacWidget::MacWidget(MacWindow *parent, int x, int y, int w, int h, bool focusable) :
_focusable(focusable), _parent(parent) {
_contentIsDirty = true;
_dims.left = x;
_dims.right = x + w;
_dims.top = y;
_dims.bottom = y + h;
}
} // End of namespace Graphics

View File

@ -25,29 +25,31 @@
#include "common/rect.h"
namespace Common {
struct Event;
}
namespace Graphics {
class MacWindow;
class ManagedSurface;
class MacWidget {
friend class MacEditableText;
public:
MacWidget(int id, bool focusable, MacWindow *parent);
MacWidget(MacWindow *parent, int x, int y, int w, int h, bool focusable);
virtual ~MacWidget() {}
const Common::Rect &getDimensions() { return _dims; }
int getId() { return _id; }
bool isFocusable() { return _focusable; }
virtual void setActive(bool active) = 0;
void setDirty(bool dirty) { _contentIsDirty = dirty; }
//virtual bool draw(ManagedSurface *g, bool forceRedraw = false) = 0;
//virtual bool processEvent(Common::Event &event) = 0;
virtual bool draw(ManagedSurface *g, bool forceRedraw = false) = 0;
virtual bool processEvent(Common::Event &event) = 0;
virtual bool hasAllFocus() = 0;
protected:
int _id;
bool _focusable;
bool _contentIsDirty;