1
//============================================================================
5
// SS tttttt eeee ll ll aaaa
6
// SSSS tt ee ee ll ll aa
7
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8
// SS SS tt ee ll ll aa aa
9
// SSSS ttt eeeee llll llll aaaaa
11
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
13
// See the file "license" for information on usage and redistribution of
14
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
// $Id: PopUpWidget.hxx,v 1.12 2006/02/22 17:38:04 stephena Exp $
18
// Based on code from ScummVM - Scumm Interpreter
19
// Copyright (C) 2002-2004 The ScummVM project
20
//============================================================================
22
#ifndef POPUP_WIDGET_HXX
23
#define POPUP_WIDGET_HXX
31
#include "Command.hxx"
33
#include "GuiUtils.hxx"
38
* Popup or dropdown widget which, when clicked, "pop up" a list of items and
39
* lets the user pick on of them.
41
* Implementation wise, when the user selects an item, then a kPopUpItemSelectedCmd
42
* is broadcast, with data being equal to the tag value of the selected entry.
44
class PopUpWidget : public Widget, public CommandSender
46
friend class PopUpDialog;
53
typedef Common::Array<Entry> EntryList;
62
PopUpWidget(GuiObject* boss, const GUI::Font& font,
63
int x, int y, int w, int h,
64
const string& label, int labelWidth = 0, int cmd = 0);
67
void handleMouseDown(int x, int y, int button, int clickCount);
69
void appendEntry(const string& entry, int tag = (int)-1);
72
/** Select the entry at the given index. */
73
void setSelected(int item);
75
/** Select the first entry matching the given tag. */
76
void setSelectedTag(int tag);
78
int getSelected() const { return _selectedItem; }
79
int getSelectedTag() const { return (_selectedItem >= 0) ? _entries[_selectedItem].tag : (int)-1; }
80
const string& getSelectedString() const { return (_selectedItem >= 0) ? _entries[_selectedItem].name : EmptyString; }
83
void drawWidget(bool hilite);
89
PopUpDialog* myPopUpDialog;
97
class PopUpDialog : public Dialog
99
friend class PopUpWidget;
102
PopUpDialog(PopUpWidget* boss, int clickX, int clickY);
106
void handleMouseDown(int x, int y, int button, int clickCount);
107
void handleMouseWheel(int x, int y, int direction); // Scroll through entries with scroll wheel
108
void handleMouseMoved(int x, int y, int button); // Redraw selections depending on mouse position
109
void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc.
112
void drawMenuEntry(int entry, bool hilite);
115
int findItem(int x, int y) const;
116
void setSelection(int item);
123
void sendSelection();
124
void cancelSelection();
127
PopUpWidget* _popUpBoss;
128
int _clickX, _clickY;
134
int _entriesPerColumn;