rofi/include/textbox.h

90 lines
2.2 KiB
C
Raw Normal View History

#ifndef __TEXTBOX_H__
#define __TEXTBOX_H__
2014-05-27 06:31:59 +00:00
#include <X11/Xft/Xft.h>
2014-03-22 20:04:19 +00:00
typedef struct
{
unsigned long flags;
2014-03-22 20:04:19 +00:00
Window window, parent;
short x, y, w, h;
short cursor;
XftFont *font;
XftColor color_fg, color_bg;
char *text;
2014-03-22 20:04:19 +00:00
XIM xim;
XIC xic;
XGlyphInfo extents;
} textbox;
2014-03-22 20:04:19 +00:00
typedef enum
{
TB_AUTOHEIGHT = 1 << 0,
TB_AUTOWIDTH = 1 << 1,
TB_LEFT = 1 << 16,
TB_RIGHT = 1 << 17,
TB_CENTER = 1 << 18,
TB_EDITABLE = 1 << 19,
} TextboxFlags;
typedef enum
{
NORMAL,
HIGHLIGHT,
ACTIVE_HIGHLIGHT,
ACTIVE
} TextBoxFontType;
2014-03-22 20:04:19 +00:00
textbox* textbox_create ( Window parent,
TextboxFlags flags,
short x, short y, short w, short h,
TextBoxFontType tbft,
char *text );
2014-03-22 20:04:19 +00:00
void textbox_free ( textbox *tb );
void textbox_font ( textbox *tb, TextBoxFontType tbft );
2014-03-22 20:04:19 +00:00
void textbox_text ( textbox *tb, char *text );
void textbox_show ( textbox *tb );
void textbox_draw ( textbox *tb );
2014-03-22 20:04:19 +00:00
int textbox_keypress ( textbox *tb, XEvent *ev );
2014-03-22 20:04:19 +00:00
void textbox_cursor_end ( textbox *tb );
2014-05-27 10:55:47 +00:00
void textbox_cursor ( textbox *tb, int pos );
2014-05-22 08:03:36 +00:00
void textbox_move ( textbox *tb, int x, int y );
2014-05-27 10:55:47 +00:00
void textbox_insert ( textbox *tb, int pos, char *str );
2014-05-27 06:31:59 +00:00
/**
* @param tb Handle to the textbox
*
* Unmap the textbox window. Effectively hiding it.
*/
void textbox_hide ( textbox *tb );
2014-05-27 06:31:59 +00:00
/**
* @param font_str The font to use.
* @param font_active_str The font to use for active entries.
* @param bg The background color.
* @param fg The foreground color.
* @param hlbg The background color for a highlighted entry.
* @param hlfg The foreground color for a highlighted entry.
*
* Setup the cached fonts. This is required to do
* before any of the textbox_ functions is called.
* Clean with textbox_cleanup()
*/
void textbox_setup (
const char *font_str, const char *font_active_str,
const char *bg, const char *fg,
const char *hlbg, const char *hlfg
);
2014-05-27 06:31:59 +00:00
/**
* Cleanup the allocated colors and fonts by textbox_setup().
*/
void textbox_cleanup ();
2014-05-27 06:31:59 +00:00
#endif //__TEXTBOX_H__