libxputty 0.1
Loading...
Searching...
No Matches
xputty.h
Go to the documentation of this file.
1/*
2 * 0BSD
3 *
4 * BSD Zero Clause License
5 *
6 * Copyright (c) 2019 Hermann Meyer
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted.
10
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
28#pragma once
29
30#ifndef XPUTTY1_H_
31#define XPUTTY1_H_
32
33#include <string.h>
34#include <stdio.h>
35#include <stdlib.h>
36#include <stdbool.h>
37#include <stddef.h>
38#include <assert.h>
39#include <limits.h>
40
41#include <math.h>
42#include <cairo.h>
43#include "xputty-mswin.h" // no ifdef needed
44
45#ifdef __linux__
46#include <cairo-xlib.h>
47#include <X11/Xutil.h>
48#include <X11/keysym.h>
49#include <X11/Xatom.h>
50#include <X11/cursorfont.h>
51#endif //__linux__
52
53#ifdef ENABLE_NLS
54#include <libintl.h>
55#include <locale.h>
56#define _(S) gettext(S)
57#else
58#define _(S) S
59#endif
60
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66#ifdef __linux__
67#define DND_STATUS_ACCEPT(e) ((e)->xclient.data.l[1] & 0x1L)
68#define DND_VERSION(e) ((e)->xclient.data.l[1] >> 24)
69#define DND_SOURCE_WIN(e) ((e)->xclient.data.l[0])
70#define DND_DROP_TIME(e) ((e)->xclient.data.l[2])
71#endif //__linux__
72
73
74/*---------------------------------------------------------------------
75-----------------------------------------------------------------------
76 define debug print
77-----------------------------------------------------------------------
78----------------------------------------------------------------------*/
79
80#ifndef DEBUG
81#define DEBUG 0
82#ifndef NDEBUG
83#define NDEBUG // switch of assertion checks
84#endif
85#endif
86#ifndef LIBDEBUG
87#define LIBDEBUG 0
88#endif
95#ifdef NODEF // _WIN32 //DebugPrint
96#define debug_print(...) \
97 { char xxdeb[1024]; snprintf(xxdeb, 1024, __VA_ARGS__); OutputDebugString(xxdeb); }
98#else
99#define debug_print(...) \
100 ((void)((LIBDEBUG) ? fprintf(stderr, __VA_ARGS__) : 0))
101#endif
102
103/*---------------------------------------------------------------------
104-----------------------------------------------------------------------
105 define min/max if not defined already
106-----------------------------------------------------------------------
107----------------------------------------------------------------------*/
108
113#ifndef min
114#define min(x, y) ((x) < (y) ? (x) : (y))
115#endif
116
121#ifndef max
122#define max(x, y) ((x) < (y) ? (y) : (x))
123#endif
124
125/*---------------------------------------------------------------------
126-----------------------------------------------------------------------
127 define check if char holds UTF 8 string
128-----------------------------------------------------------------------
129----------------------------------------------------------------------*/
130
135#define IS_UTF8(c) (((c)&0xc0)==0xc0)
136
137/*---------------------------------------------------------------------
138-----------------------------------------------------------------------
139 forward declareted structs
140-----------------------------------------------------------------------
141----------------------------------------------------------------------*/
142
148
154
159typedef struct Widget_t Widget_t;
160
165typedef struct XColor_t XColor_t;
166
172
178typedef struct Xputty Xputty;
179
186typedef void (*xfunc)(void * widget, void* user_data);
187
188#ifdef __cplusplus
189}
190#endif
191
192/*---------------------------------------------------------------------
193-----------------------------------------------------------------------
194 xputty library headers
195-----------------------------------------------------------------------
196----------------------------------------------------------------------*/
197
198// library header
199#include "xwidget.h"
200#include "xadjustment.h"
201#include "xchildlist.h"
202#include "xcolor.h"
203#include "xpngloader.h"
204#include "xsvgloader.h"
205
206
207#ifdef __cplusplus
208extern "C" {
209#endif
210
283
303void main_init(Xputty *main);
304
313void main_run(Xputty *main);
314
327void run_embedded(Xputty *main);
328
338void main_quit(Xputty *main);
339
340#ifdef __cplusplus
341}
342#endif
343
344#endif //XPUTTY_H_
345
Adjustment_t - struct to hold a controller adjustment.
Definition xadjustment.h:82
Childlist_t - struct to hold a Widget_t child list Xputty main holds a list of any Widget_t created...
Definition xchildlist.h:49
SystrayColor - the Systray Color struct SystrayColor could be used for the backgroung color of the Sy...
Definition xcolor.h:122
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
XColor_t - the Widget_t Color struct XColor_t could be used for theming you Widget_t set.
Definition xcolor.h:105
Xputty - the main struct. It should be declared before any other call to a Xputty function....
Definition xputty.h:228
Atom text_atom
Definition xputty.h:280
Atom XdndActionCopy
Definition xputty.h:270
Atom XdndPosition
Definition xputty.h:267
Atom UTF8
Definition xputty.h:281
Atom XdndSelection
Definition xputty.h:264
Atom XdndEnter
Definition xputty.h:266
SystrayColor_t * systray_color
Definition xputty.h:236
bool is_grab
Definition xputty.h:258
char pad[2]
Definition xputty.h:260
XColor_t * color_scheme
Definition xputty.h:234
bool run
Definition xputty.h:256
Atom targets_atom
Definition xputty.h:279
int big_font
Definition xputty.h:250
Window dnd_source_window
Definition xputty.h:261
int normal_font
Definition xputty.h:248
Atom dnd_type_uri
Definition xputty.h:274
Atom XdndFinished
Definition xputty.h:271
Display * dpy
Definition xputty.h:232
Widget_t * hold_grab
Definition xputty.h:238
Childlist_t * childlist
Definition xputty.h:230
Atom XdndAware
Definition xputty.h:262
Widget_t * submenu
Definition xputty.h:242
Atom XdndStatus
Definition xputty.h:265
int dnd_version
Definition xputty.h:254
Atom selection
Definition xputty.h:278
Widget_t * key_snooper
Definition xputty.h:240
Atom XdndDrop
Definition xputty.h:269
int csize
Definition xputty.h:252
unsigned char * ctext
Definition xputty.h:244
int small_font
Definition xputty.h:246
Atom dnd_type
Definition xputty.h:276
Atom XdndTypeList
Definition xputty.h:263
Atom dnd_type_utf8
Definition xputty.h:275
Atom dnd_type_text
Definition xputty.h:273
Atom XdndLeave
Definition xputty.h:268
compatibility definitions (Linux, MSWindows): This file contains definitions and structs used to prov...
XID Display
unsigned long int Atom
HWND Window
void main_quit(Xputty *main)
main_quit - destroy all remaining Widget_t's from the main->childlist. Free all resources which may...
Definition xputty.c:57
void main_init(Xputty *main)
main_init - open the Display and init the main->childlist. Set the bool run to true....
Definition xputty.c:24
void main_run(Xputty *main)
main_run - start the main event loop. It should be start after your Widget_t's been created....
Definition xputty.c:49
void(* xfunc)(void *widget, void *user_data)
*xfunc - function pointer to connect XEvents from a Widget_t to a event handler
Definition xputty.h:186
void run_embedded(Xputty *main)
run_embedded - the main event loop to run embedded UI's. It should be start after your Widget_t's b...
Definition xputty.c:53
This file contains definitions and structs used on all platforms. Platform specific definitions are l...