/* * Copyright (C) 2000-2001, Nathan Ingersoll * * This software is licensed under the GNU General Public * License. If you did not receive a copy with this software, * it may be obtained from http://www.gnu.org/ */ #include #include #include "epplet.h" #define MAXBUTTON 3 Epplet_gadget close_button, label1, label2, button1; int cur_button; unsigned char buttons[MAXBUTTON]; char curb[2]; Display *disp; static void close_cb(void *data); static void in_cb(void *data, Window w); static void out_cb(void *data, Window w); static int delete_cb(void *data, Window win); static void ok_cb(void *data); static void close_cb(void *data) { Epplet_unremember(); Esync(); Epplet_cleanup(); data = NULL; exit(0); } static void in_cb(void *data, Window w) { if (w == Epplet_get_main_window()) { Epplet_gadget_show(close_button); } return; data = NULL; } static void out_cb(void *data, Window w) { if (w == Epplet_get_main_window()) { Epplet_gadget_hide(close_button); } return; data = NULL; } static int delete_cb(void *data, Window win) { win = (Window) 0; data = NULL; return 1; } void next_button(void *data) { int b; XGetPointerMapping(disp, buttons, MAXBUTTON); b = buttons[1]; buttons[1] = buttons[2]; buttons[2] = buttons[0]; buttons[0] = b; if (XSetPointerMapping(disp, buttons, MAXBUTTON) >= 0) { cur_button = buttons[0]; Esnprintf(curb, 2, "%d", cur_button); Epplet_change_label(label2, curb); } } int main(int argc, char **argv) { atexit(Epplet_cleanup); Epplet_Init("E-UniButton", "0.1", "Mouse Button Changer", 4,3, argc, argv, 0); Epplet_load_config(); disp = Epplet_get_display(); XGetPointerMapping(disp, buttons, MAXBUTTON); cur_button = buttons[0]; Esnprintf(curb, 2, "%d", cur_button); close_button = Epplet_create_std_button("CLOSE", 2, 2, close_cb, (void *)NULL); Epplet_gadget_show(label1 = Epplet_create_label(5, 10, "Button:", 3)); Epplet_gadget_show(label2 = Epplet_create_label(48, 10, curb, 3)); Epplet_gadget_show(button1 = Epplet_create_text_button("Next", 15, 28, 30, 12, next_button, (void *)NULL)); Epplet_register_focus_in_handler(in_cb, NULL); Epplet_register_focus_out_handler(out_cb, NULL); Epplet_register_delete_event_handler(delete_cb, NULL); Epplet_show(); Epplet_Loop(); return 0; }