Sat Dec 04 01:05:38 GMT 1999

(gilbertt)

So, say hello to Epplet_create_window_config.

It rules ;)

Here's the definition:

Window Epplet_create_window_config(int w,int h,char *title,
         void (*ok_func) (void *data),void *ok_data,
         void (*apply_func) (void *data),void *apply_data,
         void (*cancel_func) (void *data),void *cancel_data);

You can picture what it does, and check it out in E-ScreenSave. (Press the
"Lock" button).

The cool thing is that if you supply NULL for any of the callbacks, that
button won't be added to the dialog. So, for an Ok, Cancel dialog, just
supply NULL for apply_func.

I have added explanation to the epplet.h file, and would like people to bang
at this now? I will set my epplets up to use the new functions fully over
the weekend. This will help me find any problems, as I haven't tested adding
every type of gadget to config windows yet, there may still be redraw issues
I missed.

Its pretty nice now though, and I have checked for memory leaks and bad
handling, please point out anything dubious you see. The api will become
more rich over the next few days, then it should stabilise.

Any feature suggestions, send 'em now :)


SVN revision: 1493
This commit is contained in:
Tom Gilbert 1999-12-03 20:56:49 +00:00
parent 180b8b08ea
commit eb5b17c67f
4 changed files with 188 additions and 71 deletions

View File

@ -1282,3 +1282,38 @@ too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
-------------------------------------------------------------------------------
Sat Dec 04 01:05:38 GMT 1999
(gilbertt)
So, say hello to Epplet_create_window_config.
It rules.
Here's the definition:
Window Epplet_create_window_config(int w,int h,char *title,
void (*ok_func) (void *data),void *ok_data,
void (*apply_func) (void *data),void *apply_data,
void (*cancel_func) (void *data),void *cancel_data);
You can picture what it does, and check it out in E-ScreenSave. (Press the
"Lock" button).
The cool thing is that if you supply NULL for any of the callbacks, that
button won't be added to the dialog. So, for an Ok, Cancel dialog, just
supply NULL for apply_func.
I have added explanation to the epplet.h file, and would like people to bang
at this now? I will set my epplets up to use the new functions fully over
the weekend. This will help me find any problems, as I haven't tested adding
every type of gadget to config windows yet, there may still be redraw issues
I missed.
Its pretty nice now though, and I have checked for memory leaks and bad
handling, please point out anything dubious you see. The api will become
more rich over the next few days, then it should stabilise.
Any feature suggestions, send 'em now :)

View File

