1999-11-12 11:54:11 -08:00
|
|
|
#include "config.h"
|
1999-10-13 08:14:42 -07:00
|
|
|
#include "epplet.h"
|
|
|
|
#include <errno.h>
|
2006-02-05 01:27:03 -08:00
|
|
|
#include <fcntl.h>
|
2021-08-26 10:21:02 -07:00
|
|
|
#include <sys/resource.h>
|
1999-10-13 08:14:42 -07:00
|
|
|
#include <sys/utsname.h>
|
1999-10-13 10:34:12 -07:00
|
|
|
#include <signal.h>
|
2021-03-26 08:15:46 -07:00
|
|
|
#include <sys/time.h>
|
1999-10-13 10:41:41 -07:00
|
|
|
#include <sys/wait.h>
|
2006-03-31 14:56:17 -08:00
|
|
|
#include <X11/Xatom.h>
|
2012-09-30 02:41:34 -07:00
|
|
|
#include <X11/XKBlib.h>
|
1999-12-12 15:12:45 -08:00
|
|
|
#include <X11/keysym.h>
|
2006-03-31 14:56:17 -08:00
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
|
|
|
|
#define DEPTH() DefaultDepth(disp, DefaultScreen(disp))
|
1999-12-12 15:12:45 -08:00
|
|
|
|
2007-03-18 15:54:02 -07:00
|
|
|
#define DEBUG_EVENTS 0
|
|
|
|
|
2003-04-06 19:40:02 -07:00
|
|
|
#define SET_HINTS_EWM 1
|
|
|
|
|
1999-12-12 15:12:45 -08:00
|
|
|
#define CRSR_WDTH 2
|
1999-10-13 08:14:42 -07:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
Window win;
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
char win_vert;
|
|
|
|
Pixmap bg_pmap;
|
|
|
|
Pixmap bg_mask;
|
|
|
|
Pixmap bg_bg;
|
2021-08-26 11:13:56 -07:00
|
|
|
} EppWindow;
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
typedef EppWindow *Epplet_window;
|
|
|
|
|
2019-03-12 08:53:14 -07:00
|
|
|
EAPI Display *disp = NULL;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
|
1999-12-03 07:08:23 -08:00
|
|
|
static int window_num = 0; /* For window list */
|
|
|
|
static Epplet_window *windows = NULL; /* List of windows to loop though */
|
|
|
|
|
|
|
|
static Epplet_window context_win; /* Current context win */
|
|
|
|
static int window_stack_pos = 0; /* For context changes */
|
|
|
|
static Epplet_window *window_stack; /* For context changes */
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
static Epplet_window mainwin; /* Always the main epplet window */
|
|
|
|
|
|
|
|
static Atom wmDeleteWindow;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
static Display *dd = NULL;
|
|
|
|
static Window comms_win = 0;
|
|
|
|
static Window my_win = 0;
|
|
|
|
static Window root = 0;
|
|
|
|
static ETimer *q_first = NULL;
|
|
|
|
static XContext xid_context = 0;
|
|
|
|
|
|
|
|
static char *conf_dir = NULL;
|
2006-04-12 12:22:45 -07:00
|
|
|
static char *data_dir = NULL;
|
|
|
|
static char *e16_user_dir = NULL;
|
1999-11-16 13:02:11 -08:00
|
|
|
static char *epplet_name = NULL;
|
|
|
|
static char *epplet_cfg_file = NULL;
|
|
|
|
static int epplet_instance = 0;
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
static char epplet_visible = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
static int gad_num = 0;
|
|
|
|
static Epplet_gadget *gads = NULL;
|
1999-11-29 10:00:00 -08:00
|
|
|
static Epplet_gadget last_gadget = NULL;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
static void *expose_data = NULL;
|
|
|
|
static void *moveresize_data = NULL;
|
|
|
|
static void *buttonpress_data = NULL;
|
|
|
|
static void *buttonrelease_data = NULL;
|
|
|
|
static void *mousemotion_data = NULL;
|
|
|
|
static void *keypress_data = NULL;
|
|
|
|
static void *keyrelease_data = NULL;
|
|
|
|
static void *enter_data = NULL;
|
|
|
|
static void *leave_data = NULL;
|
|
|
|
static void *focusin_data = NULL;
|
|
|
|
static void *focusout_data = NULL;
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
static void *delete_data = NULL;
|
1999-11-16 13:02:11 -08:00
|
|
|
static void *event_data = NULL;
|
|
|
|
static void *comms_data = NULL;
|
|
|
|
static void *child_data = NULL;
|
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
static void (*expose_func)(void *data, Window win, int x, int y, int w,
|
|
|
|
int h) = NULL;
|
|
|
|
static void (*moveresize_func)(void *data, Window win, int x, int y,
|
|
|
|
int w, int h) = NULL;
|
|
|
|
static void (*buttonpress_func)(void *data, Window win, int x, int y,
|
|
|
|
int b) = NULL;
|
|
|
|
static void (*buttonrelease_func)(void *data, Window win, int x, int y,
|
|
|
|
int b) = NULL;
|
|
|
|
static void (*mousemotion_func)(void *data, Window win, int x, int y) =
|
2006-04-15 15:04:48 -07:00
|
|
|
NULL;
|
2021-08-26 11:13:56 -07:00
|
|
|
static void (*keypress_func)(void *data, Window win, char *key) = NULL;
|
|
|
|
static void (*keyrelease_func)(void *data, Window win, char *key) =
|
2006-04-15 15:04:48 -07:00
|
|
|
NULL;
|
2021-08-26 11:13:56 -07:00
|
|
|
static void (*enter_func)(void *data, Window win) = NULL;
|
|
|
|
static void (*leave_func)(void *data, Window win) = NULL;
|
|
|
|
static void (*focusin_func)(void *data, Window win) = NULL;
|
|
|
|
static void (*focusout_func)(void *data, Window win) = NULL;
|
|
|
|
static int (*delete_func)(void *data, Window win) = NULL;
|
|
|
|
static void (*event_func)(void *data, XEvent * ev) = NULL;
|
|
|
|
static void (*comms_func)(void *data, const char *s) = NULL;
|
|
|
|
static void (*child_func)(void *data, int pid, int exit_code) = NULL;
|
1999-12-03 07:08:23 -08:00
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
/* For Keeping a list of windows owned by the epplet, to loop through and
|
|
|
|
* do stuff with. */
|
|
|
|
static void Epplet_register_window(Epplet_window win);
|
|
|
|
static void Epplet_unregister_window(Epplet_window win);
|
1999-12-03 05:07:03 -08:00
|
|
|
static void Epplet_window_destroy_children(Epplet_window win);
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
static Epplet_window Epplet_window_get_from_Window(Window win);
|
1999-12-09 07:40:08 -08:00
|
|
|
static Window Epplet_internal_create_window(int w, int h,
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *title,
|
|
|
|
char vertical, char decorate);
|
2000-03-03 14:45:02 -08:00
|
|
|
static void remember_stuff(void *data);
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
#define MWM_HINTS_DECORATIONS (1L << 1)
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
unsigned long flags;
|
|
|
|
unsigned long functions;
|
|
|
|
unsigned long decorations;
|
|
|
|
long inputMode;
|
|
|
|
unsigned long status;
|
2021-08-26 11:13:56 -07:00
|
|
|
} MWMHints;
|
|
|
|
|
|
|
|
struct _etimer {
|
2006-04-15 15:04:48 -07:00
|
|
|
char *name;
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data);
|
2006-04-15 15:04:48 -07:00
|
|
|
void *data;
|
|
|
|
double in;
|
|
|
|
char just_added;
|
|
|
|
ETimer *next;
|
|
|
|
};
|
1999-10-13 08:14:42 -07:00
|
|
|
|
2022-03-09 22:19:37 -08:00
|
|
|
#define ESYNC Epplet_send_ipc("nop");free(ECommsWaitForMessage());
|
1999-10-13 08:14:42 -07:00
|
|
|
|
1999-10-18 08:50:58 -07:00
|
|
|
/* The structures for the config file management ... */
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
ConfigItem *entries;
|
|
|
|
int num_entries;
|
2021-08-26 11:13:56 -07:00
|
|
|
} ConfigDict;
|
1999-10-18 08:50:58 -07:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
static ConfigDict *config_dict = NULL;
|
|
|
|
|
2012-09-30 02:41:36 -07:00
|
|
|
static void CommsSetup(void);
|
1999-11-16 13:02:11 -08:00
|
|
|
static void CommsFindCommsWindow(void);
|
|
|
|
static void CommsHandleDestroy(Window win);
|
|
|
|
static int CommsHandlePropertyNotify(XEvent * ev);
|
|
|
|
static char *ECommsGet(XEvent * ev);
|
|
|
|
static char *ECommsWaitForMessage(void);
|
2012-09-30 02:41:36 -07:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
static void Epplet_handle_timer(void);
|
|
|
|
static ETimer *Epplet_get_first(void);
|
|
|
|
static void Epplet_handle_event(XEvent * ev);
|
|
|
|
static Bool ev_check(Display * d, XEvent * ev, XPointer p);
|
2013-07-13 12:07:12 -07:00
|
|
|
static const char *win_name = NULL;
|
|
|
|
static const char *win_version = NULL;
|
|
|
|
static const char *win_info = NULL;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
static void Epplet_event(Epplet_gadget gadget, XEvent * ev);
|
|
|
|
static void Epplet_add_gad(Epplet_gadget gadget);
|
|
|
|
static void Epplet_del_gad(Epplet_gadget gadget);
|
|
|
|
static void Epplet_draw_button(Epplet_gadget eg);
|
|
|
|
static void Epplet_draw_textbox(Epplet_gadget eg);
|
|
|
|
static void Epplet_draw_togglebutton(Epplet_gadget eg);
|
|
|
|
static void Epplet_draw_drawingarea(Epplet_gadget eg);
|
|
|
|
static void Epplet_draw_hslider(Epplet_gadget eg);
|
|
|
|
static void Epplet_draw_vslider(Epplet_gadget eg);
|
|
|
|
static void Epplet_draw_hbar(Epplet_gadget eg);
|
|
|
|
static void Epplet_draw_vbar(Epplet_gadget eg);
|
|
|
|
static void Epplet_draw_image(Epplet_gadget eg, char un_only);
|
|
|
|
static void Epplet_draw_label(Epplet_gadget eg, char un_only);
|
|
|
|
static void Epplet_draw_popup(Epplet_gadget gadget);
|
|
|
|
static void Epplet_draw_popupbutton(Epplet_gadget eg);
|
|
|
|
static void Epplet_popup_arrange_contents(Epplet_gadget gadget);
|
|
|
|
static void Epplet_prune_events(XEvent * ev, int num);
|
|
|
|
static void Epplet_handle_child(int num);
|
|
|
|
static void Epplet_textbox_handle_keyevent(XEvent * ev,
|
|
|
|
Epplet_gadget g);
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
static void Epplet_refresh_backgrounds(void);
|
1999-11-27 08:17:16 -08:00
|
|
|
static void Epplet_textbox_textsize(Epplet_gadget gadget, int *w,
|
2013-07-13 12:07:12 -07:00
|
|
|
int *h, const char *s);
|
1999-12-14 13:18:51 -08:00
|
|
|
int Epplet_textbox_spacesize(Epplet_gadget gadget);
|
2013-07-13 12:07:12 -07:00
|
|
|
static void Epplet_find_instance(const char *name);
|
1999-12-03 05:07:03 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadType type;
|
|
|
|
char visible;
|
|
|
|
Epplet_window parent;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadGeneral;
|
1999-11-28 14:08:49 -08:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
#define GADGET_GET_TYPE(gad) (((GadGeneral *) (gad))->type)
|
|
|
|
#ifdef __GNUC__
|
2012-09-30 02:41:07 -07:00
|
|
|
#define GADGET_CONFIRM_TYPE(gad, type) \
|
2000-04-30 16:19:22 -07:00
|
|
|
do { \
|
|
|
|
if (GADGET_GET_TYPE(gad) != (type)) { \
|
|
|
|
fprintf(stderr, "ALERT: %s() called with invalid gadget " \
|
|
|
|
"type for %s (should be %s)!\n", __FUNCTION__, \
|
|
|
|
#gad, #type); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2012-09-30 02:41:07 -07:00
|
|
|
#define GADGET_CONFIRM_TYPE_RVAL(gad, type, rval) \
|
2000-04-30 16:19:22 -07:00
|
|
|
do { \
|
|
|
|
if (GADGET_GET_TYPE(gad) != (type)) { \
|
|
|
|
fprintf(stderr, "ALERT: %s() called with invalid gadget " \
|
|
|
|
"type for %s (should be %s)!\n", __FUNCTION__, \
|
|
|
|
#gad, #type); \
|
|
|
|
return (rval); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#else
|
2012-09-30 02:41:07 -07:00
|
|
|
#define GADGET_CONFIRM_TYPE(gad, type) do { \
|
2000-04-30 16:19:22 -07:00
|
|
|
if (GADGET_GET_TYPE(gad) != (type)) return;} while (0)
|
2012-09-30 02:41:07 -07:00
|
|
|
#define GADGET_CONFIRM_TYPE_RVAL(gad, type, rval) do { \
|
2000-04-30 16:19:22 -07:00
|
|
|
if (GADGET_GET_TYPE(gad) != (type)) return (rval);} while (0)
|
|
|
|
#endif
|
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
char *label;
|
|
|
|
char *image;
|
|
|
|
char hilited;
|
|
|
|
char clicked;
|
|
|
|
char pop;
|
|
|
|
Epplet_gadget pop_parent;
|
|
|
|
char *std;
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data);
|
2006-04-15 15:04:48 -07:00
|
|
|
void *data;
|
|
|
|
Pixmap pmap, mask;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadButton;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
int x_offset;
|
|
|
|
unsigned int cursor_pos, to_cursor;
|
|
|
|
char *image;
|
|
|
|
char *contents;
|
|
|
|
char hilited;
|
|
|
|
char size;
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data);
|
2006-04-15 15:04:48 -07:00
|
|
|
void *data;
|
|
|
|
Pixmap pmap, mask;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadTextBox;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
char *label;
|
|
|
|
char *image;
|
|
|
|
char hilited;
|
|
|
|
char clicked;
|
|
|
|
int *val;
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data);
|
2006-04-15 15:04:48 -07:00
|
|
|
void *data;
|
|
|
|
Pixmap pmap, mask;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadToggleButton;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
Window win_in;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadDrawingArea;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
int min, max;
|
|
|
|
int step, jump;
|
|
|
|
char hilited;
|
|
|
|
char clicked;
|
|
|
|
int *val;
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data);
|
2006-04-15 15:04:48 -07:00
|
|
|
void *data;
|
|
|
|
Window win_knob;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadHSlider;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
int min, max;
|
|
|
|
int step, jump;
|
|
|
|
char hilited;
|
|
|
|
char clicked;
|
|
|
|
int *val;
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data);
|
2006-04-15 15:04:48 -07:00
|
|
|
void *data;
|
|
|
|
Window win_knob;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadVSlider;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
int *val;
|
|
|
|
char dir;
|
|
|
|
Window win_in;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadHBar;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
int *val;
|
|
|
|
char dir;
|
|
|
|
Window win_in;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadVBar;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
int pw, ph;
|
|
|
|
char *image;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadImage;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
char size;
|
|
|
|
char *label;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadLabel;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
char *label;
|
|
|
|
char *image;
|
|
|
|
int w, h;
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data);
|
2006-04-15 15:04:48 -07:00
|
|
|
void *data;
|
|
|
|
Epplet_gadget gadget;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadPopEntry;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
Epplet_gadget popbutton;
|
|
|
|
int entry_num;
|
|
|
|
GadPopEntry *entry;
|
|
|
|
char changed;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadPopup;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2021-08-26 11:13:56 -07:00
|
|
|
typedef struct {
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral general;
|
|
|
|
int x, y, w, h;
|
|
|
|
Window win;
|
|
|
|
char *label;
|
|
|
|
char *image;
|
|
|
|
char hilited;
|
|
|
|
char clicked;
|
|
|
|
Epplet_gadget popup;
|
|
|
|
char popped;
|
|
|
|
char *std;
|
|
|
|
Pixmap pmap, mask;
|
2021-08-26 11:13:56 -07:00
|
|
|
} GadPopupButton;
|
1999-12-16 13:17:27 -08:00
|
|
|
|
2007-03-18 15:54:02 -07:00
|
|
|
#if DEBUG_EVENTS
|
|
|
|
static int
|
|
|
|
HandleXError(Display * d, XErrorEvent * ev)
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
XGetErrorText(disp, ev->error_code, buf, 63);
|
|
|
|
printf("*** ERROR: xid=%#lx error=%i req=%i/%i: %s\n",
|
|
|
|
ev->resourceid, ev->error_code,
|
|
|
|
ev->request_code, ev->minor_code, buf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-01-22 04:47:42 -08:00
|
|
|
static GC
|
|
|
|
EXCreateGC(Drawable d)
|
|
|
|
{
|
|
|
|
GC gc;
|
|
|
|
XGCValues gcv;
|
|
|
|
unsigned long mask;
|
|
|
|
|
|
|
|
gcv.graphics_exposures = False;
|
|
|
|
mask = GCGraphicsExposures;
|
|
|
|
gc = XCreateGC(disp, d, mask, &gcv);
|
|
|
|
|
|
|
|
return gc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
EXFreeGC(GC gc)
|
|
|
|
{
|
|
|
|
XFreeGC(disp, gc);
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
char *
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_wait_for_ipc(void)
|
|
|
|
{
|
|
|
|
return ECommsWaitForMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_Init(const char *name, const char *version, const char *info,
|
|
|
|
int w, int h, int argc, char **argv, char vertical)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
struct sigaction sa;
|
|
|
|
char s[1024];
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
1999-11-16 13:02:11 -08:00
|
|
|
Atom a;
|
|
|
|
XTextProperty xtp;
|
|
|
|
XClassHint *xch;
|
|
|
|
XSizeHints sh;
|
|
|
|
struct utsname ubuf;
|
|
|
|
MWMHints mwm;
|
1999-11-24 09:16:39 -08:00
|
|
|
char *msg;
|
2006-04-15 15:04:48 -07:00
|
|
|
|
2003-04-06 19:40:02 -07:00
|
|
|
#if SET_HINTS_EWM
|
|
|
|
Atom atom_list[8];
|
|
|
|
int atom_count;
|
|
|
|
#endif
|
1999-10-13 08:14:42 -07:00
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
mainwin = malloc(sizeof(EppWindow));
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
mainwin->win_vert = vertical;
|
1999-10-13 08:14:42 -07:00
|
|
|
w *= 16;
|
|
|
|
h *= 16;
|
|
|
|
disp = XOpenDisplay(NULL);
|
|
|
|
if (!disp)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Epplet Error: Cannot open display\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-03-18 15:54:02 -07:00
|
|
|
#if DEBUG_EVENTS
|
|
|
|
XSetErrorHandler(HandleXError);
|
|
|
|
#if DEBUG_EVENTS > 1
|
|
|
|
XSynchronize(disp, True);
|
|
|
|
#endif
|
|
|
|
#endif
|
2006-03-31 14:56:17 -08:00
|
|
|
|
2012-09-30 02:41:36 -07:00
|
|
|
dd = disp;
|
|
|
|
root = DefaultRootWindow(dd);
|
|
|
|
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_display(disp);
|
|
|
|
imlib_context_set_visual(DefaultVisual(disp, DefaultScreen(disp)));
|
|
|
|
imlib_context_set_colormap(DefaultColormap(disp, DefaultScreen(disp)));
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
XSelectInput(disp, DefaultRootWindow(disp), PropertyChangeMask);
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
/* Find the instance number for this instance and compose the name from it */
|
1999-10-22 15:09:18 -07:00
|
|
|
Epplet_find_instance(name);
|
1999-10-22 09:43:22 -07:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
/* create a window with everythign set */
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = StructureNotifyMask | ButtonPressMask |
|
1999-10-13 08:14:42 -07:00
|
|
|
ButtonReleaseMask | PointerMotionMask | EnterWindowMask |
|
|
|
|
LeaveWindowMask | KeyPressMask | KeyReleaseMask | ButtonMotionMask |
|
|
|
|
ExposureMask | FocusChangeMask | PropertyChangeMask |
|
|
|
|
VisibilityChangeMask;
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
mainwin->win = XCreateWindow(disp, DefaultRootWindow(disp), 0, 0, w, h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder |
|
|
|
|
CWBackingStore | CWColormap | CWBackPixel |
|
|
|
|
CWBorderPixel | CWEventMask, &attr);
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
/* set hints to be borderless */
|
|
|
|
mwm.flags = MWM_HINTS_DECORATIONS;
|
|
|
|
mwm.functions = 0;
|
|
|
|
mwm.decorations = 0;
|
|
|
|
mwm.inputMode = 0;
|
|
|
|
mwm.status = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
a = XInternAtom(disp, "_MOTIF_WM_HINTS", False);
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
XChangeProperty(disp, mainwin->win, a, a, 32, PropModeReplace,
|
1999-10-13 08:14:42 -07:00
|
|
|
(unsigned char *)&mwm, sizeof(MWMHints) / 4);
|
|
|
|
|
|
|
|
/* set the window title , name , class */
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
XStoreName(disp, mainwin->win, epplet_name);
|
1999-10-13 08:14:42 -07:00
|
|
|
xch = XAllocClassHint();
|
1999-10-22 09:43:22 -07:00
|
|
|
xch->res_name = epplet_name;
|
2013-07-13 12:07:12 -07:00
|
|
|
xch->res_class = (char *)"Epplet";
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
XSetClassHint(disp, mainwin->win, xch);
|
1999-10-13 08:14:42 -07:00
|
|
|
XFree(xch);
|
|
|
|
/* set the size hints */
|
|
|
|
sh.flags = PSize | PMinSize | PMaxSize;
|
|
|
|
sh.width = w;
|
|
|
|
sh.height = h;
|
|
|
|
sh.min_width = w;
|
|
|
|
sh.min_height = h;
|
|
|
|
sh.max_width = w;
|
|
|
|
sh.max_height = h;
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
XSetWMNormalHints(disp, mainwin->win, &sh);
|
1999-10-13 08:14:42 -07:00
|
|
|
/* set the command hint */
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
XSetCommand(disp, mainwin->win, argv, argc);
|
1999-10-13 08:14:42 -07:00
|
|
|
/* set the client machine name */
|
|
|
|
if (!uname(&ubuf))
|
|
|
|
{
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s", ubuf.nodename);
|
1999-10-13 08:14:42 -07:00
|
|
|
xtp.encoding = XA_STRING;
|
|
|
|
xtp.format = 8;
|
|
|
|
xtp.value = (unsigned char *)s;
|
|
|
|
xtp.nitems = strlen((char *)(xtp.value));
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
XSetWMClientMachine(disp, mainwin->win, &xtp);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
/* set the icons name property */
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
XSetIconName(disp, mainwin->win, epplet_name);
|
1999-10-13 08:14:42 -07:00
|
|
|
|
2003-04-06 19:40:02 -07:00
|
|
|
#if SET_HINTS_EWM
|
|
|
|
a = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False);
|
|
|
|
atom_count = 0;
|
2006-04-15 15:04:48 -07:00
|
|
|
atom_list[atom_count++] =
|
|
|
|
XInternAtom(disp, "_NET_WM_WINDOW_TYPE_UTILITY", False);
|
2003-04-06 19:40:02 -07:00
|
|
|
XChangeProperty(disp, mainwin->win, a, XA_ATOM, 32, PropModeReplace,
|
|
|
|
(unsigned char *)atom_list, atom_count);
|
|
|
|
a = XInternAtom(disp, "_NET_WM_STATE", False);
|
|
|
|
atom_count = 0;
|
|
|
|
atom_list[atom_count++] = XInternAtom(disp, "_NET_WM_STATE_STICKY", False);
|
2006-04-15 15:04:48 -07:00
|
|
|
atom_list[atom_count++] =
|
|
|
|
XInternAtom(disp, "_NET_WM_STATE_SKIP_TASKBAR", False);
|
|
|
|
atom_list[atom_count++] =
|
|
|
|
XInternAtom(disp, "_NET_WM_STATE_SKIP_PAGER", False);
|
2003-04-06 19:40:02 -07:00
|
|
|
atom_list[atom_count++] = XInternAtom(disp, "_NET_WM_STATE_BELOW", False);
|
|
|
|
XChangeProperty(disp, mainwin->win, a, XA_ATOM, 32, PropModeReplace,
|
|
|
|
(unsigned char *)atom_list, atom_count);
|
|
|
|
#endif
|
|
|
|
|
1999-10-22 09:43:22 -07:00
|
|
|
win_name = epplet_name;
|
1999-10-13 08:14:42 -07:00
|
|
|
win_version = version;
|
|
|
|
win_info = info;
|
1999-11-16 13:02:11 -08:00
|
|
|
xid_context = XUniqueContext();
|
2012-09-30 02:41:36 -07:00
|
|
|
CommsSetup();
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("set clientname %s", win_name);
|
|
|
|
Epplet_send_ipc("set version %s", win_version);
|
|
|
|
Epplet_send_ipc("set info %s", win_info);
|
1999-10-13 08:14:42 -07:00
|
|
|
ESYNC;
|
1999-11-24 09:16:39 -08:00
|
|
|
|
|
|
|
/* Check if the epplet imageclasses are there. */
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("imageclass EPPLET_BUTTON query");
|
1999-11-24 09:16:39 -08:00
|
|
|
msg = ECommsWaitForMessage();
|
|
|
|
if (!msg || strstr(msg, "not"))
|
|
|
|
{
|
1999-11-27 08:17:16 -08:00
|
|
|
Epplet_dialog_ok
|
|
|
|
("Epplet Error: Your theme does not contain the imageclasses needed to run epplets.");
|
|
|
|
ESYNC;
|
|
|
|
exit(1);
|
1999-11-24 09:16:39 -08:00
|
|
|
}
|
|
|
|
free(msg);
|
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
mainwin->w = w;
|
|
|
|
mainwin->h = h;
|
|
|
|
mainwin->bg_pmap = 0;
|
|
|
|
mainwin->bg_bg = 0;
|
|
|
|
mainwin->bg_mask = 0;
|
|
|
|
|
|
|
|
Epplet_register_window(mainwin);
|
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window_push_context(mainwin->win);
|
|
|
|
|
|
|
|
Epplet_background_properties(mainwin->win_vert, mainwin->win);
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
wmDeleteWindow = XInternAtom(disp, "WM_DELETE_WINDOW", False);
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
|
2007-03-18 16:56:14 -07:00
|
|
|
Epplet_timer(remember_stuff, NULL, 2, "REMEMBER_TIMER");
|
2000-03-03 14:45:02 -08:00
|
|
|
|
1999-10-13 10:34:12 -07:00
|
|
|
sa.sa_handler = Epplet_handle_child;
|
|
|
|
sa.sa_flags = SA_RESTART;
|
|
|
|
sigemptyset(&sa.sa_mask);
|
1999-11-16 13:02:11 -08:00
|
|
|
sigaction(SIGCHLD, &sa, (struct sigaction *)0);
|
2021-08-26 12:54:45 -07:00
|
|
|
|
|
|
|
atexit(Epplet_cleanup);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-12-09 07:40:08 -08:00
|
|
|
static Window
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_internal_create_window(int w, int h, const char *title, char vertical,
|
1999-12-09 07:40:08 -08:00
|
|
|
char decorate)
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
{
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
Atom a;
|
|
|
|
XSizeHints sh;
|
1999-12-03 05:07:03 -08:00
|
|
|
XClassHint *xch;
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
MWMHints mwm;
|
|
|
|
char *msg;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
Epplet_window ret;
|
1999-12-01 11:30:19 -08:00
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
ret = malloc(sizeof(EppWindow));
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
ret->win_vert = vertical;
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = StructureNotifyMask | ButtonPressMask |
|
|
|
|
ButtonReleaseMask | PointerMotionMask | EnterWindowMask |
|
|
|
|
LeaveWindowMask | KeyPressMask | KeyReleaseMask | ButtonMotionMask |
|
|
|
|
ExposureMask | FocusChangeMask | PropertyChangeMask |
|
|
|
|
VisibilityChangeMask;
|
1999-12-01 11:30:19 -08:00
|
|
|
|
1999-12-03 08:05:33 -08:00
|
|
|
ret->win = XCreateWindow(disp, DefaultRootWindow(disp), 0, 0, w, h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore
|
|
|
|
| CWColormap | CWBackPixel | CWBorderPixel |
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
CWEventMask, &attr);
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
XSetTransientForHint(disp, ret->win, mainwin->win);
|
1999-12-01 11:30:19 -08:00
|
|
|
|
1999-12-03 05:07:03 -08:00
|
|
|
/* set hints? */
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
mwm.flags = MWM_HINTS_DECORATIONS;
|
|
|
|
mwm.functions = 0;
|
1999-12-09 07:40:08 -08:00
|
|
|
mwm.decorations = decorate;
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
mwm.inputMode = 0;
|
|
|
|
mwm.status = 0;
|
|
|
|
a = XInternAtom(disp, "_MOTIF_WM_HINTS", False);
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XChangeProperty(disp, ret->win, a, a, 32, PropModeReplace,
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
(unsigned char *)&mwm, sizeof(MWMHints) / 4);
|
|
|
|
|
|
|
|
/* set the window title , name , class */
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XStoreName(disp, ret->win, title);
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
xch = XAllocClassHint();
|
|
|
|
xch->res_name = epplet_name;
|
2013-07-13 12:07:12 -07:00
|
|
|
xch->res_class = (char *)"Epplet_window";
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XSetClassHint(disp, ret->win, xch);
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
XFree(xch);
|
|
|
|
/* set the size hints */
|
|
|
|
sh.flags = PSize | PMinSize | PMaxSize;
|
|
|
|
sh.width = w;
|
|
|
|
sh.height = h;
|
|
|
|
sh.min_width = w;
|
|
|
|
sh.min_height = h;
|
|
|
|
sh.max_width = w;
|
|
|
|
sh.max_height = h;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XSetWMNormalHints(disp, ret->win, &sh);
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
|
|
|
|
/* set the icons name property */
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XSetIconName(disp, ret->win, epplet_name);
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
|
|
|
|
ESYNC;
|
|
|
|
|
|
|
|
/* Check if the epplet imageclasses are there. */
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("imageclass EPPLET_BUTTON query");
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
msg = ECommsWaitForMessage();
|
|
|
|
if (!msg || strstr(msg, "not"))
|
|
|
|
{
|
|
|
|
Epplet_dialog_ok
|
|
|
|
("Epplet Error: Your theme does not contain the imageclasses needed to run epplets.");
|
|
|
|
ESYNC;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
free(msg);
|
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
ret->h = h;
|
|
|
|
ret->w = w;
|
|
|
|
ret->bg_pmap = 0;
|
|
|
|
ret->bg_mask = 0;
|
|
|
|
ret->bg_bg = 0;
|
|
|
|
|
|
|
|
Epplet_register_window(ret);
|
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window_push_context(ret->win);
|
|
|
|
|
|
|
|
Epplet_background_properties(ret->win_vert, ret->win);
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
XSetWMProtocols(disp, ret->win, &wmDeleteWindow, 1);
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
return ret->win;
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
}
|
|
|
|
|
2021-08-27 06:03:30 -07:00
|
|
|
void
|
|
|
|
Epplet_Exit(int rc)
|
|
|
|
{
|
|
|
|
Epplet_unremember();
|
|
|
|
Esync();
|
|
|
|
exit(rc);
|
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Window
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_window(int w, int h, const char *title, char vertical)
|
1999-12-09 07:40:08 -08:00
|
|
|
{
|
|
|
|
return Epplet_internal_create_window(w, h, title, vertical, 1);
|
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Window
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_window_borderless(int w, int h, const char *title, char vertical)
|
1999-12-09 07:40:08 -08:00
|
|
|
{
|
|
|
|
return Epplet_internal_create_window(w, h, title, vertical, 0);
|
|
|
|
}
|
|
|
|
|
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
1999-12-03 12:56:49 -08:00
|
|
|
Window
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_window_config(int w, int h, const char *title,
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*ok_func)(void *data),
|
|
|
|
void *ok_data, void(*apply_func)(void *data),
|
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
1999-12-03 12:56:49 -08:00
|
|
|
void *apply_data,
|
2021-08-26 11:13:56 -07:00
|
|
|
void(*cancel_func)(void *data), void *cancel_data)
|
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
1999-12-03 12:56:49 -08:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-12-01 11:30:19 -08:00
|
|
|
void
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window_show(Window win)
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
{
|
|
|
|
XEvent ev;
|
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
XMapWindow(disp, win);
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
/* wait for the window to map */
|
|
|
|
XMaskEvent(disp, StructureNotifyMask, &ev);
|
|
|
|
}
|
|
|
|
|
1999-12-01 11:30:19 -08:00
|
|
|
void
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window_hide(Window win)
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
{
|
|
|
|
XEvent ev;
|
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
XUnmapWindow(disp, win);
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
/* wait for the window to unmap */
|
|
|
|
XMaskEvent(disp, StructureNotifyMask, &ev);
|
|
|
|
}
|
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
static Epplet_gadget
|
2006-04-13 05:06:25 -07:00
|
|
|
Epplet_gadget_check(Epplet_gadget g)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < gad_num; i++)
|
|
|
|
if (gads[i] == g)
|
2006-04-15 15:04:48 -07:00
|
|
|
return g;
|
2006-04-13 05:06:25 -07:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-12-03 05:07:03 -08:00
|
|
|
void
|
|
|
|
Epplet_window_destroy_children(Epplet_window win)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
int i, num;
|
2006-04-13 05:06:25 -07:00
|
|
|
Epplet_gadget *lst, g;
|
1999-12-03 07:08:23 -08:00
|
|
|
|
2006-03-31 14:56:17 -08:00
|
|
|
if (!gads || gad_num <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Create work copy of gadget list
|
|
|
|
* (gads is modified by Epplet_gadget_destroy) */
|
|
|
|
num = gad_num;
|
|
|
|
lst = malloc(num * sizeof(Epplet_gadget));
|
|
|
|
memcpy(lst, gads, num * sizeof(Epplet_gadget));
|
|
|
|
|
|
|
|
for (i = 0; i < num; i++)
|
2006-04-13 05:06:25 -07:00
|
|
|
{
|
|
|
|
/* Check - Gadget may have been removed by recursive call */
|
|
|
|
g = Epplet_gadget_check(lst[i]);
|
|
|
|
if (!g)
|
|
|
|
continue;
|
|
|
|
if (((GadGeneral *) g)->parent == win)
|
|
|
|
Epplet_gadget_destroy(g);
|
|
|
|
}
|
2006-03-31 14:56:17 -08:00
|
|
|
|
|
|
|
free(lst);
|
1999-12-03 05:07:03 -08:00
|
|
|
}
|
|
|
|
|
1999-12-01 11:30:19 -08:00
|
|
|
void
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window_destroy(Window newwin)
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
{
|
|
|
|
XEvent ev;
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window win;
|
|
|
|
|
|
|
|
win = Epplet_window_get_from_Window(newwin);
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!win)
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
return;
|
1999-12-01 11:30:19 -08:00
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
Epplet_unregister_window(win);
|
1999-12-03 05:07:03 -08:00
|
|
|
Epplet_window_destroy_children(win);
|
1999-12-03 07:08:23 -08:00
|
|
|
if (win->bg_pmap)
|
|
|
|
XFreePixmap(disp, win->bg_pmap);
|
|
|
|
if (win->bg_bg)
|
|
|
|
XFreePixmap(disp, win->bg_bg);
|
|
|
|
if (win->bg_mask)
|
|
|
|
XFreePixmap(disp, win->bg_mask);
|
2006-03-31 14:56:17 -08:00
|
|
|
|
|
|
|
XDestroyWindow(disp, win->win);
|
|
|
|
/* wait for the window to be destroyed */
|
|
|
|
XMaskEvent(disp, StructureNotifyMask, &ev);
|
|
|
|
|
1999-12-03 05:07:03 -08:00
|
|
|
free(win);
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
}
|
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
static void
|
|
|
|
Epplet_register_window(Epplet_window win)
|
|
|
|
{
|
|
|
|
window_num++;
|
|
|
|
if (windows)
|
|
|
|
windows = realloc(windows, window_num * sizeof(Epplet_window));
|
|
|
|
else
|
|
|
|
windows = malloc(window_num * sizeof(Epplet_window));
|
|
|
|
windows[window_num - 1] = win;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
Epplet_unregister_window(Epplet_window win)
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
{
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < window_num; i++)
|
1999-12-01 11:30:19 -08:00
|
|
|
{
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
if (windows[i] == win)
|
|
|
|
{
|
|
|
|
for (j = i; j < window_num - 1; j++)
|
|
|
|
windows[j] = windows[j + 1];
|
|
|
|
window_num--;
|
|
|
|
if (window_num > 0)
|
|
|
|
windows = realloc(windows, window_num * sizeof(Epplet_window));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free(windows);
|
|
|
|
windows = NULL;
|
|
|
|
}
|
|
|
|
}
|
1999-12-01 11:30:19 -08:00
|
|
|
}
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
}
|
|
|
|
|
1999-12-01 11:30:19 -08:00
|
|
|
void
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window_push_context(Window newwin)
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
{
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window win;
|
1999-12-03 06:17:56 -08:00
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
win = Epplet_window_get_from_Window(newwin);
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!win)
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
return;
|
1999-12-03 06:17:56 -08:00
|
|
|
|
2012-09-30 02:41:07 -07:00
|
|
|
window_stack = realloc(window_stack,
|
|
|
|
sizeof(Epplet_window) * (window_stack_pos + 1));
|
|
|
|
if (!window_stack)
|
1999-12-03 07:08:23 -08:00
|
|
|
exit(1);
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
window_stack[window_stack_pos] = win;
|
1999-12-03 06:17:56 -08:00
|
|
|
window_stack_pos++;
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
context_win = win;
|
1999-12-03 06:17:56 -08:00
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Window
|
|
|
|
Epplet_window_pop_context(void)
|
1999-12-03 06:17:56 -08:00
|
|
|
{
|
1999-12-03 07:08:23 -08:00
|
|
|
Epplet_window ret;
|
|
|
|
|
1999-12-03 06:17:56 -08:00
|
|
|
window_stack_pos--;
|
1999-12-03 07:08:23 -08:00
|
|
|
ret = window_stack[window_stack_pos];
|
2012-09-30 02:41:07 -07:00
|
|
|
window_stack = realloc(window_stack,
|
|
|
|
sizeof(Epplet_window) * (window_stack_pos));
|
|
|
|
if (!window_stack)
|
1999-12-03 07:08:23 -08:00
|
|
|
exit(1);
|
1999-12-03 06:17:56 -08:00
|
|
|
/* Window stack pos == 0 corresponds to the main epplet window */
|
|
|
|
if (window_stack_pos < 1)
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
return 0;
|
1999-12-03 06:17:56 -08:00
|
|
|
context_win = window_stack[window_stack_pos - 1];
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
return ret->win;
|
1999-12-03 06:17:56 -08:00
|
|
|
}
|
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
/* Refresh window backgrounds on theme change */
|
|
|
|
static void
|
|
|
|
Epplet_refresh_backgrounds(void)
|
|
|
|
{
|
|
|
|
/* Loop through windows and refresh them */
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < window_num; i++)
|
|
|
|
{
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window_push_context(windows[i]->win);
|
|
|
|
Epplet_background_properties(windows[i]->win_vert, windows[i]->win);
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
Epplet_window_pop_context();
|
|
|
|
}
|
|
|
|
}
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
|
|
|
|
static Epplet_window
|
|
|
|
Epplet_window_get_from_Window(Window win)
|
1999-12-01 11:30:19 -08:00
|
|
|
{
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
/* Loop through windows */
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
int i;
|
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
for (i = 0; i < window_num; i++)
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
{
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
if (windows[i]->win == win)
|
|
|
|
return windows[i];
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
}
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
return NULL;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_handle_delete_event(Window xwin)
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
{
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window win;
|
|
|
|
|
|
|
|
win = Epplet_window_get_from_Window(xwin);
|
|
|
|
if (win)
|
|
|
|
{
|
|
|
|
if ((delete_func) && ((*delete_func) (delete_data, win->win)))
|
|
|
|
Epplet_window_destroy(win->win);
|
|
|
|
else
|
|
|
|
Epplet_window_destroy(win->win);
|
|
|
|
}
|
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.
SVN revision: 1472
1999-12-01 11:12:33 -08:00
|
|
|
}
|
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
static void
|
2013-07-13 12:07:12 -07:00
|
|
|
remember_stuff(void *data __UNUSED__)
|
2000-02-27 05:06:43 -08:00
|
|
|
{
|
2007-03-18 16:56:14 -07:00
|
|
|
Epplet_remember();
|
2000-02-27 05:06:43 -08:00
|
|
|
}
|
|
|
|
|
1999-10-18 08:50:58 -07:00
|
|
|
void
|
|
|
|
Epplet_cleanup(void)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
char s[1024];
|
1999-10-18 08:50:58 -07:00
|
|
|
|
2009-01-01 12:42:28 -08:00
|
|
|
if (conf_dir)
|
1999-10-18 08:50:58 -07:00
|
|
|
{
|
2009-01-01 12:42:28 -08:00
|
|
|
/* remove lock file */
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s/.lock_%i", conf_dir, epplet_instance);
|
2009-01-01 12:42:28 -08:00
|
|
|
if (unlink(s) < 0)
|
|
|
|
{
|
2018-08-12 09:16:03 -07:00
|
|
|
Epplet_dialog_ok("Unable to remove lock file %s -- %s.\n",
|
|
|
|
s, strerror(errno));
|
2009-01-01 12:42:28 -08:00
|
|
|
}
|
1999-10-22 09:43:22 -07:00
|
|
|
}
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-22 09:43:22 -07:00
|
|
|
/* save config settings */
|
1999-10-22 15:09:18 -07:00
|
|
|
Epplet_save_config();
|
1999-10-18 08:50:58 -07:00
|
|
|
}
|
|
|
|
|
2021-08-26 10:21:02 -07:00
|
|
|
void
|
|
|
|
Epplet_adjust_priority(int nice)
|
|
|
|
{
|
|
|
|
int prio;
|
|
|
|
|
|
|
|
prio = getpriority(PRIO_PROCESS, getpid());
|
|
|
|
setpriority(PRIO_PROCESS, getpid(), prio + nice);
|
|
|
|
}
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
void
|
|
|
|
Epplet_show(void)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
XEvent ev;
|
|
|
|
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
epplet_visible = 1;
|
|
|
|
Epplet_redraw();
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
XMapWindow(disp, mainwin->win);
|
1999-10-13 08:14:42 -07:00
|
|
|
/* wait for the window to map */
|
|
|
|
XMaskEvent(disp, StructureNotifyMask, &ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_remember(void)
|
|
|
|
{
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("wop %x snap all auto", (unsigned int)mainwin->win);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_unremember(void)
|
|
|
|
{
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("wop %x snap none", (unsigned int)mainwin->win);
|
1999-10-25 16:54:10 -07:00
|
|
|
ESYNC;
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Window
|
|
|
|
Epplet_get_main_window(void)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
return mainwin->win;
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_imageclass_apply(const char *iclass, const char *state, Window ww)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("imageclass %s apply 0x%x %s", iclass,
|
|
|
|
(unsigned int)ww, state);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_imageclass_paste(const char *iclass, const char *state, Window ww,
|
|
|
|
int x, int y, int w, int h)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2000-02-28 11:52:11 -08:00
|
|
|
Pixmap p = 0, m = 0;
|
2022-03-09 22:19:37 -08:00
|
|
|
char *msg;
|
2022-01-22 04:47:42 -08:00
|
|
|
GC gc;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("imageclass %s apply_copy 0x%x %s %i %i", iclass,
|
|
|
|
(unsigned int)ww, state, w, h);
|
1999-10-13 08:14:42 -07:00
|
|
|
msg = ECommsWaitForMessage();
|
|
|
|
if (msg)
|
|
|
|
{
|
|
|
|
sscanf(msg, "%x %x", (unsigned int *)&p, (unsigned int *)&m);
|
|
|
|
free(msg);
|
2022-01-22 04:47:42 -08:00
|
|
|
gc = EXCreateGC(context_win->win);
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetClipMask(disp, gc, m);
|
|
|
|
XSetClipOrigin(disp, gc, x, y);
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XCopyArea(disp, p, context_win->win, gc, 0, 0, w, h, x, y);
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("imageclass %s free_pixmap 0x%x", iclass,
|
|
|
|
(unsigned int)p);
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(gc);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_imageclass_get_pixmaps(const char *iclass, const char *state, Pixmap * p,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Pixmap * m, int w, int h)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2000-02-28 11:52:11 -08:00
|
|
|
Pixmap pp = 0, mm = 0;
|
2022-03-09 22:19:37 -08:00
|
|
|
char *msg;
|
2022-01-22 04:47:42 -08:00
|
|
|
GC gc, mgc;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("imageclass %s apply_copy 0x%x %s %i %i", iclass,
|
|
|
|
(unsigned int)context_win->win, state, w, h);
|
1999-10-13 08:14:42 -07:00
|
|
|
msg = ECommsWaitForMessage();
|
|
|
|
if (msg)
|
|
|
|
{
|
|
|
|
sscanf(msg, "%x %x", (unsigned int *)&pp, (unsigned int *)&mm);
|
|
|
|
free(msg);
|
|
|
|
if (pp)
|
2006-03-31 14:56:17 -08:00
|
|
|
*p = XCreatePixmap(disp, context_win->win, w, h, DEPTH());
|
1999-10-13 08:14:42 -07:00
|
|
|
else
|
|
|
|
*p = 0;
|
|
|
|
if (mm)
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
*m = XCreatePixmap(disp, context_win->win, w, h, 1);
|
1999-10-13 08:14:42 -07:00
|
|
|
else
|
|
|
|
*m = 0;
|
|
|
|
if (*p)
|
1999-12-03 07:08:23 -08:00
|
|
|
{
|
2022-01-22 04:47:42 -08:00
|
|
|
gc = EXCreateGC(*p);
|
1999-12-03 07:08:23 -08:00
|
|
|
XCopyArea(disp, pp, *p, gc, 0, 0, w, h, 0, 0);
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(gc);
|
1999-12-03 07:08:23 -08:00
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
if (*m)
|
1999-12-03 07:08:23 -08:00
|
|
|
{
|
2022-01-22 04:47:42 -08:00
|
|
|
mgc = EXCreateGC(*m);
|
1999-12-03 07:08:23 -08:00
|
|
|
XCopyArea(disp, mm, *m, mgc, 0, 0, w, h, 0, 0);
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(mgc);
|
1999-12-03 07:08:23 -08:00
|
|
|
}
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("imageclass %s free_pixmap 0x%x", iclass,
|
|
|
|
(unsigned int)pp);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_textclass_draw(const char *iclass, const char *state, Window ww, int x,
|
|
|
|
int y, const char *txt)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("textclass %s apply 0x%x %i %i %s %s", iclass,
|
|
|
|
(unsigned int)ww, x, y, state, txt);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_textclass_get_size(const char *iclass, int *w, int *h, const char *txt)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2022-03-09 22:19:37 -08:00
|
|
|
char *msg;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("textclass %s query_size %s", iclass, txt);
|
1999-10-13 08:14:42 -07:00
|
|
|
msg = ECommsWaitForMessage();
|
|
|
|
if (msg)
|
|
|
|
{
|
|
|
|
sscanf(msg, "%i %i", w, h);
|
|
|
|
free(msg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*w = 0;
|
|
|
|
*h = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_expose_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win, int x, int y, int w,
|
|
|
|
int h), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
expose_data = data;
|
|
|
|
expose_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_move_resize_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win, int x, int y,
|
|
|
|
int w, int h), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
moveresize_data = data;
|
|
|
|
moveresize_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_button_press_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win, int x, int y,
|
|
|
|
int b), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
buttonpress_data = data;
|
|
|
|
buttonpress_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_button_release_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win, int x, int y,
|
|
|
|
int b), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
buttonrelease_data = data;
|
|
|
|
buttonrelease_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_key_press_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win, char *key),
|
1999-10-13 08:14:42 -07:00
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
keypress_data = data;
|
|
|
|
keypress_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_key_release_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win, char *key),
|
1999-10-13 08:14:42 -07:00
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
keyrelease_data = data;
|
|
|
|
keyrelease_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_mouse_motion_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win, int x, int y),
|
1999-10-13 08:14:42 -07:00
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
mousemotion_data = data;
|
|
|
|
mousemotion_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_mouse_enter_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
enter_data = data;
|
|
|
|
enter_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_mouse_leave_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
leave_data = data;
|
|
|
|
leave_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_focus_in_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
focusin_data = data;
|
|
|
|
focusin_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_focus_out_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
focusout_data = data;
|
|
|
|
focusout_func = func;
|
|
|
|
}
|
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
void
|
|
|
|
Epplet_register_delete_event_handler(int (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, Window win), void *data)
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
{
|
|
|
|
delete_data = data;
|
|
|
|
delete_func = func;
|
|
|
|
}
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
void
|
2021-08-26 11:13:56 -07:00
|
|
|
Epplet_register_event_handler(void (*func)(void *data, XEvent * ev), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
event_data = data;
|
|
|
|
event_func = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-08-26 11:13:56 -07:00
|
|
|
Epplet_register_comms_handler(void (*func)(void *data, const char *s),
|
2013-07-13 12:07:12 -07:00
|
|
|
void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
comms_data = data;
|
|
|
|
comms_func = func;
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
Display *
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_get_display(void)
|
|
|
|
{
|
|
|
|
return disp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_handle_event(XEvent * ev)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_gadget g = NULL;
|
1999-12-01 11:30:19 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
if (event_func)
|
2000-02-28 04:15:29 -08:00
|
|
|
(*event_func) (event_data, ev);
|
1999-10-13 08:14:42 -07:00
|
|
|
switch (ev->type)
|
|
|
|
{
|
|
|
|
case ClientMessage:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
char *msg;
|
|
|
|
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
if (ev->xclient.format == 32
|
2006-04-15 15:04:48 -07:00
|
|
|
&& ev->xclient.data.l[0] == (signed)wmDeleteWindow)
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_handle_delete_event(ev->xclient.window);
|
|
|
|
else
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
msg = ECommsGet(ev);
|
|
|
|
if (msg)
|
|
|
|
{
|
|
|
|
if (comms_func)
|
|
|
|
(*comms_func) (comms_data, msg);
|
|
|
|
free(msg);
|
|
|
|
}
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case KeyPress:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
if (XFindContext(disp, ev->xkey.window, xid_context,
|
|
|
|
(XPointer *) & g) == XCNOENT)
|
|
|
|
g = NULL;
|
|
|
|
|
|
|
|
if (g)
|
|
|
|
Epplet_event(g, ev);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *key;
|
2012-09-30 02:41:34 -07:00
|
|
|
KeySym keysym;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2012-09-30 02:41:34 -07:00
|
|
|
keysym = XkbKeycodeToKeysym(disp, ev->xkey.keycode, 0, 0);
|
|
|
|
key = XKeysymToString(keysym);
|
1999-11-16 13:02:11 -08:00
|
|
|
if (keypress_func)
|
|
|
|
(*keypress_func) (keypress_data, ev->xkey.window, key);
|
1999-11-28 14:08:49 -08:00
|
|
|
else
|
1999-11-29 10:00:00 -08:00
|
|
|
{
|
|
|
|
if (last_gadget &&
|
|
|
|
((GadGeneral *) last_gadget)->type == E_TEXTBOX)
|
|
|
|
{
|
|
|
|
Epplet_textbox_handle_keyevent(ev, last_gadget);
|
|
|
|
Epplet_draw_textbox(last_gadget);
|
|
|
|
}
|
|
|
|
}
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case KeyRelease:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
char *key;
|
2012-09-30 02:41:34 -07:00
|
|
|
KeySym keysym;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2012-09-30 02:41:34 -07:00
|
|
|
keysym = XkbKeycodeToKeysym(disp, ev->xkey.keycode, 0, 0);
|
|
|
|
key = XKeysymToString(keysym);
|
1999-11-16 13:02:11 -08:00
|
|
|
if (keyrelease_func)
|
|
|
|
(*keyrelease_func) (keyrelease_data, ev->xkey.window, key);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case ButtonPress:
|
1999-11-16 13:02:11 -08:00
|
|
|
if (XFindContext(disp, ev->xkey.window, xid_context,
|
|
|
|
(XPointer *) & g) == XCNOENT)
|
1999-10-13 08:14:42 -07:00
|
|
|
g = NULL;
|
|
|
|
if (g)
|
2000-03-03 14:45:02 -08:00
|
|
|
Epplet_event(g, ev);
|
1999-11-16 13:02:11 -08:00
|
|
|
else
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
if (buttonpress_func)
|
2000-03-03 14:45:02 -08:00
|
|
|
(*buttonpress_func) (buttonpress_data, ev->xbutton.window,
|
|
|
|
ev->xbutton.x, ev->xbutton.y,
|
|
|
|
ev->xbutton.button);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
1999-11-16 13:02:11 -08:00
|
|
|
if (XFindContext(disp, ev->xkey.window, xid_context,
|
|
|
|
(XPointer *) & g) == XCNOENT)
|
1999-10-13 08:14:42 -07:00
|
|
|
g = NULL;
|
|
|
|
if (g)
|
1999-11-28 14:33:31 -08:00
|
|
|
{
|
|
|
|
last_gadget = g;
|
|
|
|
Epplet_event(g, ev);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (buttonrelease_func)
|
1999-11-16 13:02:11 -08:00
|
|
|
(*buttonrelease_func) (buttonrelease_data, ev->xbutton.window,
|
|
|
|
ev->xbutton.x, ev->xbutton.y,
|
|
|
|
ev->xbutton.button);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MotionNotify:
|
1999-11-16 13:02:11 -08:00
|
|
|
if (XFindContext(disp, ev->xkey.window, xid_context,
|
|
|
|
(XPointer *) & g) == XCNOENT)
|
1999-10-13 08:14:42 -07:00
|
|
|
g = NULL;
|
|
|
|
if (g)
|
|
|
|
Epplet_event(g, ev);
|
1999-11-16 13:02:11 -08:00
|
|
|
else
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
if (mousemotion_func)
|
1999-11-16 13:02:11 -08:00
|
|
|
(*mousemotion_func) (mousemotion_data, ev->xmotion.window,
|
1999-10-13 08:14:42 -07:00
|
|
|
ev->xmotion.x, ev->xmotion.y);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EnterNotify:
|
1999-11-16 13:02:11 -08:00
|
|
|
if (XFindContext(disp, ev->xkey.window, xid_context,
|
|
|
|
(XPointer *) & g) == XCNOENT)
|
1999-10-13 08:14:42 -07:00
|
|
|
g = NULL;
|
1999-11-28 14:08:49 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
if (g)
|
|
|
|
Epplet_event(g, ev);
|
1999-11-16 13:02:11 -08:00
|
|
|
else
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
if (enter_func)
|
|
|
|
(*enter_func) (enter_data, ev->xcrossing.window);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LeaveNotify:
|
1999-11-16 13:02:11 -08:00
|
|
|
if (XFindContext(disp, ev->xkey.window, xid_context,
|
|
|
|
(XPointer *) & g) == XCNOENT)
|
1999-10-13 08:14:42 -07:00
|
|
|
g = NULL;
|
|
|
|
if (g)
|
|
|
|
Epplet_event(g, ev);
|
1999-11-16 13:02:11 -08:00
|
|
|
else
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
if (leave_func)
|
|
|
|
(*leave_func) (leave_data, ev->xcrossing.window);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FocusIn:
|
|
|
|
if (focusin_func)
|
|
|
|
(*focusin_func) (focusin_data, ev->xfocus.window);
|
|
|
|
break;
|
|
|
|
case FocusOut:
|
1999-12-01 11:30:19 -08:00
|
|
|
last_gadget = NULL;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (focusout_func)
|
|
|
|
(*focusout_func) (focusout_data, ev->xfocus.window);
|
|
|
|
break;
|
|
|
|
case Expose:
|
|
|
|
if (expose_func)
|
|
|
|
(*expose_func) (expose_data, ev->xexpose.window,
|
1999-11-16 13:02:11 -08:00
|
|
|
ev->xexpose.x, ev->xexpose.y,
|
1999-10-13 08:14:42 -07:00
|
|
|
ev->xexpose.width, ev->xexpose.height);
|
|
|
|
break;
|
|
|
|
case ConfigureNotify:
|
|
|
|
if (moveresize_func)
|
|
|
|
(*moveresize_func) (moveresize_data, ev->xconfigure.window,
|
1999-11-16 13:02:11 -08:00
|
|
|
ev->xconfigure.x, ev->xconfigure.y,
|
1999-10-13 08:14:42 -07:00
|
|
|
ev->xconfigure.width, ev->xconfigure.height);
|
|
|
|
break;
|
|
|
|
case PropertyNotify:
|
|
|
|
if (CommsHandlePropertyNotify(ev))
|
|
|
|
Epplet_redraw();
|
|
|
|
break;
|
|
|
|
case DestroyNotify:
|
1999-12-01 11:30:19 -08:00
|
|
|
CommsHandleDestroy(ev->xdestroywindow.window);
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
2021-08-26 11:13:56 -07:00
|
|
|
Epplet_timer(void (*func)(void *data), void *data, double in,
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *name)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
ETimer *et, *ptr, *pptr;
|
|
|
|
double tally;
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
Epplet_remove_timer(name);
|
|
|
|
et = malloc(sizeof(ETimer));
|
|
|
|
et->next = NULL;
|
|
|
|
et->func = func;
|
|
|
|
et->data = data;
|
|
|
|
et->name = malloc(strlen(name) + 1);
|
|
|
|
et->just_added = 1;
|
|
|
|
et->in = in;
|
|
|
|
memcpy(et->name, name, strlen(name) + 1);
|
|
|
|
tally = 0.0;
|
|
|
|
if (!q_first)
|
|
|
|
q_first = et;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pptr = NULL;
|
|
|
|
ptr = q_first;
|
|
|
|
tally = 0.0;
|
|
|
|
while (ptr)
|
|
|
|
{
|
|
|
|
tally += ptr->in;
|
|
|
|
if (tally > in)
|
|
|
|
{
|
|
|
|
tally -= ptr->in;
|
|
|
|
et->next = ptr;
|
|
|
|
if (pptr)
|
|
|
|
pptr->next = et;
|
|
|
|
else
|
|
|
|
q_first = et;
|
|
|
|
et->in -= tally;
|
|
|
|
if (et->next)
|
|
|
|
et->next->in -= et->in;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pptr = ptr;
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
if (pptr)
|
|
|
|
pptr->next = et;
|
|
|
|
else
|
1999-11-16 13:02:11 -08:00
|
|
|
q_first = et;
|
1999-10-13 08:14:42 -07:00
|
|
|
et->in -= tally;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_remove_timer(const char *name)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
ETimer *et, *ptr, *pptr;
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
pptr = NULL;
|
|
|
|
ptr = q_first;
|
|
|
|
while (ptr)
|
|
|
|
{
|
|
|
|
et = ptr;
|
|
|
|
if (!strcmp(et->name, name))
|
|
|
|
{
|
|
|
|
if (pptr)
|
|
|
|
pptr->next = et->next;
|
|
|
|
else
|
|
|
|
q_first = et->next;
|
|
|
|
if (et->next)
|
|
|
|
et->next->in += et->in;
|
2021-09-01 10:53:39 -07:00
|
|
|
free(et->name);
|
|
|
|
free(et);
|
1999-10-13 08:14:42 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
pptr = ptr;
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void *
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_timer_get_data(const char *name)
|
1999-10-20 15:23:29 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
ETimer *et, *ptr;
|
1999-10-20 15:23:29 -07:00
|
|
|
|
|
|
|
ptr = q_first;
|
|
|
|
while (ptr)
|
|
|
|
{
|
|
|
|
et = ptr;
|
|
|
|
if (!strcmp(et->name, name))
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
return et->data;
|
1999-10-20 15:23:29 -07:00
|
|
|
}
|
|
|
|
ptr = ptr->next;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
static void
|
|
|
|
Epplet_handle_timer(void)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
ETimer *et;
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
if (!q_first)
|
|
|
|
return;
|
|
|
|
et = q_first;
|
|
|
|
q_first = q_first->next;
|
|
|
|
(*(et->func)) (et->data);
|
1999-12-01 15:09:48 -08:00
|
|
|
if (et && et->name)
|
1999-10-13 08:14:42 -07:00
|
|
|
free(et->name);
|
2021-09-01 10:53:39 -07:00
|
|
|
free(et);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
Epplet_get_time(void)
|
|
|
|
{
|
|
|
|
struct timeval timev;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
gettimeofday(&timev, NULL);
|
|
|
|
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
static ETimer *
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_get_first(void)
|
|
|
|
{
|
|
|
|
return q_first;
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_prune_events(XEvent * ev, int num)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int i, j;
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
char found;
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
/* find only the last moption event */
|
|
|
|
found = 0;
|
|
|
|
for (i = num - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (ev[i].type == MotionNotify)
|
|
|
|
{
|
|
|
|
if (!found)
|
|
|
|
found = 1;
|
|
|
|
else
|
|
|
|
ev[i].type = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* find all expose events and then all following expose events for that */
|
|
|
|
/* window then do a bounding box grow of the original expose event */
|
|
|
|
for (i = num - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (ev[i].type == Expose)
|
|
|
|
{
|
|
|
|
for (j = i - 1; j >= 0; j--)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
if ((ev[j].type == Expose) &&
|
1999-10-13 08:14:42 -07:00
|
|
|
(ev[j].xexpose.window == ev[i].xexpose.window))
|
|
|
|
{
|
|
|
|
if (ev[j].xexpose.x < ev[i].xexpose.x)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
ev[i].xexpose.width +=
|
1999-10-13 08:14:42 -07:00
|
|
|
(ev[i].xexpose.x - ev[j].xexpose.x);
|
|
|
|
ev[i].xexpose.x = ev[j].xexpose.x;
|
|
|
|
}
|
1999-11-16 13:02:11 -08:00
|
|
|
if ((ev[j].xexpose.x + ev[j].xexpose.width) >
|
1999-10-13 08:14:42 -07:00
|
|
|
(ev[i].xexpose.x + ev[i].xexpose.width))
|
1999-11-16 13:02:11 -08:00
|
|
|
ev[i].xexpose.width +=
|
|
|
|
(ev[j].xexpose.x + ev[j].xexpose.width) -
|
|
|
|
(ev[i].xexpose.x + ev[i].xexpose.width);
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
if (ev[j].xexpose.y < ev[i].xexpose.y)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
ev[i].xexpose.height +=
|
1999-10-13 08:14:42 -07:00
|
|
|
(ev[i].xexpose.y - ev[j].xexpose.y);
|
|
|
|
ev[i].xexpose.y = ev[j].xexpose.y;
|
|
|
|
}
|
1999-11-16 13:02:11 -08:00
|
|
|
if ((ev[j].xexpose.y + ev[j].xexpose.height) >
|
1999-10-13 08:14:42 -07:00
|
|
|
(ev[i].xexpose.y + ev[i].xexpose.height))
|
1999-11-16 13:02:11 -08:00
|
|
|
ev[i].xexpose.height +=
|
|
|
|
(ev[j].xexpose.y + ev[j].xexpose.height) -
|
|
|
|
(ev[i].xexpose.y + ev[i].xexpose.height);
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
ev[j].type = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_Loop(void)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int xfd, fdsize, count;
|
|
|
|
double t1 = 0.0, t2 = 0.0, pt;
|
|
|
|
ETimer *et;
|
|
|
|
fd_set fdset;
|
|
|
|
struct timeval tval;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
xfd = ConnectionNumber(disp);
|
|
|
|
fdsize = xfd + 1;
|
|
|
|
pt = Epplet_get_time();
|
|
|
|
for (;;)
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
XEvent *evs = NULL;
|
|
|
|
int evs_num = 0, i;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
XFlush(disp);
|
|
|
|
t1 = Epplet_get_time();
|
|
|
|
t2 = t1 - pt;
|
|
|
|
pt = t1;
|
|
|
|
while (XPending(disp))
|
|
|
|
{
|
|
|
|
evs_num++;
|
|
|
|
if (evs)
|
|
|
|
evs = realloc(evs, sizeof(XEvent) * evs_num);
|
|
|
|
else
|
|
|
|
evs = malloc(sizeof(XEvent));
|
|
|
|
XNextEvent(disp, &(evs[evs_num - 1]));
|
|
|
|
}
|
|
|
|
if (evs)
|
|
|
|
{
|
|
|
|
Epplet_prune_events(evs, evs_num);
|
|
|
|
for (i = 0; i < evs_num; i++)
|
1999-12-01 11:30:19 -08:00
|
|
|
{
|
1999-10-13 08:14:42 -07:00
|
|
|
if (evs[i].type > 0)
|
|
|
|
Epplet_handle_event(&(evs[i]));
|
1999-12-01 11:30:19 -08:00
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
free(evs);
|
|
|
|
evs = NULL;
|
|
|
|
evs_num = 0;
|
|
|
|
}
|
|
|
|
XFlush(disp);
|
|
|
|
FD_ZERO(&fdset);
|
|
|
|
FD_SET(xfd, &fdset);
|
|
|
|
et = Epplet_get_first();
|
|
|
|
count = 0;
|
|
|
|
if (et)
|
|
|
|
{
|
|
|
|
if (et->just_added)
|
|
|
|
{
|
|
|
|
et->just_added = 0;
|
|
|
|
t1 = et->in;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t1 = et->in - t2;
|
|
|
|
if (t1 < 0.0)
|
|
|
|
t1 = 0.0;
|
|
|
|
et->in = t1;
|
|
|
|
}
|
|
|
|
tval.tv_sec = (long)t1;
|
|
|
|
tval.tv_usec = (long)((t1 - ((double)tval.tv_sec)) * 1000000);
|
|
|
|
if (tval.tv_sec < 0)
|
|
|
|
tval.tv_sec = 0;
|
|
|
|
if (tval.tv_usec <= 1000)
|
|
|
|
tval.tv_usec = 1000;
|
|
|
|
count = select(fdsize, &fdset, NULL, NULL, &tval);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
count = select(fdsize, &fdset, NULL, NULL, NULL);
|
|
|
|
if (count < 0)
|
|
|
|
{
|
|
|
|
if ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF))
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
else
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
if ((et) && (count == 0))
|
|
|
|
Epplet_handle_timer();
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-09-30 02:41:36 -07:00
|
|
|
CommsSetup(void)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2012-09-30 02:41:36 -07:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
CommsFindCommsWindow();
|
|
|
|
if (comms_win != None)
|
|
|
|
break;
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
if (!my_win)
|
|
|
|
{
|
|
|
|
my_win = XCreateSimpleWindow(dd, root, -100, -100, 5, 5, 0, 0, 0);
|
|
|
|
XSelectInput(dd, my_win, StructureNotifyMask | SubstructureNotifyMask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CommsHandleDestroy(Window win)
|
|
|
|
{
|
|
|
|
if (win == comms_win)
|
|
|
|
comms_win = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-11-16 13:02:11 -08:00
|
|
|
CommsHandlePropertyNotify(XEvent * ev)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
Atom a = 0;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
if (comms_win)
|
|
|
|
return 0;
|
|
|
|
if (!a)
|
|
|
|
a = XInternAtom(dd, "ENLIGHTENMENT_COMMS", True);
|
|
|
|
if (a == ev->xproperty.atom)
|
2012-09-30 02:41:36 -07:00
|
|
|
CommsSetup();
|
1999-10-13 08:14:42 -07:00
|
|
|
if (comms_win)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CommsFindCommsWindow(void)
|
|
|
|
{
|
|
|
|
unsigned char *s;
|
|
|
|
Atom a, ar;
|
|
|
|
unsigned long num, after;
|
|
|
|
int format;
|
|
|
|
Window rt;
|
|
|
|
int dint;
|
|
|
|
unsigned int duint;
|
|
|
|
|
|
|
|
a = XInternAtom(dd, "ENLIGHTENMENT_COMMS", True);
|
|
|
|
if (a != None)
|
|
|
|
{
|
|
|
|
s = NULL;
|
|
|
|
XGetWindowProperty(dd, root, a, 0, 14, False, AnyPropertyType, &ar,
|
|
|
|
&format, &num, &after, &s);
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
sscanf((char *)s, "%*s %x", (unsigned int *)&comms_win);
|
|
|
|
XFree(s);
|
|
|
|
}
|
|
|
|
else
|
2012-09-30 02:41:36 -07:00
|
|
|
comms_win = 0;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
if (comms_win)
|
|
|
|
{
|
|
|
|
if (!XGetGeometry(dd, comms_win, &rt, &dint, &dint,
|
|
|
|
&duint, &duint, &duint, &duint))
|
|
|
|
comms_win = 0;
|
|
|
|
s = NULL;
|
|
|
|
if (comms_win)
|
|
|
|
{
|
|
|
|
XGetWindowProperty(dd, comms_win, a, 0, 14, False,
|
1999-11-16 13:02:11 -08:00
|
|
|
AnyPropertyType, &ar, &format, &num,
|
1999-10-13 08:14:42 -07:00
|
|
|
&after, &s);
|
|
|
|
if (s)
|
|
|
|
XFree(s);
|
|
|
|
else
|
|
|
|
comms_win = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (comms_win)
|
1999-11-16 13:02:11 -08:00
|
|
|
XSelectInput(dd, comms_win, StructureNotifyMask | SubstructureNotifyMask);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
2022-03-09 22:19:37 -08:00
|
|
|
void
|
|
|
|
Epplet_send_ipc(const char *fmt, ...)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2022-03-09 22:19:37 -08:00
|
|
|
static Atom a = None;
|
|
|
|
va_list args;
|
|
|
|
char buf[1024];
|
1999-10-13 08:14:42 -07:00
|
|
|
char ss[21];
|
|
|
|
int i, j, k, len;
|
|
|
|
XEvent ev;
|
1999-10-26 08:48:35 -07:00
|
|
|
|
2022-03-09 22:19:37 -08:00
|
|
|
if (!fmt || !dd)
|
1999-10-13 08:14:42 -07:00
|
|
|
return;
|
2022-03-09 22:19:37 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
if (!a)
|
|
|
|
a = XInternAtom(dd, "ENL_MSG", False);
|
2022-03-09 22:19:37 -08:00
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
len = vsnprintf(buf, sizeof(buf), fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
if (len >= (int)sizeof(buf))
|
|
|
|
len = sizeof(buf) - 1;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
ev.xclient.type = ClientMessage;
|
|
|
|
ev.xclient.serial = 0;
|
|
|
|
ev.xclient.send_event = True;
|
|
|
|
ev.xclient.window = comms_win;
|
|
|
|
ev.xclient.message_type = a;
|
|
|
|
ev.xclient.format = 8;
|
|
|
|
|
|
|
|
for (i = 0; i < len + 1; i += 12)
|
|
|
|
{
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(ss, sizeof(ss), "%8x", (int)my_win);
|
1999-10-13 08:14:42 -07:00
|
|
|
for (j = 0; j < 12; j++)
|
|
|
|
{
|
2022-03-09 22:19:37 -08:00
|
|
|
ss[8 + j] = buf[i + j];
|
|
|
|
if (!buf[i + j])
|
1999-10-13 08:14:42 -07:00
|
|
|
j = 12;
|
|
|
|
}
|
|
|
|
ss[20] = 0;
|
|
|
|
for (k = 0; k < 20; k++)
|
|
|
|
ev.xclient.data.b[k] = ss[k];
|
|
|
|
XSendEvent(dd, comms_win, False, 0, (XEvent *) & ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
static Bool
|
2013-07-13 12:07:12 -07:00
|
|
|
ev_check(Display * d __UNUSED__, XEvent * ev, XPointer p __UNUSED__)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
if (((ev->type == ClientMessage) && (ev->xclient.window == my_win)) ||
|
1999-11-16 13:02:11 -08:00
|
|
|
((ev->type == DestroyNotify) &&
|
1999-10-13 08:14:42 -07:00
|
|
|
(ev->xdestroywindow.window == comms_win)))
|
|
|
|
return True;
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
static char *
|
1999-10-13 08:14:42 -07:00
|
|
|
ECommsWaitForMessage(void)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
XEvent ev;
|
|
|
|
char *msg = NULL;
|
1999-10-26 08:48:35 -07:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
while ((!msg) && (comms_win))
|
|
|
|
{
|
|
|
|
XIfEvent(dd, &ev, ev_check, NULL);
|
|
|
|
if (ev.type == DestroyNotify)
|
|
|
|
comms_win = 0;
|
|
|
|
else
|
|
|
|
msg = ECommsGet(&ev);
|
|
|
|
}
|
|
|
|
return msg;
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
static char *
|
1999-10-13 08:14:42 -07:00
|
|
|
ECommsGet(XEvent * ev)
|
|
|
|
{
|
|
|
|
char s[13], s2[9], *msg = NULL;
|
|
|
|
int i;
|
2000-02-28 11:52:11 -08:00
|
|
|
Window win = 0;
|
1999-10-13 08:14:42 -07:00
|
|
|
static char *c_msg = NULL;
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
if (!ev)
|
1999-10-13 08:14:42 -07:00
|
|
|
return NULL;
|
|
|
|
if (ev->type != ClientMessage)
|
|
|
|
return NULL;
|
|
|
|
s[12] = 0;
|
|
|
|
s2[8] = 0;
|
|
|
|
msg = NULL;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
s2[i] = ev->xclient.data.b[i];
|
|
|
|
for (i = 0; i < 12; i++)
|
|
|
|
s[i] = ev->xclient.data.b[i + 8];
|
|
|
|
sscanf(s2, "%x", (int *)&win);
|
|
|
|
if (win == comms_win)
|
|
|
|
{
|
|
|
|
if (c_msg)
|
|
|
|
{
|
|
|
|
c_msg = realloc(c_msg, strlen(c_msg) + strlen(s) + 1);
|
|
|
|
if (!c_msg)
|
|
|
|
return NULL;
|
|
|
|
strcat(c_msg, s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
c_msg = malloc(strlen(s) + 1);
|
|
|
|
if (!c_msg)
|
|
|
|
return NULL;
|
|
|
|
strcpy(c_msg, s);
|
|
|
|
}
|
|
|
|
if (strlen(s) < 12)
|
|
|
|
{
|
|
|
|
msg = c_msg;
|
|
|
|
c_msg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
int
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_get_color(int r, int g, int b)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
XColor xc;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
xc.red = (r << 8) | r;
|
2006-03-31 14:56:17 -08:00
|
|
|
xc.green = (g << 8) | g;
|
|
|
|
xc.blue = (b << 8) | b;
|
|
|
|
XAllocColor(disp, imlib_context_get_colormap(), &xc);
|
|
|
|
return xc.pixel;
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
static char *
|
2006-04-13 01:26:31 -07:00
|
|
|
Estrdup(const char *s)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
char *ss;
|
|
|
|
int len;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
if (!s)
|
|
|
|
return NULL;
|
|
|
|
len = strlen(s);
|
|
|
|
ss = malloc(len + 1);
|
|
|
|
memcpy(ss, s, len + 1);
|
|
|
|
return ss;
|
|
|
|
}
|
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
static char *
|
2006-04-13 01:26:31 -07:00
|
|
|
Epplet_find_file(const char *name)
|
|
|
|
{
|
|
|
|
char s[1024];
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Check if absolute path */
|
|
|
|
if (name[0] == '/')
|
|
|
|
return Estrdup(name);
|
|
|
|
|
|
|
|
/* Check if in epplet data dir */
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s/%s", Epplet_data_dir(), name);
|
2006-04-13 01:26:31 -07:00
|
|
|
if (stat(s, &st) == 0)
|
|
|
|
return Estrdup(s);
|
|
|
|
|
|
|
|
/* Just dup and return */
|
|
|
|
return Estrdup(name);
|
|
|
|
}
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_paste_image(const char *image, Window ww, int x, int y)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
Imlib_Image *im;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2006-03-31 14:56:17 -08:00
|
|
|
im = imlib_load_image(image);
|
1999-10-13 08:14:42 -07:00
|
|
|
if (im)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_image(im);
|
|
|
|
imlib_context_set_drawable(ww);
|
|
|
|
imlib_render_image_on_drawable(x, y);
|
|
|
|
imlib_free_image();
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_paste_image_size(const char *image, Window ww, int x, int y, int w,
|
|
|
|
int h)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
Imlib_Image *im;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2006-03-31 14:56:17 -08:00
|
|
|
im = imlib_load_image(image);
|
1999-10-13 08:14:42 -07:00
|
|
|
if (im)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_image(im);
|
|
|
|
imlib_context_set_drawable(ww);
|
|
|
|
imlib_render_image_on_drawable_at_size(x, y, w, h);
|
|
|
|
imlib_free_image();
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_add_gad(Epplet_gadget gadget)
|
|
|
|
{
|
|
|
|
gad_num++;
|
|
|
|
if (gads)
|
|
|
|
gads = realloc(gads, gad_num * sizeof(Epplet_gadget));
|
|
|
|
else
|
|
|
|
gads = malloc(gad_num * sizeof(Epplet_gadget));
|
|
|
|
gads[gad_num - 1] = gadget;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_del_gad(Epplet_gadget gadget)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int i, j;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
for (i = 0; i < gad_num; i++)
|
|
|
|
{
|
|
|
|
if (gads[i] == gadget)
|
|
|
|
{
|
|
|
|
for (j = i; j < gad_num - 1; j++)
|
|
|
|
gads[j] = gads[j + 1];
|
|
|
|
gad_num--;
|
|
|
|
if (gad_num > 0)
|
|
|
|
gads = realloc(gads, gad_num * sizeof(Epplet_gadget));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free(gads);
|
|
|
|
gads = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-27 21:22:02 -07:00
|
|
|
int
|
|
|
|
Epplet_gadget_get_x(Epplet_gadget gad)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
GadImage *g; /* Lowest common denominator */
|
2000-04-27 21:22:02 -07:00
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
g = (GadImage *) gad;
|
|
|
|
return (g->x);
|
2000-04-27 21:22:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Epplet_gadget_get_y(Epplet_gadget gad)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
GadImage *g; /* Lowest common denominator */
|
2000-04-27 21:22:02 -07:00
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
g = (GadImage *) gad;
|
|
|
|
return (g->y);
|
2000-04-27 21:22:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Epplet_gadget_get_width(Epplet_gadget gad)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
GadImage *g; /* Lowest common denominator */
|
2000-04-27 21:22:02 -07:00
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
g = (GadImage *) gad;
|
|
|
|
return (g->w);
|
2000-04-27 21:22:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Epplet_gadget_get_height(Epplet_gadget gad)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
GadImage *g; /* Lowest common denominator */
|
2000-04-27 21:22:02 -07:00
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
g = (GadImage *) gad;
|
|
|
|
return (g->h);
|
2000-04-27 21:22:02 -07:00
|
|
|
}
|
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
int
|
|
|
|
Epplet_gadget_get_type(Epplet_gadget gad)
|
|
|
|
{
|
2013-07-13 12:07:12 -07:00
|
|
|
return gad ? (int)GADGET_GET_TYPE(gad) : -1;
|
2000-04-30 16:19:22 -07:00
|
|
|
}
|
|
|
|
|
1999-11-09 12:10:10 -08:00
|
|
|
Epplet_gadget
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_textbox(const char *image, const char *contents, int x, int y,
|
2021-08-26 11:13:56 -07:00
|
|
|
int w, int h, char size, void (*func)(void *data),
|
1999-11-09 12:10:10 -08:00
|
|
|
void *data)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadTextBox *g;
|
|
|
|
XSetWindowAttributes attr;
|
1999-12-12 15:12:45 -08:00
|
|
|
int contents_w, contents_h;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
g = malloc(sizeof(GadTextBox));
|
|
|
|
g->general.type = E_TEXTBOX;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-11-16 13:02:11 -08:00
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
g->contents = Estrdup(contents);
|
1999-12-10 12:38:54 -08:00
|
|
|
g->cursor_pos = contents ? strlen(contents) : 0;
|
1999-12-12 15:12:45 -08:00
|
|
|
|
1999-12-10 12:38:54 -08:00
|
|
|
g->x_offset = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
|
|
|
g->size = size;
|
|
|
|
g->func = func;
|
|
|
|
g->data = data;
|
|
|
|
g->pmap = 0;
|
|
|
|
g->mask = 0;
|
2006-04-13 01:26:31 -07:00
|
|
|
g->image = Epplet_find_file(image);
|
1999-11-16 13:02:11 -08:00
|
|
|
g->hilited = 0;
|
|
|
|
|
2006-04-13 04:07:27 -07:00
|
|
|
if (contents)
|
|
|
|
{
|
|
|
|
Epplet_textbox_textsize(g, &contents_w, &contents_h, contents);
|
|
|
|
g->to_cursor = contents_w;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g->to_cursor = 0;
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask =
|
1999-11-27 08:17:16 -08:00
|
|
|
EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask |
|
|
|
|
KeyPressMask | KeyReleaseMask;
|
1999-11-16 13:02:11 -08:00
|
|
|
g->general.visible = 0;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win = XCreateWindow(disp, context_win->win, x, y, g->w, g->h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
1999-11-16 13:02:11 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel |
|
|
|
|
CWEventMask, &attr);
|
|
|
|
XSaveContext(disp, g->win, xid_context, (XPointer) g);
|
|
|
|
|
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
|
|
|
|
|
|
|
return (Epplet_gadget) g;
|
1999-11-09 12:10:10 -08:00
|
|
|
}
|
|
|
|
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *
|
1999-11-09 12:10:10 -08:00
|
|
|
Epplet_textbox_contents(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadTextBox *g;
|
1999-11-09 12:10:10 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadTextBox *) eg;
|
2006-04-15 15:04:48 -07:00
|
|
|
GADGET_CONFIRM_TYPE_RVAL(eg, E_TEXTBOX, (char *)NULL);
|
1999-12-06 16:59:24 -08:00
|
|
|
return ((g->contents) ? (g->contents) : "");
|
1999-11-09 12:10:10 -08:00
|
|
|
}
|
|
|
|
|
1999-11-10 19:02:47 -08:00
|
|
|
void
|
|
|
|
Epplet_reset_textbox(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadTextBox *g;
|
1999-11-10 19:02:47 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadTextBox *) eg;
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(eg, E_TEXTBOX);
|
1999-11-16 13:02:11 -08:00
|
|
|
if (g->contents)
|
|
|
|
{
|
|
|
|
free(g->contents);
|
|
|
|
g->contents = NULL;
|
|
|
|
}
|
1999-11-27 09:58:33 -08:00
|
|
|
|
1999-12-13 07:31:58 -08:00
|
|
|
g->cursor_pos = g->x_offset = g->to_cursor = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_draw_textbox(eg);
|
1999-11-10 19:02:47 -08:00
|
|
|
}
|
|
|
|
|
1999-11-27 09:58:33 -08:00
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_textbox_insert(Epplet_gadget eg, const char *new_contents)
|
1999-11-27 09:58:33 -08:00
|
|
|
{
|
|
|
|
GadTextBox *g;
|
|
|
|
int len, w, h;
|
|
|
|
char *s, *line_break;
|
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(eg, E_TEXTBOX);
|
1999-11-27 09:58:33 -08:00
|
|
|
if (!new_contents || ((len = strlen(new_contents)) == 0))
|
|
|
|
return;
|
|
|
|
|
|
|
|
g = (GadTextBox *) eg;
|
|
|
|
|
|
|
|
if (g->contents)
|
2022-01-18 05:01:20 -08:00
|
|
|
s = malloc(len + strlen(g->contents) + 1);
|
1999-11-27 09:58:33 -08:00
|
|
|
else
|
2022-01-18 05:01:20 -08:00
|
|
|
s = malloc(len + 1);
|
1999-11-27 09:58:33 -08:00
|
|
|
|
|
|
|
if ((line_break = strchr(new_contents, '\n')))
|
|
|
|
{
|
1999-11-29 10:00:00 -08:00
|
|
|
*line_break = '\0'; /* get rid of the new line */
|
1999-11-27 09:58:33 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
*s = '\0';
|
|
|
|
|
|
|
|
if (g->contents)
|
1999-12-14 13:18:51 -08:00
|
|
|
{
|
|
|
|
strncpy(s, g->contents, g->cursor_pos);
|
|
|
|
*(s + g->cursor_pos) = '\0';
|
|
|
|
strcat(s, new_contents);
|
|
|
|
strcat(s, (g->contents + g->cursor_pos + 1));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcat(s, new_contents);
|
1999-11-27 09:58:33 -08:00
|
|
|
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->contents);
|
1999-11-27 09:58:33 -08:00
|
|
|
|
|
|
|
g->contents = s;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Couldn't alloc mem\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (line_break)
|
|
|
|
{
|
|
|
|
if (g->func)
|
|
|
|
(*(g->func)) (g->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
Epplet_textbox_textsize(g, &w, &h, g->contents);
|
|
|
|
|
1999-12-13 04:46:22 -08:00
|
|
|
g->cursor_pos = g->contents ? strlen(g->contents) : 0;
|
1999-11-27 09:58:33 -08:00
|
|
|
|
1999-12-13 04:46:22 -08:00
|
|
|
g->x_offset = 0;
|
1999-12-10 12:38:54 -08:00
|
|
|
if (w > g->w)
|
1999-12-13 04:46:22 -08:00
|
|
|
g->x_offset -= w - g->w + 2 + CRSR_WDTH;
|
|
|
|
g->to_cursor = w;
|
1999-11-27 09:58:33 -08:00
|
|
|
|
|
|
|
Epplet_draw_textbox(eg);
|
|
|
|
}
|
|
|
|
|
1999-11-11 19:46:39 -08:00
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_change_textbox(Epplet_gadget eg, const char *new_contents)
|
1999-11-11 19:46:39 -08:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadTextBox *g;
|
1999-11-27 08:17:16 -08:00
|
|
|
int len, w, h;
|
|
|
|
char *s;
|
1999-11-12 12:27:52 -08:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(eg, E_TEXTBOX);
|
1999-11-16 13:02:11 -08:00
|
|
|
if (!new_contents || ((len = strlen(new_contents)) == 0))
|
|
|
|
{
|
|
|
|
Epplet_reset_textbox(eg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g = (GadTextBox *) eg;
|
1999-11-11 19:46:39 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
if (g->contents == new_contents)
|
|
|
|
return;
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->contents);
|
1999-11-11 19:46:39 -08:00
|
|
|
|
1999-11-27 09:58:33 -08:00
|
|
|
if ((s = strchr(new_contents, '\n')))
|
1999-11-27 08:17:16 -08:00
|
|
|
{
|
1999-11-29 10:00:00 -08:00
|
|
|
*s = '\0'; /* kill new line */
|
1999-11-27 08:17:16 -08:00
|
|
|
|
2022-01-18 05:01:20 -08:00
|
|
|
s = malloc(sizeof(char) * len + 1);
|
1999-11-11 19:46:39 -08:00
|
|
|
|
1999-11-27 09:58:33 -08:00
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
strcpy(s, new_contents);
|
|
|
|
g->contents = s;
|
|
|
|
Epplet_draw_textbox(eg);
|
1999-11-27 08:17:16 -08:00
|
|
|
|
1999-11-27 09:58:33 -08:00
|
|
|
if (g->func)
|
|
|
|
(*(g->func)) (g->data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("Couldn't allocate memory.\n");
|
|
|
|
}
|
1999-12-14 13:18:51 -08:00
|
|
|
g->contents = Estrdup(new_contents);
|
1999-11-27 08:17:16 -08:00
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Epplet_textbox_textsize(g, &w, &h, g->contents);
|
1999-11-27 08:17:16 -08:00
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
g->cursor_pos = g->contents ? strlen(g->contents) : 0;
|
1999-11-27 08:17:16 -08:00
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
g->x_offset = 0;
|
1999-12-10 12:38:54 -08:00
|
|
|
if (w > g->w)
|
1999-12-14 13:18:51 -08:00
|
|
|
g->x_offset -= w - g->w + 2 + CRSR_WDTH;
|
1999-11-11 19:46:39 -08:00
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
g->to_cursor = w;
|
1999-11-27 09:58:33 -08:00
|
|
|
g->cursor_pos = strlen(new_contents);
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_draw_textbox(eg);
|
1999-11-11 19:46:39 -08:00
|
|
|
}
|
|
|
|
|
1999-11-09 12:10:10 -08:00
|
|
|
void
|
|
|
|
Epplet_draw_textbox(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadTextBox *g;
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *state;
|
1999-11-16 13:02:11 -08:00
|
|
|
unsigned long gc_valuemask = 0;
|
|
|
|
XGCValues gc_values;
|
|
|
|
GC gc;
|
1999-11-09 12:10:10 -08:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(eg, E_TEXTBOX);
|
2012-09-30 02:41:07 -07:00
|
|
|
if (!(g = (GadTextBox *) eg))
|
1999-11-29 10:00:00 -08:00
|
|
|
return;
|
1999-11-11 19:46:39 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
if (g->hilited)
|
|
|
|
state = "hilited";
|
|
|
|
else
|
|
|
|
state = "normal";
|
1999-11-09 12:10:10 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
if (g->pmap)
|
|
|
|
XFreePixmap(disp, g->pmap);
|
|
|
|
if (g->mask)
|
|
|
|
XFreePixmap(disp, g->mask);
|
1999-12-10 12:38:54 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
g->pmap = 0;
|
|
|
|
g->mask = 0;
|
|
|
|
Epplet_imageclass_get_pixmaps("EPPLET_BUTTON", "clicked",
|
|
|
|
&(g->pmap), &(g->mask), g->w, g->h);
|
|
|
|
if (g->image)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
Imlib_Image *im;
|
1999-11-09 12:10:10 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
ESYNC;
|
2006-03-31 14:56:17 -08:00
|
|
|
im = imlib_load_image(g->image);
|
1999-11-16 13:02:11 -08:00
|
|
|
if (im)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
int x, y, w, h;
|
|
|
|
|
|
|
|
imlib_context_set_image(im);
|
|
|
|
if (g->w > imlib_image_get_width())
|
|
|
|
{
|
|
|
|
w = imlib_image_get_width();
|
|
|
|
x = (g->w - imlib_image_get_width()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w = g->w - 4;
|
|
|
|
x = 2;
|
|
|
|
}
|
|
|
|
if (g->h > imlib_image_get_height())
|
|
|
|
{
|
|
|
|
h = imlib_image_get_height();
|
|
|
|
y = (g->h - imlib_image_get_height()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
h = g->h - 4;
|
|
|
|
y = 2;
|
|
|
|
}
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_drawable(g->pmap);
|
|
|
|
imlib_render_image_on_drawable_at_size(x, y, w, h);
|
|
|
|
imlib_free_image();
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g->contents)
|
|
|
|
{
|
1999-11-27 08:17:16 -08:00
|
|
|
int x, y, h;
|
1999-12-10 12:38:54 -08:00
|
|
|
char *s, temp;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-12-10 12:38:54 -08:00
|
|
|
/* Save the character under the cursor */
|
1999-11-16 13:02:11 -08:00
|
|
|
temp = g->contents[g->cursor_pos];
|
1999-12-10 12:38:54 -08:00
|
|
|
/* nullify the character under the cursor */
|
1999-11-16 13:02:11 -08:00
|
|
|
g->contents[g->cursor_pos] = '\0';
|
1999-12-10 12:38:54 -08:00
|
|
|
/* s now points to a string ending at the cursor */
|
|
|
|
s = Estrdup(g->contents);
|
|
|
|
/* undo our change */
|
1999-11-16 13:02:11 -08:00
|
|
|
g->contents[g->cursor_pos] = temp;
|
|
|
|
|
1999-12-10 12:38:54 -08:00
|
|
|
/* Get the position in pixels to the cursor */
|
2006-03-31 14:56:17 -08:00
|
|
|
Epplet_textbox_textsize(eg, &x, &h, s);
|
|
|
|
g->to_cursor = x;
|
1999-12-12 15:12:45 -08:00
|
|
|
|
2006-04-13 04:07:27 -07:00
|
|
|
free(s);
|
|
|
|
|
1999-12-12 15:12:45 -08:00
|
|
|
if (h == 0)
|
|
|
|
Epplet_textbox_textsize(eg, &x, &h, "X");
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-12-13 04:46:22 -08:00
|
|
|
x = g->x_offset + 2;
|
1999-11-27 08:17:16 -08:00
|
|
|
y = (g->h - h) / 2;
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
switch (g->size)
|
|
|
|
{
|
|
|
|
case 0:
|
1999-12-10 12:38:54 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_BUTTON", state, g->pmap, x, y,
|
|
|
|
g->contents);
|
1999-11-16 13:02:11 -08:00
|
|
|
break;
|
|
|
|
case 1:
|
1999-12-10 12:38:54 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_TEXT_TINY", state, g->pmap, x, y,
|
|
|
|
g->contents);
|
1999-11-16 13:02:11 -08:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Epplet_textclass_draw("EPPLET_TEXT_MEDIUM", state, g->pmap, x, y,
|
1999-12-10 12:38:54 -08:00
|
|
|
g->contents);
|
1999-11-16 13:02:11 -08:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Epplet_textclass_draw("EPPLET_TEXT_LARGE", state, g->pmap, x, y,
|
1999-12-10 12:38:54 -08:00
|
|
|
g->contents);
|
1999-11-16 13:02:11 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ESYNC;
|
|
|
|
XSetWindowBackgroundPixmap(disp, g->win, g->pmap);
|
|
|
|
XShapeCombineMask(disp, g->win, ShapeBounding, 0, 0, g->mask, ShapeSet);
|
|
|
|
XClearWindow(disp, g->win);
|
|
|
|
|
|
|
|
gc_valuemask = GCFunction;
|
|
|
|
gc_values.function = GXinvert;
|
|
|
|
gc = XCreateGC(disp, g->win, gc_valuemask, &gc_values);
|
|
|
|
XSetForeground(disp, gc, Epplet_get_color(0, 0, 0));
|
|
|
|
|
1999-12-12 15:12:45 -08:00
|
|
|
if ((last_gadget == g) || (g->hilited))
|
|
|
|
XFillRectangle(disp, g->win, gc, g->to_cursor + g->x_offset + 2, 2,
|
|
|
|
CRSR_WDTH, g->h - 4);
|
2000-05-02 22:12:09 -07:00
|
|
|
#if 0
|
|
|
|
/* That empty cursor is REALLY obnoxious. Punt it. */
|
1999-11-16 13:02:11 -08:00
|
|
|
else
|
1999-12-12 15:12:45 -08:00
|
|
|
XDrawRectangle(disp, g->win, gc, g->to_cursor + g->x_offset + 2, 2,
|
|
|
|
CRSR_WDTH, g->h - 4);
|
2000-05-02 22:12:09 -07:00
|
|
|
#endif
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(gc);
|
1999-11-09 12:10:10 -08:00
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
int
|
|
|
|
Epplet_textbox_spacesize(Epplet_gadget gadget)
|
|
|
|
{
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *s1 = "Z Z";
|
|
|
|
const char *s2 = "ZZ";
|
1999-12-14 13:18:51 -08:00
|
|
|
int size1, size2, h;
|
|
|
|
GadTextBox *g;
|
|
|
|
|
|
|
|
g = (GadTextBox *) gadget;
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE_RVAL(gadget, E_TEXTBOX, -1);
|
1999-12-14 13:18:51 -08:00
|
|
|
|
|
|
|
Epplet_textbox_textsize(g, &size1, &h, s1);
|
|
|
|
Epplet_textbox_textsize(g, &size2, &h, s2);
|
|
|
|
|
|
|
|
return (size1 - size2);
|
|
|
|
}
|
|
|
|
|
1999-11-27 08:17:16 -08:00
|
|
|
static void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_textbox_textsize(Epplet_gadget gadget, int *w, int *h, const char *s)
|
1999-11-27 08:17:16 -08:00
|
|
|
{
|
|
|
|
GadTextBox *g;
|
|
|
|
|
|
|
|
g = (GadTextBox *) gadget;
|
|
|
|
|
|
|
|
switch (g->size)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
Epplet_textclass_get_size("EPPLET_BUTTON", w, h, s);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Epplet_textclass_get_size("EPPLET_TEXT_TINY", w, h, s);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Epplet_textclass_get_size("EPPLET_TEXT_MEDIUM", w, h, s);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Epplet_textclass_get_size("EPPLET_TEXT_LARGE", w, h, s);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-10 14:46:14 -08:00
|
|
|
static void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textbox_handle_keyevent(XEvent * ev, Epplet_gadget gadget)
|
|
|
|
{
|
|
|
|
int len, char_width, text_width, h;
|
|
|
|
static char kbuf[20];
|
|
|
|
KeySym keysym;
|
|
|
|
GadTextBox *g;
|
|
|
|
|
|
|
|
g = (GadTextBox *) gadget;
|
|
|
|
|
|
|
|
len = XLookupString(&ev->xkey, (char *)kbuf, sizeof(kbuf), &keysym, NULL);
|
|
|
|
/* Convert unmapped Latin2-4 keysyms into Latin1 characters */
|
|
|
|
if (!len && (keysym >= 0x0100) && (keysym < 0x0400))
|
|
|
|
{
|
|
|
|
len = 1;
|
|
|
|
kbuf[0] = (keysym & 0xff);
|
|
|
|
}
|
|
|
|
|
1999-12-12 15:12:45 -08:00
|
|
|
switch (keysym)
|
|
|
|
{
|
|
|
|
case XK_Left:
|
|
|
|
{
|
|
|
|
char s[2];
|
|
|
|
|
|
|
|
if (g->cursor_pos > 0)
|
|
|
|
{
|
|
|
|
--g->cursor_pos;
|
|
|
|
|
|
|
|
if (g->contents && *(g->contents) && (g->x_offset < 0))
|
|
|
|
{
|
|
|
|
if (g->contents[strlen(g->contents) - 1] == ' ')
|
1999-12-14 13:18:51 -08:00
|
|
|
char_width = Epplet_textbox_spacesize(g);
|
1999-12-12 15:12:45 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
s[0] = *(g->contents + g->cursor_pos - 1);
|
|
|
|
s[1] = '\0';
|
|
|
|
|
|
|
|
Epplet_textbox_textsize(g, &char_width, &h, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((int)g->to_cursor + g->x_offset) <= 2)
|
1999-12-13 04:46:22 -08:00
|
|
|
g->x_offset += char_width;
|
1999-12-13 01:36:21 -08:00
|
|
|
|
1999-12-13 04:46:22 -08:00
|
|
|
if (g->cursor_pos == 0)
|
|
|
|
g->x_offset = 0;
|
1999-12-12 15:12:45 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case XK_Right:
|
|
|
|
{
|
|
|
|
char s[2];
|
|
|
|
|
|
|
|
if (g->contents && (g->cursor_pos < strlen(g->contents)))
|
|
|
|
++g->cursor_pos;
|
|
|
|
|
|
|
|
Epplet_textbox_textsize(g, &text_width, &h, g->contents);
|
|
|
|
|
1999-12-14 13:33:46 -08:00
|
|
|
if ((int)(g->to_cursor + g->x_offset) >= (g->w - CRSR_WDTH - 5))
|
1999-12-12 15:12:45 -08:00
|
|
|
{
|
|
|
|
s[0] = *(g->contents + g->cursor_pos + 1);
|
|
|
|
s[1] = '\0';
|
|
|
|
|
|
|
|
if (s[0] == ' ')
|
1999-12-14 13:18:51 -08:00
|
|
|
char_width = Epplet_textbox_spacesize(g);
|
1999-12-12 15:12:45 -08:00
|
|
|
else
|
|
|
|
Epplet_textbox_textsize(g, &char_width, &h, s);
|
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
if (((int)g->to_cursor + g->x_offset + CRSR_WDTH) >=
|
|
|
|
(g->w - CRSR_WDTH - 5))
|
1999-12-12 15:12:45 -08:00
|
|
|
g->x_offset -= char_width;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case XK_Delete:
|
|
|
|
{
|
|
|
|
if (g->contents && *(g->contents)
|
|
|
|
&& (g->cursor_pos < strlen(g->contents)))
|
|
|
|
{
|
|
|
|
int contents_len;
|
|
|
|
|
|
|
|
contents_len = strlen(g->contents) - 1;
|
|
|
|
memmove((g->contents + g->cursor_pos),
|
|
|
|
(g->contents + g->cursor_pos + 1),
|
|
|
|
strlen(g->contents + g->cursor_pos + 1));
|
|
|
|
|
2022-01-18 05:01:20 -08:00
|
|
|
g->contents = realloc(g->contents, strlen(g->contents));
|
1999-12-12 15:12:45 -08:00
|
|
|
*(g->contents + contents_len) = '\0';
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
1999-12-13 01:36:21 -08:00
|
|
|
case XK_Home:
|
|
|
|
case XK_KP_Home:
|
|
|
|
{
|
1999-12-13 04:46:22 -08:00
|
|
|
if (g->contents)
|
|
|
|
g->cursor_pos = g->to_cursor = g->x_offset = 0;
|
|
|
|
break;
|
1999-12-13 01:36:21 -08:00
|
|
|
}
|
|
|
|
case XK_End:
|
|
|
|
case XK_KP_End:
|
|
|
|
{
|
2013-07-13 12:07:12 -07:00
|
|
|
int ww, hh;
|
1999-12-13 01:36:21 -08:00
|
|
|
|
1999-12-13 04:46:22 -08:00
|
|
|
if (g->contents && (g->cursor_pos != strlen(g->contents)))
|
|
|
|
{
|
|
|
|
g->cursor_pos = strlen(g->contents);
|
1999-12-13 01:36:21 -08:00
|
|
|
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_textbox_textsize(g, &ww, &hh, g->contents);
|
1999-12-13 01:36:21 -08:00
|
|
|
|
|
|
|
g->x_offset = 0;
|
2013-07-13 12:07:12 -07:00
|
|
|
if (ww > g->w)
|
|
|
|
g->x_offset -= ww - g->w + CRSR_WDTH + 5;
|
1999-12-13 01:36:21 -08:00
|
|
|
|
2013-07-13 12:07:12 -07:00
|
|
|
g->to_cursor = ww;
|
1999-12-13 04:46:22 -08:00
|
|
|
}
|
1999-12-13 01:36:21 -08:00
|
|
|
}
|
1999-12-12 15:12:45 -08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
if (len <= 0 || len > (int)sizeof(kbuf))
|
|
|
|
return;
|
|
|
|
kbuf[len] = 0;
|
|
|
|
|
|
|
|
if (*kbuf == '\r' || *kbuf == '\n')
|
|
|
|
{
|
|
|
|
if (g->func)
|
|
|
|
(*(g->func)) (g->data);
|
|
|
|
}
|
|
|
|
else if (*kbuf == '\b')
|
|
|
|
{
|
1999-12-12 15:12:45 -08:00
|
|
|
if (g->contents && *(g->contents) && (g->cursor_pos > 0))
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
1999-12-12 15:12:45 -08:00
|
|
|
char *s;
|
|
|
|
|
2022-01-18 05:01:20 -08:00
|
|
|
s = malloc(strlen(g->contents) + 1);
|
1999-12-12 15:12:45 -08:00
|
|
|
|
|
|
|
*(g->contents + g->cursor_pos - 1) = '\0';
|
|
|
|
sprintf(s, "%s%s", g->contents, (g->contents + g->cursor_pos));
|
|
|
|
free(g->contents);
|
|
|
|
g->contents = s;
|
|
|
|
|
1999-12-13 08:28:08 -08:00
|
|
|
if (g->cursor_pos > 0)
|
1999-12-12 15:12:45 -08:00
|
|
|
g->cursor_pos--;
|
1999-12-14 13:18:51 -08:00
|
|
|
|
|
|
|
if (g->cursor_pos == 0)
|
|
|
|
g->x_offset = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-13 10:04:13 -07:00
|
|
|
if (g->contents)
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
g->contents =
|
2022-01-18 05:01:20 -08:00
|
|
|
realloc(g->contents, (strlen(g->contents) + len + 1));
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-12-12 15:12:45 -08:00
|
|
|
if (!strcmp(kbuf, " "))
|
|
|
|
return;
|
|
|
|
|
2022-01-18 05:01:20 -08:00
|
|
|
g->contents = malloc(len + 1);
|
1999-12-12 15:12:45 -08:00
|
|
|
*(g->contents) = '\0';
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
|
1999-12-12 15:12:45 -08:00
|
|
|
len = strlen(g->contents) + 1;
|
|
|
|
memmove((g->contents + g->cursor_pos + 1),
|
|
|
|
(g->contents + g->cursor_pos),
|
|
|
|
strlen(g->contents + g->cursor_pos));
|
|
|
|
*(g->contents + g->cursor_pos) = *kbuf;
|
|
|
|
*(g->contents + len) = '\0';
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
g->cursor_pos++;
|
|
|
|
}
|
|
|
|
|
1999-11-27 08:17:16 -08:00
|
|
|
Epplet_textbox_textsize(g, &char_width, &h, kbuf);
|
|
|
|
Epplet_textbox_textsize(g, &text_width, &h, g->contents);
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-12-10 12:38:54 -08:00
|
|
|
if (*kbuf == ' ')
|
1999-12-14 13:18:51 -08:00
|
|
|
char_width = Epplet_textbox_spacesize(g);
|
1999-12-10 12:38:54 -08:00
|
|
|
|
|
|
|
if ((*kbuf == '\b') && g->contents && *(g->contents))
|
|
|
|
{
|
|
|
|
if (g->x_offset < 0)
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
1999-12-12 15:12:45 -08:00
|
|
|
if (*(g->contents + strlen(g->contents)) == ' ')
|
1999-12-14 13:18:51 -08:00
|
|
|
char_width = Epplet_textbox_spacesize(g);
|
1999-12-10 12:38:54 -08:00
|
|
|
else
|
|
|
|
Epplet_textbox_textsize(g, &char_width, &h,
|
|
|
|
&g->contents[strlen(g->contents) - 1]);
|
|
|
|
|
1999-12-13 04:46:22 -08:00
|
|
|
if (((int)g->to_cursor + g->x_offset) <= 2)
|
|
|
|
g->x_offset += char_width;
|
|
|
|
|
|
|
|
if (g->cursor_pos == 0)
|
|
|
|
g->x_offset = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
}
|
1999-12-13 04:46:22 -08:00
|
|
|
else if (((int)g->to_cursor + g->x_offset) >= (g->w - CRSR_WDTH - 2))
|
1999-12-10 12:38:54 -08:00
|
|
|
g->x_offset -= char_width;
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Epplet_gadget
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_button(const char *label, const char *image, int x, int y,
|
|
|
|
int w, int h, const char *std, Window parent,
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_gadget pop_parent,
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadButton *g;
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
g = malloc(sizeof(GadButton));
|
|
|
|
g->general.type = E_BUTTON;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
g->std = Estrdup(std);
|
|
|
|
if (g->std)
|
|
|
|
{
|
|
|
|
g->w = 12;
|
|
|
|
g->h = 12;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
|
|
|
}
|
|
|
|
g->func = func;
|
|
|
|
g->data = data;
|
|
|
|
g->pmap = 0;
|
|
|
|
g->mask = 0;
|
|
|
|
g->label = Estrdup(label);
|
2006-04-13 01:26:31 -07:00
|
|
|
g->image = Epplet_find_file(image);
|
1999-10-13 08:14:42 -07:00
|
|
|
g->hilited = 0;
|
|
|
|
g->clicked = 0;
|
|
|
|
g->pop = 0;
|
|
|
|
g->pop_parent = pop_parent;
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = ButtonPressMask | ButtonReleaseMask |
|
1999-10-13 08:14:42 -07:00
|
|
|
EnterWindowMask | LeaveWindowMask;
|
|
|
|
g->general.visible = 0;
|
|
|
|
if (parent)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
g->win = XCreateWindow(disp, parent, x, y, g->w, g->h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder |
|
|
|
|
CWBackingStore | CWColormap | CWBackPixel |
|
|
|
|
CWBorderPixel | CWEventMask, &attr);
|
1999-10-13 08:14:42 -07:00
|
|
|
g->pop = 1;
|
|
|
|
}
|
|
|
|
else
|
1999-12-03 05:07:03 -08:00
|
|
|
g->win = XCreateWindow(disp, context_win->win, x, y, g->w, g->h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore
|
|
|
|
| CWColormap | CWBackPixel | CWBorderPixel |
|
1999-10-13 08:14:42 -07:00
|
|
|
CWEventMask, &attr);
|
|
|
|
XSaveContext(disp, g->win, xid_context, (XPointer) g);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
Sat Dec 04 22:46:57 GMT 1999
(gilbertt)
Added some less complex button functions, left the old one in place, so as
not to break anyone's lovely epplets :)
Here's what you got:
/* A cut down version for text-only buttons */
Epplet_gadget Epplet_create_text_button(char *label, int x, int y,
int w, int h,
void (*func) (void *data), void *data);
/* A cut down version for stdimage-only buttons */
Epplet_gadget Epplet_create_std_button(char *std, int x, int y,
int w, int h,
void (*func) (void *data), void *data);
Those window things in the original one should really be buried in the api,
and not public, but I won't break anyone's code. There ya go :)
SVN revision: 1497
1999-12-04 10:19:04 -08:00
|
|
|
/* A cut down version for text-only buttons */
|
|
|
|
Epplet_gadget
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_text_button(const char *label, int x, int y,
|
2021-08-26 11:13:56 -07:00
|
|
|
int w, int h, void (*func)(void *data), void *data)
|
Sat Dec 04 22:46:57 GMT 1999
(gilbertt)
Added some less complex button functions, left the old one in place, so as
not to break anyone's lovely epplets :)
Here's what you got:
/* A cut down version for text-only buttons */
Epplet_gadget Epplet_create_text_button(char *label, int x, int y,
int w, int h,
void (*func) (void *data), void *data);
/* A cut down version for stdimage-only buttons */
Epplet_gadget Epplet_create_std_button(char *std, int x, int y,
int w, int h,
void (*func) (void *data), void *data);
Those window things in the original one should really be buried in the api,
and not public, but I won't break anyone's code. There ya go :)
SVN revision: 1497
1999-12-04 10:19:04 -08:00
|
|
|
{
|
|
|
|
return Epplet_create_button(label, NULL, x, y, w, h, NULL, 0, NULL, func,
|
|
|
|
data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A cut down version for stdimage-only buttons */
|
|
|
|
Epplet_gadget
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_std_button(const char *std, int x, int y,
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data), void *data)
|
Sat Dec 04 22:46:57 GMT 1999
(gilbertt)
Added some less complex button functions, left the old one in place, so as
not to break anyone's lovely epplets :)
Here's what you got:
/* A cut down version for text-only buttons */
Epplet_gadget Epplet_create_text_button(char *label, int x, int y,
int w, int h,
void (*func) (void *data), void *data);
/* A cut down version for stdimage-only buttons */
Epplet_gadget Epplet_create_std_button(char *std, int x, int y,
int w, int h,
void (*func) (void *data), void *data);
Those window things in the original one should really be buried in the api,
and not public, but I won't break anyone's code. There ya go :)
SVN revision: 1497
1999-12-04 10:19:04 -08:00
|
|
|
{
|
Sat Dec 04 22:59:21 GMT 1999
(gilbertt)
Oops. Make that:
/* A cut down version for text-only buttons */
Epplet_gadget Epplet_create_text_button(char *label, int x, int y,
int w, int h,
void (*func) (void *data), void *data);
/* A cut down version for stdimage-only buttons */
Epplet_gadget Epplet_create_std_button(char *std, int x, int y,
void (*func) (void *data), void *data);
STD images do not need w or h parameters.
=P
SVN revision: 1498
1999-12-04 10:23:52 -08:00
|
|
|
return Epplet_create_button(NULL, NULL, x, y, 12, 12, std, 0, NULL, func,
|
Sat Dec 04 22:46:57 GMT 1999
(gilbertt)
Added some less complex button functions, left the old one in place, so as
not to break anyone's lovely epplets :)
Here's what you got:
/* A cut down version for text-only buttons */
Epplet_gadget Epplet_create_text_button(char *label, int x, int y,
int w, int h,
void (*func) (void *data), void *data);
/* A cut down version for stdimage-only buttons */
Epplet_gadget Epplet_create_std_button(char *std, int x, int y,
int w, int h,
void (*func) (void *data), void *data);
Those window things in the original one should really be buried in the api,
and not public, but I won't break anyone's code. There ya go :)
SVN revision: 1497
1999-12-04 10:19:04 -08:00
|
|
|
data);
|
|
|
|
}
|
|
|
|
|
1999-12-04 10:33:47 -08:00
|
|
|
/* A cut down version for image-only buttons */
|
1999-12-09 07:40:08 -08:00
|
|
|
Epplet_gadget
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_image_button(const char *image, int x, int y,
|
2021-08-26 11:13:56 -07:00
|
|
|
int w, int h, void (*func)(void *data), void *data)
|
1999-12-04 10:33:47 -08:00
|
|
|
{
|
|
|
|
return Epplet_create_button(NULL, image, x, y, w, h, NULL, 0, NULL, func,
|
1999-12-08 10:35:38 -08:00
|
|
|
data);
|
1999-12-04 10:33:47 -08:00
|
|
|
}
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
void
|
|
|
|
Epplet_draw_button(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadButton *g;
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *state;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
g = (GadButton *) eg;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (g->hilited)
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "hilited";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "normal";
|
|
|
|
}
|
|
|
|
if (g->pmap)
|
|
|
|
XFreePixmap(disp, g->pmap);
|
|
|
|
if (g->mask)
|
|
|
|
XFreePixmap(disp, g->mask);
|
|
|
|
g->pmap = 0;
|
|
|
|
g->mask = 0;
|
|
|
|
if (g->std)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
char s[1024];
|
|
|
|
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "EPPLET_%s", g->std);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_get_pixmaps(s, state,
|
1999-10-13 08:14:42 -07:00
|
|
|
&(g->pmap), &(g->mask), g->w, g->h);
|
|
|
|
}
|
|
|
|
else if (g->pop)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_get_pixmaps("EPPLET_POPUP_ENTRY", state,
|
1999-10-13 08:14:42 -07:00
|
|
|
&(g->pmap), &(g->mask), g->w, g->h);
|
|
|
|
if (g->image)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
Imlib_Image *im;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
ESYNC;
|
2006-03-31 14:56:17 -08:00
|
|
|
im = imlib_load_image(g->image);
|
1999-10-13 08:14:42 -07:00
|
|
|
if (im)
|
|
|
|
{
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
int x, y, w, h;
|
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
imlib_context_set_image(im);
|
|
|
|
if (g->w > imlib_image_get_width())
|
|
|
|
{
|
|
|
|
w = imlib_image_get_width();
|
|
|
|
x = (g->w - imlib_image_get_width()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w = g->w - 4;
|
|
|
|
x = 2;
|
|
|
|
}
|
|
|
|
if (g->h > imlib_image_get_height())
|
|
|
|
{
|
|
|
|
h = imlib_image_get_height();
|
|
|
|
y = (g->h - imlib_image_get_height()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
h = g->h - 4;
|
|
|
|
y = 2;
|
|
|
|
}
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_drawable(g->pmap);
|
|
|
|
imlib_render_image_on_drawable_at_size(x, y, w, h);
|
|
|
|
imlib_free_image();
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (g->label)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int x, y, w, h;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_textclass_get_size("EPPLET_POPUP", &w, &h, g->label);
|
|
|
|
x = (g->w - w) / 2;
|
|
|
|
y = (g->h - h) / 2;
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_POPUP", state, g->pmap, x, y,
|
|
|
|
g->label);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_get_pixmaps("EPPLET_BUTTON", state,
|
1999-10-13 08:14:42 -07:00
|
|
|
&(g->pmap), &(g->mask), g->w, g->h);
|
|
|
|
if (g->image)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
Imlib_Image *im;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
ESYNC;
|
2006-03-31 14:56:17 -08:00
|
|
|
im = imlib_load_image(g->image);
|
1999-10-13 08:14:42 -07:00
|
|
|
if (im)
|
|
|
|
{
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
int x, y, w, h;
|
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
imlib_context_set_image(im);
|
|
|
|
if (g->w > imlib_image_get_width())
|
|
|
|
{
|
|
|
|
w = imlib_image_get_width();
|
|
|
|
x = (g->w - imlib_image_get_width()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w = g->w - 4;
|
|
|
|
x = 2;
|
|
|
|
}
|
|
|
|
if (g->h > imlib_image_get_height())
|
|
|
|
{
|
|
|
|
h = imlib_image_get_height();
|
|
|
|
y = (g->h - imlib_image_get_height()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
h = g->h - 4;
|
|
|
|
y = 2;
|
|
|
|
}
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_drawable(g->pmap);
|
|
|
|
imlib_render_image_on_drawable_at_size(x, y, w, h);
|
|
|
|
imlib_free_image();
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (g->label)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int x, y, w, h;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_textclass_get_size("EPPLET_BUTTON", &w, &h, g->label);
|
|
|
|
x = (g->w - w) / 2;
|
|
|
|
y = (g->h - h) / 2;
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_BUTTON", state, g->pmap, x, y,
|
|
|
|
g->label);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ESYNC;
|
|
|
|
XSetWindowBackgroundPixmap(disp, g->win, g->pmap);
|
1999-11-16 13:02:11 -08:00
|
|
|
XShapeCombineMask(disp, g->win, ShapeBounding, 0, 0, g->mask, ShapeSet);
|
1999-10-13 08:14:42 -07:00
|
|
|
XClearWindow(disp, g->win);
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_gadget
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_togglebutton(const char *label, const char *image, int x,
|
1999-10-13 08:14:42 -07:00
|
|
|
int y, int w, int h, int *val,
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadToggleButton *g;
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
g = malloc(sizeof(GadToggleButton));
|
|
|
|
g->general.type = E_TOGGLEBUTTON;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
|
|
|
g->func = func;
|
|
|
|
g->data = data;
|
|
|
|
g->pmap = 0;
|
|
|
|
g->mask = 0;
|
|
|
|
g->val = val;
|
|
|
|
g->label = Estrdup(label);
|
2006-04-13 01:26:31 -07:00
|
|
|
g->image = Epplet_find_file(image);
|
1999-10-13 08:14:42 -07:00
|
|
|
g->hilited = 0;
|
|
|
|
g->clicked = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = ButtonPressMask | ButtonReleaseMask |
|
1999-10-13 08:14:42 -07:00
|
|
|
EnterWindowMask | LeaveWindowMask;
|
|
|
|
g->general.visible = 0;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win = XCreateWindow(disp, context_win->win, x, y, w, h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
1999-10-13 08:14:42 -07:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel |
|
|
|
|
CWEventMask, &attr);
|
|
|
|
XSaveContext(disp, g->win, xid_context, (XPointer) g);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_togglebutton(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadToggleButton *g;
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *state;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
g = (GadToggleButton *) eg;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (g->hilited)
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "hilited";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "normal";
|
|
|
|
}
|
|
|
|
if (g->pmap)
|
|
|
|
XFreePixmap(disp, g->pmap);
|
|
|
|
if (g->mask)
|
|
|
|
XFreePixmap(disp, g->mask);
|
|
|
|
g->pmap = 0;
|
|
|
|
g->mask = 0;
|
|
|
|
if (*(g->val))
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_get_pixmaps("EPPLET_TOGGLEBUTTON_ON", state,
|
1999-10-13 08:14:42 -07:00
|
|
|
&(g->pmap), &(g->mask), g->w, g->h);
|
|
|
|
else
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_get_pixmaps("EPPLET_TOGGLEBUTTON_OFF", state,
|
1999-10-13 08:14:42 -07:00
|
|
|
&(g->pmap), &(g->mask), g->w, g->h);
|
|
|
|
if (g->image)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
Imlib_Image *im;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
ESYNC;
|
2006-03-31 14:56:17 -08:00
|
|
|
im = imlib_load_image(g->image);
|
1999-10-13 08:14:42 -07:00
|
|
|
if (im)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
int x, y, w, h;
|
2006-03-31 14:56:17 -08:00
|
|
|
|
|
|
|
imlib_context_set_image(im);
|
2006-04-15 15:04:48 -07:00
|
|
|
if (g->w > imlib_image_get_width())
|
|
|
|
{
|
|
|
|
w = imlib_image_get_width();
|
|
|
|
x = (g->w - imlib_image_get_width()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w = g->w - 4;
|
|
|
|
x = 2;
|
|
|
|
}
|
|
|
|
if (g->h > imlib_image_get_height())
|
|
|
|
{
|
|
|
|
h = imlib_image_get_height();
|
|
|
|
y = (g->h - imlib_image_get_height()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
h = g->h - 4;
|
|
|
|
y = 2;
|
|
|
|
}
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_drawable(g->pmap);
|
|
|
|
imlib_render_image_on_drawable_at_size(x, y, w, h);
|
|
|
|
imlib_free_image();
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (g->label)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int x, y, w, h;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
if (*(g->val))
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textclass_get_size("EPPLET_TOGGLEBUTTON_ON", &w, &h,
|
|
|
|
g->label);
|
1999-10-13 08:14:42 -07:00
|
|
|
x = (g->w - w) / 2;
|
|
|
|
y = (g->h - h) / 2;
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_TOGGLEBUTTON_ON", state, g->pmap, x,
|
|
|
|
y, g->label);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textclass_get_size("EPPLET_TOGGLEBUTTON_OFF", &w, &h,
|
|
|
|
g->label);
|
1999-10-13 08:14:42 -07:00
|
|
|
x = (g->w - w) / 2;
|
|
|
|
y = (g->h - h) / 2;
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_TOGGLEBUTTON_OFF", state, g->pmap, x,
|
|
|
|
y, g->label);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ESYNC;
|
|
|
|
XSetWindowBackgroundPixmap(disp, g->win, g->pmap);
|
1999-11-16 13:02:11 -08:00
|
|
|
XShapeCombineMask(disp, g->win, ShapeBounding, 0, 0, g->mask, ShapeSet);
|
1999-10-13 08:14:42 -07:00
|
|
|
XClearWindow(disp, g->win);
|
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Epplet_gadget
|
|
|
|
Epplet_create_drawingarea(int x, int y, int w, int h)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadDrawingArea *g;
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
g = malloc(sizeof(GadDrawingArea));
|
|
|
|
g->general.type = E_DRAWINGAREA;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = 0;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->general.visible = 0;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win = XCreateWindow(disp, context_win->win, x, y, w, h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
1999-10-13 08:14:42 -07:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel |
|
|
|
|
CWEventMask, &attr);
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.event_mask = ButtonPressMask |
|
1999-10-13 08:14:42 -07:00
|
|
|
ButtonReleaseMask | PointerMotionMask | EnterWindowMask |
|
|
|
|
LeaveWindowMask | KeyPressMask | KeyReleaseMask | ButtonMotionMask |
|
|
|
|
ExposureMask;
|
1999-11-16 13:02:11 -08:00
|
|
|
g->win_in = XCreateWindow(disp, g->win, 2, 2, w - 4, h - 4, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore
|
|
|
|
| CWColormap | CWBackPixel | CWBorderPixel |
|
1999-10-13 08:14:42 -07:00
|
|
|
CWEventMask, &attr);
|
|
|
|
XSetWindowBackgroundPixmap(disp, g->win_in, ParentRelative);
|
|
|
|
XMapWindow(disp, g->win_in);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_drawingarea(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadDrawingArea *g;
|
|
|
|
|
|
|
|
g = (GadDrawingArea *) eg;
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_imageclass_apply("EPPLET_DRAWINGAREA", "normal", g->win);
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_gadget
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_create_hslider(int x, int y, int len, int min, int max,
|
|
|
|
int step, int jump, int *val,
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadHSlider *g;
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
if (len < 9)
|
|
|
|
len = 9;
|
|
|
|
g = malloc(sizeof(GadHSlider));
|
|
|
|
g->general.type = E_HSLIDER;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
g->w = len;
|
|
|
|
g->h = 8;
|
|
|
|
g->max = max;
|
|
|
|
g->min = min;
|
|
|
|
g->step = step;
|
|
|
|
g->jump = jump;
|
|
|
|
g->val = val;
|
|
|
|
g->func = func;
|
|
|
|
g->data = data;
|
1999-10-18 08:04:54 -07:00
|
|
|
g->hilited = 0;
|
|
|
|
g->clicked = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = ButtonPressMask | ButtonReleaseMask;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->general.visible = 0;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win = XCreateWindow(disp, context_win->win, x, y, len, 8, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
1999-10-13 08:14:42 -07:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel |
|
|
|
|
CWEventMask, &attr);
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.event_mask = ButtonPressMask | ButtonReleaseMask |
|
1999-10-13 08:14:42 -07:00
|
|
|
PointerMotionMask | EnterWindowMask | LeaveWindowMask | ButtonMotionMask;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win_knob = XCreateWindow(disp, context_win->win, x, y, 8, 8, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder |
|
|
|
|
CWBackingStore | CWColormap | CWBackPixel |
|
|
|
|
CWBorderPixel | CWEventMask, &attr);
|
1999-10-13 08:14:42 -07:00
|
|
|
XSaveContext(disp, g->win, xid_context, (XPointer) g);
|
|
|
|
XSaveContext(disp, g->win_knob, xid_context, (XPointer) g);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_hslider(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadHSlider *g;
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *state;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
g = (GadHSlider *) eg;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (g->hilited)
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "hilited";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "normal";
|
|
|
|
}
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_apply("EPPLET_HSLIDER_BASE", "normal", g->win);
|
|
|
|
XMoveWindow(disp, g->win_knob,
|
2006-04-15 15:04:48 -07:00
|
|
|
g->x + ((g->w - 8) * (*(g->val))) / (g->max - g->min + 1), g->y);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_apply("EPPLET_HSLIDER_KNOB", state, g->win_knob);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_gadget
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_create_vslider(int x, int y, int len, int min, int max,
|
|
|
|
int step, int jump, int *val,
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadVSlider *g;
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
if (len < 9)
|
|
|
|
len = 9;
|
|
|
|
g = malloc(sizeof(GadVSlider));
|
|
|
|
g->general.type = E_VSLIDER;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
g->w = 8;
|
|
|
|
g->h = len;
|
|
|
|
g->max = max;
|
|
|
|
g->min = min;
|
|
|
|
g->step = step;
|
|
|
|
g->jump = jump;
|
|
|
|
g->val = val;
|
|
|
|
g->func = func;
|
|
|
|
g->data = data;
|
1999-10-18 08:04:54 -07:00
|
|
|
g->hilited = 0;
|
|
|
|
g->clicked = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = ButtonPressMask | ButtonReleaseMask;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->general.visible = 0;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win = XCreateWindow(disp, context_win->win, x, y, 8, len, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
1999-10-13 08:14:42 -07:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel |
|
|
|
|
CWEventMask, &attr);
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.event_mask = ButtonPressMask | ButtonReleaseMask |
|
1999-10-13 08:14:42 -07:00
|
|
|
PointerMotionMask | EnterWindowMask | LeaveWindowMask | ButtonMotionMask;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win_knob = XCreateWindow(disp, context_win->win, x, y, 8, 8, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder |
|
|
|
|
CWBackingStore | CWColormap | CWBackPixel |
|
|
|
|
CWBorderPixel | CWEventMask, &attr);
|
1999-10-13 08:14:42 -07:00
|
|
|
XSaveContext(disp, g->win, xid_context, (XPointer) g);
|
|
|
|
XSaveContext(disp, g->win_knob, xid_context, (XPointer) g);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_vslider(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadVSlider *g;
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *state;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
g = (GadVSlider *) eg;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (g->hilited)
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "hilited";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "normal";
|
|
|
|
}
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_apply("EPPLET_VSLIDER_BASE", "normal", g->win);
|
|
|
|
XMoveWindow(disp, g->win_knob,
|
2006-04-15 15:04:48 -07:00
|
|
|
g->x, g->y + ((g->h - 8) * (*(g->val))) / (g->max - g->min + 1));
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_apply("EPPLET_VSLIDER_KNOB", state, g->win_knob);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Epplet_gadget
|
|
|
|
Epplet_create_hbar(int x, int y, int w, int h, char dir, int *val)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadHBar *g;
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
g = malloc(sizeof(GadHBar));
|
|
|
|
g->general.type = E_HBAR;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
|
|
|
g->dir = dir;
|
|
|
|
g->val = val;
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = 0;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->general.visible = 0;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win = XCreateWindow(disp, context_win->win, x, y, w, h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
1999-10-13 08:14:42 -07:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel |
|
|
|
|
CWEventMask, &attr);
|
1999-11-16 13:02:11 -08:00
|
|
|
g->win_in = XCreateWindow(disp, g->win, 2, 2, w - 4, h - 4, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore
|
|
|
|
| CWColormap | CWBackPixel | CWBorderPixel |
|
1999-10-13 08:14:42 -07:00
|
|
|
CWEventMask, &attr);
|
|
|
|
XMapWindow(disp, g->win_in);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_hbar(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadHBar *g;
|
|
|
|
int l;
|
|
|
|
|
|
|
|
g = (GadHBar *) eg;
|
1999-10-13 08:14:42 -07:00
|
|
|
l = (((g->w - 4) * (*(g->val))) / 100);
|
|
|
|
if (l < 1)
|
|
|
|
l = 1;
|
|
|
|
if (l > (g->w - 4))
|
|
|
|
l = g->w - 4;
|
|
|
|
if (g->dir)
|
|
|
|
XMoveResizeWindow(disp, g->win_in, g->w - 2 - l, 2, l, g->h - 4);
|
|
|
|
else
|
|
|
|
XMoveResizeWindow(disp, g->win_in, 2, 2, l, g->h - 4);
|
|
|
|
XSync(disp, False);
|
|
|
|
Epplet_imageclass_apply("EPPLET_HBAR_BASE", "normal", g->win);
|
|
|
|
Epplet_imageclass_apply("EPPLET_HBAR_BAR", "normal", g->win_in);
|
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Epplet_gadget
|
|
|
|
Epplet_create_vbar(int x, int y, int w, int h, char dir, int *val)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2010-07-11 20:35:43 -07:00
|
|
|
GadVBar *g;
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
g = malloc(sizeof(GadVBar));
|
|
|
|
g->general.type = E_VBAR;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
|
|
|
g->dir = dir;
|
|
|
|
g->val = val;
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = 0;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->general.visible = 0;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win = XCreateWindow(disp, context_win->win, x, y, w, h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
1999-10-13 08:14:42 -07:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel |
|
|
|
|
CWEventMask, &attr);
|
1999-11-16 13:02:11 -08:00
|
|
|
g->win_in = XCreateWindow(disp, g->win, 2, 2, w - 4, h - 4, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore
|
|
|
|
| CWColormap | CWBackPixel | CWBorderPixel |
|
1999-10-13 08:14:42 -07:00
|
|
|
CWEventMask, &attr);
|
|
|
|
XMapWindow(disp, g->win_in);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_vbar(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadVBar *g;
|
|
|
|
int l;
|
|
|
|
|
|
|
|
g = (GadVBar *) eg;
|
1999-10-13 08:14:42 -07:00
|
|
|
l = (((g->h - 4) * (*(g->val))) / 100);
|
|
|
|
if (l < 1)
|
|
|
|
l = 1;
|
|
|
|
if (l > (g->h - 4))
|
|
|
|
l = g->h - 4;
|
|
|
|
if (g->dir)
|
|
|
|
XMoveResizeWindow(disp, g->win_in, 2, g->h - 2 - l, g->w - 4, l);
|
|
|
|
else
|
|
|
|
XMoveResizeWindow(disp, g->win_in, 2, 2, g->w - 4, l);
|
|
|
|
XSync(disp, False);
|
|
|
|
Epplet_imageclass_apply("EPPLET_VBAR_BASE", "normal", g->win);
|
|
|
|
Epplet_imageclass_apply("EPPLET_VBAR_BAR", "normal", g->win_in);
|
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Epplet_gadget
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_image(int x, int y, int w, int h, const char *image)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadImage *g;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
g = malloc(sizeof(GadImage));
|
|
|
|
g->general.type = E_IMAGE;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->general.visible = 0;
|
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
1999-12-16 13:17:27 -08:00
|
|
|
g->win = None;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->pw = 0;
|
|
|
|
g->ph = 0;
|
2006-04-13 01:26:31 -07:00
|
|
|
g->image = Epplet_find_file(image);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_image(Epplet_gadget eg, char un_only)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadImage *g;
|
2022-01-22 04:47:42 -08:00
|
|
|
GC gc;
|
2006-03-31 14:56:17 -08:00
|
|
|
Imlib_Image *im;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
g = (GadImage *) eg;
|
2022-01-22 04:47:42 -08:00
|
|
|
gc = EXCreateGC(g->general.parent->bg_pmap);
|
1999-10-13 08:14:42 -07:00
|
|
|
if ((g->pw > 0) && (g->ph > 0))
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XCopyArea(disp, g->general.parent->bg_bg, g->general.parent->bg_pmap, gc,
|
|
|
|
g->x, g->y, g->pw, g->ph, g->x, g->y);
|
2006-03-31 14:56:17 -08:00
|
|
|
if (g->image && !un_only)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
im = imlib_load_image(g->image);
|
1999-10-13 08:14:42 -07:00
|
|
|
if (im)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_image(im);
|
|
|
|
imlib_context_set_drawable(g->general.parent->bg_pmap);
|
1999-10-13 08:14:42 -07:00
|
|
|
if ((g->w > 0) && (g->h > 0))
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
imlib_render_image_on_drawable_at_size(g->x, g->y, g->w,
|
|
|
|
g->h);
|
1999-10-13 08:14:42 -07:00
|
|
|
g->pw = g->w;
|
|
|
|
g->ph = g->h;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_render_image_on_drawable(g->x, g->y);
|
|
|
|
g->pw = imlib_image_get_width();
|
|
|
|
g->ph = imlib_image_get_height();
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_free_image();
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XSetWindowBackgroundPixmap(disp, g->general.parent->win,
|
|
|
|
g->general.parent->bg_pmap);
|
2006-04-16 01:41:59 -07:00
|
|
|
if (!un_only)
|
|
|
|
XClearWindow(disp, g->general.parent->win);
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(gc);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Epplet_gadget
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_label(int x, int y, const char *label, char size)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadLabel *g;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
g = malloc(sizeof(GadLabel));
|
|
|
|
g->general.type = E_LABEL;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->general.visible = 0;
|
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
1999-12-16 13:17:27 -08:00
|
|
|
g->win = None;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->size = size;
|
|
|
|
g->label = Estrdup(label);
|
|
|
|
if (g->size == 0)
|
|
|
|
Epplet_textclass_get_size("EPPLET_LABEL", &(g->w), &(g->h), g->label);
|
|
|
|
else if (g->size == 1)
|
|
|
|
Epplet_textclass_get_size("EPPLET_TEXT_TINY", &(g->w), &(g->h), g->label);
|
|
|
|
else if (g->size == 2)
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textclass_get_size("EPPLET_TEXT_MEDIUM", &(g->w), &(g->h),
|
|
|
|
g->label);
|
1999-10-13 08:14:42 -07:00
|
|
|
else
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textclass_get_size("EPPLET_TEXT_LARGE", &(g->w), &(g->h),
|
|
|
|
g->label);
|
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_label(Epplet_gadget eg, char un_only)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadLabel *g;
|
2022-01-22 04:47:42 -08:00
|
|
|
GC gc;
|
1999-11-16 13:02:11 -08:00
|
|
|
int x;
|
1999-10-26 08:48:35 -07:00
|
|
|
|
2000-06-29 16:54:24 -07:00
|
|
|
GADGET_CONFIRM_TYPE(eg, E_LABEL);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadLabel *) eg;
|
2022-01-22 04:47:42 -08:00
|
|
|
gc = EXCreateGC(g->general.parent->bg_pmap);
|
1999-10-26 08:48:35 -07:00
|
|
|
if (g->x < 0)
|
|
|
|
{
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
x = g->general.parent->w + g->x - g->w;
|
1999-11-16 13:02:11 -08:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
1999-10-26 08:48:35 -07:00
|
|
|
}
|
|
|
|
else
|
1999-11-16 13:02:11 -08:00
|
|
|
x = g->x;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XCopyArea(disp, g->general.parent->bg_bg, g->general.parent->bg_pmap, gc,
|
1999-11-16 13:02:11 -08:00
|
|
|
x - 1, g->y - 1, g->w + 2, g->h + 2, x - 1, g->y - 1);
|
1999-10-13 08:14:42 -07:00
|
|
|
if (!un_only)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
XSync(disp, False);
|
|
|
|
if (g->size == 0)
|
|
|
|
{
|
|
|
|
Epplet_textclass_get_size("EPPLET_LABEL", &(g->w), &(g->h),
|
|
|
|
g->label);
|
|
|
|
if (g->x < 0)
|
|
|
|
{
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
x = g->general.parent->w + g->x - g->w;
|
1999-11-16 13:02:11 -08:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
x = g->x;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_LABEL", "normal",
|
|
|
|
g->general.parent->bg_pmap, x, g->y,
|
1999-11-16 13:02:11 -08:00
|
|
|
g->label);
|
|
|
|
}
|
|
|
|
else if (g->size == 1)
|
|
|
|
{
|
|
|
|
Epplet_textclass_get_size("EPPLET_TEXT_TINY", &(g->w), &(g->h),
|
|
|
|
g->label);
|
|
|
|
if (g->x < 0)
|
|
|
|
{
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
x = g->general.parent->w + g->x - g->w;
|
1999-11-16 13:02:11 -08:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
x = g->x;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_TEXT_TINY", "normal",
|
|
|
|
g->general.parent->bg_pmap, x, g->y,
|
|
|
|
g->label);
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
else if (g->size == 2)
|
|
|
|
{
|
|
|
|
Epplet_textclass_get_size("EPPLET_TEXT_MEDIUM", &(g->w), &(g->h),
|
|
|
|
g->label);
|
|
|
|
if (g->x < 0)
|
|
|
|
{
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
x = g->general.parent->w + g->x - g->w;
|
1999-11-16 13:02:11 -08:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
x = g->x;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_TEXT_MEDIUM", "normal",
|
|
|
|
g->general.parent->bg_pmap, x, g->y,
|
|
|
|
g->label);
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Epplet_textclass_get_size("EPPLET_TEXT_LARGE", &(g->w), &(g->h),
|
|
|
|
g->label);
|
|
|
|
if (g->x < 0)
|
|
|
|
{
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
x = g->general.parent->w + g->x - g->w;
|
1999-11-16 13:02:11 -08:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
x = g->x;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_TEXT_LARGE", "normal",
|
|
|
|
g->general.parent->bg_pmap, x, g->y,
|
|
|
|
g->label);
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
|
|
|
ESYNC;
|
1999-11-09 10:24:35 -08:00
|
|
|
}
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XSetWindowBackgroundPixmap(disp, g->general.parent->win,
|
|
|
|
g->general.parent->bg_pmap);
|
|
|
|
XClearWindow(disp, g->general.parent->win);
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(gc);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Epplet_gadget
|
|
|
|
Epplet_create_popup(void)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopup *g;
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
g = malloc(sizeof(GadPopup));
|
|
|
|
g->general.type = E_POPUP;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->general.visible = 0;
|
|
|
|
g->x = 0;
|
|
|
|
g->y = 0;
|
|
|
|
g->w = 5;
|
|
|
|
g->h = 5;
|
|
|
|
g->popbutton = NULL;
|
|
|
|
g->entry_num = 0;
|
|
|
|
g->entry = NULL;
|
1999-10-13 11:14:19 -07:00
|
|
|
g->changed = 1;
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = True;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = ButtonPressMask | ButtonReleaseMask |
|
1999-10-13 08:14:42 -07:00
|
|
|
PointerMotionMask | EnterWindowMask | LeaveWindowMask | ButtonMotionMask;
|
1999-11-16 13:02:11 -08:00
|
|
|
g->win = XCreateWindow(disp, root, 0, 0, 5, 5, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
1999-10-13 08:14:42 -07:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel |
|
|
|
|
CWEventMask, &attr);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
|
|
|
return (Epplet_gadget) g;
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_add_popup_entry(Epplet_gadget gadget, const char *label,
|
2021-08-26 11:13:56 -07:00
|
|
|
const char *pixmap, void (*func)(void *data), void *data)
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
Epplet_add_sized_popup_entry(gadget, label, pixmap, -1, -1, func, data);
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_add_sized_popup_entry(Epplet_gadget gadget, const char *label,
|
|
|
|
const char *pixmap, int w, int h,
|
2021-08-26 11:13:56 -07:00
|
|
|
void (*func)(void *data), void *data)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopup *g;
|
|
|
|
|
|
|
|
g = (GadPopup *) gadget;
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_POPUP);
|
1999-10-13 08:14:42 -07:00
|
|
|
g->entry_num++;
|
|
|
|
if (g->entry)
|
2010-07-11 20:35:43 -07:00
|
|
|
g->entry = realloc(g->entry, sizeof(*g->entry) * g->entry_num);
|
1999-10-13 08:14:42 -07:00
|
|
|
else
|
2010-07-11 20:35:43 -07:00
|
|
|
g->entry = malloc(sizeof(*g->entry));
|
1999-10-13 08:14:42 -07:00
|
|
|
g->entry[g->entry_num - 1].label = Estrdup(label);
|
|
|
|
g->entry[g->entry_num - 1].image = Estrdup(pixmap);
|
|
|
|
g->entry[g->entry_num - 1].w = 0;
|
|
|
|
g->entry[g->entry_num - 1].h = 0;
|
|
|
|
g->entry[g->entry_num - 1].func = func;
|
|
|
|
g->entry[g->entry_num - 1].data = data;
|
|
|
|
g->entry[g->entry_num - 1].gadget = NULL;
|
|
|
|
if (g->entry[g->entry_num - 1].image)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
Imlib_Image *im;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2006-03-31 14:56:17 -08:00
|
|
|
im = imlib_load_image(g->entry[g->entry_num - 1].image);
|
|
|
|
imlib_context_set_image(im);
|
2006-04-15 15:04:48 -07:00
|
|
|
g->entry[g->entry_num - 1].w =
|
|
|
|
((w == -1) ? imlib_image_get_width() : w);
|
|
|
|
g->entry[g->entry_num - 1].h =
|
|
|
|
((h == -1) ? imlib_image_get_height() : h);
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_free_image();
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
else if (g->entry[g->entry_num - 1].label)
|
|
|
|
{
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
int tw, th;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_textclass_get_size("EPPLET_POPUP",
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
&tw, &th, g->entry[g->entry_num - 1].label);
|
|
|
|
g->entry[g->entry_num - 1].w = ((w == -1) ? tw : w);
|
|
|
|
g->entry[g->entry_num - 1].h = ((h == -1) ? th : h);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
1999-10-13 11:14:19 -07:00
|
|
|
g->changed = 1;
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-10-23 03:15:45 -07:00
|
|
|
void
|
|
|
|
Epplet_remove_popup_entry(Epplet_gadget gadget, int entry_num)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopup *g;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
g = (GadPopup *) gadget;
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_POPUP);
|
1999-10-28 16:30:09 -07:00
|
|
|
if (!g->entry)
|
1999-11-16 13:02:11 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (entry_num < 0)
|
|
|
|
entry_num = g->entry_num + entry_num;
|
|
|
|
if (g->entry_num < entry_num)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (g->entry[entry_num].label)
|
|
|
|
{
|
|
|
|
free(g->entry[entry_num].label);
|
|
|
|
g->entry[entry_num].label = NULL;
|
|
|
|
}
|
|
|
|
if (g->entry[entry_num].image)
|
|
|
|
{
|
|
|
|
free(g->entry[entry_num].image);
|
|
|
|
g->entry[entry_num].image = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
g->entry_num--;
|
|
|
|
for (i = entry_num; i < g->entry_num; i++)
|
|
|
|
{
|
|
|
|
*((g->entry) + i) = *((g->entry) + i + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g->entry_num)
|
|
|
|
g->entry = realloc(g->entry, sizeof(GadPopup) * g->entry_num);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free(g->entry);
|
|
|
|
g->entry = NULL;
|
|
|
|
}
|
|
|
|
g->changed = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
1999-11-09 11:02:15 -08:00
|
|
|
Epplet_popup_entry_get_data(Epplet_gadget gadget, int entry_num)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopup *g;
|
|
|
|
|
1999-11-09 11:02:15 -08:00
|
|
|
/* int i; */
|
1999-11-16 13:02:11 -08:00
|
|
|
|
|
|
|
g = (GadPopup *) gadget;
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE_RVAL(gadget, E_POPUP, NULL);
|
1999-11-09 11:02:15 -08:00
|
|
|
if (!g->entry)
|
1999-11-16 13:02:11 -08:00
|
|
|
return NULL;
|
1999-10-28 16:30:09 -07:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
if (entry_num < 0)
|
|
|
|
entry_num = g->entry_num + entry_num;
|
|
|
|
if (g->entry_num < entry_num)
|
|
|
|
return NULL;
|
1999-10-28 16:30:09 -07:00
|
|
|
|
1999-11-09 11:02:15 -08:00
|
|
|
return ((g->entry)[entry_num]).data;
|
|
|
|
}
|
1999-11-09 10:24:35 -08:00
|
|
|
|
1999-11-09 11:02:15 -08:00
|
|
|
int
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_popup_entry_num(Epplet_gadget gadget)
|
1999-11-09 11:02:15 -08:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
if (((GadGeneral *) gadget)->type == E_POPUP)
|
|
|
|
return ((GadPopup *) gadget)->entry_num;
|
1999-10-28 16:30:09 -07:00
|
|
|
else
|
1999-11-16 13:02:11 -08:00
|
|
|
return 0;
|
1999-10-28 16:30:09 -07:00
|
|
|
}
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
void
|
|
|
|
Epplet_popup_arrange_contents(Epplet_gadget gadget)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopup *g;
|
|
|
|
int i, mw, mh, x, y;
|
|
|
|
|
|
|
|
g = (GadPopup *) gadget;
|
1999-10-13 08:14:42 -07:00
|
|
|
mw = 0;
|
|
|
|
mh = 0;
|
|
|
|
for (i = 0; i < g->entry_num; i++)
|
|
|
|
{
|
|
|
|
if (g->entry[i].w > mw)
|
|
|
|
mw = g->entry[i].w;
|
|
|
|
if (g->entry[i].h > mh)
|
|
|
|
mh = g->entry[i].h;
|
|
|
|
}
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
XResizeWindow(disp, g->win, mw + 8, ((mh + 4) * g->entry_num) + 4);
|
|
|
|
for (i = 0; i < g->entry_num; i++)
|
|
|
|
{
|
|
|
|
g->entry[i].gadget = Epplet_create_button(g->entry[i].label,
|
|
|
|
g->entry[i].image,
|
1999-11-16 13:02:11 -08:00
|
|
|
x + 2, y + 2,
|
1999-10-13 08:14:42 -07:00
|
|
|
mw + 4, mh + 4, NULL,
|
|
|
|
g->win, gadget,
|
|
|
|
g->entry[i].func,
|
|
|
|
g->entry[i].data);
|
|
|
|
Epplet_gadget_show(g->entry[i].gadget);
|
|
|
|
y += mh + 4;
|
|
|
|
}
|
|
|
|
g->x = 0;
|
|
|
|
g->y = 0;
|
|
|
|
g->w = mw + 8;
|
|
|
|
g->h = ((mh + 4) * g->entry_num) + 4;
|
|
|
|
XSync(disp, False);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_popup(Epplet_gadget gadget)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopup *g;
|
|
|
|
|
|
|
|
g = (GadPopup *) gadget;
|
1999-10-13 11:14:19 -07:00
|
|
|
if (g->changed)
|
|
|
|
{
|
|
|
|
g->changed = 0;
|
|
|
|
Epplet_imageclass_apply("EPPLET_POPUP_BASE", "normal", g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_pop_popup(Epplet_gadget gadget, Window ww)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopup *g;
|
|
|
|
|
|
|
|
g = (GadPopup *) gadget;
|
1999-10-13 11:14:19 -07:00
|
|
|
if (g->changed)
|
|
|
|
Epplet_popup_arrange_contents(gadget);
|
1999-10-13 08:14:42 -07:00
|
|
|
if (ww)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int px, py, rw, rh, x, y;
|
|
|
|
Window dw;
|
|
|
|
unsigned int w, h, b, d;
|
|
|
|
|
|
|
|
XGetGeometry(disp, root, &dw, &x, &y,
|
|
|
|
(unsigned int *)&rw, (unsigned int *)&rh, &b, &d);
|
1999-10-13 08:14:42 -07:00
|
|
|
XGetGeometry(disp, ww, &dw, &x, &y, &w, &h, &b, &d);
|
|
|
|
XTranslateCoordinates(disp, ww, root, 0, 0, &px, &py, &dw);
|
|
|
|
if ((py + ((int)h / 2)) > (rh / 2))
|
|
|
|
{
|
|
|
|
g->x = px + ((w - g->w) / 2);
|
|
|
|
g->y = py - g->h;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g->x = px + ((w - g->w) / 2);
|
|
|
|
g->y = py + h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-13 12:07:12 -07:00
|
|
|
int rw, rh, rr, x, y;
|
1999-11-16 13:02:11 -08:00
|
|
|
Window dw;
|
|
|
|
unsigned int b, d;
|
|
|
|
|
|
|
|
XGetGeometry(disp, root, &dw, &x, &y,
|
|
|
|
(unsigned int *)&rw, (unsigned int *)&rh, &b, &d);
|
2013-07-13 12:07:12 -07:00
|
|
|
XQueryPointer(disp, root, &dw, &dw, &rr, &rr, &x, &y, &b);
|
1999-10-13 08:14:42 -07:00
|
|
|
g->x = x - (g->w / 2);
|
|
|
|
g->y = y - 8;
|
|
|
|
if (g->x < 0)
|
|
|
|
g->x = 0;
|
|
|
|
if (g->y < 0)
|
|
|
|
g->y = 0;
|
|
|
|
if ((g->x + g->w) > rw)
|
|
|
|
g->x = rw - g->w;
|
|
|
|
if ((g->y + g->h) > rh)
|
|
|
|
g->y = rh - g->h;
|
|
|
|
}
|
|
|
|
XMoveWindow(disp, g->win, g->x, g->y);
|
|
|
|
Epplet_gadget_show(gadget);
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_gadget
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_create_popupbutton(const char *label, const char *image, int x,
|
|
|
|
int y, int w, int h, const char *std,
|
|
|
|
Epplet_gadget popup)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopupButton *g;
|
1999-10-13 08:14:42 -07:00
|
|
|
XSetWindowAttributes attr;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
g = malloc(sizeof(GadPopupButton));
|
|
|
|
g->general.type = E_POPUPBUTTON;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->general.parent = context_win;
|
1999-10-13 08:14:42 -07:00
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
1999-11-09 11:02:15 -08:00
|
|
|
g->std = Estrdup(std);
|
|
|
|
if (g->std)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
g->w = 12;
|
|
|
|
g->h = 12;
|
1999-11-09 11:02:15 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
1999-11-09 11:02:15 -08:00
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
g->pmap = 0;
|
|
|
|
g->mask = 0;
|
|
|
|
g->label = Estrdup(label);
|
2006-04-13 01:26:31 -07:00
|
|
|
g->image = Epplet_find_file(image);
|
1999-10-13 08:14:42 -07:00
|
|
|
g->hilited = 0;
|
|
|
|
g->clicked = 0;
|
|
|
|
g->popped = 0;
|
|
|
|
g->popup = popup;
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.backing_store = NotUseful;
|
1999-10-13 08:14:42 -07:00
|
|
|
attr.override_redirect = False;
|
2006-03-31 14:56:17 -08:00
|
|
|
attr.colormap = imlib_context_get_colormap();
|
1999-11-16 13:02:11 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = ButtonPressMask | ButtonReleaseMask |
|
1999-10-13 08:14:42 -07:00
|
|
|
EnterWindowMask | LeaveWindowMask;
|
|
|
|
g->general.visible = 0;
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
g->win = XCreateWindow(disp, context_win->win, x, y, g->w, g->h, 0,
|
2006-03-31 14:56:17 -08:00
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
1999-10-13 08:14:42 -07:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel |
|
|
|
|
CWEventMask, &attr);
|
|
|
|
XSaveContext(disp, g->win, xid_context, (XPointer) g);
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_add_gad((Epplet_gadget) g);
|
1999-10-13 08:14:42 -07:00
|
|
|
return (Epplet_gadget) g;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_draw_popupbutton(Epplet_gadget eg)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopupButton *g;
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *state;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2000-06-29 16:54:24 -07:00
|
|
|
GADGET_CONFIRM_TYPE(eg, E_POPUPBUTTON);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadPopupButton *) eg;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (g->hilited)
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "hilited";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g->clicked)
|
|
|
|
state = "clicked";
|
|
|
|
else
|
|
|
|
state = "normal";
|
|
|
|
}
|
|
|
|
if (g->popped)
|
|
|
|
state = "clicked";
|
|
|
|
if (g->pmap)
|
|
|
|
XFreePixmap(disp, g->pmap);
|
|
|
|
if (g->mask)
|
|
|
|
XFreePixmap(disp, g->mask);
|
|
|
|
g->pmap = 0;
|
|
|
|
g->mask = 0;
|
1999-11-09 11:02:15 -08:00
|
|
|
if (g->std)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
char s[1024];
|
1999-10-28 16:30:09 -07:00
|
|
|
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "EPPLET_%s", g->std);
|
1999-11-09 11:02:15 -08:00
|
|
|
Epplet_imageclass_get_pixmaps(s, state,
|
1999-11-16 13:02:11 -08:00
|
|
|
&(g->pmap), &(g->mask), g->w, g->h);
|
1999-11-09 11:02:15 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_get_pixmaps("EPPLET_BUTTON", state,
|
|
|
|
&(g->pmap), &(g->mask), g->w, g->h);
|
1999-11-09 11:02:15 -08:00
|
|
|
if (g->image)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
Imlib_Image *im;
|
1999-10-28 16:30:09 -07:00
|
|
|
|
1999-11-09 11:02:15 -08:00
|
|
|
ESYNC;
|
2006-03-31 14:56:17 -08:00
|
|
|
im = imlib_load_image(g->image);
|
1999-11-09 11:02:15 -08:00
|
|
|
if (im)
|
|
|
|
{
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
int x, y, w, h;
|
|
|
|
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_image(im);
|
2006-04-15 15:04:48 -07:00
|
|
|
if (g->w > imlib_image_get_width())
|
|
|
|
{
|
|
|
|
w = imlib_image_get_width();
|
|
|
|
x = (g->w - imlib_image_get_width()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w = g->w - 4;
|
|
|
|
x = 2;
|
|
|
|
}
|
|
|
|
if (g->h > imlib_image_get_height())
|
|
|
|
{
|
|
|
|
h = imlib_image_get_height();
|
|
|
|
y = (g->h - imlib_image_get_height()) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
h = g->h - 4;
|
|
|
|
y = 2;
|
|
|
|
}
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_drawable(g->pmap);
|
|
|
|
imlib_render_image_on_drawable_at_size(x, y, w, h);
|
|
|
|
imlib_free_image();
|
1999-11-09 11:02:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (g->label)
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
|
1999-11-09 11:02:15 -08:00
|
|
|
Epplet_textclass_get_size("EPPLET_BUTTON", &w, &h, g->label);
|
|
|
|
x = (g->w - w) / 2;
|
|
|
|
y = (g->h - h) / 2;
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textclass_draw("EPPLET_BUTTON", state, g->pmap, x, y,
|
|
|
|
g->label);
|
1999-10-28 16:30:09 -07:00
|
|
|
}
|
1999-11-09 10:24:35 -08:00
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
ESYNC;
|
|
|
|
XSetWindowBackgroundPixmap(disp, g->win, g->pmap);
|
1999-11-16 13:02:11 -08:00
|
|
|
XShapeCombineMask(disp, g->win, ShapeBounding, 0, 0, g->mask, ShapeSet);
|
1999-10-13 08:14:42 -07:00
|
|
|
XClearWindow(disp, g->win);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_change_popbutton_popup(Epplet_gadget gadget, Epplet_gadget popup)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadPopupButton *g;
|
1999-12-08 10:35:38 -08:00
|
|
|
GadGeneral *gg;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_POPUPBUTTON);
|
|
|
|
GADGET_CONFIRM_TYPE(popup, E_POPUP);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadPopupButton *) gadget;
|
1999-12-08 10:35:38 -08:00
|
|
|
gg = (GadGeneral *) gadget;
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_gadget_destroy(g->popup);
|
1999-10-13 08:14:42 -07:00
|
|
|
g->popped = 0;
|
|
|
|
g->popup = popup;
|
1999-12-08 10:35:38 -08:00
|
|
|
if (gg->visible != 0)
|
|
|
|
Epplet_draw_popupbutton(gadget);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
2000-06-29 16:54:24 -07:00
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_change_popbutton_label(Epplet_gadget gadget, const char *label)
|
2000-06-29 16:54:24 -07:00
|
|
|
{
|
|
|
|
GadPopupButton *g;
|
|
|
|
GadGeneral *gg;
|
|
|
|
|
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_POPUPBUTTON);
|
|
|
|
g = (GadPopupButton *) gadget;
|
|
|
|
gg = (GadGeneral *) gadget;
|
|
|
|
if (g->label)
|
|
|
|
{
|
|
|
|
if (label && !strcmp(g->label, label))
|
|
|
|
return; /* The labels are identical, so no sense in redrawing */
|
|
|
|
else
|
|
|
|
free(g->label); /* The labels are different. Proceed. */
|
|
|
|
}
|
|
|
|
g->label = Estrdup(label);
|
|
|
|
if (gg->visible != 0)
|
|
|
|
Epplet_draw_popupbutton(gadget);
|
|
|
|
}
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_change_image(Epplet_gadget gadget, int w, int h, const char *image)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadImage *g;
|
1999-12-08 10:35:38 -08:00
|
|
|
GadGeneral *gg;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_IMAGE);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadImage *) gadget;
|
1999-12-08 10:35:38 -08:00
|
|
|
gg = (GadGeneral *) gadget;
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->image);
|
2006-04-13 01:26:31 -07:00
|
|
|
g->image = Epplet_find_file(image);
|
1999-10-13 08:14:42 -07:00
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
1999-12-08 10:35:38 -08:00
|
|
|
if (gg->visible != 0)
|
|
|
|
Epplet_draw_image(gadget, 0);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-12-06 15:29:54 -08:00
|
|
|
void
|
1999-12-09 07:40:08 -08:00
|
|
|
Epplet_move_change_image(Epplet_gadget gadget, int x, int y, int w, int h,
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *image)
|
1999-12-06 15:29:54 -08:00
|
|
|
{
|
|
|
|
GadImage *g;
|
1999-12-08 10:35:38 -08:00
|
|
|
GadGeneral *gg;
|
1999-12-06 15:29:54 -08:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_IMAGE);
|
1999-12-06 15:29:54 -08:00
|
|
|
g = (GadImage *) gadget;
|
1999-12-08 10:35:38 -08:00
|
|
|
gg = (GadGeneral *) gadget;
|
1999-12-06 15:29:54 -08:00
|
|
|
Epplet_draw_image(gadget, 1);
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->image);
|
2006-04-13 01:26:31 -07:00
|
|
|
g->image = Epplet_find_file(image);
|
1999-12-06 15:29:54 -08:00
|
|
|
g->w = w;
|
|
|
|
g->h = h;
|
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
1999-12-08 10:35:38 -08:00
|
|
|
if (gg->visible != 0)
|
|
|
|
Epplet_draw_image(gadget, 0);
|
1999-12-06 15:29:54 -08:00
|
|
|
}
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_change_label(Epplet_gadget gadget, const char *label)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadLabel *g;
|
1999-12-08 10:35:38 -08:00
|
|
|
GadGeneral *gg;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_LABEL);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadLabel *) gadget;
|
1999-12-08 10:35:38 -08:00
|
|
|
gg = (GadGeneral *) gadget;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (g->label)
|
1999-10-26 06:26:21 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
if (label && !strcmp(g->label, label))
|
|
|
|
return; /* The labels are identical, so no sense in redrawing */
|
|
|
|
else
|
|
|
|
free(g->label); /* The labels are different. Proceed. */
|
1999-10-26 06:26:21 -07:00
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
g->label = Estrdup(label);
|
1999-12-08 10:35:38 -08:00
|
|
|
if (gg->visible != 0)
|
|
|
|
Epplet_draw_label(gadget, 0);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-12-16 13:17:27 -08:00
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_move_change_label(Epplet_gadget gadget, int x, int y, const char *label)
|
1999-12-16 13:17:27 -08:00
|
|
|
{
|
|
|
|
GadLabel *g;
|
|
|
|
GadGeneral *gg;
|
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_LABEL);
|
1999-12-16 13:17:27 -08:00
|
|
|
g = (GadLabel *) gadget;
|
|
|
|
gg = (GadGeneral *) gadget;
|
|
|
|
if (gg->visible)
|
2000-01-14 18:30:43 -08:00
|
|
|
Epplet_draw_label(gadget, 1);
|
1999-12-16 13:17:27 -08:00
|
|
|
if (g->label)
|
|
|
|
{
|
|
|
|
if (label && !strcmp(g->label, label))
|
|
|
|
return; /* The labels are identical, so no sense in redrawing */
|
|
|
|
else
|
|
|
|
free(g->label); /* The labels are different. Proceed. */
|
|
|
|
}
|
|
|
|
g->label = Estrdup(label);
|
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
if (gg->visible)
|
|
|
|
Epplet_draw_label(gadget, 0);
|
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
Window
|
|
|
|
Epplet_get_drawingarea_window(Epplet_gadget gadget)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadDrawingArea *g;
|
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE_RVAL(gadget, E_DRAWINGAREA, None);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadDrawingArea *) gadget;
|
1999-10-13 08:14:42 -07:00
|
|
|
return g->win_in;
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
|
|
|
Epplet_event(Epplet_gadget gadget, XEvent * ev)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
static int rx = 0, ry = 0, dx, dy;
|
|
|
|
GadGeneral *gg;
|
1999-10-13 08:14:42 -07:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
gg = (GadGeneral *) gadget;
|
1999-10-13 08:14:42 -07:00
|
|
|
switch (ev->type)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
case KeyPress:
|
|
|
|
rx = ev->xbutton.x_root;
|
|
|
|
ry = ev->xbutton.y_root;
|
|
|
|
switch (gg->type)
|
1999-11-09 12:10:10 -08:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
case E_BUTTON:
|
|
|
|
break;
|
|
|
|
case E_TEXTBOX:
|
|
|
|
{
|
|
|
|
GadTextBox *g;
|
1999-11-09 12:10:10 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadTextBox *) gadget;
|
1999-11-09 12:10:10 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_textbox_handle_keyevent(ev, gadget);
|
1999-11-09 12:10:10 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_draw_textbox(g);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
|
|
|
break;
|
|
|
|
case E_HSLIDER:
|
|
|
|
break;
|
|
|
|
case E_POPUPBUTTON:
|
|
|
|
break;
|
|
|
|
case E_DRAWINGAREA:
|
|
|
|
break;
|
|
|
|
case E_IMAGE:
|
|
|
|
break;
|
|
|
|
case E_LABEL:
|
|
|
|
break;
|
|
|
|
case E_VBAR:
|
|
|
|
break;
|
|
|
|
case E_HBAR:
|
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
|
|
|
break;
|
|
|
|
case E_POPUP:
|
|
|
|
break;
|
1999-11-09 12:10:10 -08:00
|
|
|
}
|
1999-11-16 13:02:11 -08:00
|
|
|
break;
|
1999-10-13 08:14:42 -07:00
|
|
|
case ButtonPress:
|
|
|
|
rx = ev->xbutton.x_root;
|
|
|
|
ry = ev->xbutton.y_root;
|
|
|
|
switch (gg->type)
|
|
|
|
{
|
|
|
|
case E_BUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadButton *g;
|
|
|
|
|
2000-02-04 19:25:24 -08:00
|
|
|
if (ev->xbutton.button > 3)
|
2000-03-03 14:45:02 -08:00
|
|
|
break;
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadButton *) gadget;
|
|
|
|
g->clicked = 1;
|
|
|
|
Epplet_draw_button(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_HSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHSlider *g;
|
|
|
|
|
|
|
|
g = (GadHSlider *) gadget;
|
2000-03-03 14:45:02 -08:00
|
|
|
if (ev->xbutton.button < 4)
|
|
|
|
g->clicked = 1;
|
1999-11-16 13:02:11 -08:00
|
|
|
if (ev->xbutton.window == g->win)
|
|
|
|
{
|
2000-03-03 14:45:02 -08:00
|
|
|
if (ev->xbutton.button == 4)
|
|
|
|
(*(g->val)) += g->jump;
|
|
|
|
else if (ev->xbutton.button == 5)
|
|
|
|
(*(g->val)) -= g->jump;
|
|
|
|
else if (ev->xbutton.x > (((*(g->val)) * g->w) /
|
|
|
|
(g->max - g->min + 1)))
|
1999-11-16 13:02:11 -08:00
|
|
|
(*(g->val)) += g->jump;
|
|
|
|
else
|
|
|
|
(*(g->val)) -= g->jump;
|
|
|
|
if ((*(g->val)) < g->min)
|
|
|
|
(*(g->val)) = g->min;
|
|
|
|
if ((*(g->val)) > g->max)
|
|
|
|
(*(g->val)) = g->max;
|
|
|
|
}
|
|
|
|
if (g->func)
|
|
|
|
(*(g->func)) (g->data);
|
|
|
|
Epplet_draw_hslider(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVSlider *g;
|
|
|
|
|
|
|
|
g = (GadVSlider *) gadget;
|
2000-03-03 14:45:02 -08:00
|
|
|
if (ev->xbutton.button < 4)
|
|
|
|
g->clicked = 1;
|
1999-11-16 13:02:11 -08:00
|
|
|
if (ev->xbutton.window == g->win)
|
2000-03-03 14:45:02 -08:00
|
|
|
{
|
|
|
|
if (ev->xbutton.button == 4)
|
|
|
|
(*(g->val)) -= g->jump;
|
|
|
|
else if (ev->xbutton.button == 5)
|
|
|
|
(*(g->val)) += g->jump;
|
|
|
|
else if (ev->xbutton.y > (((*(g->val)) * g->h) /
|
|
|
|
(g->max - g->min + 1)))
|
1999-11-16 13:02:11 -08:00
|
|
|
(*(g->val)) += g->jump;
|
|
|
|
else
|
|
|
|
(*(g->val)) -= g->jump;
|
|
|
|
if ((*(g->val)) < g->min)
|
|
|
|
(*(g->val)) = g->min;
|
|
|
|
if ((*(g->val)) > g->max)
|
|
|
|
(*(g->val)) = g->max;
|
|
|
|
}
|
|
|
|
if (g->func)
|
|
|
|
(*(g->func)) (g->data);
|
|
|
|
Epplet_draw_vslider(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadToggleButton *g;
|
|
|
|
|
2000-02-04 19:25:24 -08:00
|
|
|
if (ev->xbutton.button > 3)
|
2000-03-03 14:45:02 -08:00
|
|
|
break;
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadToggleButton *) gadget;
|
|
|
|
g->clicked = 1;
|
|
|
|
Epplet_draw_togglebutton(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUPBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopupButton *g;
|
|
|
|
|
2000-02-04 19:25:24 -08:00
|
|
|
if (ev->xbutton.button > 3)
|
2000-03-03 14:45:02 -08:00
|
|
|
break;
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadPopupButton *) gadget;
|
|
|
|
g->clicked = 1;
|
|
|
|
Epplet_draw_popupbutton(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUP:
|
|
|
|
break;
|
2000-01-31 08:23:48 -08:00
|
|
|
case E_TEXTBOX:
|
|
|
|
{
|
2000-03-03 14:45:02 -08:00
|
|
|
GadTextBox *g;
|
2006-04-15 15:04:48 -07:00
|
|
|
int tmp_x, tmp_y, width, length, index,
|
|
|
|
last_index, text_w, text_h, text_wl, text_wr;
|
2000-01-31 08:23:48 -08:00
|
|
|
Window dummy;
|
2000-03-03 14:45:02 -08:00
|
|
|
char buf, left = 1, right = 1;
|
2000-01-31 08:23:48 -08:00
|
|
|
float delta;
|
|
|
|
|
|
|
|
g = (GadTextBox *) gadget;
|
2000-02-16 09:07:48 -08:00
|
|
|
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!g->contents)
|
2000-03-03 14:45:02 -08:00
|
|
|
break;
|
2000-02-16 09:07:48 -08:00
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
XTranslateCoordinates(disp, g->win, root, 0, 0, &tmp_x, &tmp_y,
|
|
|
|
&dummy);
|
2000-01-31 08:23:48 -08:00
|
|
|
width = rx - tmp_x;
|
|
|
|
length = strlen(g->contents);
|
2000-03-03 14:45:02 -08:00
|
|
|
index = last_index = length / 2;
|
|
|
|
delta = last_index / 2;
|
2000-01-31 08:23:48 -08:00
|
|
|
|
2006-04-13 04:07:27 -07:00
|
|
|
Epplet_textbox_textsize(g, &text_w, &text_h, g->contents);
|
|
|
|
|
2000-01-31 08:23:48 -08:00
|
|
|
while (delta >= 1.0)
|
|
|
|
{
|
2000-03-03 14:45:02 -08:00
|
|
|
index = last_index;
|
|
|
|
buf = g->contents[index];
|
|
|
|
g->contents[index] = 0;
|
|
|
|
Epplet_textbox_textsize(g, &text_w, &text_h, g->contents);
|
|
|
|
g->contents[index] = buf;
|
|
|
|
if (text_w <= width)
|
|
|
|
last_index += rint(delta);
|
|
|
|
else
|
|
|
|
last_index -= rint(delta);
|
|
|
|
delta /= 2.0;
|
2000-01-31 08:23:48 -08:00
|
|
|
}
|
2000-03-03 14:45:02 -08:00
|
|
|
|
2000-01-31 08:23:48 -08:00
|
|
|
while (1)
|
|
|
|
{
|
2000-03-03 14:45:02 -08:00
|
|
|
if (left)
|
|
|
|
{
|
2006-04-13 04:07:27 -07:00
|
|
|
if (index <= 0)
|
|
|
|
break;
|
2000-03-03 14:45:02 -08:00
|
|
|
buf = g->contents[index - 1];
|
|
|
|
g->contents[index - 1] = 0;
|
2006-04-15 15:04:48 -07:00
|
|
|
Epplet_textbox_textsize(g, &text_wl, &text_h,
|
|
|
|
g->contents);
|
2000-03-03 14:45:02 -08:00
|
|
|
g->contents[index - 1] = buf;
|
|
|
|
}
|
|
|
|
if (right)
|
|
|
|
{
|
2006-04-13 04:07:27 -07:00
|
|
|
if (index >= length)
|
|
|
|
break;
|
2000-03-03 14:45:02 -08:00
|
|
|
buf = g->contents[index + 1];
|
|
|
|
g->contents[index + 1] = 0;
|
2006-04-15 15:04:48 -07:00
|
|
|
Epplet_textbox_textsize(g, &text_wr, &text_h,
|
|
|
|
g->contents);
|
2000-03-03 14:45:02 -08:00
|
|
|
g->contents[index + 1] = buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (abs(text_wl - width) < abs(text_w - width))
|
|
|
|
{
|
|
|
|
right = 0;
|
|
|
|
text_wr = text_w;
|
|
|
|
text_w = text_wl;
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
else if (abs(text_wr - width) < abs(text_w - width))
|
|
|
|
{
|
|
|
|
left = 0;
|
|
|
|
text_wl = text_w;
|
|
|
|
text_w = text_wr;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
2000-01-31 08:23:48 -08:00
|
|
|
}
|
|
|
|
g->cursor_pos = index;
|
|
|
|
Epplet_draw_textbox(g);
|
|
|
|
}
|
|
|
|
break;
|
1999-10-13 08:14:42 -07:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
|
|
|
rx = ev->xbutton.x_root;
|
|
|
|
ry = ev->xbutton.y_root;
|
|
|
|
switch (gg->type)
|
|
|
|
{
|
|
|
|
case E_BUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadButton *g;
|
|
|
|
|
2000-02-04 19:25:24 -08:00
|
|
|
if (ev->xbutton.button > 3)
|
2000-03-03 14:45:02 -08:00
|
|
|
break;
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadButton *) gadget;
|
|
|
|
g->clicked = 0;
|
|
|
|
Epplet_draw_button(gadget);
|
|
|
|
if (g->pop_parent)
|
|
|
|
Epplet_gadget_hide(g->pop_parent);
|
|
|
|
if ((g->hilited) && (g->func))
|
|
|
|
(*(g->func)) (g->data);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
1999-11-27 08:17:16 -08:00
|
|
|
case E_TEXTBOX:
|
|
|
|
{
|
|
|
|
GadTextBox *g;
|
|
|
|
char *s;
|
|
|
|
int nbytes_return;
|
|
|
|
|
|
|
|
g = (GadTextBox *) gadget;
|
|
|
|
|
|
|
|
if (ev->xbutton.button == 2)
|
|
|
|
{
|
1999-11-27 09:58:33 -08:00
|
|
|
s = XFetchBuffer(disp, &nbytes_return, 0);
|
|
|
|
if (nbytes_return)
|
|
|
|
Epplet_textbox_insert(g, s);
|
1999-11-27 08:17:16 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-10-13 08:14:42 -07:00
|
|
|
case E_HSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHSlider *g;
|
|
|
|
|
|
|
|
g = (GadHSlider *) gadget;
|
2000-03-03 14:45:02 -08:00
|
|
|
if (ev->xbutton.button < 4)
|
|
|
|
g->clicked = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_draw_hslider(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVSlider *g;
|
|
|
|
|
|
|
|
g = (GadVSlider *) gadget;
|
2000-03-03 14:45:02 -08:00
|
|
|
if (ev->xbutton.button < 4)
|
|
|
|
g->clicked = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_draw_vslider(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadToggleButton *g;
|
|
|
|
|
2000-02-04 19:25:24 -08:00
|
|
|
if (ev->xbutton.button > 3)
|
2000-03-03 14:45:02 -08:00
|
|
|
break;
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadToggleButton *) gadget;
|
|
|
|
g->clicked = 0;
|
|
|
|
if (g->hilited)
|
|
|
|
{
|
|
|
|
if (*(g->val))
|
|
|
|
*(g->val) = 0;
|
|
|
|
else
|
|
|
|
*(g->val) = 1;
|
|
|
|
}
|
|
|
|
Epplet_draw_togglebutton(gadget);
|
|
|
|
if ((g->hilited) && (g->func))
|
|
|
|
(*(g->func)) (g->data);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUPBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopupButton *g;
|
|
|
|
|
2000-02-04 19:25:24 -08:00
|
|
|
if (ev->xbutton.button > 3)
|
2000-03-03 14:45:02 -08:00
|
|
|
break;
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadPopupButton *) gadget;
|
|
|
|
g->clicked = 0;
|
|
|
|
if (g->popped)
|
|
|
|
{
|
|
|
|
if (g->popup)
|
|
|
|
Epplet_gadget_hide(g->popup);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g->popup)
|
|
|
|
{
|
|
|
|
Epplet_pop_popup(g->popup, g->win);
|
|
|
|
((GadPopup *) g->popup)->popbutton = gadget;
|
|
|
|
g->popped = 1;
|
|
|
|
}
|
|
|
|
Epplet_draw_popupbutton(gadget);
|
|
|
|
}
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUP:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MotionNotify:
|
|
|
|
dx = ev->xbutton.x_root - rx;
|
|
|
|
dy = ev->xbutton.y_root - ry;
|
|
|
|
rx = ev->xbutton.x_root;
|
|
|
|
ry = ev->xbutton.y_root;
|
|
|
|
switch (gg->type)
|
|
|
|
{
|
|
|
|
case E_HSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHSlider *g;
|
|
|
|
int v, x, xx;
|
|
|
|
|
|
|
|
g = (GadHSlider *) gadget;
|
|
|
|
if (g->clicked)
|
|
|
|
{
|
|
|
|
x = ((g->w - 8) * (*(g->val))) / (g->max - g->min + 1);
|
|
|
|
xx = x + dx;
|
2006-04-15 15:04:48 -07:00
|
|
|
(*(g->val)) =
|
|
|
|
g->min + ((xx * (g->max - g->min)) / (g->w - 8));
|
1999-11-16 13:02:11 -08:00
|
|
|
v = (*(g->val)) / g->step;
|
|
|
|
if ((*(g->val)) - (v * g->step) >= (g->step / 2))
|
|
|
|
v++;
|
|
|
|
(*(g->val)) = v * g->step;
|
|
|
|
if ((*(g->val)) < g->min)
|
|
|
|
(*(g->val)) = g->min;
|
|
|
|
if ((*(g->val)) > g->max)
|
|
|
|
(*(g->val)) = g->max;
|
|
|
|
xx = ((g->w - 8) * (*(g->val))) / (g->max - g->min + 1);
|
|
|
|
rx = rx - dx + (xx - x);
|
|
|
|
if (g->func)
|
|
|
|
(*(g->func)) (g->data);
|
|
|
|
Epplet_draw_hslider(gadget);
|
|
|
|
}
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVSlider *g;
|
|
|
|
int v, y, yy;
|
|
|
|
|
|
|
|
g = (GadVSlider *) gadget;
|
|
|
|
if (g->clicked)
|
|
|
|
{
|
|
|
|
y = ((g->h - 8) * (*(g->val))) / (g->max - g->min + 1);
|
|
|
|
yy = y + dy;
|
2006-04-15 15:04:48 -07:00
|
|
|
(*(g->val)) =
|
|
|
|
g->min + ((yy * (g->max - g->min)) / (g->h - 8));
|
1999-11-16 13:02:11 -08:00
|
|
|
v = (*(g->val)) / g->step;
|
|
|
|
if ((*(g->val)) - (v * g->step) >= (g->step / 2))
|
|
|
|
v++;
|
|
|
|
(*(g->val)) = v * g->step;
|
|
|
|
if ((*(g->val)) < g->min)
|
|
|
|
(*(g->val)) = g->min;
|
|
|
|
if ((*(g->val)) > g->max)
|
|
|
|
(*(g->val)) = g->max;
|
|
|
|
yy = ((g->h - 8) * (*(g->val))) / (g->max - g->min + 1);
|
|
|
|
ry = ry - dy + (yy - y);
|
|
|
|
if (g->func)
|
|
|
|
(*(g->func)) (g->data);
|
|
|
|
Epplet_draw_vslider(gadget);
|
|
|
|
}
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EnterNotify:
|
|
|
|
switch (gg->type)
|
|
|
|
{
|
|
|
|
case E_BUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadButton *g;
|
1999-11-09 12:10:10 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadButton *) gadget;
|
|
|
|
g->hilited = 1;
|
|
|
|
Epplet_draw_button(gadget);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_TEXTBOX:
|
|
|
|
{
|
|
|
|
GadTextBox *g;
|
|
|
|
|
|
|
|
g = (GadTextBox *) gadget;
|
|
|
|
g->hilited = 1;
|
|
|
|
Epplet_draw_textbox(gadget);
|
|
|
|
}
|
|
|
|
break;
|
1999-10-13 08:14:42 -07:00
|
|
|
case E_HSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHSlider *g;
|
|
|
|
|
|
|
|
g = (GadHSlider *) gadget;
|
|
|
|
g->hilited = 1;
|
|
|
|
Epplet_draw_hslider(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVSlider *g;
|
|
|
|
|
|
|
|
g = (GadVSlider *) gadget;
|
|
|
|
g->hilited = 1;
|
|
|
|
Epplet_draw_vslider(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadToggleButton *g;
|
|
|
|
|
|
|
|
g = (GadToggleButton *) gadget;
|
|
|
|
g->hilited = 1;
|
|
|
|
Epplet_draw_togglebutton(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUPBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopupButton *g;
|
|
|
|
|
|
|
|
g = (GadPopupButton *) gadget;
|
|
|
|
g->hilited = 1;
|
|
|
|
Epplet_draw_popupbutton(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUP:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LeaveNotify:
|
|
|
|
switch (gg->type)
|
|
|
|
{
|
|
|
|
case E_BUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadButton *g;
|
1999-11-09 12:10:10 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadButton *) gadget;
|
|
|
|
g->hilited = 0;
|
|
|
|
Epplet_draw_button(gadget);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_TEXTBOX:
|
|
|
|
{
|
|
|
|
GadTextBox *g;
|
|
|
|
|
|
|
|
g = (GadTextBox *) gadget;
|
|
|
|
g->hilited = 0;
|
|
|
|
Epplet_draw_textbox(gadget);
|
|
|
|
}
|
|
|
|
break;
|
1999-10-13 08:14:42 -07:00
|
|
|
case E_HSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHSlider *g;
|
|
|
|
|
|
|
|
g = (GadHSlider *) gadget;
|
|
|
|
g->hilited = 0;
|
|
|
|
Epplet_draw_hslider(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVSlider *g;
|
|
|
|
|
|
|
|
g = (GadVSlider *) gadget;
|
|
|
|
g->hilited = 0;
|
|
|
|
Epplet_draw_vslider(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadToggleButton *g;
|
|
|
|
|
|
|
|
g = (GadToggleButton *) gadget;
|
|
|
|
g->hilited = 0;
|
|
|
|
Epplet_draw_togglebutton(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUPBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopupButton *g;
|
|
|
|
|
|
|
|
g = (GadPopupButton *) gadget;
|
|
|
|
g->hilited = 0;
|
|
|
|
Epplet_draw_popupbutton(gadget);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUP:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_background_properties(char vertical, Window newwin)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2022-01-22 04:47:42 -08:00
|
|
|
GC gc;
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
Epplet_window win;
|
|
|
|
|
|
|
|
win = Epplet_window_get_from_Window(newwin);
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!win)
|
Fri Dec 03 23:47:45 GMT 1999
(gilbertt)
Okay. Lots has changed. It was pretty inconsistant to have loads of
functions returning or requiring a "Window win" paramater, and mine dealing
with "Epplet_window" parameters. I had to lose one, so I lost the one which
caused no breakage. Mine :)
I still use Epplet_window internally to encapsulate data on a per-window
basis. However, all public functions deal with "Window win" again. Now
things are consistant. The Epplet_window type is now private and hidden.
To do this, I have implemented a little lookup function to relate
Epplet_windows to Windows, which should be more than adequate for our needs.
You can now declare a delete event handler for your whole epplet, although I
may change to per-window delete event handlers if people request it.
If you return 1 from the delete event handler, or don't supply one, or
supply NULL, the window will be destroyed for you, if you return 0, the
delete event will be ignored. Use this to do things like saying "hrm, those
two settings cannot coexist" or "that file does not exist" etc.
I'm nearly finished with the window functions now, and will next add
convenience wrappers such as Epplet_create_window_config(...) to add ok,
apply and save buttons and setup callbacks for you, and some other stuff
too.
I'd appreciate it if people would poke around and see what they think, I'm
new at this Xlib stuf...
SVN revision: 1490
1999-12-03 11:34:55 -08:00
|
|
|
return;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
if (win->bg_pmap)
|
|
|
|
XFreePixmap(disp, win->bg_pmap);
|
|
|
|
if (win->bg_bg)
|
|
|
|
XFreePixmap(disp, win->bg_bg);
|
|
|
|
if (win->bg_mask)
|
|
|
|
XFreePixmap(disp, win->bg_mask);
|
|
|
|
win->bg_pmap = 0;
|
|
|
|
win->bg_mask = 0;
|
|
|
|
win->bg_bg = 0;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
if (vertical)
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_get_pixmaps("EPPLET_BACKGROUND_VERTICAL", "normal",
|
2006-04-15 15:04:48 -07:00
|
|
|
&win->bg_bg, &win->bg_mask, win->w, win->h);
|
1999-10-13 08:14:42 -07:00
|
|
|
else
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_imageclass_get_pixmaps("EPPLET_BACKGROUND_HORIZONTAL", "normal",
|
2006-04-15 15:04:48 -07:00
|
|
|
&win->bg_bg, &win->bg_mask, win->w, win->h);
|
2006-03-31 14:56:17 -08:00
|
|
|
win->bg_pmap = XCreatePixmap(disp, win->win, win->w, win->h, DEPTH());
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
|
2022-01-22 04:47:42 -08:00
|
|
|
gc = EXCreateGC(win->bg_pmap);
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
XCopyArea(disp, win->bg_bg, win->bg_pmap, gc, 0, 0, win->w, win->h, 0, 0);
|
|
|
|
XSetWindowBackgroundPixmap(disp, win->win, win->bg_pmap);
|
|
|
|
XShapeCombineMask(disp, win->win, ShapeBounding, 0, 0, win->bg_mask,
|
|
|
|
ShapeSet);
|
|
|
|
XClearWindow(disp, win->win);
|
Fri Dec 03 20:11:23 GMT 1999
(gilbertt)
Right. You can now specify a "vertical" property for your new window. Works
the same as the vertical parameter in Epplet_init. Uses the same
imageclasses too.
I had a big headache debugging this, it just didn't seem to work, I knew
BrushedMetal (the theme I use) had a different (green) vertical pixmap, but
the windows always came up grey. Just when I was about to go mental, I found
this in epplet.cfg:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
Gah. No wonder the images weren't changing!
Is there a reason for this? If not, could it be changed to:
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_HORIZONTAL
__NORMAL "epplets/images/bg.png"
__EDGE_SCALING 2 2 2 2
__END
__ICLASS __BGN
__NAME EPPLET_BACKGROUND_VERTICAL
__NORMAL "epplets/images/bg_v.png"
__EDGE_SCALING 2 2 2 2
__END
Please?
Anyway, the vertical stuff works now, and probably did an hour ago, before I
went off chasing nonexistant bugs :)
I also tidied up some other stuff, and killed another global :)
See E-ScreenSave in cvs for an example, press the "lock" button to see it in
action :)
SVN revision: 1486
1999-12-03 07:59:17 -08:00
|
|
|
win->win_vert = vertical;
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(gc);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
|
|
|
Epplet_gadget_destroy(Epplet_gadget gadget)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadGeneral *gg;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_gadget_hide(gadget);
|
1999-11-16 13:02:11 -08:00
|
|
|
gg = (GadGeneral *) gadget;
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_del_gad(gadget);
|
1999-11-16 13:02:11 -08:00
|
|
|
switch (gg->type)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
case E_BUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadButton *g;
|
|
|
|
|
|
|
|
g = (GadButton *) gadget;
|
|
|
|
XDestroyWindow(disp, g->win);
|
|
|
|
XDeleteContext(disp, g->win, xid_context);
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->label);
|
|
|
|
free(g->image);
|
|
|
|
free(g->std);
|
1999-11-16 13:02:11 -08:00
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_DRAWINGAREA:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadDrawingArea *g;
|
|
|
|
|
|
|
|
g = (GadDrawingArea *) gadget;
|
|
|
|
XDestroyWindow(disp, g->win);
|
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_HSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHSlider *g;
|
|
|
|
|
|
|
|
g = (GadHSlider *) gadget;
|
|
|
|
XDestroyWindow(disp, g->win);
|
|
|
|
XDestroyWindow(disp, g->win_knob);
|
|
|
|
XDeleteContext(disp, g->win, xid_context);
|
|
|
|
XDeleteContext(disp, g->win_knob, xid_context);
|
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVSlider *g;
|
|
|
|
|
|
|
|
g = (GadVSlider *) gadget;
|
|
|
|
XDestroyWindow(disp, g->win);
|
|
|
|
XDestroyWindow(disp, g->win_knob);
|
|
|
|
XDeleteContext(disp, g->win, xid_context);
|
|
|
|
XDeleteContext(disp, g->win_knob, xid_context);
|
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadToggleButton *g;
|
|
|
|
|
|
|
|
g = (GadToggleButton *) gadget;
|
|
|
|
XDestroyWindow(disp, g->win);
|
|
|
|
XDeleteContext(disp, g->win, xid_context);
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->label);
|
|
|
|
free(g->image);
|
1999-11-16 13:02:11 -08:00
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUPBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopupButton *g;
|
|
|
|
|
|
|
|
g = (GadPopupButton *) gadget;
|
|
|
|
XDestroyWindow(disp, g->win);
|
|
|
|
XDeleteContext(disp, g->win, xid_context);
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->std);
|
|
|
|
free(g->label);
|
|
|
|
free(g->image);
|
1999-11-16 13:02:11 -08:00
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUP:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopup *g;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
g = (GadPopup *) gadget;
|
|
|
|
for (i = 0; i < g->entry_num; i++)
|
|
|
|
{
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->entry[i].label);
|
|
|
|
free(g->entry[i].image);
|
1999-11-28 08:31:23 -08:00
|
|
|
if (g->entry[i].gadget)
|
|
|
|
Epplet_gadget_destroy(g->entry[i].gadget);
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->entry);
|
1999-11-16 13:02:11 -08:00
|
|
|
XDestroyWindow(disp, g->win);
|
|
|
|
XDeleteContext(disp, g->win, xid_context);
|
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_IMAGE:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadImage *g;
|
|
|
|
|
|
|
|
g = (GadImage *) gadget;
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->image);
|
1999-11-16 13:02:11 -08:00
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_LABEL:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadLabel *g;
|
|
|
|
|
|
|
|
g = (GadLabel *) gadget;
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->label);
|
1999-11-16 13:02:11 -08:00
|
|
|
free(g);
|
|
|
|
}
|
1999-11-09 10:24:35 -08:00
|
|
|
break;
|
|
|
|
case E_HBAR:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHBar *g;
|
|
|
|
|
|
|
|
g = (GadHBar *) gadget;
|
|
|
|
XDestroyWindow(disp, g->win);
|
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VBAR:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVBar *g;
|
|
|
|
|
|
|
|
g = (GadVBar *) gadget;
|
|
|
|
XDestroyWindow(disp, g->win);
|
|
|
|
free(g);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
default:
|
1999-11-16 13:02:11 -08:00
|
|
|
break;
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_gadget_hide(Epplet_gadget gadget)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadGeneral *gg;
|
|
|
|
|
|
|
|
gg = (GadGeneral *) gadget;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (!(gg->visible))
|
|
|
|
return;
|
|
|
|
gg->visible = 0;
|
1999-11-16 13:02:11 -08:00
|
|
|
switch (gg->type)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
case E_BUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadButton *g;
|
|
|
|
|
|
|
|
g = (GadButton *) gadget;
|
1999-12-27 11:55:30 -08:00
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_TEXTBOX:
|
|
|
|
{
|
|
|
|
GadTextBox *g;
|
|
|
|
|
|
|
|
g = (GadTextBox *) gadget;
|
1999-11-16 13:02:11 -08:00
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_DRAWINGAREA:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadDrawingArea *g;
|
|
|
|
|
|
|
|
g = (GadDrawingArea *) gadget;
|
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_HSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHSlider *g;
|
|
|
|
|
|
|
|
g = (GadHSlider *) gadget;
|
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
XUnmapWindow(disp, g->win_knob);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVSlider *g;
|
|
|
|
|
|
|
|
g = (GadVSlider *) gadget;
|
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
XUnmapWindow(disp, g->win_knob);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadToggleButton *g;
|
|
|
|
|
|
|
|
g = (GadToggleButton *) gadget;
|
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUPBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopupButton *g;
|
|
|
|
|
|
|
|
g = (GadPopupButton *) gadget;
|
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUP:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopup *g;
|
|
|
|
|
|
|
|
g = (GadPopup *) gadget;
|
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
if (g->popbutton)
|
|
|
|
{
|
|
|
|
((GadPopupButton *) g->popbutton)->popped = 0;
|
|
|
|
Epplet_draw_popupbutton(g->popbutton);
|
|
|
|
g->popbutton = NULL;
|
|
|
|
}
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_IMAGE:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
Epplet_draw_image(gadget, 1);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_LABEL:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
Epplet_draw_label(gadget, 1);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_HBAR:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHBar *g;
|
|
|
|
|
|
|
|
g = (GadHBar *) gadget;
|
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VBAR:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVBar *g;
|
|
|
|
|
|
|
|
g = (GadVBar *) gadget;
|
|
|
|
XUnmapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
default:
|
1999-11-16 13:02:11 -08:00
|
|
|
break;
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_gadget_show(Epplet_gadget gadget)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadGeneral *gg;
|
|
|
|
|
|
|
|
gg = (GadGeneral *) gadget;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (gg->visible)
|
|
|
|
return;
|
|
|
|
gg->visible = 1;
|
Wed Apr 26 20:06:43 PDT 2000
(KainX)
First off, I altered the API library so that images would be properly scaled
before being drawn, rather than just assuming that the image size was okay. I
also added a function, Epplet_add_sized_popup_entry(), to allow for image
buttons with scaled images in a popup. Added popup support to E-Toolbox as
well. You can now have buttons that popup other buttons, and those other
buttons can have images or labels. So can the popup button itself, and the
popup button can be a "standard" button too. (The only caviat is that the
popup button must come before any of the buttons in the menu that it pops up;
no biggie.)
I've included a sample config file to demonstrate this. popup-sample.cfg
shows a single 1x1 up-arrow button which pops up several other buttons. Nice
and small; stays out of your way until you need it. :-)
I had to fix several issues with the epplet library to make some of this stuff
work, but nothing that violates the spirit of epplets. For example,
Epplet_gadget_show() now delays the actual drawing of the epplet gadgets until
the epplet itself is unhidden. And the image button sizing bug with the popup
stuff is fixed. Stuff like that. =)
I'm going to try to add a GUI configuration interface, as well as come up with
some more sophisticated sample configs. Just give me time.
Also, if you have a toolbox icon (preferably rendered) or can make one, please
let me know. E-Toolbox needs an icon. :-)
SVN revision: 2558
2000-04-26 22:25:45 -07:00
|
|
|
if (!epplet_visible)
|
|
|
|
return;
|
1999-11-16 13:02:11 -08:00
|
|
|
switch (gg->type)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
case E_BUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadButton *g;
|
|
|
|
|
|
|
|
g = (GadButton *) gadget;
|
|
|
|
Epplet_draw_button(gadget);
|
|
|
|
XMapWindow(disp, g->win);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_TEXTBOX:
|
|
|
|
{
|
|
|
|
GadTextBox *g;
|
|
|
|
|
|
|
|
g = (GadTextBox *) gadget;
|
|
|
|
Epplet_draw_textbox(gadget);
|
|
|
|
XMapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_DRAWINGAREA:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadDrawingArea *g;
|
|
|
|
|
|
|
|
g = (GadDrawingArea *) gadget;
|
|
|
|
Epplet_draw_drawingarea(gadget);
|
|
|
|
XMapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_HSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHSlider *g;
|
|
|
|
|
|
|
|
g = (GadHSlider *) gadget;
|
|
|
|
Epplet_draw_hslider(gadget);
|
|
|
|
XMapWindow(disp, g->win);
|
|
|
|
XMapRaised(disp, g->win_knob);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVSlider *g;
|
|
|
|
|
|
|
|
g = (GadVSlider *) gadget;
|
|
|
|
Epplet_draw_vslider(gadget);
|
|
|
|
XMapWindow(disp, g->win);
|
|
|
|
XMapRaised(disp, g->win_knob);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadToggleButton *g;
|
|
|
|
|
|
|
|
g = (GadToggleButton *) gadget;
|
|
|
|
Epplet_draw_togglebutton(gadget);
|
|
|
|
XMapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUPBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopupButton *g;
|
|
|
|
|
|
|
|
g = (GadPopupButton *) gadget;
|
|
|
|
Epplet_draw_popupbutton(gadget);
|
|
|
|
XMapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_POPUP:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadPopup *g;
|
|
|
|
|
|
|
|
g = (GadPopup *) gadget;
|
|
|
|
Epplet_popup_arrange_contents(gadget);
|
|
|
|
Epplet_draw_popup(gadget);
|
|
|
|
XMapRaised(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_IMAGE:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
Epplet_draw_image(gadget, 0);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_LABEL:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
Epplet_draw_label(gadget, 0);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_HBAR:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadHBar *g;
|
|
|
|
|
|
|
|
g = (GadHBar *) gadget;
|
|
|
|
Epplet_draw_hbar(gadget);
|
|
|
|
XMapWindow(disp, g->win);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VBAR:
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
GadVBar *g;
|
|
|
|
|
|
|
|
g = (GadVBar *) gadget;
|
|
|
|
Epplet_draw_vbar(gadget);
|
|
|
|
XMapWindow(disp, g->win);
|
|
|
|
}
|
1999-11-09 10:24:35 -08:00
|
|
|
break;
|
1999-10-28 16:30:09 -07:00
|
|
|
default:
|
1999-11-16 13:02:11 -08:00
|
|
|
break;
|
1999-10-28 16:30:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-16 13:17:27 -08:00
|
|
|
void
|
|
|
|
Epplet_gadget_move(Epplet_gadget gadget, int x, int y)
|
|
|
|
{
|
2000-01-14 18:30:43 -08:00
|
|
|
GadImage *g; /* Image is the lowest common denominator, sorta. */
|
1999-12-16 13:17:27 -08:00
|
|
|
|
|
|
|
g = (GadImage *) gadget;
|
|
|
|
Epplet_gadget_draw(gadget, 1, 0);
|
|
|
|
g->x = x;
|
|
|
|
g->y = y;
|
|
|
|
if (g->win != None)
|
|
|
|
{
|
2000-01-14 18:30:43 -08:00
|
|
|
XMoveWindow(disp, g->win, x, y);
|
1999-12-16 13:17:27 -08:00
|
|
|
}
|
|
|
|
Epplet_gadget_draw(gadget, 0, 0);
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void *
|
|
|
|
Epplet_gadget_get_data(Epplet_gadget gadget)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
if (!gadget)
|
|
|
|
return NULL;
|
1999-11-09 10:24:35 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
switch (((GadGeneral *) gadget)->type)
|
1999-11-09 11:02:15 -08:00
|
|
|
{
|
|
|
|
case E_BUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
return ((GadButton *) gadget)->data;
|
1999-11-09 11:02:15 -08:00
|
|
|
case E_TOGGLEBUTTON:
|
1999-11-16 13:02:11 -08:00
|
|
|
return ((GadToggleButton *) gadget)->data;
|
1999-11-09 11:02:15 -08:00
|
|
|
case E_HSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
return ((GadHSlider *) gadget)->data;
|
1999-11-09 11:02:15 -08:00
|
|
|
case E_VSLIDER:
|
1999-11-16 13:02:11 -08:00
|
|
|
return ((GadVSlider *) gadget)->data;
|
1999-11-09 11:02:15 -08:00
|
|
|
default:
|
1999-11-16 13:02:11 -08:00
|
|
|
return NULL;
|
1999-11-09 11:02:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
1999-11-09 11:02:15 -08:00
|
|
|
Epplet_gadget_data_changed(Epplet_gadget gadget)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadGeneral *gg;
|
|
|
|
|
|
|
|
gg = (GadGeneral *) gadget;
|
1999-10-13 08:14:42 -07:00
|
|
|
if (!gg->visible)
|
|
|
|
return;
|
2013-07-13 12:07:12 -07:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
switch (gg->type)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
case E_HSLIDER:
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_draw_hslider(gadget);
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_draw_vslider(gadget);
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_draw_togglebutton(gadget);
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_IMAGE:
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_draw_image(gadget, 0);
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_LABEL:
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_draw_label(gadget, 0);
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_HBAR:
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_draw_hbar(gadget);
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
case E_VBAR:
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_draw_vbar(gadget);
|
1999-10-13 08:14:42 -07:00
|
|
|
break;
|
|
|
|
default:
|
1999-11-16 13:02:11 -08:00
|
|
|
break;
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-16 13:17:27 -08:00
|
|
|
void
|
|
|
|
Epplet_gadget_draw(Epplet_gadget g, int un_only, int force)
|
|
|
|
{
|
2000-01-14 18:30:43 -08:00
|
|
|
GadGeneral *gg = (GadGeneral *) g;
|
|
|
|
|
|
|
|
if (gg->visible || force)
|
|
|
|
{
|
|
|
|
switch (gg->type)
|
|
|
|
{
|
|
|
|
case E_BUTTON:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_button(g);
|
|
|
|
break;
|
|
|
|
case E_TEXTBOX:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_textbox(g);
|
|
|
|
break;
|
|
|
|
case E_DRAWINGAREA:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_drawingarea(g);
|
|
|
|
break;
|
|
|
|
case E_HSLIDER:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_hslider(g);
|
|
|
|
break;
|
|
|
|
case E_VSLIDER:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_vslider(g);
|
|
|
|
break;
|
|
|
|
case E_TOGGLEBUTTON:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_togglebutton(g);
|
|
|
|
break;
|
|
|
|
case E_POPUPBUTTON:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_popupbutton(g);
|
|
|
|
break;
|
|
|
|
case E_POPUP:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_popup(g);
|
|
|
|
break;
|
|
|
|
case E_IMAGE:
|
|
|
|
Epplet_draw_image(g, un_only);
|
|
|
|
break;
|
|
|
|
case E_LABEL:
|
|
|
|
Epplet_draw_label(g, un_only);
|
|
|
|
break;
|
|
|
|
case E_HBAR:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_hbar(g);
|
|
|
|
break;
|
|
|
|
case E_VBAR:
|
|
|
|
if (!un_only)
|
|
|
|
Epplet_draw_vbar(g);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-12-16 13:17:27 -08:00
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_redraw(void)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int i;
|
2006-04-15 15:04:48 -07:00
|
|
|
GadGeneral *gg;
|
1999-10-13 08:14:42 -07:00
|
|
|
|
Thu Dec 02 23:07:45 GMT 1999
(gilbertt)
Ok. More config window stuff.
Fun fun. I had to create a new type, Epplet_window to hold some window info,
and a stack to push and pop contexts for adding gadgets to different new
windows. This stuff works real well, and I am chuffed with it :)
The extra windows now redraw themselves on exposes, and new gadgets can be
added to them successfully. W00p.
I had to implement some new stuff, so please check nothing is broke (I am
not finished, but I don't want to commit code that breaks stuff).
Here are some details on the new stuff :)
---------------
PUBLIC STUFF
typedef struct epplet_window
{
Window win;
int w;
int h;
Pixmap bg_pmap;
Pixmap bg_mask;
Pixmap bg_bg;
}EppWindow;
typedef EppWindow *Epplet_window;
Epplet_window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Epplet_window win);
void Epplet_window_hide(Epplet_window win);
void Epplet_window_destroy(Epplet_window win);
void Epplet_window_push_context(Epplet_window newwin);
Epplet_window Epplet_window_pop_context(void);
---------------
PRIVATE STUFF
static Epplet_window context_win; /* Current context win */
static int window_stack_pos; /* For context changes */
static Epplet_window window_stack[20]; /* For context changes */
static Epplet_window mainwin; /* Always the main epplet window */
static int window_num = 0; /* For window list */
static Epplet_window *windows = NULL; /* List of windows to loop though */
/* For Keeping a list of windows owned by the epplet, to loop through and
* do stuff with. */
static void Epplet_register_window(Epplet_window win);
static void Epplet_unregister_window(Epplet_window win);
/* Redraw all epplet windows (excluding the main epplet window) */
static void Epplet_draw_windows(void);
/* Redraw window win */
static void Epplet_draw_window(Epplet_window win);
/* Refresh window backgrounds on theme change */
static void Epplet_refresh_backgrounds(void);
-------------
I also added an item to GadGeneral so that I can find what window a gadget
was created on:
typedef struct gad_general
{
GadType type;
char visible;
Epplet_window parent;
}
GadGeneral;
-------------
Not to mention the reworking of code which draws or handles windows.
I have more tinkering to do in the event handling, to catch delete_events,
and to filter out mouseovers etc for separate windows. Tomorrow :)
SVN revision: 1478
1999-12-02 11:08:48 -08:00
|
|
|
Epplet_refresh_backgrounds();
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
for (i = 0; i < gad_num; i++)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
gg = (GadGeneral *) gads[i];
|
|
|
|
if (gg->visible)
|
|
|
|
{
|
|
|
|
gg->visible = 0;
|
|
|
|
Epplet_gadget_show(gads[i]);
|
|
|
|
}
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
|
|
|
Esync(void)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
|
|
|
XSync(disp, False);
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
|
|
|
Epplet_draw_line(Window win, int x1, int y1, int x2, int y2,
|
|
|
|
int r, int g, int b)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
static int cr = -1, cg = -1, cb = -1;
|
2022-01-22 04:47:42 -08:00
|
|
|
GC gc;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2022-01-22 04:47:42 -08:00
|
|
|
gc = EXCreateGC(win);
|
1999-10-13 08:14:42 -07:00
|
|
|
if ((cr != r) || (cg != g) || (cb != b))
|
1999-11-16 13:02:11 -08:00
|
|
|
XSetForeground(disp, gc, Epplet_get_color(r, g, b));
|
|
|
|
XDrawLine(disp, win, gc, x1, y1, x2, y2);
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(gc);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
|
|
|
Epplet_draw_box(Window win, int x, int y, int w, int h, int r, int g, int b)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
static int cr = -1, cg = -1, cb = -1;
|
2022-01-22 04:47:42 -08:00
|
|
|
GC gc;
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
if ((w <= 0) || (h <= 0))
|
|
|
|
return;
|
2022-01-22 04:47:42 -08:00
|
|
|
gc = EXCreateGC(win);
|
1999-10-13 08:14:42 -07:00
|
|
|
if ((cr != r) || (cg != g) || (cb != b))
|
1999-11-16 13:02:11 -08:00
|
|
|
XSetForeground(disp, gc, Epplet_get_color(r, g, b));
|
1999-10-13 08:14:42 -07:00
|
|
|
XFillRectangle(disp, win, gc, x, y, (unsigned int)w, (unsigned int)h);
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(gc);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
|
|
|
Epplet_draw_outline(Window win, int x, int y, int w, int h, int r, int g, int b)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
static int cr = -1, cg = -1, cb = -1;
|
2022-01-22 04:47:42 -08:00
|
|
|
GC gc;
|
1999-10-13 08:14:42 -07:00
|
|
|
|
|
|
|
if ((w <= 0) || (h <= 0))
|
|
|
|
return;
|
2022-01-22 04:47:42 -08:00
|
|
|
gc = EXCreateGC(win);
|
1999-10-13 08:14:42 -07:00
|
|
|
if ((cr != r) || (cg != g) || (cb != b))
|
1999-11-16 13:02:11 -08:00
|
|
|
XSetForeground(disp, gc, Epplet_get_color(r, g, b));
|
|
|
|
XDrawRectangle(disp, win, gc, x, y, (unsigned int)(w - 1),
|
1999-10-13 08:14:42 -07:00
|
|
|
(unsigned int)(h - 1));
|
2022-01-22 04:47:42 -08:00
|
|
|
EXFreeGC(gc);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
RGB_buf
|
|
|
|
Epplet_make_rgb_buf(int w, int h)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
RGB_buf buf;
|
|
|
|
|
1999-10-13 08:14:42 -07:00
|
|
|
buf = malloc(sizeof(RGB_buf));
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2006-03-31 14:56:17 -08:00
|
|
|
buf->im = imlib_create_image(w, h);
|
1999-10-13 08:14:42 -07:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
unsigned char *
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_get_rgb_pointer(RGB_buf buf)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_image(buf->im);
|
2006-04-15 15:04:48 -07:00
|
|
|
return (unsigned char *)imlib_image_get_data(); /* Readonly? */
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
1999-10-13 08:14:42 -07:00
|
|
|
Epplet_paste_buf(RGB_buf buf, Window win, int x, int y)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_image(buf->im);
|
|
|
|
imlib_context_set_drawable(win);
|
|
|
|
imlib_render_image_on_drawable(x, y);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-12-20 07:41:23 -08:00
|
|
|
void
|
|
|
|
Epplet_free_rgb_buf(RGB_buf buf)
|
|
|
|
{
|
2000-01-14 18:30:43 -08:00
|
|
|
if (buf)
|
|
|
|
{
|
|
|
|
if (buf->im)
|
|
|
|
{
|
2006-03-31 14:56:17 -08:00
|
|
|
imlib_context_set_image(buf->im);
|
|
|
|
imlib_free_image();
|
2000-01-14 18:30:43 -08:00
|
|
|
}
|
|
|
|
free(buf);
|
|
|
|
}
|
1999-12-20 07:41:23 -08:00
|
|
|
}
|
|
|
|
|
1999-10-13 10:34:12 -07:00
|
|
|
static void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_handle_child(int num __UNUSED__)
|
1999-10-13 10:34:12 -07:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
pid_t pid;
|
1999-11-16 13:02:11 -08:00
|
|
|
|
1999-10-13 10:34:12 -07:00
|
|
|
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
|
|
|
|
{
|
|
|
|
if (WIFEXITED(status))
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int code;
|
|
|
|
|
1999-10-13 10:34:12 -07:00
|
|
|
code = WEXITSTATUS(status);
|
|
|
|
if (child_func)
|
|
|
|
(*child_func) (child_data, pid, code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-09 11:02:15 -08:00
|
|
|
int
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_run_command(const char *cmd)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-09 11:02:15 -08:00
|
|
|
return system(cmd);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *
|
|
|
|
Epplet_read_run_command(const char *cmd)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
2013-07-13 12:07:12 -07:00
|
|
|
return cmd;
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_spawn_command(const char *cmd)
|
1999-10-13 08:14:42 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
pid_t pid;
|
|
|
|
|
1999-10-13 10:34:12 -07:00
|
|
|
pid = fork();
|
|
|
|
if (pid)
|
|
|
|
return (int)pid;
|
|
|
|
execl("/bin/sh", "/bin/sh", "-c", cmd, NULL);
|
|
|
|
exit(0);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_pause_spawned_command(int pid)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
kill((pid_t) pid, SIGSTOP);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_unpause_spawned_command(int pid)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
kill((pid_t) pid, SIGCONT);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_kill_spawned_command(int pid)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
kill((pid_t) pid, SIGINT);
|
1999-10-13 10:34:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Epplet_destroy_spawned_command(int pid)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
kill((pid_t) pid, SIGKILL);
|
1999-10-13 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
1999-10-13 10:34:12 -07:00
|
|
|
void
|
1999-11-16 13:02:11 -08:00
|
|
|
Epplet_register_child_handler(void (*func)
|
2006-04-15 15:04:48 -07:00
|
|
|
(void *data, int pid, int exit_code), void *data)
|
1999-10-13 10:34:12 -07:00
|
|
|
{
|
|
|
|
child_data = data;
|
|
|
|
child_func = func;
|
|
|
|
}
|
1999-10-13 11:14:19 -07:00
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_change_button_label(Epplet_gadget gadget, const char *label)
|
1999-10-13 11:14:19 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadButton *g;
|
|
|
|
GadGeneral *gg;
|
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_BUTTON);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadButton *) gadget;
|
|
|
|
gg = (GadGeneral *) gadget;
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->label);
|
1999-10-13 11:14:19 -07:00
|
|
|
g->label = Estrdup(label);
|
|
|
|
if (gg->visible)
|
|
|
|
Epplet_draw_button(gadget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_change_button_image(Epplet_gadget gadget, const char *image)
|
1999-10-13 11:14:19 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadButton *g;
|
|
|
|
GadGeneral *gg;
|
1999-10-13 11:14:19 -07:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE(gadget, E_BUTTON);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadButton *) gadget;
|
|
|
|
gg = (GadGeneral *) gadget;
|
2021-09-01 10:53:39 -07:00
|
|
|
free(g->image);
|
2006-04-13 01:26:31 -07:00
|
|
|
g->image = Epplet_find_file(image);
|
1999-10-13 11:14:19 -07:00
|
|
|
if (gg->visible)
|
|
|
|
Epplet_draw_button(gadget);
|
|
|
|
}
|
1999-10-13 12:04:05 -07:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
void
|
1999-10-13 12:04:05 -07:00
|
|
|
Epplet_clear_window(Window ww)
|
|
|
|
{
|
|
|
|
XClearWindow(disp, ww);
|
|
|
|
}
|
1999-10-13 14:13:40 -07:00
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_show_about(const char *name __UNUSED__)
|
1999-10-13 14:13:40 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
char s[1024];
|
|
|
|
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "edox %s/ABOUT", Epplet_data_dir());
|
1999-10-13 14:13:40 -07:00
|
|
|
Epplet_spawn_command(s);
|
|
|
|
}
|
1999-10-13 15:31:43 -07:00
|
|
|
|
|
|
|
void
|
2018-08-12 09:16:03 -07:00
|
|
|
Epplet_dialog_ok(const char *fmt, ...)
|
1999-10-13 15:31:43 -07:00
|
|
|
{
|
2018-08-12 09:16:03 -07:00
|
|
|
va_list args;
|
2022-03-09 22:19:37 -08:00
|
|
|
char buf[1000];
|
2018-08-12 09:16:03 -07:00
|
|
|
|
|
|
|
va_start(args, fmt);
|
2021-08-30 22:38:38 -07:00
|
|
|
vsnprintf(buf, sizeof(buf), fmt, args);
|
2018-08-12 09:16:03 -07:00
|
|
|
va_end(args);
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2009-01-01 12:42:28 -08:00
|
|
|
if (!dd)
|
|
|
|
{
|
2018-08-12 09:16:03 -07:00
|
|
|
printf("*** %s\n", buf);
|
2009-01-01 12:42:28 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-09 22:19:37 -08:00
|
|
|
Epplet_send_ipc("dialog_ok %s", buf);
|
1999-10-13 15:31:43 -07:00
|
|
|
}
|
1999-10-18 08:04:54 -07:00
|
|
|
|
1999-10-22 15:09:18 -07:00
|
|
|
static void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_find_instance(const char *name)
|
1999-10-22 09:43:22 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
struct stat st;
|
2006-02-05 01:27:03 -08:00
|
|
|
struct flock fl;
|
2006-04-12 12:22:45 -07:00
|
|
|
char s[1024];
|
2006-02-05 01:27:03 -08:00
|
|
|
int i, fd, err, exists, locked;
|
1999-11-16 13:02:11 -08:00
|
|
|
pid_t pid;
|
1999-10-22 09:43:22 -07:00
|
|
|
|
2006-04-12 12:22:45 -07:00
|
|
|
/* Set epplet data dir */
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), ENLIGHTENMENT_ROOT "/epplet_data/%s", name);
|
2006-04-12 12:22:45 -07:00
|
|
|
data_dir = Estrdup(s);
|
|
|
|
|
2005-02-10 20:29:17 -08:00
|
|
|
/* Find E dir */
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s/.e16", getenv("HOME"));
|
2005-02-10 20:29:17 -08:00
|
|
|
if (stat(s, &st) < 0)
|
|
|
|
{
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s/.enlightenment", getenv("HOME"));
|
2006-04-15 15:04:48 -07:00
|
|
|
if (stat(s, &st) < 0)
|
|
|
|
{
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s/.enlightenment", getenv("HOME"));
|
2006-04-15 15:04:48 -07:00
|
|
|
mkdir(s, S_IRWXU);
|
|
|
|
}
|
2005-02-10 20:29:17 -08:00
|
|
|
}
|
2006-04-12 12:22:45 -07:00
|
|
|
e16_user_dir = strdup(s);
|
2005-02-10 20:29:17 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
/* make sure basic dir exists */
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s/epplet_config", Epplet_e16_user_dir());
|
1999-11-16 13:02:11 -08:00
|
|
|
if (stat(s, &st) < 0)
|
|
|
|
{
|
|
|
|
if (mkdir(s, S_IRWXU) < 0)
|
|
|
|
{
|
2018-08-12 09:16:03 -07:00
|
|
|
Epplet_dialog_ok
|
|
|
|
("Unable to create epplet config directory %s -- %s.\n",
|
|
|
|
s, strerror(errno));
|
1999-11-16 13:02:11 -08:00
|
|
|
epplet_instance = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-10 20:29:17 -08:00
|
|
|
/* make sure this epplet's config dir exists */
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s/epplet_config/%s", Epplet_e16_user_dir(), name);
|
1999-11-16 13:02:11 -08:00
|
|
|
conf_dir = strdup(s);
|
2005-02-10 20:29:17 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
if (stat(s, &st) < 0)
|
|
|
|
{
|
|
|
|
if (mkdir(s, S_IRWXU) < 0)
|
|
|
|
{
|
2018-08-12 09:16:03 -07:00
|
|
|
Epplet_dialog_ok
|
|
|
|
("Unable to create epplet config directory %s -- %s.\n",
|
|
|
|
s, strerror(errno));
|
1999-11-16 13:02:11 -08:00
|
|
|
epplet_instance = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pick our instance number. 255 is the max to avoid infinite loops, which could be caused by
|
|
|
|
* lack of insert permissions in the config directory. */
|
2006-02-05 01:27:03 -08:00
|
|
|
fl.l_type = F_WRLCK;
|
|
|
|
fl.l_whence = SEEK_SET;
|
|
|
|
fl.l_start = fl.l_len = 0;
|
|
|
|
locked = 0;
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
for (i = 1; i < 256; i++)
|
|
|
|
{
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s/.lock_%i", conf_dir, i);
|
2006-02-05 01:27:03 -08:00
|
|
|
|
|
|
|
exists = stat(s, &st) == 0;
|
|
|
|
|
|
|
|
if (exists)
|
|
|
|
fd = open(s, (O_RDWR | O_CREAT), 0600);
|
|
|
|
else
|
|
|
|
fd = open(s, (O_WRONLY | O_EXCL | O_CREAT), 0600);
|
|
|
|
if (fd < 0)
|
|
|
|
continue;
|
|
|
|
for (;;)
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
2006-02-05 01:27:03 -08:00
|
|
|
err = fcntl(fd, F_SETLK, &fl);
|
2007-11-11 09:56:29 -08:00
|
|
|
if (err == 0 || errno != EINTR)
|
2006-04-15 15:04:48 -07:00
|
|
|
break;
|
2006-02-05 01:27:03 -08:00
|
|
|
}
|
|
|
|
if (err == 0)
|
|
|
|
{
|
|
|
|
/* Locking succeeded, file is open for writing */
|
|
|
|
locked = 1;
|
|
|
|
break;
|
|
|
|
}
|
2007-11-11 09:56:29 -08:00
|
|
|
if (errno == EACCES || errno == EAGAIN)
|
|
|
|
{
|
|
|
|
/* Locking failed due to held lock */
|
|
|
|
continue;
|
|
|
|
}
|
2006-02-05 01:27:03 -08:00
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
{
|
|
|
|
/* Locking failed, but file was successfully created with O_EXCL */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check pid */
|
|
|
|
if ((read(fd, &pid, sizeof(pid_t))) < ((int)sizeof(pid_t)))
|
|
|
|
{
|
|
|
|
/* We didn't get enough bytes. Next! */
|
|
|
|
fprintf(stderr,
|
2006-04-15 15:04:48 -07:00
|
|
|
"Read attempt for lock file %s failed -- %s\n", s,
|
|
|
|
strerror(errno));
|
1999-11-16 13:02:11 -08:00
|
|
|
close(fd);
|
2006-02-05 01:27:03 -08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
if (pid <= 0)
|
|
|
|
{
|
|
|
|
/* We got a bogus process ID. Next! */
|
|
|
|
fprintf(stderr,
|
|
|
|
"Lock file %s contained a bogus process ID (%lu)\n",
|
|
|
|
s, (unsigned long)pid);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((kill(pid, 0) == 0) || (errno != ESRCH))
|
|
|
|
{
|
|
|
|
/* The process exists. Next! */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* Okay, looks like a stale lockfile at this point. Remove it. */
|
|
|
|
if ((unlink(s)) != 0)
|
|
|
|
{
|
|
|
|
/* Removal failed. Next! */
|
|
|
|
fprintf(stderr,
|
|
|
|
"Unable to remove stale lock file %s -- %s. Please remove it manually.\n",
|
|
|
|
s, strerror(errno));
|
|
|
|
continue;
|
1999-11-16 13:02:11 -08:00
|
|
|
}
|
2006-02-05 01:27:03 -08:00
|
|
|
|
2000-09-07 17:57:26 -07:00
|
|
|
srand(getpid());
|
|
|
|
usleep((rand() & 0xfffff));
|
1999-11-16 13:02:11 -08:00
|
|
|
if ((fd = open(s, (O_WRONLY | O_EXCL | O_CREAT), 0600)) < 0)
|
|
|
|
{
|
|
|
|
/* Apparently another process just came in under us and created it. Next! */
|
|
|
|
continue;
|
|
|
|
}
|
2006-02-05 01:27:03 -08:00
|
|
|
/* If we made it here, we've just created the lock file. We have our instance
|
1999-11-16 13:02:11 -08:00
|
|
|
* number, so exit the loop. */
|
|
|
|
break;
|
|
|
|
}
|
2003-11-24 06:59:02 -08:00
|
|
|
|
2006-02-05 01:27:03 -08:00
|
|
|
if (i < 256)
|
|
|
|
{
|
|
|
|
pid = getpid();
|
2006-04-15 15:04:48 -07:00
|
|
|
write(fd, &pid, sizeof(pid_t)); /* Not sure how best to deal with write errors here */
|
2006-02-05 01:27:03 -08:00
|
|
|
/* If locked do not close fd, otherwise lock is lost */
|
|
|
|
if (!locked)
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
else
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
i = 1;
|
|
|
|
}
|
|
|
|
epplet_instance = i;
|
|
|
|
|
|
|
|
/* find out epplet's name */
|
|
|
|
if (epplet_instance > 1)
|
|
|
|
{
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(s, sizeof(s), "%s-%i", name, epplet_instance);
|
1999-11-16 13:02:11 -08:00
|
|
|
epplet_name = strdup(s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
epplet_name = strdup(name);
|
1999-10-22 15:09:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Epplet_get_instance(void)
|
|
|
|
{
|
|
|
|
return epplet_instance;
|
|
|
|
}
|
|
|
|
|
2006-04-12 12:22:45 -07:00
|
|
|
const char *
|
|
|
|
Epplet_data_dir(void)
|
|
|
|
{
|
|
|
|
return data_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
Epplet_e16_user_dir(void)
|
|
|
|
{
|
|
|
|
return e16_user_dir;
|
|
|
|
}
|
|
|
|
|
1999-10-22 16:12:12 -07:00
|
|
|
void
|
2000-04-30 16:19:22 -07:00
|
|
|
Epplet_load_config_file(const char *file)
|
1999-10-22 15:09:18 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
char s[1024], s2[1024], s3[1024];
|
|
|
|
FILE *f = NULL;
|
|
|
|
|
2006-04-15 15:04:48 -07:00
|
|
|
if (config_dict)
|
2022-01-18 05:01:20 -08:00
|
|
|
Epplet_clear_config();
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2022-01-18 05:01:20 -08:00
|
|
|
config_dict = calloc(1, sizeof(ConfigDict));
|
2000-04-30 16:19:22 -07:00
|
|
|
config_dict->entries = malloc(sizeof(ConfigItem));
|
1999-11-16 13:02:11 -08:00
|
|
|
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!(f = fopen(file, "r")))
|
1999-11-16 13:02:11 -08:00
|
|
|
return;
|
2022-01-18 05:01:20 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
for (; fgets(s, sizeof(s), f);)
|
|
|
|
{
|
2010-04-30 07:04:50 -07:00
|
|
|
s2[0] = s3[0] = '\0';
|
|
|
|
sscanf(s, "%s %[^\n]\n", s2, s3);
|
1999-11-16 13:02:11 -08:00
|
|
|
if (!(*s2) || (!*s3) || (*s2 == '\n') || (*s2 == '#'))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Epplet_add_config(s2, s3);
|
|
|
|
}
|
2022-01-18 05:01:20 -08:00
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
fclose(f);
|
1999-10-22 09:43:22 -07:00
|
|
|
}
|
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
void
|
|
|
|
Epplet_load_config(void)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
char s[1024];
|
2000-04-30 16:19:22 -07:00
|
|
|
|
|
|
|
/* If they haven't initialized, abort */
|
|
|
|
if (epplet_instance == 0)
|
|
|
|
return;
|
|
|
|
|
2021-08-27 08:05:39 -07:00
|
|
|
if (!epplet_cfg_file)
|
|
|
|
{
|
|
|
|
/* create config file name */
|
|
|
|
snprintf(s, sizeof(s), "%s/%s.cfg", conf_dir, epplet_name);
|
|
|
|
epplet_cfg_file = strdup(s);
|
|
|
|
}
|
2000-04-30 16:19:22 -07:00
|
|
|
Epplet_load_config_file(epplet_cfg_file);
|
|
|
|
}
|
|
|
|
|
1999-10-22 09:43:22 -07:00
|
|
|
void
|
1999-10-22 15:09:18 -07:00
|
|
|
Epplet_save_config(void)
|
1999-10-18 08:50:58 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
FILE *f;
|
|
|
|
int i;
|
1999-10-22 09:43:22 -07:00
|
|
|
|
1999-10-26 08:48:35 -07:00
|
|
|
if (!(config_dict) || (config_dict->num_entries <= 0))
|
1999-11-16 13:02:11 -08:00
|
|
|
return;
|
1999-10-26 08:48:35 -07:00
|
|
|
|
|
|
|
if (!(f = fopen(epplet_cfg_file, "w")))
|
1999-10-22 15:09:18 -07:00
|
|
|
{
|
2018-08-12 09:16:03 -07:00
|
|
|
Epplet_dialog_ok("Unable to write to config file %s -- %s.\n",
|
|
|
|
epplet_cfg_file, strerror(errno));
|
1999-11-16 13:02:11 -08:00
|
|
|
return;
|
1999-10-26 08:48:35 -07:00
|
|
|
}
|
1999-11-16 13:02:11 -08:00
|
|
|
fprintf(f, "### Automatically generated Epplet config file for %s.\n\n",
|
|
|
|
epplet_name);
|
1999-10-26 08:48:35 -07:00
|
|
|
for (i = 0; i < config_dict->num_entries; i++)
|
|
|
|
{
|
2000-04-30 23:42:42 -07:00
|
|
|
if (config_dict->entries[i].key && *(config_dict->entries[i].value))
|
1999-11-16 13:02:11 -08:00
|
|
|
{
|
|
|
|
fprintf(f, "%s %s\n", config_dict->entries[i].key,
|
|
|
|
config_dict->entries[i].value);
|
|
|
|
}
|
1999-10-18 08:50:58 -07:00
|
|
|
}
|
1999-10-26 08:48:35 -07:00
|
|
|
fclose(f);
|
1999-10-18 08:50:58 -07:00
|
|
|
}
|
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
void
|
|
|
|
Epplet_clear_config(void)
|
|
|
|
{
|
2006-04-15 15:04:48 -07:00
|
|
|
int i;
|
|
|
|
ConfigItem *ci;
|
2000-04-30 16:19:22 -07:00
|
|
|
|
|
|
|
for (i = 0; i < config_dict->num_entries; i++)
|
|
|
|
{
|
|
|
|
ci = &(config_dict->entries[i]);
|
2021-09-01 10:53:39 -07:00
|
|
|
free(ci->key);
|
|
|
|
free(ci->value);
|
2000-04-30 16:19:22 -07:00
|
|
|
}
|
|
|
|
free(config_dict->entries);
|
|
|
|
free(config_dict);
|
|
|
|
config_dict = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_add_config(const char *key, const char *value)
|
2000-04-30 16:19:22 -07:00
|
|
|
{
|
|
|
|
if (!key)
|
|
|
|
return;
|
2022-01-18 05:01:20 -08:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
if (!config_dict)
|
|
|
|
{
|
2022-01-18 05:01:20 -08:00
|
|
|
config_dict = calloc(1, sizeof(ConfigDict));
|
2000-04-30 16:19:22 -07:00
|
|
|
config_dict->entries = malloc(sizeof(ConfigItem));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
config_dict->entries =
|
|
|
|
realloc(config_dict->entries,
|
|
|
|
sizeof(ConfigItem) * (config_dict->num_entries + 1));
|
|
|
|
}
|
2022-01-18 05:01:20 -08:00
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
config_dict->entries[config_dict->num_entries].key = strdup(key);
|
|
|
|
config_dict->entries[config_dict->num_entries].value =
|
|
|
|
(value ? strdup(value) : strdup(""));
|
|
|
|
config_dict->num_entries++;
|
|
|
|
}
|
|
|
|
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *
|
|
|
|
Epplet_query_config(const char *key)
|
1999-10-18 08:50:58 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int i;
|
|
|
|
ConfigItem *ci;
|
1999-10-18 08:50:58 -07:00
|
|
|
|
1999-12-08 10:35:38 -08:00
|
|
|
if (!key)
|
2013-07-13 12:07:12 -07:00
|
|
|
return NULL;
|
1999-11-16 13:02:11 -08:00
|
|
|
for (i = 0; i < config_dict->num_entries; i++)
|
|
|
|
{
|
|
|
|
ci = &(config_dict->entries[i]);
|
|
|
|
if ((ci->key) && !strcmp(key, ci->key))
|
|
|
|
/* we've found the key */
|
|
|
|
return (ci->value);
|
|
|
|
}
|
2013-07-13 12:07:12 -07:00
|
|
|
return NULL;
|
1999-10-18 08:50:58 -07:00
|
|
|
}
|
|
|
|
|
2013-07-13 12:07:12 -07:00
|
|
|
const char *
|
|
|
|
Epplet_query_config_def(const char *key, const char *def)
|
1999-10-24 06:10:22 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int i;
|
|
|
|
ConfigItem *ci;
|
1999-10-24 06:10:22 -07:00
|
|
|
|
1999-12-08 10:35:38 -08:00
|
|
|
if (!key)
|
2013-07-13 12:07:12 -07:00
|
|
|
return def;
|
1999-11-16 13:02:11 -08:00
|
|
|
for (i = 0; i < config_dict->num_entries; i++)
|
|
|
|
{
|
|
|
|
ci = &(config_dict->entries[i]);
|
|
|
|
if ((ci->key) && !strcmp(key, ci->key))
|
|
|
|
/* we've found the key */
|
|
|
|
return (ci->value);
|
|
|
|
}
|
|
|
|
Epplet_add_config(key, def); /* Not found. Add the default. */
|
2013-07-13 12:07:12 -07:00
|
|
|
return def;
|
1999-10-24 06:10:22 -07:00
|
|
|
}
|
|
|
|
|
1999-10-22 09:43:22 -07:00
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_modify_config(const char *key, const char *value)
|
1999-10-22 09:43:22 -07:00
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
int i;
|
|
|
|
ConfigItem *ci;
|
|
|
|
|
1999-12-08 10:35:38 -08:00
|
|
|
if (!key)
|
|
|
|
return;
|
1999-11-16 13:02:11 -08:00
|
|
|
for (i = 0; i < config_dict->num_entries; i++)
|
|
|
|
{
|
|
|
|
ci = &(config_dict->entries[i]);
|
|
|
|
if ((ci->key) && !strcmp(key, ci->key))
|
|
|
|
/* we've found the key */
|
|
|
|
{
|
|
|
|
if (ci->value != value)
|
|
|
|
{
|
|
|
|
free(ci->value);
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
ci->value = strdup(value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ci->value = strdup("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* so we couldn't find the key, thus add it ... */
|
|
|
|
Epplet_add_config(key, value);
|
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
void
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_modify_multi_config(const char *shortkey, char **values, int num)
|
1999-12-13 09:38:52 -08:00
|
|
|
{
|
1999-12-14 13:18:51 -08:00
|
|
|
int i, j, k, matches;
|
2018-08-12 08:39:13 -07:00
|
|
|
char key[64], key2[80];
|
1999-12-13 09:38:52 -08:00
|
|
|
char *s;
|
|
|
|
|
|
|
|
if (!shortkey)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* build the actual key: */
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(key, sizeof(key), "__%s__", shortkey);
|
1999-12-13 09:38:52 -08:00
|
|
|
matches = 0;
|
|
|
|
|
|
|
|
/* first wipe out old ones */
|
|
|
|
for (i = 0; i < config_dict->num_entries; i++)
|
|
|
|
{
|
|
|
|
if (config_dict->entries[i].key)
|
|
|
|
{
|
1999-12-14 13:18:51 -08:00
|
|
|
s = strstr(config_dict->entries[i].key, key);
|
|
|
|
if (s == config_dict->entries[i].key)
|
|
|
|
/* we've found a key matching at the beginning */
|
|
|
|
{
|
|
|
|
/* check how many keys match (in a row) */
|
|
|
|
for (j = i + 1; j < config_dict->num_entries; j++)
|
|
|
|
{
|
|
|
|
s = strstr(config_dict->entries[i].key, key);
|
|
|
|
if (s != config_dict->entries[i].key)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* free their pointers */
|
|
|
|
matches = j - i;
|
|
|
|
for (k = i; k < j; k++)
|
|
|
|
{
|
|
|
|
free(config_dict->entries[k].key);
|
|
|
|
free(config_dict->entries[k].value);
|
|
|
|
}
|
|
|
|
/* and move the rest. */
|
|
|
|
for (k = 0; k < config_dict->num_entries - j; k++)
|
|
|
|
{
|
|
|
|
config_dict->entries[i + k] =
|
|
|
|
config_dict->entries[j + k];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1999-12-13 09:38:52 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then insert new ones */
|
|
|
|
config_dict->entries = realloc(config_dict->entries,
|
1999-12-14 13:18:51 -08:00
|
|
|
sizeof(ConfigItem) *
|
|
|
|
(config_dict->num_entries - matches + num));
|
1999-12-13 09:38:52 -08:00
|
|
|
for (i = 0, j = config_dict->num_entries - matches; i < num; i++, j++)
|
|
|
|
{
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(key2, sizeof(key2), "%s%i", key, i);
|
1999-12-14 13:18:51 -08:00
|
|
|
config_dict->entries[j].key = strdup(key2);
|
|
|
|
config_dict->entries[j].value = strdup(values[i]);
|
1999-12-13 09:38:52 -08:00
|
|
|
}
|
|
|
|
config_dict->num_entries = config_dict->num_entries - matches + num;
|
|
|
|
}
|
|
|
|
|
1999-12-14 13:18:51 -08:00
|
|
|
char **
|
2013-07-13 12:07:12 -07:00
|
|
|
Epplet_query_multi_config(const char *shortkey, int *num)
|
1999-12-13 09:38:52 -08:00
|
|
|
{
|
1999-12-14 13:18:51 -08:00
|
|
|
char **result = NULL;
|
|
|
|
char *s;
|
|
|
|
char key[64];
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
if (!shortkey)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* build the actual key: */
|
2021-08-30 22:38:38 -07:00
|
|
|
snprintf(key, sizeof(key), "__%s__", shortkey);
|
1999-12-14 13:18:51 -08:00
|
|
|
*num = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < config_dict->num_entries; i++)
|
|
|
|
{
|
|
|
|
if (config_dict->entries[i].key)
|
|
|
|
{
|
|
|
|
s = strstr(config_dict->entries[i].key, key);
|
|
|
|
if (s == config_dict->entries[i].key)
|
|
|
|
/* we've found a key matching at the beginning */
|
|
|
|
{
|
|
|
|
/* check how many keys match (in a row) */
|
|
|
|
for (j = i + 1, (*num) = 1; j < config_dict->num_entries;
|
|
|
|
j++, (*num)++)
|
1999-12-13 09:38:52 -08:00
|
|
|
{
|
1999-12-14 13:18:51 -08:00
|
|
|
s = strstr(config_dict->entries[j].key, key);
|
|
|
|
if (s != config_dict->entries[j].key)
|
|
|
|
break;
|
1999-12-13 09:38:52 -08:00
|
|
|
}
|
1999-12-14 13:18:51 -08:00
|
|
|
/* and build result */
|
2022-01-18 05:01:20 -08:00
|
|
|
result = malloc(sizeof(char *) * (*num));
|
1999-12-14 13:18:51 -08:00
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
for (k = 0; k < (*num); k++)
|
|
|
|
{
|
|
|
|
result[k] = config_dict->entries[i + k].value;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
*num = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*num = 0;
|
|
|
|
return NULL;
|
1999-12-13 09:38:52 -08:00
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
int
|
1999-10-18 08:04:54 -07:00
|
|
|
Epplet_get_hslider_clicked(Epplet_gadget gadget)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadHSlider *g;
|
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE_RVAL(gadget, E_HSLIDER, -1);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadHSlider *) gadget;
|
1999-10-18 08:04:54 -07:00
|
|
|
return (int)g->clicked;
|
|
|
|
}
|
|
|
|
|
1999-11-16 13:02:11 -08:00
|
|
|
int
|
1999-10-18 08:04:54 -07:00
|
|
|
Epplet_get_vslider_clicked(Epplet_gadget gadget)
|
|
|
|
{
|
1999-11-16 13:02:11 -08:00
|
|
|
GadVSlider *g;
|
|
|
|
|
2000-04-30 16:19:22 -07:00
|
|
|
GADGET_CONFIRM_TYPE_RVAL(gadget, E_VSLIDER, -1);
|
1999-11-16 13:02:11 -08:00
|
|
|
g = (GadVSlider *) gadget;
|
1999-10-18 08:04:54 -07:00
|
|
|
return (int)g->clicked;
|
|
|
|
}
|