void progress_init( const char * title_msg, long max ) { rsrc_gaddr( 0, PROC_BOX, &progress_tree ); progress_tree[PB_PROGBAR].ob_width = 0; progress_tree[PB_CANCEL].ob_state &= ~SELECTED; strcpy( ObjcString( progress_tree, PB_ELATIME, NULL ), "--:--" ); strcpy( ObjcString( progress_tree, PB_REMTIME, NULL ), "--:--" ); ObjcString( progress_tree, PB_STATUS, "" ); if( preferences.pref_flags.multitask ) { progress_tree[0].ob_state &= ~OUTLINED; progress_tree[PB_CANCEL].ob_flags &= ~HIDETREE; progress_tree[PB_ESC].ob_flags |= HIDETREE; progress_win = FormWindBegin( progress_tree, get_string( title_msg ) ); } else { /* MouseWork(); */ graf_mouse( BUSYBEE, NULL ); progress_tree[0].ob_state |= OUTLINED; progress_tree[PB_CANCEL].ob_flags |= HIDETREE; progress_tree[PB_ESC].ob_flags &= ~HIDETREE; FormBegin( progress_tree, NULL ); } progress_exitflag = 0; progress_max = max; progress_count = 0; progress_info = NULL; progress_start_time = 0; progress_next_refresh = 0; }
/* Parse encoded menu key shortcut The format is: "[" - marks start of the shortcut "@,^,<" - If the keyshortcut is only valid with modifier keys, one of these characters must directly follow the start mark. Meaning: @ -> Alternate ^ -> Control "#" - keycode or ascii character. The value is handled as keycode if the character value is <= 28 ( Atari chracter table ) or if it is interpreted as function key string. (strings: F1 - F10) */ static void register_menu_str( struct s_menu_item_evnt * mi ) { char * str = ObjcString( h_gem_menu, mi->rid, NULL ); int l = strlen(str); int i = l; int x = -1; struct s_accelerator * accel = &mi->accel; while( i>2 ){ if( str[i] == '['){ x = i; break; } i--; } if( x > -1 ){ mi->menustr = malloc( l+1 ); strcpy(mi->menustr, str ); mi->menustr[x]=' '; x++; if( str[x] == '@' ){ accel->mod = K_ALT; mi->menustr[x] = 0x07; x++; } else if( str[x] == '^' ) { accel->mod = K_CTRL; x++; } if( str[x] <= 28 ){ // parse symbol unsigned short keycode=0; switch( str[x] ){ case 0x03: accel->keycode = NK_RIGHT; break; case 0x04: accel->keycode = NK_LEFT; break; case 0x1B: accel->keycode = NK_ESC; break; default: break; } } else { if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){ // parse function key short fkey = atoi( &str[x+1] ); if( (fkey >= 0) && (fkey <= 10) ){ accel->keycode = NK_F1 - 1 + fkey; } } else { accel->ascii = str[x]; } } } }
void progress_setinfo( char * info ) { /*if( progress_info != info ) {*/ ObjcString( progress_tree, PB_STATUS, info ); progress_display_object( PB_STATUS ); progress_info = info; progress_display(); /*} */ }
/* Fonction appelée continuellement en cours de traitement */ int yield( void ) { int ret; long time, elapsed, remaining; evnt.timer = 0; if( preferences.pref_flags.multitask ) { ret = FormWindDo( FORM_EVNT|MU_MESAG|MU_TIMER ); if( !(ret & FORM_EVNT) ) { if( ret == PB_CANCEL ) progress_exitflag = 1; } } else { ret = EvntWindom( MU_KEYBD|MU_TIMER ); if( (ret & MU_KEYBD) && evnt.keybd == 0x11b ) progress_exitflag = 1; } if( progress_start_time ) { time = timer(); if( time > progress_next_refresh ) { elapsed = (time - progress_start_time) / 200; remaining = progress_count ? (progress_max * elapsed / progress_count - elapsed) : 0; sprintf( ObjcString( progress_tree, PB_ELATIME, NULL ), "%02d:%02d", (int)(elapsed/60), (int)(elapsed%60) ); if( remaining > 0 ) sprintf( ObjcString( progress_tree, PB_REMTIME, NULL ), "%02d:%02d", (int)(remaining/60), (int)(remaining%60) ); progress_display_object( PB_ELATIME ); progress_display_object( PB_REMTIME ); progress_next_refresh = time + PROGRESS_REFRESH_RATE; } } return progress_exitflag; }
void tao_default( OBJECT * form ) { struct device_info * info; int i; strncpy( src_file, preferences.tao_src_file, 255 ); reduce_name( src_fred, src_file, MAX_FRED_SRC ); strncpy( dest_file, preferences.tao_dest_file, 255 ); reduce_name( dest_fred, dest_file, MAX_FRED_DEST ); ObjcString( form, TB_SRC_FILE, src_fred ); for( i=0; i<tao_popup.item_count; i++ ) { info = (struct device_info *)tao_popup.item[i].info; if( info && info->id == preferences.tao_id && info->bus_no == preferences.tao_bus ) tao_popup.selected = i; } if( preferences.tao_id < 0 ) form[ TB_DEST ].ob_spec.free_string = dest_fred; else form[ TB_DEST ].ob_spec.free_string = tao_popup.item[tao_popup.selected].text; if( tao_popup.selected ) gen_speed_popup( &speed_popup, ((struct device_info*)tao_popup.item[tao_popup.selected].info)->sets->max_write_speed ); speed_popup.selected = 0; for( i=0; i<speed_popup.item_count; i++ ) { if( *((unsigned int *)(speed_popup.item[i].info)) == preferences.tao_write_speed ) speed_popup.selected = i; } form[ TB_SPEED ].ob_spec.free_string = speed_popup.item[speed_popup.selected].text; objc_select( form, TB_SIMUL, preferences.tao_flags.simul ); objc_select( form, TB_WR, preferences.tao_flags.write_cd ); }
/* Bind global and menu events to event handler functions, create accelerators */ void bind_global_events( void ) { int i, len; int maxlen[NUM_MENU_TITLES]={0}; char * m, *u, *t; char spare[128]; memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) ); EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data ); EvntAttach( NULL, AP_TERM, global_evnt_apterm ); EvntAttach( NULL, MN_SELECTED, global_evnt_menu ); EvntAttach( NULL, WM_XM1, global_evnt_m1 ); /* parse and update menu items: */ i = 0; while( menu_evnt_tbl[i].rid != -1 ) { char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL ); register_menu_str( &menu_evnt_tbl[i] ); if( menu_evnt_tbl[i].menustr != NULL ){ MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr ); } i++; } main_menu_update(); }
bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_infos_n , unsigned long num_certs ) { OBJECT *tree; WINDOW * form; bool bres = false; bool cont = true; int res = 0; dp.cert_infos_n = (struct ssl_cert_info *)cert_infos_n; dp.num_certs = num_certs; dp.scrollx = 0; dp.scrolly = 0; dp.current = 0; dp.cols = cert_display_width( &dp.cert_infos_n[dp.current] ); dp.rows = 8; dp.tree = tree; RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree); ObjcString( tree, VERIFY_LBL_HOST, (char*)url ); ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 ); ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 ); form = FormWindBegin( tree, (char*)"SSL Verify failed" ); EvntDataAdd( form, WM_REDRAW, cert_info_draw, (void*)&dp, EV_BOT ); /* this results in some extended objects which can not be freed: :( */ /* RsrcUserDraw( OC_FORM, tree, VERIFY_BOX_DETAILS, cert_info_draw,(void*)&dp ) ; */ ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp ); /* ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp ); ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp ); */ while( cont ) { res = FormWindDo( MU_MESAG ); cont = false; switch( res ){ case VERIFY_BT_ACCEPT: bres = true; break; case VERIFY_BT_NEXT_CERT: /* select box clicked or dragged... */ cont = true; break; case VERIFY_BT_REJECT: bres = false; break; case VERIFY_BT_SCROLL_D: cont = true; dp.scrolly += 1; ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG ); break; case VERIFY_BT_SCROLL_U: cont = true; dp.scrolly -= 1; ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG ); break; case VERIFY_BT_SCROLL_R: LOG(( "scroll r!" )); cont = true; dp.scrollx += 1; if( dp.scrollx > (dp.cols - (272 / 8 )) ) dp.scrollx -= 1; ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG); break; case VERIFY_BT_SCROLL_L: cont = true; dp.scrollx -= 1; if( dp.scrollx < 0 ) dp.scrollx = 0; ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG ); break; default: break; } } FormWindEnd( ); return( bres ); }