nomlib
Toggle main menu visibility
Loading...
Searching...
No Matches
include
nomlib
gui
UIWidget.hpp
1
/******************************************************************************
2
3
nomlib - C++11 cross-platform game engine
4
5
Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions are met:
10
11
1. Redistributions of source code must retain the above copyright notice, this
12
list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
******************************************************************************/
29
#ifndef NOMLIB_GUI_UIWIDGET_HPP
30
#define NOMLIB_GUI_UIWIDGET_HPP
31
32
#include <string>
33
34
#include "export.hpp"
35
#include "nomlib/config.hpp"
36
#include "nomlib/math/Point2.hpp"
37
#include "nomlib/math/Size2.hpp"
38
#include "nomlib/gui/RocketUtilities.hpp"
39
40
namespace
nom {
41
42
// Forward declarations
43
class
UIEventListener
;
44
class
UIContext
;
45
46
class
NOM_EXPORT
UIWidget
47
{
48
public
:
49
typedef
UIWidget
self_type;
50
typedef
self_type* raw_ptr;
51
52
enum
FocusPolicy
53
{
54
NONE = rocket::ElementDocument::FocusFlags::NONE,
55
FOCUS = rocket::ElementDocument::FocusFlags::FOCUS,
56
MODAL = rocket::ElementDocument::FocusFlags::MODAL
57
};
58
63
UIWidget
();
64
66
virtual
~UIWidget
();
67
76
virtual
Point2i
position
()
const
;
77
86
virtual
Size2i
size
()
const
;
87
95
virtual
void
set_position
(
const
Point2i& pos );
96
108
virtual
void
set_size
(
const
Size2i& dims );
109
111
UIContext
*
context
()
const
;
112
114
rocket::ElementDocument*
document
()
const
;
115
116
bool
valid()
const
;
117
bool
valid( rocket::Element* target )
const
;
118
bool
visible()
const
;
119
120
const
std::string& title_id()
const
;
121
std::string title()
const
;
122
126
uint32
text_alignment
( rocket::Element* target )
const
;
127
128
bool
set_context(
UIContext
* ctx);
129
130
bool
load_document_file(
const
std::string& filename );
131
132
void
show();
133
void
hide();
134
void
close();
135
139
void
set_focus
( uint32 focus = FocusPolicy::FOCUS );
140
142
bool
hit_test
( rocket::Element* target,
const
Point2i& pt );
143
144
void
set_title(
const
std::string& text );
145
146
void
set_title_id(
const
std::string&
id
);
147
148
void
set_font( rocket::Element* target,
const
std::string& font );
149
void
set_font_size( rocket::Element* target,
int
point_size );
150
151
bool
set_alignment(uint32 alignment);
152
157
void
set_text_alignment
( rocket::Element* element, uint32 alignment );
158
166
void
register_event_listener
( rocket::Element* element,
167
const
std::string& ev,
168
UIEventListener
* observer,
169
bool
interruptible =
false
);
170
171
private
:
173
UIContext
*
ctx_
;
174
176
rocket::ElementDocument*
document_
;
177
178
std::string title_id_;
179
};
180
181
}
// namespace nom
182
183
#endif
// include guard defined
nom::UIContext
libRocket context abstraction
Definition
UIContext.hpp:61
nom::UIEventListener
Interface for an event listener for libRocket's platform.
Definition
UIEventListener.hpp:51
nom::UIWidget::size
virtual Size2i size() const
Get the size of the widget.
nom::UIWidget::hit_test
bool hit_test(rocket::Element *target, const Point2i &pt)
Perform a bounds coordinates collision test.
nom::UIWidget::register_event_listener
void register_event_listener(rocket::Element *element, const std::string &ev, UIEventListener *observer, bool interruptible=false)
Register an event listener for an element.
nom::UIWidget::context
UIContext * context() const
nom::UIWidget::position
virtual Point2i position() const
Get the position of the widget.
nom::UIWidget::set_focus
void set_focus(uint32 focus=FocusPolicy::FOCUS)
Set the focus policy.
nom::UIWidget::UIWidget
UIWidget()
Default constructor; initialize default title element ID.
nom::UIWidget::text_alignment
uint32 text_alignment(rocket::Element *target) const
Get an element's text alignment.
nom::UIWidget::document
rocket::ElementDocument * document() const
nom::UIWidget::set_position
virtual void set_position(const Point2i &pos)
Set the position of the widget.
nom::UIWidget::document_
rocket::ElementDocument * document_
Definition
UIWidget.hpp:176
nom::UIWidget::set_size
virtual void set_size(const Size2i &dims)
Set the size of the widget.
nom::UIWidget::set_text_alignment
void set_text_alignment(rocket::Element *element, uint32 alignment)
nom::UIWidget::ctx_
UIContext * ctx_
Definition
UIWidget.hpp:173
nom::UIWidget::~UIWidget
virtual ~UIWidget()
Destructor.
Generated on
for nomlib by
1.18.0