| 1 | //============================================================================ |
| 2 | // |
| 3 | // SSSS tt lll lll |
| 4 | // SS SS tt ll ll |
| 5 | // SS tttttt eeee ll ll aaaa |
| 6 | // SSSS tt ee ee ll ll aa |
| 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
| 8 | // SS SS tt ee ll ll aa aa |
| 9 | // SSSS ttt eeeee llll llll aaaaa |
| 10 | // |
| 11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
| 12 | // and the Stella Team |
| 13 | // |
| 14 | // See the file "License.txt" for information on usage and redistribution of |
| 15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 16 | //============================================================================ |
| 17 | |
| 18 | #ifndef INPUT_TEXT_DIALOG_HXX |
| 19 | #define INPUT_TEXT_DIALOG_HXX |
| 20 | |
| 21 | class GuiObject; |
| 22 | class StaticTextWidget; |
| 23 | class EditTextWidget; |
| 24 | |
| 25 | #include "Dialog.hxx" |
| 26 | #include "Command.hxx" |
| 27 | #include "EditableWidget.hxx" |
| 28 | |
| 29 | class InputTextDialog : public Dialog, public CommandSender |
| 30 | { |
| 31 | public: |
| 32 | InputTextDialog(GuiObject* boss, const GUI::Font& font, |
| 33 | const StringList& labels, const string& title = "" ); |
| 34 | InputTextDialog(GuiObject* boss, const GUI::Font& lfont, |
| 35 | const GUI::Font& nfont, const StringList& labels, const string& title = "" ); |
| 36 | virtual ~InputTextDialog() = default; |
| 37 | |
| 38 | /** Place the input dialog onscreen and center it */ |
| 39 | void show(); |
| 40 | |
| 41 | /** Show input dialog onscreen at the specified coordinates */ |
| 42 | void show(uInt32 x, uInt32 y, const Common::Rect& bossRect); |
| 43 | |
| 44 | const string& getResult(int idx = 0); |
| 45 | |
| 46 | void setText(const string& str, int idx = 0); |
| 47 | void setTextFilter(const EditableWidget::TextFilter& f, int idx = 0); |
| 48 | |
| 49 | void setEmitSignal(int cmd) { myCmd = cmd; } |
| 50 | void setMessage(const string& title); |
| 51 | |
| 52 | void setFocus(int idx = 0); |
| 53 | |
| 54 | protected: |
| 55 | void initialize(const GUI::Font& lfont, const GUI::Font& nfont, |
| 56 | const StringList& labels); |
| 57 | void handleCommand(CommandSender* sender, int cmd, int data, int id) override; |
| 58 | |
| 59 | /** This dialog uses its own positioning, so we override Dialog::center() */ |
| 60 | void center() override; |
| 61 | |
| 62 | private: |
| 63 | vector<EditTextWidget*> myInput; |
| 64 | StaticTextWidget* myMessage; |
| 65 | |
| 66 | bool myEnableCenter; |
| 67 | bool myErrorFlag; |
| 68 | int myCmd; |
| 69 | |
| 70 | uInt32 myXOrig, myYOrig; |
| 71 | |
| 72 | private: |
| 73 | // Following constructors and assignment operators not supported |
| 74 | InputTextDialog() = delete; |
| 75 | InputTextDialog(const InputTextDialog&) = delete; |
| 76 | InputTextDialog(InputTextDialog&&) = delete; |
| 77 | InputTextDialog& operator=(const InputTextDialog&) = delete; |
| 78 | InputTextDialog& operator=(InputTextDialog&&) = delete; |
| 79 | }; |
| 80 | |
| 81 | #endif |
| 82 | |