我有以下函数为头文件准备画布
hasHeader(canv,cb);
cb函数具有以下结构
void cb(DBE el, HeaderEvent event, int hIndex, int param) {
// do something
}
我知道事件可以是headerResize,headerEdit,headerSelect或headerReorder但我的问题是如何打印这个参数我是为了看看他的价值?我想这可能不知何故,但我想不出来......
答案 0 :(得分:0)
因此,HeaderEvent实际上最终更像是一个枚举。看看以下内容:
// Set the current module
Module m = current
// Redraw function for canvas - required (empty for this example)
void reDraw ( DBE canv ) {
}
// Header callback function
void cb ( DBE el , HeaderEvent event, int hIndex, int param ) {
// Header Event Cases
if ( event == headerEdit ) {
print "HeaderEdit" "\t" hIndex "\n"
}
if ( event == headerResize ) {
print "HeaderResize" "\t" param "\n"
}
if ( event == headerSelect ) {
print "HeaderSelect" "\t" hIndex "\n"
}
if ( event == headerReorder ) {
print "HeaderReorder" "\t" hIndex "\t" param "\n"
}
}
// Create the Main Window and Callbacks
DB main_DB = create ( m , "Header Test" , styleSubWindow | styleFloating )
DBE canv_DBE = canvas ( main_DB , 100 , 100 , reDraw )
// Prep for headers
hasHeader ( canv_DBE , cb )
// Realize the dialog box - required before adding columns to the canvas
realize mainDB
// Add canvas columns
headerAddColumn ( canvas_test , "Header Test 1" , 100 )
headerAddColumn ( canvas_test , "Header Test 2" , 100 )
// Show the dialog box
show mainDB
当您点击标题并拖动它们时,您将从事件案例结构中获得反馈。
我没有看到更简单的方法来实现这一点,但其他人可能比我更有洞察力!