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

gui/widgets/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 
00083     uint32          _cmd;
00084 
00085     ThemeEngine::FontColor _editColor;
00086 
00087 public:
00088     ListWidget(Dialog *boss, const String &name, const char *tooltip = 0, uint32 cmd = 0);
00089     ListWidget(Dialog *boss, int x, int y, int w, int h, const char *tooltip = 0, uint32 cmd = 0);
00090 
00091     virtual bool containsWidget(Widget *) const;
00092     virtual Widget *findWidget(int x, int y);
00093 
00094     void setList(const StringArray &list, const ColorList *colors = 0);
00095     const StringArray &getList()    const           { return _dataList; }
00096 
00097     void append(const String &s, ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal);
00098 
00099     void setSelected(int item);
00100     int getSelected() const                     { return (_filter.empty() || _selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
00101 
00102     const String &getSelectedString() const     { return _list[_selectedItem]; }
00103     ThemeEngine::FontColor getSelectionColor() const;
00104 
00105     void setNumberingMode(NumberingMode numberingMode)  { _numberingMode = numberingMode; }
00106 
00107     void scrollTo(int item);
00108     void scrollToEnd();
00109     int getCurrentScrollPos() const { return _currentPos; }
00110 
00111     void enableQuickSelect(bool enable)         { _quickSelect = enable; }
00112     String getQuickSelectString() const         { return _quickSelectStr; }
00113 
00114     bool isEditable() const                     { return _editable; }
00115     void setEditable(bool editable)             { _editable = editable; }
00116     void setEditColor(ThemeEngine::FontColor color) { _editColor = color; }
00117 
00118     // Made startEditMode/endEditMode for SaveLoadChooser
00119     void startEditMode();
00120     void endEditMode();
00121 
00122     void setFilter(const String &filter, bool redraw = true);
00123 
00124     virtual void handleTickle();
00125     virtual void handleMouseDown(int x, int y, int button, int clickCount);
00126     virtual void handleMouseUp(int x, int y, int button, int clickCount);
00127     virtual void handleMouseWheel(int x, int y, int direction);
00128     virtual bool handleKeyDown(Common::KeyState state);
00129     virtual bool handleKeyUp(Common::KeyState state);
00130     virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
00131 
00132     virtual void reflowLayout();
00133 
00134     virtual bool wantsFocus() { return true; }
00135 
00136 protected:
00137     void drawWidget();
00138 
00140     int findItem(int x, int y) const;
00141     void scrollBarRecalc();
00142 
00143     void abortEditMode();
00144 
00145     Common::Rect getEditRect() const;
00146 
00147     void receivedFocusWidget();
00148     void lostFocusWidget();
00149     void checkBounds();
00150     void scrollToCurrent();
00151 };
00152 
00153 } // End of namespace GUI
00154 
00155 #endif


Generated on Sat May 18 2019 05:01:07 for ResidualVM by doxygen 1.7.1
curved edge   curved edge