]> icculus.org git repositories - manmower/openbox.git/blob - openbox/popup.h
small change to the render API. RrMinsize became RrMinSize. added RrMinWidth and...
[manmower/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 w;
49     gint h;
50     gboolean mapped;
51  
52     void (*draw_icon)(gint x, gint y, gint w, gint h, gpointer data);
53     gpointer draw_icon_data;
54 };
55
56 struct _ObIconPopup
57 {
58     ObPopup *popup;
59
60     Window icon;
61     RrAppearance *a_icon;
62 };
63
64 struct _ObPagerPopup
65 {
66     ObPopup *popup;
67
68     guint desks;
69     guint curdesk;
70     Window *wins;
71     RrAppearance *hilight;
72     RrAppearance *unhilight;
73 };
74
75 ObPopup *popup_new(gboolean hasicon);
76 void popup_free(ObPopup *self);
77
78 /*! Position the popup. The gravity rules are not the same X uses for windows,
79   instead of the position being the top-left of the window, the gravity
80   specifies which corner of the popup will be placed at the given coords.
81   Static and Forget gravity are equivilent to NorthWest.
82 */
83 void popup_position(ObPopup *self, gint gravity, gint x, gint y);
84 /*! Set the sizes for the popup. When set to 0, the size will be based on
85   the text size. */
86 void popup_width(ObPopup *self, gint w);
87 void popup_height(ObPopup *self, gint w);
88 void popup_width_to_string(ObPopup *self, gchar *text, gint max);
89 void popup_height_to_string(ObPopup *self, gchar *text);
90 void popup_width_to_strings(ObPopup *self, gchar **strings, gint max);
91
92 void popup_set_text_align(ObPopup *self, RrJustify align);
93
94 void popup_show(ObPopup *self, gchar *text);
95 void popup_hide(ObPopup *self);
96
97 RrAppearance *popup_icon_appearance(ObPopup *self);
98
99
100 ObIconPopup *icon_popup_new();
101 void icon_popup_free(ObIconPopup *self);
102
103 void icon_popup_show(ObIconPopup *self,
104                      gchar *text, const struct _ObClientIcon *icon);
105 #define icon_popup_hide(p) popup_hide((p)->popup)
106 #define icon_popup_position(p, g, x, y) popup_position((p)->popup,(g),(x),(y))
107 #define icon_popup_width(p, w) popup_width((p)->popup,(w))
108 #define icon_popup_height(p, h) popup_height((p)->popup,(h))
109 #define icon_popup_width_to_string(p, s, m) \
110     popup_width_to_string((p)->popup,(s),(m))
111 #define icon_popup_width_to_strings(p, s, m) \
112     popup_width_to_strings((p)->popup,(s),(m))
113 #define icon_popup_set_text_align(p, j) popup_set_text_align((p)->popup,(j))
114
115 ObPagerPopup *pager_popup_new();
116 void pager_popup_free(ObPagerPopup *self);
117
118 void pager_popup_show(ObPagerPopup *self, gchar *text, guint desk);
119 #define pager_popup_hide(p) popup_hide((p)->popup)
120 #define pager_popup_position(p, g, x, y) popup_position((p)->popup,(g),(x),(y))
121 #define pager_popup_width(p, w) popup_width((p)->popup,(w))
122 #define pager_popup_height(p, h) popup_height((p)->popup,(h))
123 #define pager_popup_width_to_string(p, s, m) \
124     popup_width_to_string((p)->popup,(s),(m))
125 #define pager_popup_width_to_strings(p, s, m) \
126     popup_width_to_strings((p)->popup,(s),(m))
127 #define pager_popup_set_text_align(p, j) popup_set_text_align((p)->popup,(j))
128
129 #endif