rofi  1.5.4
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;
71  PangoEllipsizeMode emode;
73  //
74  const char *theme_name;
75 } textbox;
76 
80 typedef enum
81 {
82  TB_AUTOHEIGHT = 1 << 0,
83  TB_AUTOWIDTH = 1 << 1,
84  TB_EDITABLE = 1 << 19,
85  TB_MARKUP = 1 << 20,
86  TB_WRAP = 1 << 21,
87  TB_PASSWORD = 1 << 22,
88  TB_INDICATOR = 1 << 23,
89  TB_ICON = 1 << 24,
90 } TextboxFlags;
94 typedef enum
95 {
97  NORMAL = 0,
99  URGENT = 1,
101  ACTIVE = 2,
103  SELECTED = 4,
105  MARKUP = 8,
106 
108  ALT = 16,
110  HIGHLIGHT = 32,
116 
132 textbox* textbox_create ( widget *parent, WidgetType type, const char *name, TextboxFlags flags,
133  TextBoxFontType tbft, const char *text, double xalign, double yalign );
140 void textbox_font ( textbox *tb, TextBoxFontType tbft );
141 
148 void textbox_text ( textbox *tb, const char *text );
149 
156 void textbox_icon ( textbox *tb, cairo_surface_t *icon );
157 
166 int textbox_keybinding ( textbox *tb, KeyBindingAction action );
175 gboolean textbox_append_text ( textbox *tb, const char *pad, const int pad_len );
176 
183 void textbox_cursor ( textbox *tb, int pos );
184 
193 void textbox_insert ( textbox *tb, const int char_pos, const char *str, const int slen );
194 
200 void textbox_setup ( void );
201 
205 void textbox_cleanup ( void );
206 
214 int textbox_get_height ( const textbox *tb );
215 
223 int textbox_get_font_height ( const textbox *tb );
224 
232 int textbox_get_font_width ( const textbox *tb );
233 
239 double textbox_get_estimated_char_width ( void );
240 
246 double textbox_get_estimated_ch ( void );
252 double textbox_get_estimated_char_height ( void );
253 
261 void textbox_delete ( textbox *tb, int pos, int dlen );
262 
273 void textbox_moveresize ( textbox *tb, int x, int y, int w, int h );
274 
284 int textbox_get_estimated_height ( const textbox *tb, int eh );
291 void textbox_set_pango_context ( const char *font, PangoContext *p );
298 void textbox_set_pango_attributes ( textbox *tb, PangoAttrList *list );
299 
306 void textbox_set_icon_index ( textbox *tb, int index );
307 
315 PangoAttrList *textbox_get_pango_attributes ( textbox *tb );
316 
322 const char *textbox_get_visible_text ( const textbox *tb );
330 int textbox_get_desired_width ( widget *wid );
331 
337 void textbox_cursor_end ( textbox *tb );
338 
345 void textbox_set_ellipsize ( textbox *tb, PangoEllipsizeMode mode );
347 #endif //ROFI_TEXTBOX_H
void textbox_cursor_end(textbox *tb)
Definition: textbox.c:600
int left_offset
Definition: textbox.h:72
int blink
Definition: textbox.h:64
WidgetType
Definition: widget.h:56
void textbox_cleanup(void)
Definition: textbox.c:851
guint blink_timeout
Definition: textbox.h:65
void textbox_setup(void)
Definition: textbox.c:833
unsigned long flags
Definition: textbox.h:53
void textbox_text(textbox *tb, const char *text)
Definition: textbox.c:305
int icon_index
Definition: textbox.h:62
void textbox_icon(textbox *tb, cairo_surface_t *icon)
Definition: textbox.c:337
double textbox_get_estimated_char_width(void)
Definition: textbox.c:910
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:231
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:166
void textbox_cursor(textbox *tb, int pos)
Definition: textbox.c:497
Definition: textbox.h:108
int textbox_get_font_width(const textbox *tb)
Definition: textbox.c:890
int changed
Definition: textbox.h:59
PangoFontMetrics * metrics
Definition: textbox.h:70
short cursor
Definition: textbox.h:54
Definition: icon.c:40
TextboxFlags
Definition: textbox.h:80
double textbox_get_estimated_ch(void)
Definition: textbox.c:921
int textbox_keybinding(textbox *tb, KeyBindingAction action)
Definition: textbox.c:737
const char * textbox_get_visible_text(const textbox *tb)
Definition: textbox.c:282
TextBoxFontType
Definition: textbox.h:94
Definition: textbox.h:97
const char * theme_name
Definition: textbox.h:74
Definition: textbox.h:99
void textbox_moveresize(textbox *tb, int x, int y, int w, int h)
Definition: textbox.c:353
int tbft
Definition: textbox.h:57
KeyBindingAction
Definition: keyb.h:58
void textbox_insert(textbox *tb, const int char_pos, const char *str, const int slen)
Definition: textbox.c:614
int textbox_get_height(const textbox *tb)
Definition: textbox.c:878
void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode)
Definition: textbox.c:958
MenuFlags flags
Definition: view.c:108
double xalign
Definition: textbox.h:68
PangoAttrList * textbox_get_pango_attributes(textbox *tb)
Definition: textbox.c:289
cairo_surface_t * icon
Definition: textbox.h:61
int textbox_get_estimated_height(const textbox *tb, int eh)
Definition: textbox.c:930
int textbox_get_font_height(const textbox *tb)
Definition: textbox.c:883
int textbox_get_desired_width(widget *wid)
Definition: textbox.c:935
double textbox_get_estimated_char_height(void)
Definition: textbox.c:899
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:296
void textbox_delete(textbox *tb, int pos, int dlen)
Definition: textbox.c:638
gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len)
Definition: textbox.c:801
PangoEllipsizeMode emode
Definition: textbox.h:71
void textbox_set_pango_context(const char *font, PangoContext *p)
Definition: textbox.c:840