2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-07-10 22:49:41 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-07-10 22:49:41 +00:00
|
|
|
*
|
2006-02-11 10:08:56 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-07-10 22:49:41 +00:00
|
|
|
*/
|
|
|
|
|
2005-01-29 16:30:51 +00:00
|
|
|
#ifndef GUI_LISTWIDGET_H
|
|
|
|
#define GUI_LISTWIDGET_H
|
2002-07-10 22:49:41 +00:00
|
|
|
|
2005-01-29 16:30:51 +00:00
|
|
|
#include "gui/editable.h"
|
2002-11-21 12:48:50 +00:00
|
|
|
#include "common/str.h"
|
2002-07-10 22:49:41 +00:00
|
|
|
|
2009-08-20 09:19:37 +00:00
|
|
|
#include "gui/ThemeEngine.h"
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2002-07-12 16:24:11 +00:00
|
|
|
class ScrollBarWidget;
|
2002-07-10 22:49:41 +00:00
|
|
|
|
2003-11-03 20:13:04 +00:00
|
|
|
enum NumberingMode {
|
2002-07-10 22:49:41 +00:00
|
|
|
kListNumberingOff = -1,
|
|
|
|
kListNumberingZero = 0,
|
|
|
|
kListNumberingOne = 1
|
|
|
|
};
|
|
|
|
|
2009-10-08 21:28:57 +00:00
|
|
|
/// Some special commands
|
2002-07-27 14:16:14 +00:00
|
|
|
enum {
|
2009-10-08 21:28:57 +00:00
|
|
|
kListItemDoubleClickedCmd = 'LIdb', ///< double click on item - 'data' will be item index
|
|
|
|
kListItemActivatedCmd = 'LIac', ///< item activated by return/enter - 'data' will be item index
|
|
|
|
kListItemRemovalRequestCmd = 'LIrm', ///< request to remove the item with the delete/backspace keys - 'data' will be item index
|
|
|
|
kListSelectionChangedCmd = 'Lsch' ///< selection changed - 'data' will be item index
|
2002-07-27 14:16:14 +00:00
|
|
|
};
|
|
|
|
|
2002-07-10 22:49:41 +00:00
|
|
|
/* ListWidget */
|
2009-06-06 17:53:25 +00:00
|
|
|
class ListWidget : public EditableWidget {
|
2005-01-29 16:30:51 +00:00
|
|
|
public:
|
2003-10-02 17:43:02 +00:00
|
|
|
typedef Common::String String;
|
2010-03-18 15:09:24 +00:00
|
|
|
typedef Common::Array<Common::String> StringArray;
|
2009-08-20 09:19:37 +00:00
|
|
|
typedef Common::Array<ThemeEngine::FontColor> ColorList;
|
2002-07-10 22:49:41 +00:00
|
|
|
protected:
|
2010-03-18 15:09:24 +00:00
|
|
|
StringArray _list;
|
|
|
|
StringArray _dataList;
|
2009-08-20 09:19:37 +00:00
|
|
|
ColorList _listColors;
|
2009-06-06 17:54:59 +00:00
|
|
|
Common::Array<int> _listIndex;
|
2002-07-12 16:24:11 +00:00
|
|
|
bool _editable;
|
2002-07-16 10:52:48 +00:00
|
|
|
bool _editMode;
|
2003-11-03 20:13:04 +00:00
|
|
|
NumberingMode _numberingMode;
|
2002-07-12 16:24:11 +00:00
|
|
|
int _currentPos;
|
|
|
|
int _entriesPerPage;
|
2002-07-13 09:19:23 +00:00
|
|
|
int _selectedItem;
|
2002-07-12 16:24:11 +00:00
|
|
|
ScrollBarWidget *_scrollBar;
|
2002-07-18 14:47:25 +00:00
|
|
|
int _currentKeyDown;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-07-21 14:28:57 +00:00
|
|
|
String _quickSelectStr;
|
|
|
|
uint32 _quickSelectTime;
|
2005-01-29 16:30:51 +00:00
|
|
|
|
2006-04-16 10:23:36 +00:00
|
|
|
int _hlLeftPadding;
|
|
|
|
int _hlRightPadding;
|
|
|
|
int _leftPadding;
|
|
|
|
int _rightPadding;
|
|
|
|
int _topPadding;
|
|
|
|
int _bottomPadding;
|
2006-05-27 05:46:04 +00:00
|
|
|
int _scrollBarWidth;
|
2006-04-16 10:23:36 +00:00
|
|
|
|
2009-06-06 17:54:08 +00:00
|
|
|
String _filter;
|
2009-06-06 17:54:28 +00:00
|
|
|
bool _quickSelect;
|
|
|
|
|
|
|
|
uint32 _cmd;
|
2009-06-06 17:54:08 +00:00
|
|
|
|
2009-08-20 10:04:21 +00:00
|
|
|
ThemeEngine::FontColor _editColor;
|
|
|
|
|
2002-07-10 22:49:41 +00:00
|
|
|
public:
|
2010-06-15 10:54:22 +00:00
|
|
|
ListWidget(Dialog *boss, const String &name, const char *tooltip = 0, uint32 cmd = 0);
|
|
|
|
ListWidget(Dialog *boss, int x, int y, int w, int h, const char *tooltip = 0, uint32 cmd = 0);
|
2002-07-10 22:49:41 +00:00
|
|
|
virtual ~ListWidget();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-05-27 06:38:45 +00:00
|
|
|
virtual Widget *findWidget(int x, int y);
|
|
|
|
|
2010-03-18 15:09:24 +00:00
|
|
|
void setList(const StringArray &list, const ColorList *colors = 0);
|
|
|
|
const StringArray &getList() const { return _dataList; }
|
2009-08-20 10:05:00 +00:00
|
|
|
|
|
|
|
void append(const String &s, ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal);
|
|
|
|
|
2004-10-01 21:12:18 +00:00
|
|
|
void setSelected(int item);
|
2009-08-20 10:05:00 +00:00
|
|
|
int getSelected() const { return (_filter.empty() || _selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
|
|
|
|
|
2008-11-07 13:20:25 +00:00
|
|
|
const String &getSelectedString() const { return _list[_selectedItem]; }
|
2009-08-20 10:04:21 +00:00
|
|
|
ThemeEngine::FontColor getSelectionColor() const;
|
2009-08-20 10:05:00 +00:00
|
|
|
|
2003-11-03 20:13:04 +00:00
|
|
|
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
|
2009-08-20 10:05:00 +00:00
|
|
|
|
2002-11-14 14:42:39 +00:00
|
|
|
void scrollTo(int item);
|
2009-06-06 17:49:59 +00:00
|
|
|
void scrollToEnd();
|
2009-08-20 10:05:00 +00:00
|
|
|
|
2009-06-06 17:54:28 +00:00
|
|
|
void enableQuickSelect(bool enable) { _quickSelect = enable; }
|
|
|
|
String getQuickSelectString() const { return _quickSelectStr; }
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2009-08-20 10:05:00 +00:00
|
|
|
bool isEditable() const { return _editable; }
|
|
|
|
void setEditable(bool editable) { _editable = editable; }
|
2009-08-20 10:04:21 +00:00
|
|
|
void setEditColor(ThemeEngine::FontColor color) { _editColor = color; }
|
|
|
|
|
2009-08-20 10:05:00 +00:00
|
|
|
// Made startEditMode/endEditMode for SaveLoadChooser
|
|
|
|
void startEditMode();
|
|
|
|
void endEditMode();
|
|
|
|
|
2009-06-06 17:54:59 +00:00
|
|
|
void setFilter(const String &filter, bool redraw = true);
|
2009-06-06 17:54:08 +00:00
|
|
|
|
2002-10-23 14:00:47 +00:00
|
|
|
virtual void handleTickle();
|
2002-07-27 14:16:14 +00:00
|
|
|
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
|
|
|
virtual void handleMouseUp(int x, int y, int button, int clickCount);
|
2002-10-16 20:32:12 +00:00
|
|
|
virtual void handleMouseWheel(int x, int y, int direction);
|
2007-06-30 12:26:59 +00:00
|
|
|
virtual bool handleKeyDown(Common::KeyState state);
|
|
|
|
virtual bool handleKeyUp(Common::KeyState state);
|
2002-07-12 16:24:11 +00:00
|
|
|
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
2002-07-10 22:49:41 +00:00
|
|
|
|
2006-08-04 13:55:53 +00:00
|
|
|
virtual void reflowLayout();
|
2006-04-19 01:05:28 +00:00
|
|
|
|
2005-04-06 15:21:32 +00:00
|
|
|
virtual bool wantsFocus() { return true; }
|
2002-09-08 16:00:13 +00:00
|
|
|
|
2002-07-10 22:49:41 +00:00
|
|
|
protected:
|
2007-11-04 03:38:30 +00:00
|
|
|
void drawWidget();
|
2005-01-29 16:30:51 +00:00
|
|
|
|
2009-10-08 21:28:57 +00:00
|
|
|
/// Finds the item at position (x,y). Returns -1 if there is no item there.
|
2005-03-12 15:29:16 +00:00
|
|
|
int findItem(int x, int y) const;
|
2005-01-29 16:30:51 +00:00
|
|
|
void scrollBarRecalc();
|
|
|
|
|
|
|
|
void abortEditMode();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-01-29 16:30:51 +00:00
|
|
|
Common::Rect getEditRect() const;
|
2003-11-18 23:44:28 +00:00
|
|
|
|
2009-09-13 20:03:04 +00:00
|
|
|
void receivedFocusWidget();
|
2002-07-16 10:52:48 +00:00
|
|
|
void lostFocusWidget();
|
|
|
|
void scrollToCurrent();
|
2006-01-28 18:21:46 +00:00
|
|
|
|
|
|
|
int *_textWidth;
|
2002-07-10 22:49:41 +00:00
|
|
|
};
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
} // End of namespace GUI
|
|
|
|
|
2002-07-10 22:49:41 +00:00
|
|
|
#endif
|