Intermec ck1 Guida Di Riferimento

Pagina di 390
Chapter 4 — SDK Components 
228 
CK1 SDK Programmer’s Reference Manual 
otk_selection2_refresh 
 
Purpose:  Redraw the selection2. After calling the setting functions and adding to the 
parent, this function needs to be called. 
 
Prototype: 
void otk_selection2_refresh (OtkSelection2* selection2);
 
 
Parameter:  selection2 
Pointer of the OtkSelection2 instance 
 
Return: None 
Example Code 
#include <stdio.h> 
#include <stdlib.h> 
#include "otkapplication.h" 
#include "otkselection2.h" 
 
OTK_BOOL range_callback (OtkWidget*, int, int); 
OTK_BOOL togglebutton_callback (OtkWidget*, int, int); 
 
OtkControl contr1; 
OtkSelection2 selection2; 
OtkToggleButton enable_tog; 
static int label1[5] = {9, 13, 54, 397, 9}; 
 
int main() 

 otk_app_init(160, 
142); 
 otk_control_init 
(&contr1); 
 
otk_widget_set_size (OTK_WIDGET(&contr1), 160, 142); 
 otk_widget_set_gc_background_color 
(OTK_WIDGET(&contr1), 
OTK_COL_WHITE); 
 otk_app_add(&contr1); 
 otk_control_show(&contr1); 
 
 //selection2 
 otk_selection2_init 
(&selection2); 
 
otk_selection2_set_label_number (&selection2, 5); 
 
otk_selection2_set_label (&selection2, label2);   
 
otk_selection2_set_size (&selection2, 150, 15); 
 
otk_selection2_set_position (&selection2, 40, 200); 
 
otk_selection2_set_default (&selection2, 3); 
 
otk_control_add_child (&contr1, OTK_WIDGET(&selection2));  
 otk_selection2_refresh 
(&selection2); 
 
otk_range_set_change_callback (OTK_RANGE(&selection2), range_callback); 
 otk_widget_set_sensitive(OTK_WIDGET(&selection2), 
enable_tog.value); 
 
 //enable_tog 
 otk_toggle_button_init 
(&enable_tog); 
 
otk_button_set_label (OTK_BUTTON(&enable_tog), "Enable"); 
 
otk_widget_set_size (OTK_WIDGET(&enable_tog), 60, 15); 
 
otk_widget_set_position(OTK_WIDGET(&enable_tog), 0, 0); 
 otk_widget_set_gc_background_color 
(OTK_WIDGET(&enable_tog), 
OTK_COL_WHITE); 
 otk_widget_set_gc_foreground_color 
(OTK_WIDGET(&enable_tog), 
OTK_COL_BLACK);