Intermec ck1 Reference Guide
Chapter 4 — SDK Components
CK1 SDK Programmer’s Reference Manual
225
Parameter: selection
Pointer of the OtkSelection instance
Return: None
Example Code
#include <stdio.h>
#include <stdlib.h>
#include "otkapplication.h"
#include "otkselection.h"
OTK_BOOL range_callback (OtkWidget*, int, int);
OTK_BOOL togglebutton_callback (OtkWidget*, int, int);
OtkControl contr1;
OtkSelection selection1;
OtkToggleButton enable_tog;
static int label1[5] = {9, 13, 54, 397, 9};
int main()
{
otk_app_init(160,
#include <stdlib.h>
#include "otkapplication.h"
#include "otkselection.h"
OTK_BOOL range_callback (OtkWidget*, int, int);
OTK_BOOL togglebutton_callback (OtkWidget*, int, int);
OtkControl contr1;
OtkSelection selection1;
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);
//selection1
otk_selection_init
otk_app_add(&contr1);
otk_control_show(&contr1);
//selection1
otk_selection_init
(&selection1);
otk_selection_set_label_number (&selection1, 4);
otk_selection_set_label (&selection1, label1);
otk_selection_set_size (&selection1, 120, 15);
otk_selection_set_position (&selection1, 40, 180);
//otk_selection_set_default (&selection1, 3);
otk_control_add_child (&contr1, OTK_WIDGET(&selection1));
otk_selection_refresh
(&selection1);
otk_range_set_change_callback (OTK_RANGE(&selection1), range_callback);
otk_widget_set_sensitive(OTK_WIDGET(&selection1),
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_set_gc_foreground_color
(OTK_WIDGET(&enable_tog),
OTK_COL_BLACK);
otk_control_add_child (&contr1, OTK_WIDGET(&enable_tog));
otk_toggle_button_set_value(&enable_tog,
OTK_FALSE);
otk_button_set_click_callback(OTK_BUTTON(&enable_tog),
togglebutton_callback);
printf("RUN
togglebutton_callback);
printf("RUN
loop\n");
return otk_app_loop();
}
}