@ -373,7 +373,8 @@ Epplet_Init(char *name,
sigaction(SIGCHLD, &sa, (struct sigaction *)0);
}
Window Epplet_create_window(int w, int h, char *title, char vertical)
Window
Epplet_create_window(int w, int h, char *title, char vertical)
{
XSetWindowAttributes attr;
Atom a;
@ -466,6 +467,55 @@ Window Epplet_create_window(int w, int h, char *title, char vertical)
return ret->win;
}
Window
Epplet_create_window_config(int w, int h, char *title,
void (*ok_func) (void *data),
void *ok_data, void (*apply_func) (void *data),
void *apply_data,
void (*cancel_func) (void *data), void *cancel_data)
{
Window ret;
Epplet_gadget ok_btn, apply_btn, cancel_btn;
int dw;
if (w < 200)
w = 200;
if (h < 40)
h = 40;
dw = w - 60;
ret = Epplet_create_window(w, h, title, 0);
if (cancel_func)
{
Epplet_gadget_show(cancel_btn =
Epplet_create_button("Cancel", NULL, dw, h - 20, 50,
16, NULL, 0, NULL, cancel_func,
cancel_data));
dw -= 60;
}
if (apply_func)
{
Epplet_gadget_show(apply_btn =
Epplet_create_button("Apply", NULL, dw, h - 20, 50,
16, NULL, 0, NULL, apply_func,
apply_data));
dw -= 60;
}
if (ok_func)
{
Epplet_gadget_show(ok_btn =
Epplet_create_button("Ok", NULL, dw, h - 20, 50,
16, NULL, 0, NULL, ok_func,
ok_data));
}
return ret;
}
void
Epplet_window_show(Window win)
{
@ -575,7 +625,8 @@ Epplet_window_push_context(Window newwin)
context_win = win;
}
Window Epplet_window_pop_context(void)
Window
Epplet_window_pop_context(void)
{
Epplet_window ret;
@ -738,8 +789,7 @@ Epplet_unremember(void)
ESYNC;
}
Window
Epplet_get_main_window(void)
Window Epplet_get_main_window(void)
{
return mainwin->win;
}
@ -2464,8 +2514,7 @@ typedef struct
}
GadDrawingArea;
Epplet_gadget
Epplet_create_drawingarea(int x, int y, int w, int h)
Epplet_gadget Epplet_create_drawingarea(int x, int y, int w, int h)
{
GadDrawingArea *g;
XSetWindowAttributes attr;
@ -2854,8 +2903,7 @@ typedef struct
}
GadImage;
Epplet_gadget
Epplet_create_image(int x, int y, int w, int h, char *image)
Epplet_gadget Epplet_create_image(int x, int y, int w, int h, char *image)
{
GadImage *g;
@ -2924,8 +2972,7 @@ typedef struct
}
GadLabel;
Epplet_gadget
Epplet_create_label(int x, int y, char *label, char size)
Epplet_gadget Epplet_create_label(int x, int y, char *label, char size)
{
GadLabel *g;
@ -3085,8 +3132,7 @@ struct _gadpopupbutton
Pixmap pmap, mask;
};
Epplet_gadget
Epplet_create_popup(void)
Epplet_gadget Epplet_create_popup(void)
{
GadPopup *g;
XSetWindowAttributes attr;
@ -3502,8 +3548,7 @@ Epplet_change_label(Epplet_gadget gadget, char *label)
Epplet_draw_label(gadget, 0);
}
Window
Epplet_get_drawingarea_window(Epplet_gadget gadget)
Window Epplet_get_drawingarea_window(Epplet_gadget gadget)
{
GadDrawingArea *g;
@ -4569,8 +4614,7 @@ Epplet_draw_outline(Window win, int x, int y, int w, int h, int r, int g, int b)
XFreeGC(disp, gc);
}
RGB_buf
Epplet_make_rgb_buf(int w, int h)
RGB_buf Epplet_make_rgb_buf(int w, int h)
{
RGB_buf buf;
unsigned char *data;

View File

@ -338,17 +338,38 @@ void Epplet_change_label(Epplet_gadget gadget, char *label);
/* or other such things */
/****************************************************************************/
/* PLEASE DO NOT USE THESE FUNCTIONS YET, THEY ARE NOT STABLE */
/* Create a window of width w, height h, with title title, using the themes
* vertical (1), or horizontal (0) background */
Window Epplet_create_window(int w,int h,char *title, char vertical);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
/* Create a config window, of width w, height h, with title title, using the
* functions listed for ok, apply and cancel. If you specify any of the
* functions as null, the button won't be displayed. This means you can get
* just Ok and Cancel by supplying NULL for apply_cb. */
Window Epplet_create_window_config(int w,int h,char *title,
void (*ok_func) (void *data),void *ok_data,
void (*apply_func) (void *data),void *apply_data,
void (*cancel_func) (void *data),void *cancel_data);
/* This is how you add gadgets to specific windows. When you create a
* window, its context is automatically pushed for you. This means any
* gadgets created with this window in context will go onto this window. In
* fact, until you either push another window onto the context, or pop this
* one back off, all created gadgets will go on here. A create_window should
* always be followed by a pop_context (after gadgets have been added). */
void Epplet_window_push_context(Window newwin);
Window Epplet_window_pop_context(void);
/* Show and hide an already created Window win. */
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
/* Destroy Window win. Any gadgets you have added to the window are
* destroyed also */
void Epplet_window_destroy(Window win);
/****************************************************************************/
/* baisc line, filled rectangle and box outline drawing functions to make */
/* basic line, filled rectangle and box outline drawing functions to make */
/* life easy */
/****************************************************************************/
/* draw a line from (x1, y1) to (x2, y2) in window win, in color (r, g, b) */

View File

@ -28,6 +28,7 @@
#include "cloak.h"
#include "E-ScreenSave.h"
Window confwin = 0;
static void
choose_random_cloak (void *data)
@ -320,29 +321,75 @@ cb_out (void *data, Window w)
w = (Window) 0;
}
static int
delete_cb (void *data, Window win)
{
confwin = 0;
/* Yes, please destroy the window for me... */
return 1;
win = (Window) 0;
data = NULL;
}
static void
ok_cb (void *data)
{
printf ("Ok pressed\n");
Epplet_window_destroy (confwin);
confwin = 0;
return;
data = NULL;
}
static void
apply_cb (void *data)
{
printf ("Apply pressed\n");
return;
data = NULL;
}
static void
cancel_cb (void *data)
{
printf ("Cancel pressed\n");
Epplet_window_destroy (confwin);
confwin = 0;
return;
data = NULL;
}
/* Amongst all the fluff, this is the bit that does the actual work. */
static void
cb_shoot (void *data)
{
#if 0
if (opt.lock_cmd)
system (opt.lock_cmd);
#endif
static int temp = 20;
static int temp2 = 50;
static int temp3 = 80;
Window mywin, mywin2, mywin3;
Epplet_gadget sld, sld2, sld3, lbl;
mywin =
Epplet_create_window (400, 300,
"See! I told you this stuff was easy ;)", 1);
Epplet_window_show (mywin);
Epplet_gadget sld, sld2, sld3, lbl, lbl2;
if (confwin)
return;
confwin =
Epplet_create_window_config (400, 300, "E-ScreenSave Config", ok_cb,
&confwin, apply_cb, &confwin, cancel_cb,
&confwin);
Epplet_gadget_show (lbl =
Epplet_create_label (20, 10,
"This window was created on its own, and is vertical.",
"This window was created using Epplet_create_window_config.",
2));
Epplet_gadget_show (lbl2 =
Epplet_create_label (20, 25,
"I added this text and the sliders myself.",
2));
Epplet_gadget_show (sld =
Epplet_create_hslider (20, 50, 100, 0, 100, 1, 5, &temp,
NULL, NULL));
@ -353,45 +400,14 @@ cb_shoot (void *data)
Epplet_create_hslider (20, 150, 300, 0, 100, 1, 5,
&temp3, NULL, NULL));
Epplet_window_show (confwin);
Epplet_window_pop_context ();
mywin2 =
Epplet_create_window (400, 300,
"See! I told you this stuff was easy ;)", 0);
Epplet_window_show (mywin2);
Epplet_gadget_show (lbl =
Epplet_create_label (20, 10,
"This window was created first of two on the context stack.",
2));
Epplet_gadget_show (sld =
Epplet_create_hslider (20, 50, 100, 0, 100, 1, 5, &temp,
NULL, NULL));
Epplet_gadget_show (sld2 =
Epplet_create_hslider (20, 100, 200, 0, 100, 1, 5,
&temp2, NULL, NULL));
Epplet_gadget_show (sld3 =
Epplet_create_hslider (20, 150, 300, 0, 100, 1, 5,
&temp3, NULL, NULL));
mywin3 =
Epplet_create_window (400, 300,
"See! I told you this stuff was easy ;)", 0);
Epplet_window_show (mywin3);
Epplet_gadget_show (lbl =
Epplet_create_label (20, 10,
"This window was created second of two on the context stack.",
2));
Epplet_gadget_show (sld =
Epplet_create_hslider (20, 50, 100, 0, 100, 1, 5, &temp,
NULL, NULL));
Epplet_gadget_show (sld2 =
Epplet_create_hslider (20, 100, 200, 0, 100, 1, 5,
&temp2, NULL, NULL));
Epplet_gadget_show (sld3 =
Epplet_create_hslider (20, 150, 300, 0, 100, 1, 5,
&temp3, NULL, NULL));
Epplet_window_pop_context ();
Epplet_window_pop_context ();
#if 0
if (opt.lock_cmd)
system (opt.lock_cmd);
#endif
return;
data = NULL;
@ -552,6 +568,7 @@ create_epplet_layout (void)
Epplet_timer (cloak_epplet, NULL, opt.cloak_delay, "CLOAK_TIMER");
Epplet_register_mouse_enter_handler (cb_in, (void *) win);
Epplet_register_mouse_leave_handler (cb_out, NULL);
Epplet_register_delete_event_handler (delete_cb, NULL);
}
static void