2002-07-10 22:49:41 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2002-2006 The ScummVM project
|
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
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2002-07-27 14:16:14 +00:00
|
|
|
// Some special commands
|
|
|
|
enum {
|
2002-10-01 23:11:19 +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
|
2002-12-25 00:38:53 +00:00
|
|
|
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 */
|
2005-01-29 16:30:51 +00:00
|
|
|
class ListWidget : public EditableWidget, public CommandSender {
|
|
|
|
public:
|
2003-10-02 17:43:02 +00:00
|
|
|
typedef Common::String String;
|
2005-01-29 16:30:51 +00:00
|
|
|
typedef Common::StringList StringList;
|
2002-07-10 22:49:41 +00:00
|
|
|
protected:
|
2002-07-12 16:24:11 +00:00
|
|
|
StringList _list;
|
|
|
|
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
|
|
|
|
2002-07-10 22:49:41 +00:00
|
|
|
public:
|
2006-06-03 13:33:39 +00:00
|
|
|
ListWidget(GuiObject *boss, const String &name);
|
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);
|
|
|
|
|
2002-10-19 01:22:41 +00:00
|
|
|
void setList(const StringList& list);
|
2002-07-13 12:02:10 +00:00
|
|
|
const StringList& getList() const { return _list; }
|
|
|
|
int getSelected() const { return _selectedItem; }
|
2004-10-01 21:12:18 +00:00
|
|
|
void setSelected(int item);
|
2002-08-25 10:50:18 +00:00
|
|
|
const String& getSelectedString() const { return _list[_selectedItem]; }
|
2003-11-03 20:13:04 +00:00
|
|
|
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
|
2002-09-30 12:56:59 +00:00
|
|
|
bool isEditable() const { return _editable; }
|
|
|
|
void setEditable(bool editable) { _editable = editable; }
|
2002-11-14 14:42:39 +00:00
|
|
|
void scrollTo(int item);
|
2005-07-30 21:11:48 +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);
|
2002-11-22 14:02:54 +00:00
|
|
|
virtual bool handleKeyDown(uint16 ascii, int keycode, int modifiers);
|
|
|
|
virtual bool handleKeyUp(uint16 ascii, int keycode, int modifiers);
|
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
|
|
|
|
2005-01-29 16:30:51 +00:00
|
|
|
// Made startEditMode for SCUMM's SaveLoadChooser
|
2002-10-19 01:22:41 +00:00
|
|
|
void startEditMode();
|
2005-03-27 11:27:07 +00:00
|
|
|
void endEditMode();
|
2002-07-18 20:26:35 +00:00
|
|
|
|
2002-07-10 22:49:41 +00:00
|
|
|
protected:
|
|
|
|
void drawWidget(bool hilite);
|
2005-01-29 16:30:51 +00:00
|
|
|
|
2006-06-24 13:21:46 +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
|
|
|
|
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
|