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


Generated on Sat Sep 26 2020 05:00:48 for ResidualVM by doxygen 1.7.1
curved edge   curved edge