void Btn_DrawCheck(HELE hEle,HDRAW hDraw,RECT &rect) { button_ *pObj=BUTTON(hEle); XDraw_HImageSuper_(hDraw,pObj->hImage_check,&rect); }
void Btn_DrawIconAndText(HELE hEle,HDRAW hDraw,RECT &rect) //绘制图标和文本 { button_ *pButton=BUTTON(hEle); wchar_t *pText=XBtn_GetText(hEle); int textFlag=pButton->textFlag; RECT rcText=rect; //绘制图标 if(pButton->hImage_icon) { int width=XImage_GetWidth(pButton->hImage_icon); int height=XImage_GetHeight(pButton->hImage_icon); int iconX=0; int iconY=0; if(pText) { //获取文本大小 RECT rcArea=rect; XDraw_DrawText_(hDraw,pText,XStr_GetLength(pButton->hString),&rcArea,DT_CALCRECT); switch(pButton->iconAlign) { case XC_ICON_ALIGN_LEFT: { int half=(rect.right-(rcArea.right+width))/2; iconX=half-1; iconY=(rect.bottom-height)/2; rcText.left=width+half+1; }break; case XC_ICON_ALIGN_TOP: { int half=(rect.bottom-(rcArea.bottom+height))/2; iconX=(rect.right-width)/2; iconY=half-1; rcText.top=height+half+1; }break; case XC_ICON_ALIGN_RIGHT: { int half=(rect.right-(rcArea.right+width))/2; iconX=rect.right-width-half+1; iconY=(rect.bottom-height)/2; rcText.right=rect.right-width-half-1; }break; case XC_ICON_ALIGN_BOTTOM: { int half=(rect.bottom-(rcArea.bottom+height))/2; iconX=(rect.right-width)/2; iconY=rect.bottom-height-half+1; rcText.bottom=rect.bottom-height-half-1; }break; } }else { iconX=(rect.right-width)/2; iconY=(rect.bottom-height)/2; } if(STATE_DOWN==BUTTON(hEle)->state) XDraw_HImageStretch_(hDraw,pButton->hImage_icon,iconX+1+pButton->offset.x,iconY+1+pButton->offset.y,width,height); else XDraw_HImageStretch_(hDraw,pButton->hImage_icon,iconX+pButton->offset.x,iconY+pButton->offset.y,width,height); } //绘制文本 if(pText) { // if(FALSE==((ele_*)hEle)->bEnable) //禁用 // { // COLORREF color=XDraw_SetTextColor_(hDraw,RGB(128,128,128)); // XDraw_DrawText_(hDraw,pText,XStr_GetLength(pObj->hString),&rcText,pObj->textFlag); // XDraw_SetTextColor_(hDraw,color); // }else // { //防止文本绘制到边界 if(rcText.left<3) rcText.left+=3; if(rcText.top<3) rcText.top+=3; if(rcText.right>(rect.right-3)) rcText.right-=3; if(rcText.bottom>(rect.bottom-3)) rcText.bottom-=3; if(STATE_DOWN==BUTTON(hEle)->state) { rcText.left++; rcText.top++; rcText.right++; rcText.bottom++; } rcText.left+=pButton->offset.x; rcText.right+=pButton->offset.x; rcText.top+=pButton->offset.y; rcText.bottom+=pButton->offset.y; XDraw_DrawText_(hDraw,pText,XStr_GetLength(pButton->hString),&rcText,textFlag); //XTRACEW(L"绘制 %s \n",pText); // } } }
void WINAPI XBtn_EnableCursorHand(HELE hEle,BOOL bEnable) //鼠标停留,光标变为手型 { IsButtonDebug(hEle,__FUNCTION__); BUTTON(hEle)->bCursorHand=bEnable; }
void WINAPI XBtn_SetOffset(HELE hEle,int x,int y) //设置内容坐标偏移量 { IsButtonDebug(hEle,__FUNCTION__); BUTTON(hEle)->offset.x=x; BUTTON(hEle)->offset.y=y; }
void WINAPI XBtn_SetTextAlign(HELE hEle,int flag) //设置文本对齐 { IsButtonDebug(hEle,__FUNCTION__); BUTTON(hEle)->textFlag=flag; }
void WINAPI XBtn_SetIconAlign(HELE hEle,int align) { IsButtonDebug(hEle,__FUNCTION__); BUTTON(hEle)->iconAlign=align; }
static cb_ret_t advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); int i; int f_pos; unsigned long id; id = dlg_get_current_widget_id (h); for (i = 0; i < BUTTONS_PERM; i++) if (chown_advanced_but[i].id == id) break; f_pos = i; i = 0; switch (msg) { case MSG_DRAW: chown_refresh (); chown_info_update (); return MSG_HANDLED; case MSG_POST_KEY: if (f_pos < 3) b_setpos (f_pos); return MSG_HANDLED; case MSG_FOCUS: if (f_pos < 3) { if ((flag_pos / 3) != f_pos) flag_pos = f_pos * 3; b_setpos (f_pos); } else if (f_pos < BUTTONS_PERM) flag_pos = f_pos + 6; return MSG_HANDLED; case MSG_KEY: switch (parm) { case XCTRL ('b'): case KEY_LEFT: if (f_pos < BUTTONS_PERM) return (dec_flag_pos (f_pos)); break; case XCTRL ('f'): case KEY_RIGHT: if (f_pos < BUTTONS_PERM) return (inc_flag_pos (f_pos)); break; case ' ': if (f_pos < 3) return MSG_HANDLED; break; case '\n': case KEY_ENTER: if (f_pos <= 2 || f_pos >= BUTTONS_PERM) break; do_enter_key (h, f_pos); return MSG_HANDLED; case ALT ('x'): i++; case ALT ('w'): i++; case ALT ('r'): parm = i + 3; for (i = 0; i < 3; i++) ch_flags[i * 3 + parm - 3] = (x_toggle & (1 << parm)) ? '-' : '+'; x_toggle ^= (1 << parm); update_mode (h); dlg_broadcast_msg (h, MSG_DRAW); send_message (h->current->data, NULL, MSG_FOCUS, 0, NULL); break; case XCTRL ('x'): i++; case XCTRL ('w'): i++; case XCTRL ('r'): parm = i; for (i = 0; i < 3; i++) ch_flags[i * 3 + parm] = (x_toggle & (1 << parm)) ? '-' : '+'; x_toggle ^= (1 << parm); update_mode (h); dlg_broadcast_msg (h, MSG_DRAW); send_message (h->current->data, NULL, MSG_FOCUS, 0, NULL); break; case 'x': i++; case 'w': i++; case 'r': if (f_pos > 2) break; flag_pos = f_pos * 3 + i; /* (strchr(ch_perm,parm)-ch_perm); */ if (BUTTON (h->current->data)->text.start[(flag_pos % 3)] == '-') ch_flags[flag_pos] = '+'; else ch_flags[flag_pos] = '-'; update_mode (h); break; case '4': i++; case '2': i++; case '1': if (f_pos <= 2) { flag_pos = i + f_pos * 3; ch_flags[flag_pos] = '='; update_mode (h); } break; case '-': if (f_pos > 2) break; case '*': if (parm == '*') parm = '='; case '=': case '+': if (f_pos <= 4) { ch_flags[flag_pos] = parm; update_mode (h); send_message (h, sender, MSG_KEY, KEY_RIGHT, NULL); if (flag_pos > 8 || (flag_pos % 3) == 0) dlg_one_down (h); } break; default: break; } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
BOOL WINAPI XBtn_IsCheck(HELE hEle) //按钮是否被选中 { IsButtonDebug(hEle,__FUNCTION__); return BUTTON(hEle)->bCheck; }
static APTR build_gui(int ieee, int userport) { APTR app, ui, ok, cancel; APTR browse_button1, browse_button2, browse_button3; APTR ff_button1, ff_button2, ff_button3, ff_button4; #ifdef AMIGA_MORPHOS static const struct Hook BrowseFileHook1 = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)Browse1, NULL }; static const struct Hook BrowseFileHook2 = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)Browse2, NULL }; static const struct Hook BrowseFileHook3 = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)Browse3, NULL }; static const struct Hook FFHook4 = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)formfeed_4, NULL }; static const struct Hook FFHook5 = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)formfeed_5, NULL }; static const struct Hook FFHook6 = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)formfeed_6, NULL }; static const struct Hook FFHookUserport = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)formfeed_userport, NULL }; #else static const struct Hook BrowseFileHook1 = { { NULL, NULL }, (VOID *)Browse1, NULL, NULL }; static const struct Hook BrowseFileHook2 = { { NULL, NULL }, (VOID *)Browse2, NULL, NULL }; static const struct Hook BrowseFileHook3 = { { NULL, NULL }, (VOID *)Browse3, NULL, NULL }; static const struct Hook FFHook4 = { { NULL, NULL }, (VOID *)formfeed_4, NULL, NULL }; static const struct Hook FFHook5 = { { NULL, NULL }, (VOID *)formfeed_5, NULL, NULL }; static const struct Hook FFHook5 = { { NULL, NULL }, (VOID *)formfeed_6, NULL, NULL }; static const struct Hook FFHookUserport = { { NULL, NULL }, (VOID *)formfeed_userport, NULL, NULL }; #endif app = mui_get_app(); if (ieee) { ui = GroupObject, CYCLE(ui_to_from[0].object, translate_text(IDS_PRINTER_4_EMULATION), ui_printer_emulation) CYCLE(ui_to_from[1].object, translate_text(IDS_PRINTER_4_DRIVER), ui_printer_driver) CYCLE(ui_to_from[2].object, translate_text(IDS_PRINTER_4_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[3].object, translate_text(IDS_PRINTER_4_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button1, translate_text(IDS_PRINTER_4_SEND_FORMFEED)) CYCLE(ui_to_from[5].object, translate_text(IDS_PRINTER_5_EMULATION), ui_printer_emulation) CYCLE(ui_to_from[6].object, translate_text(IDS_PRINTER_5_DRIVER), ui_printer_driver) CYCLE(ui_to_from[7].object, translate_text(IDS_PRINTER_5_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[8].object, translate_text(IDS_PRINTER_5_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button2, translate_text(IDS_PRINTER_5_SEND_FORMFEED)) CYCLE(ui_to_from[10].object, translate_text(IDS_PRINTER_6_EMULATION), ui_printer_emulation) CYCLE(ui_to_from[11].object, translate_text(IDS_PRINTER_6_DRIVER), ui_plotter_driver) CYCLE(ui_to_from[12].object, translate_text(IDS_PRINTER_6_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[13].object, translate_text(IDS_PRINTER_6_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button3, translate_text(IDS_PRINTER_6_SEND_FORMFEED)) CYCLE(ui_to_from[15].object, translate_text(IDS_USERPORT_PRINTER_EMULATION), ui_printer_enable) CYCLE(ui_to_from[16].object, translate_text(IDS_USERPORT_PRINTER_DRIVER), ui_printer_driver) CYCLE(ui_to_from[17].object, translate_text(IDS_USERPORT_PRINTER_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[18].object, translate_text(IDS_USERPORT_PRINTER_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button4, translate_text(IDS_USERPORT_PRINTER_SEND_FORMFEED)) FILENAME(ui_to_from[19].object, translate_text(IDS_PRINTER_DEVICE_1_FILENAME), browse_button1) FILENAME(ui_to_from[20].object, translate_text(IDS_PRINTER_DEVICE_2_FILENAME), browse_button2) FILENAME(ui_to_from[21].object, translate_text(IDS_PRINTER_DEVICE_3_FILENAME), browse_button3) OK_CANCEL_BUTTON End; } else { if (userport) { ui = GroupObject, CYCLE(ui_to_from[0].object, translate_text(IDS_PRINTER_4_EMULATION), ui_printer_emulation) CYCLE(ui_to_from[1].object, translate_text(IDS_PRINTER_4_DRIVER), ui_printer_driver) CYCLE(ui_to_from[2].object, translate_text(IDS_PRINTER_4_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[3].object, translate_text(IDS_PRINTER_4_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button1, translate_text(IDS_PRINTER_4_SEND_FORMFEED)) CYCLE(ui_to_from[4].object, translate_text(IDS_ENABLE_IEC_PRINTER_4), ui_printer_enable) CYCLE(ui_to_from[5].object, translate_text(IDS_PRINTER_5_EMULATION), ui_printer_emulation) CYCLE(ui_to_from[6].object, translate_text(IDS_PRINTER_5_DRIVER), ui_printer_driver) CYCLE(ui_to_from[7].object, translate_text(IDS_PRINTER_5_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[8].object, translate_text(IDS_PRINTER_5_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button2, translate_text(IDS_PRINTER_5_SEND_FORMFEED)) CYCLE(ui_to_from[9].object, translate_text(IDS_ENABLE_IEC_PRINTER_5), ui_printer_enable) CYCLE(ui_to_from[10].object, translate_text(IDS_PRINTER_6_EMULATION), ui_printer_emulation) CYCLE(ui_to_from[11].object, translate_text(IDS_PRINTER_6_DRIVER), ui_plotter_driver) CYCLE(ui_to_from[12].object, translate_text(IDS_PRINTER_6_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[13].object, translate_text(IDS_PRINTER_6_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button3, translate_text(IDS_PRINTER_6_SEND_FORMFEED)) CYCLE(ui_to_from[14].object, translate_text(IDS_ENABLE_IEC_PRINTER_6), ui_printer_enable) CYCLE(ui_to_from[15].object, translate_text(IDS_USERPORT_PRINTER_EMULATION), ui_printer_enable) CYCLE(ui_to_from[16].object, translate_text(IDS_USERPORT_PRINTER_DRIVER), ui_printer_driver) CYCLE(ui_to_from[17].object, translate_text(IDS_USERPORT_PRINTER_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[18].object, translate_text(IDS_USERPORT_PRINTER_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button4, translate_text(IDS_USERPORT_PRINTER_SEND_FORMFEED)) FILENAME(ui_to_from[19].object, translate_text(IDS_PRINTER_DEVICE_1_FILENAME), browse_button1) FILENAME(ui_to_from[20].object, translate_text(IDS_PRINTER_DEVICE_2_FILENAME), browse_button2) FILENAME(ui_to_from[21].object, translate_text(IDS_PRINTER_DEVICE_3_FILENAME), browse_button3) OK_CANCEL_BUTTON End; } else { ui = GroupObject, CYCLE(ui_to_from[0].object, translate_text(IDS_PRINTER_4_EMULATION), ui_printer_emulation) CYCLE(ui_to_from[1].object, translate_text(IDS_PRINTER_4_DRIVER), ui_printer_driver) CYCLE(ui_to_from[2].object, translate_text(IDS_PRINTER_4_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[3].object, translate_text(IDS_PRINTER_4_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button1, translate_text(IDS_PRINTER_4_SEND_FORMFEED)) CYCLE(ui_to_from[4].object, translate_text(IDS_ENABLE_IEC_PRINTER_4), ui_printer_enable) CYCLE(ui_to_from[5].object, translate_text(IDS_PRINTER_5_EMULATION), ui_printer_emulation) CYCLE(ui_to_from[6].object, translate_text(IDS_PRINTER_5_DRIVER), ui_printer_driver) CYCLE(ui_to_from[7].object, translate_text(IDS_PRINTER_5_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[8].object, translate_text(IDS_PRINTER_5_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button2, translate_text(IDS_PRINTER_5_SEND_FORMFEED)) CYCLE(ui_to_from[9].object, translate_text(IDS_ENABLE_IEC_PRINTER_5), ui_printer_enable) CYCLE(ui_to_from[10].object, translate_text(IDS_PRINTER_6_EMULATION), ui_printer_emulation) CYCLE(ui_to_from[11].object, translate_text(IDS_PRINTER_6_DRIVER), ui_plotter_driver) CYCLE(ui_to_from[12].object, translate_text(IDS_PRINTER_6_OUTPUT_TYPE), ui_printer_output_type) CYCLE(ui_to_from[13].object, translate_text(IDS_PRINTER_6_OUTPUT_DEVICE), ui_printer_output_device) BUTTON(ff_button3, translate_text(IDS_PRINTER_6_SEND_FORMFEED)) CYCLE(ui_to_from[14].object, translate_text(IDS_ENABLE_IEC_PRINTER_6), ui_printer_enable) FILENAME(ui_to_from[19].object, translate_text(IDS_PRINTER_DEVICE_1_FILENAME), browse_button1) FILENAME(ui_to_from[20].object, translate_text(IDS_PRINTER_DEVICE_2_FILENAME), browse_button2) FILENAME(ui_to_from[21].object, translate_text(IDS_PRINTER_DEVICE_3_FILENAME), browse_button3) OK_CANCEL_BUTTON End; } } if (ui != NULL) { DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit); DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, BTN_OK); DoMethod(browse_button1, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_CallHook, &BrowseFileHook1); DoMethod(browse_button2, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_CallHook, &BrowseFileHook2); DoMethod(browse_button3, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_CallHook, &BrowseFileHook3); DoMethod(ff_button1, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_CallHook, &FFHook4); DoMethod(ff_button2, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_CallHook, &FFHook5); DoMethod(ff_button3, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_CallHook, &FFHook6); DoMethod(ff_button4, MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_CallHook, &FFHookUserport); } return ui; }
void file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta, filegui_dialog_type_t dialog_type) { file_op_context_ui_t *ui; int buttons_width; int dlg_width = 58, dlg_height = 17; int y = 2, x = 3; if (ctx == NULL || ctx->ui != NULL) return; #ifdef ENABLE_NLS if (progress_buttons[0].len == -1) { size_t i; for (i = 0; i < G_N_ELEMENTS (progress_buttons); i++) progress_buttons[i].text = _(progress_buttons[i].text); } #endif ctx->dialog_type = dialog_type; ctx->recursive_result = RECURSIVE_YES; ctx->ui = g_new0 (file_op_context_ui_t, 1); ui = ctx->ui; ui->replace_result = REPLACE_YES; ui->op_dlg = dlg_create (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors, NULL, NULL, NULL, op_names[ctx->operation], DLG_CENTER); if (dialog_type != FILEGUI_DIALOG_DELETE_ITEM) { ui->showing_eta = with_eta && ctx->progress_totals_computed; ui->showing_bps = with_eta; ui->src_file_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->src_file_label); ui->src_file = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->src_file); ui->tgt_file_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->tgt_file_label); ui->tgt_file = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->tgt_file); ui->progress_file_gauge = gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0); if (!classic_progressbar && (current_panel == right_panel)) ui->progress_file_gauge->from_left_to_right = FALSE; add_widget_autopos (ui->op_dlg, ui->progress_file_gauge, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL); ui->progress_file_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->progress_file_label); if (verbose && dialog_type == FILEGUI_DIALOG_MULTI_ITEM) { ui->total_bytes_label = hline_new (y++, -1, -1); add_widget (ui->op_dlg, ui->total_bytes_label); if (ctx->progress_totals_computed) { ui->progress_total_gauge = gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0); if (!classic_progressbar && (current_panel == right_panel)) ui->progress_total_gauge->from_left_to_right = FALSE; add_widget_autopos (ui->op_dlg, ui->progress_total_gauge, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL); } ui->total_files_processed_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->total_files_processed_label); ui->time_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->time_label); } } else { ui->src_file = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->src_file); ui->total_files_processed_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->total_files_processed_label); } add_widget (ui->op_dlg, hline_new (y++, -1, -1)); progress_buttons[0].w = WIDGET (button_new (y, 0, progress_buttons[0].action, progress_buttons[0].flags, progress_buttons[0].text, progress_button_callback)); if (progress_buttons[0].len == -1) progress_buttons[0].len = button_get_len (BUTTON (progress_buttons[0].w)); progress_buttons[1].w = WIDGET (button_new (y, 0, progress_buttons[1].action, progress_buttons[1].flags, progress_buttons[1].text, progress_button_callback)); if (progress_buttons[1].len == -1) progress_buttons[1].len = button_get_len (BUTTON (progress_buttons[1].w)); if (progress_buttons[2].len == -1) { /* create and destroy button to get it length */ progress_buttons[2].w = WIDGET (button_new (y, 0, progress_buttons[2].action, progress_buttons[2].flags, progress_buttons[2].text, progress_button_callback)); progress_buttons[2].len = button_get_len (BUTTON (progress_buttons[2].w)); send_message (progress_buttons[2].w, NULL, MSG_DESTROY, 0, NULL); g_free (progress_buttons[2].w); } progress_buttons[2].w = progress_buttons[1].w; progress_buttons[3].w = WIDGET (button_new (y, 0, progress_buttons[3].action, progress_buttons[3].flags, progress_buttons[3].text, NULL)); if (progress_buttons[3].len == -1) progress_buttons[3].len = button_get_len (BUTTON (progress_buttons[3].w)); add_widget (ui->op_dlg, progress_buttons[0].w); add_widget (ui->op_dlg, progress_buttons[1].w); add_widget (ui->op_dlg, progress_buttons[3].w); buttons_width = 2 + progress_buttons[0].len + max (progress_buttons[1].len, progress_buttons[2].len) + progress_buttons[3].len; /* adjust dialog sizes */ dlg_set_size (ui->op_dlg, y + 3, max (COLS * 2 / 3, buttons_width + 6)); place_progress_buttons (ui->op_dlg, FALSE); dlg_select_widget (progress_buttons[0].w); /* We will manage the dialog without any help, that's why we have to call dlg_init */ dlg_init (ui->op_dlg); }
BUTTON::BUTTON() { BUTTON(D2_PIN); }
void main() { char *song; char *voc; volatile int32_t lasttime; RegisterShutdownFunction(ShutDown); KB_Startup(); timerhandle = TIME_AddTimer(40, &timer); //CONFIG_GetSetupFilename(); CONFIG_ReadSetup(); CONTROL_Startup(1, &GetTime, 1500); SetupGameButtons(); MusicStartup(); SoundStartup(); RTS_Init(RTSName); // load in some test data LoadFile("test.mid",&song); LoadFile("test.voc",&voc); // start playing a song MUSIC_PlaySong(song, MUSIC_LoopSong); lasttime = timer; while (1) { int32_t i; ControlInfo info; while (lasttime==timer) { ServiceEvents(); } lasttime = timer; // printf("timer=%ld\n",timer); CONTROL_GetInput(&info); if ( info.dx!=0 || info.dy!=0 || info.dz!=0 || info.dpitch!=0 || info.dyaw!=0 || info.droll!=0 ) printf("x=%6ld y=%6ld z=%6ld yaw=%6ld pitch=%6ld roll=%6ld\n", info.dx,info.dy,info.dz,info.dyaw,info.dpitch,info.droll); // Get Keyboard input and set appropiate game function states for (i=0; i<NUMGAMEFUNCTIONS; i++) { if (BUTTON(i) && !BUTTONHELD(i)) { printf("%s\n",gamefunctions[i]); } } for (i=0; i<10; i++) { if (KB_KeyPressed(sc_F1+i)) { uint8_t *ptr; KB_ClearKeyDown(sc_F1+i); ptr = RTS_GetSound(i); FX_PlayVOC(ptr, 0, 255, 255, 255, 255, 0); } } // Check to see if fire is being pressed so we can play a sound if (BUTTON(gamefunc_Fire) && !BUTTONHELD(gamefunc_Fire)) { FX_PlayVOC(voc, 0, 255, 255, 255, 255, 0); } // Check to see if we want to exit if (KB_KeyPressed(sc_Escape)) { break; } } ShutDown(); }
void tunAutoconfigDeviceRec (LocalDevicePtr local, TunDevicePtr tun, TunDeviceInfo info) { if (TUN_DEVICE_TEST_VAL_REL (info, REL_X) && TUN_DEVICE_TEST_VAL_REL (info, REL_Y) && TUN_DEVICE_TEST_KEY (info, BTN_LEFT)) { OTLOG (local, "I found Rel(X,Y), Button(Left)"); OTLOG (local, "I think it is a mouse! :)"); VREL (REL_X, 0); VREL (REL_Y, 1); if (TUN_DEVICE_TEST_VAL_REL (info, REL_WHEEL)) { OTLOG (local, "I found mouse wheel - mapping to BUTTON 4 & 5"); RVALUATOR (REL_WHEEL). mouse_wheel_hack = TRUE; } BUTTON_TEST_AND_ASSIGN (BTN_LEFT, 1); BUTTON_TEST_AND_ASSIGN (BTN_RIGHT, 2); BUTTON_TEST_AND_ASSIGN (BTN_MIDDLE, 3); tun->is_absolute = FALSE; return; } if (TUN_DEVICE_TEST_VAL_ABS (info, ABS_X) && TUN_DEVICE_TEST_VAL_ABS (info, ABS_Y) && TUN_DEVICE_TEST_KEY (info, BTN_TOUCH)) { OTLOG (local, "I found Abs (X,Y), Button(Touch)"); OTLOG (local, "I think it is a Tablet! :)"); VABS (ABS_X,0); VABS (ABS_Y,1); TLOG ("Reverse Y coordinate (tablets have 0,0 in left lower corner)"); AVALUATOR (ABS_Y).upsidedown = TRUE; if (TUN_DEVICE_TEST_VAL_ABS (info, ABS_PRESSURE)) VABS (ABS_PRESSURE, 2); if (TUN_DEVICE_TEST_VAL_ABS (info, ABS_TILT_X)) VABS (ABS_TILT_X, 3); if (TUN_DEVICE_TEST_VAL_ABS (info, ABS_TILT_Y)) VABS (ABS_TILT_Y, 4); BUTTON (BTN_TOUCH, 1); BUTTON_TEST_AND_ASSIGN (BTN_STYLUS, 2); if (TUN_DEVICE_TEST_KEY (info, BTN_TOOL_PEN)) { OTLOG (local, "Proximity event using ToolPen button"); tun->lbut_to_xbut_tbl [BTN_TOOL_PEN - tun->first_lbutton] = TUN_BUTTON_PROXIMITY; } tun->is_absolute = TRUE; return; } if (TUN_DEVICE_TEST_VAL_ABS (info, ABS_X) && TUN_DEVICE_TEST_VAL_ABS (info, ABS_Y) && TUN_DEVICE_TEST_VAL_ABS (info, ABS_Z) && TUN_DEVICE_TEST_VAL_ABS (info, ABS_RX) && TUN_DEVICE_TEST_VAL_ABS (info, ABS_RY) && TUN_DEVICE_TEST_VAL_ABS (info, ABS_RZ) && AVALUATOR(ABS_X).min == - AVALUATOR(ABS_X).max && AVALUATOR(ABS_Y).min == - AVALUATOR(ABS_Y).max && AVALUATOR(ABS_Z).min == - AVALUATOR(ABS_Z).max && AVALUATOR(ABS_RX).min == - AVALUATOR(ABS_RX).max && AVALUATOR(ABS_RY).min == - AVALUATOR(ABS_RY).max && AVALUATOR(ABS_RZ).min == - AVALUATOR(ABS_RZ).max) { OTLOG (local, "found Abs (X,Y,Z,RX,RY,RZ)"); OTLOG (local, "I think it is some sort of 6DO device! :)"); VABSASREL (ABS_X, 0); VABSASREL (ABS_Y, 1); VABSASREL (ABS_Z, 2); VABSASREL (ABS_RX, 3); VABSASREL (ABS_RY, 4); VABSASREL (ABS_RZ, 5); tun->is_absolute = FALSE; return; } }
SimpleCalcButtons::SimpleCalcButtons(const Rect &r) :View(r, "SimpleCalcButtons",CF_FOLLOW_LEFT|CF_FOLLOW_TOP,WID_CLEAR_BACKGROUND) { m_NWidth = 10; m_NHeight = 5; m_Spacing = 2; m_Buttons = new Button *[m_NWidth*m_NHeight]; float bheight = (int)(r.Height()/m_NHeight+0.5); float bwidth = (int)(r.Width()/m_NWidth+0.5); #define BUTTON(y, x, text, id) \ m_Buttons[x*m_NHeight+y] = new Button( \ Rect(x*bwidth+m_Spacing, y*bheight+m_Spacing, \ (x+1)*bwidth-m_Spacing, (y+1)*bheight-m_Spacing), \ text, text, new Message(id)); \ AddChild(m_Buttons[x*m_NHeight+y]); #define TBUTTON(y, x, text, id) \ m_Buttons[x*m_NHeight+y] = new ToggleButton( \ Rect(x*bwidth+m_Spacing, y*bheight+m_Spacing, \ (x+1)*bwidth-m_Spacing, (y+1)*bheight-m_Spacing), \ text, text, new Message(id)); \ AddChild(m_Buttons[x*m_NHeight+y]); BUTTON(0, 0, "7", CB_7); BUTTON(0, 1, "8", CB_8); BUTTON(0, 2, "9", CB_9); BUTTON(0, 3, "/", CB_DIV); BUTTON(0, 4, "AC", CB_CLEAR_ALL); BUTTON(0, 5, "MC", CB_CLEAR_MEM); BUTTON(0, 6, "(", CB_OPEN_PAR); BUTTON(0, 7, "sin", CB_SIN); BUTTON(0, 8, "x^2", CB_POW2); BUTTON(0, 9, "and", CB_AND); BUTTON(1, 0, "4", CB_4); BUTTON(1, 1, "5", CB_5); BUTTON(1, 2, "6", CB_6); BUTTON(1, 3, "*", CB_MUL); BUTTON(1, 4, "C", CB_CLEAR); BUTTON(1, 5, "MR", CB_READ_MEM); BUTTON(1, 6, ")", CB_CLOSE_PAR); BUTTON(1, 7, "cos", CB_COS); BUTTON(1, 8, "x^3", CB_POW3); BUTTON(1, 9, "or", CB_OR); BUTTON(2, 0, "1", CB_1); BUTTON(2, 1, "2", CB_2); BUTTON(2, 2, "3", CB_3); BUTTON(2, 3, "-", CB_MINUS); BUTTON(2, 4, "<-", CB_BACKSPACE); BUTTON(2, 5, "M+", CB_ADD_MEM); BUTTON(2, 6, "log", CB_LOG); BUTTON(2, 7, "tan", CB_TAN); BUTTON(2, 8, "x^y", CB_POWX); BUTTON(2, 9, "xor", CB_XOR); BUTTON(3, 0, "0", CB_0); BUTTON(3, 1, ".", CB_POINT); BUTTON(3, 2, "+/-", CB_SIGN); BUTTON(3, 3, "+", CB_PLUS); BUTTON(3, 4, "=", CB_EQUAL); BUTTON(3, 5, "M-", CB_SUB_MEM); BUTTON(3, 6, "ln", CB_LN); TBUTTON(3, 7, "inv", CB_INV); BUTTON(3, 8, "e^x", CB_POWE); BUTTON(3, 9, "not", CB_NOT); BUTTON(4, 0, "A", CB_A); BUTTON(4, 1, "B", CB_B); BUTTON(4, 2, "C", CB_C); BUTTON(4, 3, "D", CB_D); BUTTON(4, 4, "E", CB_E); BUTTON(4, 5, "F", CB_F); BUTTON(4, 6, "lg2", CB_LOG2); TBUTTON(4, 7, "hyp", CB_HYP); BUTTON(4, 8, "sqrt", CB_SQRT); BUTTON(4, 9, "int", CB_INT); SetDecimal(); }
BOOL CALLBACK SliderBar_OnLButtonDown(HELE hEle,UINT flags,POINT *pPt) { slider_ *pObj=SLIDER(hEle); if(!pObj->bDown) { pObj->bDown=TRUE; RECT rect; XEle_GetClientRect(hEle,&rect); int cx=rect.right-rect.left; int cy=rect.bottom-rect.top; int btnWidth= ((ele_*)(pObj->hButton))->rect.right-((ele_*)(pObj->hButton))->rect.left; int btnHeight= ((ele_*)(pObj->hButton))->rect.bottom-((ele_*)(pObj->hButton))->rect.top; if(pObj->bHorizon) { int x=pPt->x-(btnWidth/2); if(x<0) x=0; else if(x>(cx-btnWidth)) x=cx-btnWidth; int pos=(int)( x/pObj->minPos); if(pos != pObj->pos) { pObj->pos=pos; RECT rc; rc.left=(long)(pos*pObj->minPos); rc.top=cy/2-btnHeight/2; rc.right=rc.left+btnWidth; rc.bottom=rc.top+btnHeight; XEle_SetRect(pObj->hButton,&rc); XEle_SetCapture(hEle); //ÉèÖÃÔªËØÊó±ê²¶»ñ BUTTON(pObj->hButton)->state=STATE_DOWN; Ele_SendEvent(hEle,XE_SLIDER_CHANGE,(WPARAM)pObj->pos,0); XEle_RedrawEle(hEle); } }else { int height=rect.bottom-pPt->y; height=height-(btnHeight/2); if(height<0) height=0; else if(height>(cy-btnHeight)) height=cy-btnHeight; int pos=(int)( height/pObj->minPos); if(pos != pObj->pos) { pObj->pos=pos; RECT rc=rect; rc.left=cx/2-btnWidth/2; rc.right=rc.left+btnWidth; rc.bottom=rc.bottom-height; rc.top=rc.bottom-pObj->btnWidth; XEle_SetRect(pObj->hButton,&rc); XEle_SetCapture(hEle); //ÉèÖÃÔªËØÊó±ê²¶»ñ Ele_SendEvent(hEle,XE_SLIDER_CHANGE,(WPARAM)pObj->pos,0); XEle_RedrawEle(hEle); } } } return FALSE; }