ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

object.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GUI_OBJECT_H
00024 #define GUI_OBJECT_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/str.h"
00028 #include "common/rect.h"
00029 
00030 namespace GUI {
00031 
00032 class CommandSender;
00033 
00034 class CommandReceiver {
00035     friend class CommandSender;
00036 protected:
00037     virtual ~CommandReceiver() {}
00038     virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {}
00039 };
00040 
00041 class CommandSender {
00042     // TODO - allow for multiple targets, i.e. store targets in a list
00043     // and add methods addTarget/removeTarget.
00044 protected:
00045     CommandReceiver *_target;
00046 public:
00047     CommandSender(CommandReceiver *target) : _target(target) {}
00048     virtual ~CommandSender() {}
00049 
00050     void setTarget(CommandReceiver *target) { _target = target; }
00051     CommandReceiver *getTarget() const      { return _target; }
00052 
00053     virtual void sendCommand(uint32 cmd, uint32 data) {
00054         if (_target && cmd)
00055             _target->handleCommand(this, cmd, data);
00056     }
00057 };
00058 
00059 class Widget;
00060 
00061 class GuiObject : public CommandReceiver {
00062     friend class Widget;
00063 protected:
00064     Common::Rect _textDrawableArea;
00065 
00066     int16       _x, _y;
00067     uint16      _w, _h;
00068     const Common::String _name;
00069 
00070     Widget      *_firstWidget;
00071 
00072 public:
00073     GuiObject(int x, int y, int w, int h) : _x(x), _y(y), _w(w), _h(h), _firstWidget(nullptr) { }
00074     GuiObject(const Common::String &name);
00075     ~GuiObject();
00076 
00077     virtual void setTextDrawableArea(const Common::Rect &r) { _textDrawableArea = r; }
00078 
00079     virtual int16   getRelX() const     { return _x; }
00080     virtual int16   getRelY() const     { return _y; }
00081     virtual int16   getAbsX() const     { return _x; }
00082     virtual int16   getAbsY() const     { return _y; }
00083     virtual int16   getChildX() const   { return getAbsX(); }
00084     virtual int16   getChildY() const   { return getAbsY(); }
00085     virtual uint16  getWidth() const    { return _w; }
00086     virtual uint16  getHeight() const   { return _h; }
00087 
00088     virtual bool    isVisible() const = 0;
00089 
00090     virtual void    reflowLayout();
00091 
00092     virtual void    removeWidget(Widget *widget);
00093 
00094     virtual bool    isPointIn(int x, int y) {
00095         return (x >= _x && x < (_x + _w) && (y >= _y) && (y < _y + _h));
00096     }
00097 
00101     virtual Common::Rect getClipRect() const;
00102 
00103 protected:
00104     virtual void    releaseFocus() = 0;
00105 };
00106 
00107 } // End of namespace GUI
00108 
00109 #endif


Generated on Sat Sep 14 2019 05:01:17 for ResidualVM by doxygen 1.7.1
curved edge   curved edge