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

dialog.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_DIALOG_H
00024 #define GUI_DIALOG_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/str.h"
00028 #include "common/keyboard.h"
00029 
00030 #include "gui/object.h"
00031 #include "gui/ThemeEngine.h"
00032 
00033 namespace Common {
00034 struct Event;
00035 }
00036 
00037 namespace GUI {
00038 
00039 class EventRecorder;
00040 
00041 class Widget;
00042 
00043 // Some "common" commands sent to handleCommand()
00044 enum {
00045     kCloseWithResultCmd  = 'clsr',
00046     kCloseCmd            = 'clos',
00047     kOKCmd               = 'ok  '
00048 };
00049 
00050 class Dialog : public GuiObject {
00051     friend class GuiManager;
00052     friend class EventRecorder;
00053     friend class Tooltip;
00054 protected:
00055     Widget  *_mouseWidget;
00056     Widget  *_focusedWidget;
00057     Widget  *_dragWidget;
00058     Widget  *_tickleWidget;
00059     bool    _visible;
00060 
00061     ThemeEngine::DialogBackground _backgroundType;
00062 
00063 private:
00064     int     _result;
00065 
00066 public:
00067     Dialog(int x, int y, int w, int h);
00068     Dialog(const Common::String &name);
00069 
00070     virtual int runModal();
00071 
00072     bool    isVisible() const override  { return _visible; }
00073 
00074     void    releaseFocus() override;
00075     void    setFocusWidget(Widget *widget);
00076     Widget *getFocusWidget() { return _focusedWidget; }
00077 
00078     void setTickleWidget(Widget *widget) { _tickleWidget = widget; }
00079     void unSetTickleWidget() { _tickleWidget = nullptr; }
00080     Widget *getTickleWidget() { return _tickleWidget; }
00081 
00082     void reflowLayout() override;
00083     virtual void lostFocus();
00084     virtual void receivedFocus(int x = -1, int y = -1) { if (x >= 0 && y >= 0) handleMouseMoved(x, y, 0); }
00085 
00086 protected:
00087     virtual void open();
00088     virtual void close();
00089 
00091     void markWidgetsAsDirty();
00092 
00094     virtual void drawDialog(DrawLayer layerToDraw);
00095 
00097     void drawWidgets();
00098 
00099     virtual void handleTickle(); // Called periodically (in every guiloop() )
00100     virtual void handleMouseDown(int x, int y, int button, int clickCount);
00101     virtual void handleMouseUp(int x, int y, int button, int clickCount);
00102     virtual void handleMouseWheel(int x, int y, int direction);
00103     virtual void handleKeyDown(Common::KeyState state);
00104     virtual void handleKeyUp(Common::KeyState state);
00105     virtual void handleMouseMoved(int x, int y, int button);
00106     virtual void handleMouseLeft(int button) {}
00107     virtual void handleOtherEvent(const Common::Event &evt) {}
00108     void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00109 
00110     Widget *findWidget(int x, int y); // Find the widget at pos x,y if any
00111     Widget *findWidget(const char *name);
00112     void removeWidget(Widget *widget) override;
00113 
00114     void setDefaultFocusedWidget();
00115 
00116     void setResult(int result) { _result = result; }
00117     int getResult() const { return _result; }
00118 };
00119 
00120 } // End of namespace GUI
00121 
00122 #endif


Generated on Sat Aug 8 2020 05:01:16 for ResidualVM by doxygen 1.7.1
curved edge   curved edge