2002-07-10 22:49:41 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2002-2003 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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LISTWIDGET_H
|
|
|
|
#define LISTWIDGET_H
|
|
|
|
|
|
|
|
#include "widget.h"
|
2002-11-21 12:48:50 +00:00
|
|
|
#include "common/str.h"
|
|
|
|
#include "common/list.h"
|
2002-07-10 22:49:41 +00:00
|
|
|
|
2002-07-12 16:24:11 +00:00
|
|
|
class ScrollBarWidget;
|
2002-07-10 22:49:41 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
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 */
|
2002-07-18 20:26:35 +00:00
|
|
|
class ListWidget : public Widget, public CommandReceiver, public CommandSender {
|
2003-10-02 17:43:02 +00:00
|
|
|
typedef Common::StringList StringList;
|
|
|
|
typedef Common::String String;
|
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;
|
2002-07-12 16:24:11 +00:00
|
|
|
int _numberingMode;
|
|
|
|
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;
|
2002-07-27 14:16:14 +00:00
|
|
|
String _backupString;
|
2002-10-23 14:00:47 +00:00
|
|
|
bool _caretVisible;
|
|
|
|
uint32 _caretTime;
|
2002-07-10 22:49:41 +00:00
|
|
|
public:
|
|
|
|
ListWidget(Dialog *boss, int x, int y, int w, int h);
|
|
|
|
virtual ~ListWidget();
|
|
|
|
|
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; }
|
2002-08-25 10:50:18 +00:00
|
|
|
const String& getSelectedString() const { return _list[_selectedItem]; }
|
2002-07-10 22:49:41 +00:00
|
|
|
void setNumberingMode(int 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);
|
2002-07-10 22:49:41 +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
|
|
|
|
2002-09-08 16:00:13 +00:00
|
|
|
virtual bool wantsFocus() { return true; };
|
|
|
|
|
2002-07-18 20:26:35 +00:00
|
|
|
void scrollBarRecalc();
|
2002-10-19 01:22:41 +00:00
|
|
|
|
|
|
|
void startEditMode();
|
|
|
|
void abortEditMode();
|
2002-07-18 20:26:35 +00:00
|
|
|
|
2002-07-10 22:49:41 +00:00
|
|
|
protected:
|
|
|
|
void drawWidget(bool hilite);
|
2002-10-23 14:00:47 +00:00
|
|
|
void drawCaret(bool erase);
|
2002-07-16 10:52:48 +00:00
|
|
|
void lostFocusWidget();
|
|
|
|
void scrollToCurrent();
|
2002-07-10 22:49:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|