rofi  1.5.1
textbox.h
Go to the documentation of this file.
1 /*
2  * rofi
3  *
4  * MIT/X11 License
5  * Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  */
27 
28 #ifndef ROFI_TEXTBOX_H
29 #define ROFI_TEXTBOX_H
30 
31 #include <xkbcommon/xkbcommon.h>
32 #include <pango/pango.h>
33 #include <pango/pango-fontmap.h>
34 #include <pango/pangocairo.h>
35 #include <cairo.h>
36 #include "widgets/widget.h"
38 #include "keyb.h"
39 
50 typedef struct
51 {
53  unsigned long flags;
54  short cursor;
55  char *text;
56  PangoLayout *layout;
57  int tbft;
58  int markup;
59  int changed;
60 
61  cairo_surface_t *icon; // AA TODO - pass in icons for a textbox line if needed
63 
64  int blink;
66 
67  double yalign;
68  double xalign;
69 
70  PangoFontMetrics *metrics;
72  //
73  const char *theme_name;
74 } textbox;
75 
79 typedef enum
80 {
81  TB_AUTOHEIGHT = 1 << 0,
82  TB_AUTOWIDTH = 1 << 1,
83  TB_EDITABLE = 1 << 19,
84  TB_MARKUP = 1 << 20,
85  TB_WRAP = 1 << 21,
86  TB_PASSWORD = 1 << 22,
87  TB_INDICATOR = 1 << 23,
88  TB_ICON = 1 << 24,
89 } TextboxFlags;
93 typedef enum
94 {
96  NORMAL = 0,
98  URGENT = 1,
100  ACTIVE = 2,
102  SELECTED = 4,
104  MARKUP = 8,
105 
107  ALT = 16,
109  HIGHLIGHT = 32,
115 
131 textbox* textbox_create ( widget *parent, WidgetType type, const char *name, TextboxFlags flags,
132  TextBoxFontType tbft, const char *text, double xalign, double yalign );
139 void textbox_font ( textbox *tb, TextBoxFontType tbft );
140 
147 void textbox_text ( textbox *tb, const char *text );
148 
155 void textbox_icon ( textbox *tb, cairo_surface_t *icon );
156 
165 int textbox_keybinding ( textbox *tb, KeyBindingAction action );
174 gboolean textbox_append_text ( textbox *tb, const char *pad, const int pad_len );
175 
182 void textbox_cursor ( textbox *tb, int pos );
183 
192 void textbox_insert ( textbox *tb, const int char_pos, const char *str, const int slen );
193 
199 void textbox_setup ( void );
200 
204 void textbox_cleanup ( void );
205 
213 int textbox_get_height ( const textbox *tb );
214 
222 int textbox_get_font_height ( const textbox *tb );
223 
231 int textbox_get_font_width ( const textbox *tb );
232 
238 double textbox_get_estimated_char_width ( void );
239 
245 double textbox_get_estimated_ch ( void );
251 double textbox_get_estimated_char_height ( void );
252 
260 void textbox_delete ( textbox *tb, int pos, int dlen );
261 
272 void textbox_moveresize ( textbox *tb, int x, int y, int w, int h );
273 
283 int textbox_get_estimated_height ( const textbox *tb, int eh );
290 void textbox_set_pango_context ( const char *font, PangoContext *p );
297 void textbox_set_pango_attributes ( textbox *tb, PangoAttrList *list );
298 
305 void textbox_set_icon_index ( textbox *tb, int index );
306 
314 PangoAttrList *textbox_get_pango_attributes ( textbox *tb );
315 
321 const char *textbox_get_visible_text ( const textbox *tb );
322 int textbox_get_desired_width ( widget *wid );
323 
329 void textbox_cursor_end ( textbox *tb );
331 #endif //ROFI_TEXTBOX_H
void textbox_cursor_end(textbox *tb)
Definition: textbox.c:584
int left_offset
Definition: textbox.h:71
int blink
Definition: textbox.h:64
WidgetType
Definition: widget.h:56
void textbox_cleanup(void)
Definition: textbox.c:835
guint blink_timeout
Definition: textbox.h:65
void textbox_setup(void)
Definition: textbox.c:817
unsigned long flags
Definition: textbox.h:53
void textbox_text(textbox *tb, const char *text)
Definition: textbox.c:303
int icon_index
Definition: textbox.h:62
void textbox_icon(textbox *tb, cairo_surface_t *icon)
Definition: textbox.c:335
double textbox_get_estimated_char_width(void)
Definition: textbox.c:894
int markup
Definition: textbox.h:58
double yalign
Definition: textbox.h:67
widget widget
Definition: textbox.h:52
void textbox_font(textbox *tb, TextBoxFontType tbft)
Definition: textbox.c:229
char * text
Definition: textbox.h:55
textbox * textbox_create(widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign)
Definition: textbox.c:165
void textbox_cursor(textbox *tb, int pos)
Definition: textbox.c:481
Definition: textbox.h:107
int textbox_get_font_width(const textbox *tb)
Definition: textbox.c:874
int changed
Definition: textbox.h:59
PangoFontMetrics * metrics
Definition: textbox.h:70
short cursor
Definition: textbox.h:54
TextboxFlags
Definition: textbox.h:79
double textbox_get_estimated_ch(void)
Definition: textbox.c:904
int textbox_keybinding(textbox *tb, KeyBindingAction action)
Definition: textbox.c:721
const char * textbox_get_visible_text(const textbox *tb)
Definition: textbox.c:280
TextBoxFontType
Definition: textbox.h:93
Definition: textbox.h:96
const char * theme_name
Definition: textbox.h:73
Definition: textbox.h:98
void textbox_moveresize(textbox *tb, int x, int y, int w, int h)
Definition: textbox.c:343
int tbft
Definition: textbox.h:57
KeyBindingAction
Definition: keyb.h:55
void textbox_insert(textbox *tb, const int char_pos, const char *str, const int slen)
Definition: textbox.c:598
int textbox_get_height(const textbox *tb)
Definition: textbox.c:862
MenuFlags flags
Definition: view.c:107
double xalign
Definition: textbox.h:68
PangoAttrList * textbox_get_pango_attributes(textbox *tb)
Definition: textbox.c:287
cairo_surface_t * icon
Definition: textbox.h:61
int textbox_get_estimated_height(const textbox *tb, int eh)
Definition: textbox.c:913
int textbox_get_font_height(const textbox *tb)
Definition: textbox.c:867
int textbox_get_desired_width(widget *wid)
Definition: textbox.c:918
double textbox_get_estimated_char_height(void)
Definition: textbox.c:883
void textbox_set_icon_index(textbox *tb, int index)
PangoLayout * layout
Definition: textbox.h:56
void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list)
Definition: textbox.c:294
void textbox_delete(textbox *tb, int pos, int dlen)
Definition: textbox.c:622
gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len)
Definition: textbox.c:785
void textbox_set_pango_context(const char *font, PangoContext *p)
Definition: textbox.c:824