]> icculus.org git repositories - dana/openbox.git/blob - openbox/popup.h
popups fixes. if the text for the popup is empty now, there wont be extra padding...
[dana/openbox.git] / openbox / popup.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    popup.h for the Openbox window manager
4    Copyright (c) 2003-2007   Dana Jansens
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #ifndef __popup_h
20 #define __popup_h
21
22 #include "window.h"
23 #include "render/render.h"
24 #include <glib.h>
25
26 struct _ObClientIcon;
27
28 #define POPUP_WIDTH 320
29 #define POPUP_HEIGHT 48
30
31 typedef struct _ObPopup      ObPopup;
32 typedef struct _ObIconPopup  ObIconPopup;
33 typedef struct _ObPagerPopup ObPagerPopup;
34
35 struct _ObPopup
36 {
37     ObWindow obwin;
38     Window bg;
39
40     Window text;
41
42     gboolean hasicon;
43     RrAppearance *a_bg;
44     RrAppearance *a_text;
45     gint gravity;
46     gint x;
47     gint y;
48     gint textw;
49     gint h;
50     gint minw;
51     gint maxw;
52     gboolean mapped;
53     gboolean delay_mapped;
54  
55     void (*draw_icon)(gint x, gint y, gint w, gint h, gpointer data);
56     gpointer draw_icon_data;
57 };
58
59 struct _ObIconPopup
60 {
61     ObPopup *popup;
62
63     Window icon;
64     RrAppearance *a_icon;
65 };
66
67 struct _ObPagerPopup
68 {
69     ObPopup *popup;
70
71     guint desks;
72     guint curdesk;
73     Window *wins;
74     RrAppearance *hilight;
75     RrAppearance *unhilight;
76 };
77
78 ObPopup *popup_new();
79 void popup_free(ObPopup *self);
80
81 /*! Position the popup. The gravity rules are not the same X uses for windows,
82   instead of the position being the top-left of the window, the gravity
83   specifies which corner of the popup will be placed at the given coords.
84   Static and Forget gravity are equivilent to NorthWest.
85 */
86 void popup_position(ObPopup *self, gint gravity, gint x, gint y);
87 /*! Set the sizes for the popup. When set to 0, the size will be based on
88   the text size. */
89 void popup_height(ObPopup *self, gint w);
90 void popup_min_width(ObPopup *self, gint minw);
91 void popup_max_width(ObPopup *self, gint maxw);
92 void popup_text_width(ObPopup *self, gint w);
93 void popup_text_width_to_string(ObPopup *self, gchar *text);
94 void popup_height_to_string(ObPopup *self, gchar *text);
95 void popup_text_width_to_strings(ObPopup *self, gchar **strings, gint num);
96
97 void popup_set_text_align(ObPopup *self, RrJustify align);
98
99 #define popup_show(s, t) popup_delay_show((s),0,(t))
100 void popup_delay_show(ObPopup *self, gulong usec, gchar *text);
101 void popup_hide(ObPopup *self);
102
103 RrAppearance *popup_icon_appearance(ObPopup *self);
104
105
106 ObIconPopup *icon_popup_new();
107 void icon_popup_free(ObIconPopup *self);
108
109 #define icon_popup_show(s, t, i) icon_popup_delay_show((s),0,(t),(i))
110 void icon_popup_delay_show(ObIconPopup *self, gulong usec,
111                            gchar *text, const struct _ObClientIcon *icon);
112 #define icon_popup_hide(p) popup_hide((p)->popup)
113 #define icon_popup_position(p, g, x, y) popup_position((p)->popup,(g),(x),(y))
114 #define icon_popup_text_width(p, w) popup_text_width((p)->popup,(w))
115 #define icon_popup_height(p, h) popup_height((p)->popup,(h))
116 #define icon_popup_min_width(p, m) popup_min_width((p)->popup,(m))
117 #define icon_popup_max_width(p, m) popup_max_width((p)->popup,(m))
118 #define icon_popup_text_width_to_string(p, s) \
119     popup_text_width_to_string((p)->popup,(s))
120 #define icon_popup_text_width_to_strings(p, s, n) \
121     popup_text_width_to_strings((p)->popup,(s),(n))
122 #define icon_popup_set_text_align(p, j) popup_set_text_align((p)->popup,(j))
123
124 ObPagerPopup *pager_popup_new();
125 void pager_popup_free(ObPagerPopup *self);
126
127 #define pager_popup_show(s, t, d) pager_popup_delay_show((s),0,(t),(d))
128 void pager_popup_delay_show(ObPagerPopup *self, gulong usec,
129                             gchar *text, guint desk);
130 #define pager_popup_hide(p) popup_hide((p)->popup)
131 #define pager_popup_position(p, g, x, y) popup_position((p)->popup,(g),(x),(y))
132 #define pager_popup_text_width(p, w) popup_text_width((p)->popup,(w))
133 #define pager_popup_height(p, h) popup_height((p)->popup,(h))
134 #define pager_popup_min_width(p, m) popup_min_width((p)->popup,(m))
135 #define pager_popup_max_width(p, m) popup_max_width((p)->popup,(m))
136 #define pager_popup_text_width_to_string(p, s) \
137     popup_text_width_to_string((p)->popup,(s))
138 #define pager_popup_text_width_to_strings(p, s, n) \
139     popup_text_width_to_strings((p)->popup,(s),(n))
140 #define pager_popup_set_text_align(p, j) popup_set_text_align((p)->popup,(j))
141
142 #endif