gitkrwoptionchoiceboolean.c

Go to the documentation of this file.
00001 
00012 #define GITK_RENDERER_C
00013 #define GITKR_WIDGET_OPTIONCHOICE_BOOLEAN_C
00014 
00015 #include "gitkrincludes.h"
00016 
00018 void gitkr_widget_optionchoice_boolean_new(GitkrTextWidgetPtr widget,GitkDialogPtr dialog,xmlNodePtr node) {
00019   widget->icon='#';
00020   gitkr_widget_new(widget,dialog,node);
00021   widget->type=GITK_WIDGET_TYPE_OPTIONCHOICE_BOOLEAN;
00022   widget->output=gitkr_widget_optionchoice_boolean_output;
00023   widget->handle=gitkr_widget_optionchoice_boolean_handle;
00024 }
00025 
00027 void gitkr_widget_optionchoice_boolean_output(GitkrTextWidgetPtr widget,gint line,gboolean active) {
00028   gint str_len;
00029   gchar *value=gitkr_widget_get_value(widget->dialog,widget->id,"value");
00030   gint cur_value;
00031 
00032   //-- determine selected entry
00033   cur_value=(value?atoi(value):0);
00034   g_free(value);
00035 
00036   gitkr_widget_output_pre(widget,line,active);
00037 
00038   //-- display label
00039   if(widget->label) {
00040     mvaddstr(line,2,widget->label);
00041     str_len=strlen(widget->label);
00042   }
00043   else {
00044     mvaddstr(line,2,"-");
00045     str_len=1;
00046   }
00047   mvaddstr(line,2+str_len," : [");
00048   mvaddstr(line,2+str_len+4,((cur_value!=0)?"#":" "));
00049   mvaddstr(line,2+str_len+5,"]");
00050 
00051   if(active && widget->label) { festival_say_text(ftinfo,widget->label); }
00052   gitkr_widget_output_post(widget,line,active);
00053 }
00054 
00056 gboolean gitkr_widget_optionchoice_boolean_handle(GitkrTextWidgetPtr widget,gint line) {
00057   gchar *value=gitkr_widget_get_value(widget->dialog,widget->id,"value");
00058   gint cur_value;
00059   char res[10]; //-- temporary buffer for setting the result
00060 
00061   //-- determine selected entry
00062   cur_value=1-(value?atoi(value):0);
00063   g_free(value);
00064   sprintf(res,"%d",cur_value);
00065   gitkr_widget_set_value(widget->dialog,widget->id,"value",res);
00066 
00067   return(TRUE);
00068 }

Generated on Thu Oct 28 10:59:14 2004 for gitk by doxygen 1.3.6