Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F629753
GUIListBox.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
GUIListBox.h
View Options
/*
* Copyright (C) 2011-2012 Me and My Shadow
*
* This file is part of Me and My Shadow.
*
* Me and My Shadow 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 3 of the License, or
* (at your option) any later version.
*
* Me and My Shadow 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 Me and My Shadow. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GUILISTBOX_H
#define GUILISTBOX_H
#include
"GUIObject.h"
#include
"GUIScrollBar.h"
//GUIObject that displays a list.
//It extends GUIObject because it's a special GUIObject.
class
GUIListBox
:
public
GUIObject
{
public
:
//Vector containing the entries of the list.
std
::
vector
<
std
::
string
>
item
;
std
::
vector
<
SDL_Surface
*>
images
;
private
:
//Scrollbar used when there are more entries than fit on the screen.
GUIScrollBar
*
scrollBar
;
int
itemHeight
;
public
:
//Constructor.
//left: The relative x location of the GUIListBox.
//top: The relative y location of the GUIListBox.
//witdh: The width of the GUIListBox.
//height: The height of the GUIListBox.
//enabled: Boolean if the GUIListBox is enabled or not.
//visible: Boolean if the GUIListBox is visisble or not.
GUIListBox
(
int
left
=
0
,
int
top
=
0
,
int
width
=
0
,
int
height
=
0
,
bool
enabled
=
true
,
bool
visible
=
true
,
int
gravity
=
GUIGravityLeft
);
//Destructor
~
GUIListBox
();
//Method to remove all items and clear cache.
void
clearItems
();
//Method to add an item to the widget.
//name: Text of the item.
//image: Custom image for the widget, if NULL the image will be generated from name string.
void
addItem
(
std
::
string
name
,
SDL_Surface
*
image
=
NULL
);
//Method to update an item in the widget.
//index: index of the item.
//newName: New text for the item.
//newImage: New custom image for the widget, if NULL the image will be generated from newName string.
void
updateItem
(
int
index
,
std
::
string
newText
,
SDL_Surface
*
newImage
=
NULL
);
//Method used the get item names from the widget.
//index: index of the item.
std
::
string
getItem
(
int
index
);
//Method used to handle mouse and/or key events.
//x: The x mouse location.
//y: The y mouse location.
//enabled: Boolean if the parent is enabled or not.
//visible: Boolean if the parent is visible or not.
//processed: Boolean if the event has been processed (by the parent) or not.
//Returns: Boolean if the event is processed by the child.
virtual
bool
handleEvents
(
int
x
=
0
,
int
y
=
0
,
bool
enabled
=
true
,
bool
visible
=
true
,
bool
processed
=
false
);
//Method that will render the GUIListBox.
//x: The x location to draw the GUIListBox. (x+left)
//y: The y location to draw the GUIListBox. (y+top)
virtual
void
render
(
int
x
=
0
,
int
y
=
0
,
bool
draw
=
true
);
};
//GUIObject that displays a list on only one line.
//Instead of clicking the entries of the list you iterate through them.
//It extends GUIObject because it's a special GUIObject.
class
GUISingleLineListBox
:
public
GUIObject
{
public
:
//Vector containing the entries of the list.
std
::
vector
<
std
::
string
>
item
;
//Integer used for the animation of the arrow.
int
animation
;
public
:
//Constructor.
//left: The relative x location of the GUIListBox.
//top: The relative y location of the GUIListBox.
//witdh: The width of the GUIListBox.
//height: The height of the GUIListBox.
//enabled: Boolean if the GUIListBox is enabled or not.
//visible: Boolean if the GUIListBox is visisble or not.
GUISingleLineListBox
(
int
left
=
0
,
int
top
=
0
,
int
width
=
0
,
int
height
=
0
,
bool
enabled
=
true
,
bool
visible
=
true
,
int
gravity
=
GUIGravityLeft
);
//Method used to handle mouse and/or key events.
//x: The x mouse location.
//y: The y mouse location.
//enabled: Boolean if the parent is enabled or not.
//visible: Boolean if the parent is visible or not.
//processed: Boolean if the event has been processed (by the parent) or not.
//Returns: Boolean if the event is processed by the child.
virtual
bool
handleEvents
(
int
x
=
0
,
int
y
=
0
,
bool
enabled
=
true
,
bool
visible
=
true
,
bool
processed
=
false
);
//Method that will render the GUIListBox.
//x: The x location to draw the GUIListBox. (x+left)
//y: The y location to draw the GUIListBox. (y+top)
virtual
void
render
(
int
x
=
0
,
int
y
=
0
,
bool
draw
=
true
);
};
#endif
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Nov 15, 7:42 AM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
143372
Default Alt Text
GUIListBox.h (4 KB)
Attached To
Mode
R79 meandmyshadow
Attached
Detach File
Event Timeline