1、button->image(new TiledImage(SharedImage::get("./title.png")))
button->redraw();
改变button的图片(文字也是如此),要redraw()一下,其他的控件也是如此
2、fltk::remove_timeout(time_add_signal, data); remove一个定时器时,传入的data参数要跟add时一样,否则remove无效
fltk::add_timeout(1.0, time_add_signal,tree_window); 如
void time_add_signal (void * data)
{
TREE_WINDOW *tree_window = (TREE_WINDOW *)data;
Window *window =tree_window->window;
uint8_t sig_levels[TEL_NTW_MAX_CELL_NUM];
int sig;
char old_level[26];
tel_ntw_signal_level_get(sid, sig_levels, NULL, NULL);
sprintf(sigq, "%d", sig_levels[0]);
sig = sig_levels[0];
printf("signal levels= %d\n",sig);
strcpy(old_level,sigq);
sprintf(sigq,"signal levels : %ddB",sig);
if( strcmp(sigq,old_level) )
{
window->redraw();
}
fltk::repeat_timeout(1.0, time_add_signal, data);
}
fltk::add_timeout(1.0, time_add_signal,tree_window);
3、InvisibleBox 控件的label要全局变量,并设成fltk::ALIGN_INSIDE属性
如InvisibleBox *free= new InvisibleBox(20, 80, 150, 30, sigq);
free->align(fltk::ALIGN_INSIDE);
这里sigq是全局变量
4、 Browser 控件
const char *labels[]={"设置项","个数",0};//标题头,即每列的标题,这里共2列
int widths[] ={150,90, 0} ;//每列的宽度
tree->column_labels(labels);
tree->column_widths(widths);
tree->insert(0,"收音机\t未插入",NULL);
tree->insert(1,"存储卡\t已插入",NULL);//用\t区分每行中不同的列的内容
tree->callback(unsolicited_left_softkey_callback, tree_window);
tree->when(WHEN_RELEASE_ALWAYS);//这里属性是WHEN_RELEASE_ALWAYS,目的是保证当前选中的这项后,点击该项还能触发该回调函数,如改为WHEN_RELEASE,则选中后点击该项不能触发回调函数
void unsolicited_left_softkey_callback(Widget *widget, void *data)
{
TREE_WINDOW *tree_window = (TREE_WINDOW *)data;
Browser *tree = tree_window->tree;
int tree_index = 0;
tree_index = tree->value();//得到点击项的行的索引,从0开始
Widget *w = tree->goto_index(tree_index);//得到点击项的widget,这时就可以通过widget改变该项的图片或label了
w->copy_label( alarm_detail.time ); //这里要用copy_label,而不是label(),label指向一个全局的变量
而且如果都指向同一指针时,下次刷洗时以前的项也会跟着刷新
w->image(get_icon_by_status(flag));
tree->redraw();//这个必不就可少
.....................................
}
阅读(2105) | 评论(0) | 转发(0) |