libxputty 0.1
Loading...
Searching...
No Matches
simple-example.c

Simple example of how to use this

/*
* 0BSD
*
* BSD Zero Clause License
*
* Copyright (c) 2019 Hermann Meyer
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*/
#include "xputty.h"
#include "xwidgets.h"
/*
* this is our own expose call to draw the window
*/
static void draw_window(void *w_, void* user_data) {
Widget_t *w = (Widget_t*)w_;
cairo_paint (w->crb);
}
int main (int argc, char ** argv)
{
/* Reference to Xputty struct */
Xputty app;
/* init Xputty */
main_init(&app);
/* create a window with decoration on default screen */
Widget_t *w = create_window(&app, os_get_root_window(&app, IS_WINDOW), 0, 0, 300, 200);
/* set the window title */
os_set_title(w, "Hello world");
/* overwrite the expose function callback to implement your own */
w->func.expose_callback = draw_window;
/* map the widget on screen */
/* run the main loop */
main_run(&app);
/* clean up after run, close the widget with the cross in the window title bar */
main_quit(&app);
return 0;
}
xevfunc expose_callback
Definition xwidget.h:85
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
cairo_t * crb
Definition xwidget.h:489
Func_t func
Definition xwidget.h:481
Xputty - the main struct. It should be declared before any other call to a Xputty function....
Definition xputty.h:228
Color_state get_color_state(Widget_t *wid)
get_color_state - get the Color_state to use in relation to the Widget_t state
Definition xcolor.c:222
void use_bg_color_scheme(Widget_t *w, Color_state st)
use_bg_color_scheme - use background Colors to paint on Widget_t
Definition xcolor.c:252
This file contains definitions and structs used on all platforms. Platform specific definitions are l...
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
Window os_get_root_window(Xputty *main, int flag)
os_get_root_window - get a pointer to the root window (desktop)
void os_set_title(Widget_t *w, const char *title)
os_set_title - Set the title of a Widget_t
Widget_t * create_window(Xputty *app, Window win, int x, int y, int width, int height)
*create_window - create a Window You need to create as least minimun one Window to get started....
Definition xwidget.c:163
@ IS_WINDOW
Definition xwidget.h:390
void widget_show_all(Widget_t *w)
widget_show_all - map/show Widget_t with all childs
Definition xwidget.c:386
xwidgets.h include some predefined widgets for libxputty, include this to use them if you would only ...