33 static const int text_width = 400;
38 : rect(r),
message(msg), action(act), markup(use_markup), foreground(fg)
47 std::map<int, tooltip>
tips;
48 std::map<int, tooltip>::const_iterator current_tooltip = tips.end();
50 int tooltip_handle = 0;
53 surface current_background =
nullptr;
59 if(tooltip_handle != 0) {
67 if(video_ ==
nullptr) {
73 const SDL_Color bgcolor = {0,0,0,160};
93 if(tip.rect.y > rect.h) {
94 rect.y = tip.rect.y - rect.h;
96 rect.y = tip.rect.y + tip.rect.h;
102 }
else if(rect.x + rect.w > area.w) {
103 rect.x = area.w - rect.w;
129 current_tooltip = tips.end();
136 if (
i==current_tooltip) {
140 current_tooltip = tips.end();
153 if (it == tips.end() )
return false;
154 it->second.action = action;
155 it->second.markup = use_markup;
157 it->second.rect = rect;
165 if (it == tips.end() )
return false;
166 it->second.action = action;
167 it->second.foreground = foreground;
168 it->second.markup = use_markup;
170 it->second.rect = rect;
190 int id = tooltip_id++;
192 tips.insert(std::make_pair(
id, tooltip(rect, message, action, use_markup, foreground) ));
194 current_tooltip = tips.end();
200 for(std::map<int, tooltip>::const_iterator
i = tips.begin();
i != tips.end(); ++
i) {
201 if(mousex >
i->second.rect.x && mousey >
i->second.rect.y &&
202 mousex < i->second.rect.x +
i->second.rect.w && mousey < i->second.rect.y +
i->second.rect.h) {
203 if(current_tooltip !=
i) {
213 current_tooltip = tips.end();
218 for(std::map<int, tooltip>::const_iterator
i = tips.begin();
i != tips.end(); ++
i) {
void show_help(CVideo &video, const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
void set_clip_rect(const SDL_Rect &r)
bool rects_overlap(const SDL_Rect &rect1, const SDL_Rect &rect2)
Tests whether two rectangles overlap.
void set_bg_color(const SDL_Color &bg_color)
void remove_floating_label(int handle)
removes the floating label given by 'handle' from the screen
void set_font_size(int font_size)
const SDL_Color NORMAL_COLOR
void move_floating_label(int handle, double xmove, double ymove)
moves the floating label given by 'handle' by (xmove,ymove)
void set_alignment(ALIGN align)
void set_color(const SDL_Color &color)
bool point_in_rect(int x, int y, const SDL_Rect &rect)
Tests whether a point is inside a rectangle.
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
SDL_Rect get_floating_label_rect(int handle)
GLdouble GLdouble GLdouble r
void set_border_size(int border)
GLint GLint GLsizei GLsizei GLsizei GLint border
CVideo & video()
Gets the underlying screen object.
GLsizei GLenum GLuint GLuint GLsizei char * message
GLsizei const GLcharARB ** string
static std::vector< ttip > tips