~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/Xv/tw_button.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <stdio.h>
  4 #include <math.h>
  5 #include <tina/sys.h>
  6 #include <tina/math.h>
  7 #include <tina/tw.h>
  8 #include <tina/tv.h>
  9 #include <tina/tvfuncs.h>
 10 #include <tina/tv_screen.h>
 11 #include <xview/xview.h>
 12 #include <xview/frame.h>
 13 #include <xview/panel.h>
 14 #include <xview/textsw.h>
 15 #include <xview/font.h>
 16 #include <xview/canvas.h>
 17 #include <xview/cms.h>
 18 #include <xview/xv_xrect.h>
 19 #include <xview/openmenu.h>
 20 #include <tina/Xvfuncs.h>
 21 #include <tina/X11funcs.h>
 22 
 23 static void button_call(Tw_callback * twc)
 24 {
 25     tw_set_tool((Frame) twc->data2);
 26     (*twc->func) (twc->data1);
 27 }
 28 
 29 static void button_cmnd(Tw_callback * twc)
 30 {
 31     tw_set_tool((Frame) twc->data2);
 32     (*twc->func) (twc->data1);
 33 }
 34 
 35 static void button_prnt(FILE * fp, Tw_callback * twc)
 36 {
 37     (void) fprintf(fp, "%s\n", twc->name);
 38 }
 39 
 40 void    tw_button(char *name, void (*func) ( /* ??? */ ), void * data)
 41 {
 42     int     row;
 43     Tw_callback *twc;
 44     Panel_item button;
 45     Frame   tool = tw_get_tool();
 46     Panel   panel = tw_get_panel();
 47     Bool    newrow = tw_get_newrow();
 48     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
 49 
 50     button = (Panel_item) xv_create(panel, PANEL_BUTTON,
 51                                     PANEL_LABEL_STRING, name,
 52                                     NULL);
 53     twc = tw_callback_make(fullname, button,
 54                            button_call, button_cmnd, button_prnt, func, data, (void *) tool);
 55     xv_set(button,
 56            PANEL_NOTIFY_PROC, tw_button_callback,
 57            PANEL_CLIENT_DATA, twc,
 58            NULL);
 59 
 60     if (newrow)
 61     {
 62         row = tw_get_row();
 63         xv_set(button,
 64                XV_X, xv_col(panel, 0),
 65                XV_Y, xv_row(panel, row),
 66                NULL);
 67         tw_set_newrow(false);
 68     }
 69 }
 70 
 71 Panel_item tw_icon_button(char *name, int w, int h,short *image_bits,
 72                        void (*func) ( /* ??? */ ), int data)
 73 
 74 {
 75     int     row;
 76     Tw_callback *twc;
 77     Panel_item button;
 78     Frame   tool = tw_get_tool();
 79     Panel   panel = tw_get_panel();
 80     Server_image image;
 81     Bool    newrow = tw_get_newrow();
 82     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
 83 
 84     image=(Server_image)xv_create((Frame)NULL,SERVER_IMAGE,
 85                                   XV_WIDTH, w,
 86                                   XV_HEIGHT, h,
 87                                   SERVER_IMAGE_BITS,image_bits,
 88                                   NULL);
 89     button = (Panel_item) xv_create(panel, PANEL_BUTTON,
 90                                     PANEL_LABEL_IMAGE, image,
 91                                     NULL);
 92     twc = tw_callback_make(fullname, button,
 93                            button_call, button_cmnd, button_prnt, func, (void *) data, (void *) tool);
 94     xv_set(button,
 95            PANEL_NOTIFY_PROC, tw_button_callback,
 96            PANEL_CLIENT_DATA, twc,
 97            NULL);
 98 
 99     if (newrow)
100     {
101         row = tw_get_row();
102         xv_set(button,
103                XV_X, xv_col(panel, 0),
104                XV_Y, xv_row(panel, row),
105                NULL);
106         tw_set_newrow(false);
107     }
108     return button;
109 }
110 void tw_button_reset_image(Panel_item button,int w, int h,
111                          short *image_bits)
112 {
113   Server_image image,old_image;
114   image=(Server_image)xv_create((Frame)NULL,SERVER_IMAGE,
115                                   XV_WIDTH, w,
116                                   XV_HEIGHT, h,
117                                   SERVER_IMAGE_BITS,image_bits,
118                                   NULL);
119   old_image=xv_get(button,PANEL_LABEL_IMAGE,NULL);
120   xv_set(button,PANEL_LABEL_IMAGE,image,NULL);
121   xv_destroy_safe(old_image);
122 }
123 #ifdef INTERRUPT_BUTTON
124 static void interrupt_calc_proc(void)
125 {
126     format("Interrupted!\n");
127 }
128 
129 void    tw_interrupt_button(void)
130 {
131     (void) printf("tw_interrupt_button: NOT implemented in Xview.\n");
132     /****
133         int             row;
134         Tw_callback    *twc;
135         Panel_item      interrupt_button;
136         Frame           tool = tw_get_tool();
137         Panel           panel = tw_get_panel();
138         Bool            newrow = tw_get_newrow();
139         char            name[] = "Interrupt";
140 
141 
142         interrupt_button = (Panel_item) xv_create(panel, PANEL_BUTTON,
143             PANEL_LABEL_STRING, name,
144             NULL);
145 
146         xv_set(interrupt_button,
147             PANEL_NOTIFY_PROC, interrupt_calc_proc,
148             NULL);
149 
150         if (newrow)
151         {
152             row = tw_get_row();
153             xv_set(interrupt_button,
154                 XV_X, xv_col(panel, 0),
155                 XV_Y, xv_row(panel, row),
156                 NULL);
157             tw_set_newrow(false);
158         }
159         interrupt_button_set(//display of interrupt_button//,
160     //window of interrupt_button. NB in current Xview, buttons are not windows//);
161     ****/
162 }
163 
164 /* NB can't handle interrupts in Xview */
165 void    interrupt_button_data_get(Display ** display, Window * window)
166 {
167     *display = NULL;
168     *window = None;
169 }
170 #endif /*INTERRUPT_BUTTON*/
171 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.