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

list.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_WIDGETS_LIST_H
00024 #define GUI_WIDGETS_LIST_H
00025 
00026 #include "gui/widgets/editable.h"
00027 #include "common/str.h"
00028 
00029 #include "gui/ThemeEngine.h"
00030 
00031 namespace GUI {
00032 
00033 class ScrollBarWidget;
00034 
00035 enum NumberingMode {
00036     kListNumberingOff   = -1,
00037     kListNumberingZero  = 0,
00038     kListNumberingOne   = 1
00039 };
00040 
00042 enum {
00043     kListItemDoubleClickedCmd   = 'LIdb',   
00044     kListItemActivatedCmd       = 'LIac',   
00045     kListItemRemovalRequestCmd  = 'LIrm',   
00046     kListSelectionChangedCmd    = 'Lsch'    
00047 };
00048 
00049 /* ListWidget */
00050 class ListWidget : public EditableWidget {
00051 public:
00052     typedef Common::String String;
00053     typedef Common::Array<Common::String> StringArray;
00054     typedef Common::Array<ThemeEngine::FontColor> ColorList;
00055 protected:
00056     StringArray     _list;
00057     StringArray     _dataList;
00058     ColorList       _listColors;
00059     Common::Array<int>      _listIndex;
00060     bool            _editable;
00061     bool            _editMode;
00062     NumberingMode   _numberingMode;
00063     int             _currentPos;
00064     int             _entriesPerPage;
00065     int             _selectedItem;
00066     ScrollBarWidget *_scrollBar;
00067     int             _currentKeyDown;
00068 
00069     String          _quickSelectStr;
00070     uint32          _quickSelectTime;
00071 
00072     int             _hlLeftPadding;
00073     int             _hlRightPadding;
00074     int             _leftPadding;
00075     int             _rightPadding;
00076     int             _topPadding;
00077     int             _bottomPadding;
00078     int             _scrollBarWidth;
00079 
00080     String          _filter;
00081     bool            _quickSelect;
00082     bool            _dictionarySelect;
00083 
00084     uint32          _cmd;
00085 
00086     ThemeEngine::FontColor _editColor;
00087 
00088     int             _lastRead;
00089 
00090 public:
00091     ListWidget(Dialog *boss, const String &name, const char *tooltip = nullptr, uint32 cmd = 0);
00092     ListWidget(Dialog *boss, int x, int y, int w, int h, const char *tooltip = nullptr, uint32 cmd = 0);
00093 
00094     bool containsWidget(Widget *) const override;
00095     Widget *findWidget(int x, int y) override;
00096 
00097     void setList(const StringArray &list, const ColorList *colors = nullptr);
00098     const StringArray &getList()    const           { return _dataList; }
00099 
00100     void append(const String &s, ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal);
00101 
00102     void setSelected(int item);
00103     int getSelected() const                     { return (_filter.empty() || _selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
00104 
00105     const String &getSelectedString() const     { return _list[_selectedItem]; }
00106     ThemeEngine::FontColor getSelectionColor() const;
00107 
00108     void setNumberingMode(NumberingMode numberingMode)  { _numberingMode = numberingMode; }
00109 
00110     void scrollTo(int item);
00111     void scrollToEnd();
00112     int getCurrentScrollPos() const { return _currentPos; }
00113 
00114     void enableQuickSelect(bool enable)         { _quickSelect = enable; }
00115     String getQuickSelectString() const         { return _quickSelectStr; }
00116 
00117     void enableDictionarySelect(bool enable)    { _dictionarySelect = enable; }
00118 
00119     bool isEditable() const                     { return _editable; }
00120     void setEditable(bool editable)             { _editable = editable; }
00121     void setEditColor(ThemeEngine::FontColor color) { _editColor = color; }
00122 
00123     // Made startEditMode/endEditMode for SaveLoadChooser
00124     void startEditMode() override;
00125     void endEditMode() override;
00126 
00127     void setFilter(const String &filter, bool redraw = true);
00128 
00129     void handleTickle() override;
00130     void handleMouseDown(int x, int y, int button, int clickCount) override;
00131     void handleMouseUp(int x, int y, int button, int clickCount) override;
00132     void handleMouseWheel(int x, int y, int direction) override;
00133     void handleMouseMoved(int x, int y, int button) override;
00134     void handleMouseLeft(int button) override;
00135     bool handleKeyDown(Common::KeyState state) override;
00136     bool handleKeyUp(Common::KeyState state) override;
00137     void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00138 
00139     void reflowLayout() override;
00140 
00141     bool wantsFocus() override { return true; }
00142 
00143 protected:
00144     void drawWidget() override;
00145 
00147     int findItem(int x, int y) const;
00148     void scrollBarRecalc();
00149 
00150     void abortEditMode() override;
00151 
00152     Common::Rect getEditRect() const override;
00153 
00154     void receivedFocusWidget() override;
00155     void lostFocusWidget() override;
00156     void checkBounds();
00157     void scrollToCurrent();
00158 };
00159 
00160 } // End of namespace GUI
00161 
00162 #endif


Generated on Sat May 30 2020 05:00:39 for ResidualVM by doxygen 1.7.1
curved edge   curved edge