// MakeRegisterPanel(): // Creates the Register Panel bool SimplifyDongle::MakeRegisterPanel() { if( simp_int == NULL ) return false; // Create the Panel register_panel = simp_int->panel_funcs->Create( "Simplify Registration" ); try { if( !( dongle_id = STRRO_CTL( simp_int->panel_funcs->orig_struct, register_panel, "Dongle ID", 43 ) ) ) throw false; if( !( reg_code = STR_CTL( simp_int->panel_funcs->orig_struct, register_panel, "Reg Code", 43 ) ) ) throw false; if( !( register_now = WBUTTON_CTL( simp_int->panel_funcs->orig_struct, register_panel, "Register Now", 150 ) ) ) throw false; // Position some things MOVE_CON( dongle_id, 25, 212 ); PanelTools::AlignLabels( dongle_id, reg_code ); PAN_SETW( simp_int->panel_funcs->orig_struct, register_panel, 400 ); PAN_SETH( simp_int->panel_funcs->orig_struct, register_panel, 350 ); PanelTools::PutUnder( reg_code, register_now ); int pw = PAN_GETW( simp_int->panel_funcs->orig_struct, register_panel ); int w = CON_W( register_now ); int y = CON_Y( register_now ); MOVE_CON( register_now, (pw/2 - w/2), y ); // Default Values char buffer[10]; sprintf( buffer, "%ld", GetDongleID() ); SET_STR( dongle_id, buffer, strlen( buffer ) ); // Listener Functions CON_SETEVENT( register_now, OnRegisterNow, this ); CON_SETEVENT( reg_code, OnRegisterNow, this ); // Set the Draw Functions simp_int->panel_funcs->Set( register_panel, PAN_USERDRAW, DrawRegisterPanel ); return true; } catch( bool a ) { if( !a ) { simp_int->message->Error("Error creating interface controls; aborting" ); return false; } } return true; }
static void create_controls( void ) { static char *labtype[] = { "Byte", "Word", "Long", "Float", "Double", NULL }; static char *labbyte[] = { "Intel", "Motorola", NULL }; static char *labjump[] = { "Absolute", "Forward", "Backward", NULL }; static char *labsrch[] = { "Text", "Text + Hex", "Current", NULL }; int x, y, ph; /* create a control */ ctl[ 1 ] = STR_CTL( panf, panel, "", 58 ); /* find out how much vertical space the panel wants for drawing its own decorations */ ph = PAN_GETH( panf, panel ) - CON_H( ctl[ 1 ] ); /* create the rest of the controls */ ctl[ 0 ] = CANVAS_CTL( panf, panel, "", 78 * TXWIDTH + DX * 2, NROWS * TXHEIGHT + DY * 2 ); ctl[ 2 ] = STRRO_CTL( panf, panel, "", 21 ); ctl[ 3 ] = WPOPUP_CTL( panf, panel, "", labtype, 76 ); ctl[ 4 ] = BOOL_CTL( panf, panel, "Unsigned" ); ctl[ 5 ] = WPOPUP_CTL( panf, panel, "", labbyte, 76 ); ctl[ 6 ] = MINISLIDER_CTL( panf, panel, "", 4, 1, 16 ); ctl[ 7 ] = STR_CTL( panf, panel, "Jump", 12 ); ctl[ 8 ] = WBUTTON_CTL( panf, panel, "Search", 56 ); ctl[ 9 ] = STRRO_CTL( panf, panel, "Mod", 4 ); ctl[ 10 ] = VSLIDER_CTL( panf, panel, "", NROWS * TXHEIGHT + DY * 2, 0, 1000 ); ctl[ 11 ] = STRRO_CTL( panf, panel, "", 12 ); ctl[ 12 ] = WPOPUP_CTL( panf, panel, "", labjump, 80 ); ctl[ 13 ] = STR_CTL( panf, panel, "", 24 ); ctl[ 14 ] = WPOPUP_CTL( panf, panel, "", labsrch, 80 ); ctl[ 15 ] = CANVAS_CTL( panf, panel, "", 32, 32 ); ctl[ 16 ] = WBUTTON_CTL( panf, panel, "New", 40 ); /* position all of the controls */ x = CON_X( ctl[ 0 ] ); y = CON_Y( ctl[ 0 ] ); y += CON_H( ctl[ 2 ] ); MOVE_CON( ctl[ 0 ], x, y + 2 ); y = CON_Y( ctl[ 0 ] ); MOVE_CON( ctl[ 10 ], 79 * TXWIDTH + 10, y + 1 ); y = CON_Y( ctl[ 1 ] ) + 2; x = CON_X( ctl[ 0 ] ); MOVE_CON( ctl[ 16 ], x + DX, y ); x += CON_W( ctl[ 16 ] ); MOVE_CON( ctl[ 1 ], x, y ); x = CON_X( ctl[ 1 ] ); x += CON_W( ctl[ 1 ] ); MOVE_CON( ctl[ 2 ], x, y ); x = CON_X( ctl[ 10 ] ); x += CON_W( ctl[ 10 ] ); MOVE_CON( ctl[ 15 ], x - 32, y ); y += CON_H( ctl[ 1 ] ) - 2; x = CON_X( ctl[ 0 ] ); MOVE_CON( ctl[ 11 ], x - 3, y ); x += CON_W( ctl[ 11 ] ); MOVE_CON( ctl[ 9 ], x, y ); x = CON_X( ctl[ 9 ] ); x += CON_W( ctl[ 9 ] ); MOVE_CON( ctl[ 6 ], x, y ); x = CON_X( ctl[ 6 ] ); x += CON_W( ctl[ 6 ] ); MOVE_CON( ctl[ 5 ], x, y ); x = CON_X( ctl[ 5 ] ); x += CON_W( ctl[ 5 ] ); MOVE_CON( ctl[ 3 ], x - 6, y ); x = CON_X( ctl[ 3 ] ); x += CON_W( ctl[ 3 ] ); MOVE_CON( ctl[ 4 ], x, y ); y = CON_Y( ctl[ 0 ] ); y += CON_H( ctl[ 0 ] ); x = CON_X( ctl[ 0 ] ); MOVE_CON( ctl[ 7 ], x + DX, y ); x = CON_X( ctl[ 7 ] ); x += CON_W( ctl[ 7 ] ); MOVE_CON( ctl[ 12 ], x - 4, y ); x = CON_X( ctl[ 12 ] ); x += CON_W( ctl[ 12 ] ); MOVE_CON( ctl[ 8 ], x + 18, y ); x = CON_X( ctl[ 8 ] ); x += CON_W( ctl[ 8 ] ); MOVE_CON( ctl[ 13 ], x - 4, y ); x = CON_X( ctl[ 13 ] ); x += CON_W( ctl[ 13 ] ); MOVE_CON( ctl[ 14 ], x - 4, y ); /* now that we know how much room the controls will take up, set the height of the panel */ y = CON_Y( ctl[ 8 ] ); y += CON_H( ctl[ 8 ] ); PAN_SETH( panf, panel, y + ph - 6 ); /* initialize the controls */ SET_INT( ctl[ 3 ], datatype ); SET_INT( ctl[ 4 ], unsign ); SET_INT( ctl[ 5 ], byteorder ); SET_INT( ctl[ 6 ], linesize ); SET_STR( ctl[ 7 ], "0", 2 ); SET_STR( ctl[ 9 ], "0", 2 ); SET_INT( ctl[ 10 ], 0 ); SET_STR( ctl[ 11 ], "0", 2 ); SET_INT( ctl[ 12 ], 0 ); SET_INT( ctl[ 14 ], 0 ); /* set the control event callbacks */ CON_SETEVENT( ctl[ 1 ], handle_file, NULL ); CON_SETEVENT( ctl[ 3 ], handle_datatype, NULL ); CON_SETEVENT( ctl[ 4 ], handle_unsigned, NULL ); CON_SETEVENT( ctl[ 5 ], handle_byteorder, NULL ); CON_SETEVENT( ctl[ 6 ], handle_rowsize, NULL ); CON_SETEVENT( ctl[ 7 ], handle_jump, NULL ); CON_SETEVENT( ctl[ 8 ], handle_search, NULL ); CON_SETEVENT( ctl[ 10 ], handle_scroll, NULL ); CON_SETEVENT( ctl[ 13 ], handle_search, NULL ); CON_SETEVENT( ctl[ 16 ], handle_new, NULL ); /* set the control drawing callbacks */ ival.ptr.ptr = drawcb_text; ctl[ 0 ]->set( ctl[ 0 ], CTL_USERDRAW, &ival ); ival.ptr.ptr = drawcb_icon; ctl[ 15 ]->set( ctl[ 15 ], CTL_USERDRAW, &ival ); }