예제 #1
0
SsdWidget ssd_checkbox_new (const char *name,
                          BOOL Selected,
                          int flags,
                          SsdCallback callback,
                          const char *checked_icon,
                          const char *unchecked_icon,
                          int style) {


   SsdWidget button;
   SsdWidget choice;

   struct ssd_checkbox_data *data =
      (struct ssd_checkbox_data *)calloc (1, sizeof(*data));

   choice =
      ssd_container_new (name, NULL, SSD_MIN_SIZE, SSD_MIN_SIZE, flags);
   ssd_widget_set_color(choice, NULL, NULL);

   data->callback = callback;
   data->selected = Selected;
   data->style = style;
   choice->get_value = get_value;
   choice->get_data = get_data;
   choice->set_value = set_value;
   choice->set_data = set_data;
   choice->data = data;
   choice->bg_color = NULL;

   if (checked_icon == NULL)
   		data->checked_icon = checked_button[data->style];
   else
   		data->checked_icon = checked_icon;

   if (unchecked_icon == NULL)
   		data->unchecked_icon = unchecked_button[data->style];
   else
   		data->unchecked_icon = unchecked_icon;


   if (Selected)
   	button = ssd_button_new ("checkbox_button", "", &data->checked_icon, 1,
                   SSD_ALIGN_VCENTER, choice_callback);
   else
   	button = ssd_button_new ("checkbox_button", "", &data->unchecked_icon, 1,
                   SSD_ALIGN_VCENTER, choice_callback);
   ssd_widget_add (choice, button);

   if (sgChkBoxOffsets.left == 0) {
      sgChkBoxOffsets.left = -ADJ_SCALE(CHKBOX_CLICK_OFFSET_DEFAULT_X);
      sgChkBoxOffsets.top = -ADJ_SCALE(CHKBOX_CLICK_OFFSET_DEFAULT_Y);
      sgChkBoxOffsets.right = ADJ_SCALE(CHKBOX_CLICK_OFFSET_DEFAULT_X);
      sgChkBoxOffsets.bottom = ADJ_SCALE(CHKBOX_CLICK_OFFSET_DEFAULT_Y);
   }

   ssd_widget_set_click_offsets( button, &sgChkBoxOffsets );
   ssd_widget_set_click_offsets( choice, &sgChkBoxOffsets );

   return choice;
}
예제 #2
0
SsdWidget ssd_button_new (const char *name, const char *value,
                          const char **bitmap_names, int num_bitmaps,
                          int flags, SsdCallback callback) {

   int i;
   SsdWidget w;
   SsdClickOffsets btn_offsets = BUTTON_CLICK_OFFSETS_DEFAULT;
//   RoadMapImage image;
   struct ssd_button_data *data =
      (struct ssd_button_data *)calloc (1, sizeof(*data));


   w = ssd_widget_new (name, ssd_button_on_key_pressed, flags);

   w->_typeid = "Button";

   w->draw  = draw;
   w->release = release;
   w->flags = flags;
   w->data = data;

   data->state  = BUTTON_STATE_NORMAL;
   // TODO :: Load the bitmaps here
   for (i=0; i<num_bitmaps; i++)
   {
	   set_bitmap_name( data, i, bitmap_names[i] );

	   data->bitmap_images[i] = NULL;
   }


   w->callback = callback;

   set_value (w, value);

#ifdef TOUCH_SCREEN
   ssd_widget_set_pointer_force_click( w );
   ssd_widget_set_click_offsets( w, &btn_offsets );
#endif

   w->short_click  = ssd_button_short_click;
   w->long_click   = ssd_button_long_click;
   w->set_value    = set_value;

   return w;
}