static void handle_file( LWControl *ectl, void *edata ) { char a[ 24 ]; struct stat s; time_t timestamp; GET_STR( ectl, filename, sizeof( filename )); if ( filename[ 0 ] == 0 ) return; if ( fp ) fclose( fp ); if ( !( fp = fopen( filename, "rb" ))) { msgf->error( "Couldn't open", filename ); return; } stat( filename, &s ); filesize = s.st_size; timestamp = s.st_mtime; pos = 0; set_scroll(); SET_STR( ctl[ 11 ], itoa( filesize, a, 10 ), sizeof( a )); strftime( a, sizeof( a ), "%d %b %y %X", localtime( ×tamp )); SET_STR( ctl[ 2 ], a, strlen( a )); ctl[ 0 ]->draw( ctl[ 0 ], DR_REFRESH ); }
void driver_info_destroy(DriverInfo* thiz) { if(thiz != NULL) { SET_STR(thiz->name, NULL); SET_STR(thiz->author, NULL); SET_STR(thiz->email, NULL); SET_STR(thiz->description, NULL); SET_STR(thiz->license, NULL); g_free(thiz); } }
void gncEntrySetDescription (GncEntry *entry, const char *desc) { if (!entry || !desc) return; SET_STR (entry, entry->desc, desc); mark_entry (entry); gncEntryCommitEdit (entry); }
void gncEntrySetAction (GncEntry *entry, const char *action) { if (!entry || !action) return; SET_STR (entry, entry->action, action); mark_entry (entry); gncEntryCommitEdit (entry); }
void gncEntrySetNotes (GncEntry *entry, const char *notes) { if (!entry || !notes) return; SET_STR (entry, entry->notes, notes); mark_entry (entry); gncEntryCommitEdit (entry); }
void gncEmployeeSetLanguage (GncEmployee *employee, const char *language) { if (!employee) return; if (!language) return; SET_STR(employee, employee->language, language); mark_employee (employee); gncEmployeeCommitEdit (employee); }
void gncEmployeeSetUsername (GncEmployee *employee, const char *username) { if (!employee) return; if (!username) return; SET_STR(employee, employee->username, username); mark_employee (employee); gncEmployeeCommitEdit (employee); }
void gncEmployeeSetID (GncEmployee *employee, const char *id) { if (!employee) return; if (!id) return; SET_STR(employee, employee->id, id); mark_employee (employee); gncEmployeeCommitEdit (employee); }
void gncBillTermSetDescription (GncBillTerm *term, const char *desc) { if (!term || !desc) return; SET_STR (term, term->desc, desc); mark_term (term); maybe_resort_list (term); gncBillTermCommitEdit (term); }
void gncCustomerSetName (GncCustomer *cust, const char *name) { if (!cust) return; if (!name) return; SET_STR(cust, cust->name, name); mark_customer (cust); gncCustomerCommitEdit (cust); }
void gncAddressSetFax (GncAddress *addr, const char *fax) { if (!addr) return; if (!fax) return; SET_STR(addr, addr->fax, fax); mark_address (addr); gncAddressCommitEdit (addr); }
void gncAddressSetPhone (GncAddress *addr, const char *phone) { if (!addr) return; if (!phone) return; SET_STR(addr, addr->phone, phone); mark_address (addr); gncAddressCommitEdit (addr); }
void gncAddressSetAddr4 (GncAddress *addr, const char *addr4) { if (!addr) return; if (!addr4) return; SET_STR(addr, addr->addr4, addr4); mark_address (addr); gncAddressCommitEdit (addr); }
void gncAddressSetName (GncAddress *addr, const char *name) { if (!addr) return; if (!name) return; SET_STR(addr, addr->name, name); mark_address (addr); gncAddressCommitEdit (addr); }
void gncTaxTableSetName (GncTaxTable *table, const char *name) { if (!table || !name) return; SET_STR (table, table->name, name); mark_table (table); maybe_resort_list (table); gncTaxTableCommitEdit (table); }
void gncCustomerSetID (GncCustomer *cust, const char *id) { if (!cust) return; if (!id) return; SET_STR(cust, cust->id, id); mark_customer (cust); gncCustomerCommitEdit (cust); }
void gncAddressSetEmail (GncAddress *addr, const char *email) { if (!addr) return; if (!email) return; SET_STR(addr, addr->email, email); mark_address (addr); gncAddressCommitEdit (addr); }
void gncCustomerSetNotes (GncCustomer *cust, const char *notes) { if (!cust) return; if (!notes) return; SET_STR(cust, cust->notes, notes); mark_customer (cust); gncCustomerCommitEdit (cust); }
void gncBillTermSetName (GncBillTerm *term, const char *name) { if (!term || !name) return; SET_STR (term, term->name, name); mark_term (term); maybe_resort_list (term); gncBillTermCommitEdit (term); }
void gncEmployeeSetAcl (GncEmployee *employee, const char *acl) { if (!employee) return; if (!acl) return; SET_STR(employee, employee->acl, acl); mark_employee (employee); gncEmployeeCommitEdit (employee); }
void gncJobSetReference (GncJob *job, const char *desc) { if (!job) return; if (!desc) return; SET_STR(job, job->desc, desc); mark_job (job); gncJobCommitEdit (job); }
void gncJobSetName (GncJob *job, const char *name) { if (!job) return; if (!name) return; SET_STR(job, job->name, name); mark_job (job); gncJobCommitEdit (job); }
void gncJobSetID (GncJob *job, const char *id) { if (!job) return; if (!id) return; SET_STR(job, job->id, id); mark_job (job); gncJobCommitEdit (job); }
// 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; }
// OnItemMultiScroll(): // Called to handle the custom scroll bar under the lister void OnItemMultiScroll( LWControl *ctl, int mx, fk_mousestate mouse_state ) { static last_clicked = CLICKED_NONE; static down_pos = 0; static item_pos = 0; // Mouse Released; Reset if( mouse_state == MSTATE_UP ) { SET_STR( fk_int->select_item_name, "MS: Mouse Released", strlen( "MS: Mouse Released" ) ); last_clicked = CLICKED_NONE; REDRAW_CON( fk_int->item_multiscroll ); return; } // Mouse was just clicked; see what was clicked if( mouse_state == MSTATE_DOWN ) { down_pos = mx; mx -= CON_HOTX( ctl ); // Test the Divider int div_near = mx > fk_int->ms_divider ? mx-fk_int->ms_divider: fk_int->ms_divider-mx; if( div_near < 6 ) { last_clicked = CLICKED_DIVIDER; item_pos = fk_int->ms_divider; SET_STR( fk_int->select_item_name, "MS: Clicked Divider", strlen( "MS: Clicked Divider" ) ); } return; } // Mouse Moved: Change some value if( mouse_state == MSTATE_MOVING ) { if( last_clicked == CLICKED_DIVIDER ) fk_int->ms_divider = mx; // fk_int->ms_divider = down_pos - item_pos + mx - item_pos; char buffer[ 64 ]; sprintf( buffer, "MS: Moved Divider to %d", fk_int->ms_divider ); SET_STR( fk_int->select_item_name, buffer, strlen( buffer ) ); REDRAW_CON( ctl ); } }
// HandleList(): void HandleList( LWControl *con, void *data ) { int index, column, other; GET_IVEC( rint->list, index, column, other ); if( index >= (int)rint->swaps.NumElements() ) { index = ((int)rint->swaps.NumElements()) - 1; SET_IVEC( rint->list, index, 1, 0 ); } else { if( index != -1 ) { int x = CON_MOUSEX( con ); int y = CON_MOUSEY( con ); if( x < list_column_widths[0] + 8 ) rint->swaps[ index ]->SetUse( !rint->swaps[ index ]->GetUse() ); } } if( index == -1 ) { SET_STR( rint->path, "", 0 ); SET_FLOAT( rint->weight, 1.0 ); SET_INT( rint->enable, 1 ); GHOST_CON( rint->path ); GHOST_CON( rint->weight ); GHOST_CON( rint->enable ); } else { char * string = (char *)rint->swaps[ index ]->GetFullPath(); if( string == NULL ) { SET_STR( rint->path, "", 0 ); } else { SET_STR( rint->path, string, strlen( string ) ); } SET_FLOAT( rint->weight, rint->swaps[ index ]->GetWeight() ); SET_INT( rint->enable, rint->swaps[ index ]->GetUse() ); UNGHOST_CON( rint->path ); UNGHOST_CON( rint->weight ); UNGHOST_CON( rint->enable ); } }
static void saver_event( LWControl *sctl, LWControl *ectl ) { LWValue ival = { LWT_INTEGER }, sval = { LWT_STRING }; char filename[ 260 ]; int saver; GET_INT( sctl, saver ); GET_STR( ectl, filename, sizeof( filename )); filename_ext( saver, filename ); SET_STR( ectl, filename, sizeof( filename )); RENDER_CON( ectl ); }
static void drawcb_text( LWControl *ectl, void *edata, DrMode mode ) { static int size[] = { 1, 2, 4, 4, 8, 2, 4 }; char a[ 10 ]; int rlen; if ( !fp ) return; fseek( fp, pos, SEEK_SET ); rlen = fread( buf, 1, pagesize, fp ); SET_STR( ctl[ 9 ], itoa( pos % size[ datatype ], a, 10 ), sizeof( a )); show_byt( pos, rlen, linesize ); show_prt( buf, rlen, linesize ); show_num( buf, rlen, datatype, unsign, byteorder != natorder, linesize ); }
static void ctl_set( void ) { int i; SET_STR( ctl[ 0 ], sequence, strlen( sequence )); SET_INT( ctl[ 1 ], atom_type ); SET_INT( ctl[ 2 ], atom_nsides ); SET_INT( ctl[ 3 ], atom_nsegments ); for ( i = 0; i < 5; i++ ) SET_FLOAT( ctl[ i + 5 ], atom_radius[ i ] ); SET_INT( ctl[ 10 ], bond_type ); SET_INT( ctl[ 11 ], bond_nsides ); SET_INT( ctl[ 12 ], bond_nsegments ); SET_FLOAT( ctl[ 13 ], bond_radius ); SET_INT( ctl[ 14 ], do_plates ); }
/* * UI_UtilString1 QUERY ONE STRING */ int UI_UtilString1( LWPanelFuncs *panfunc, char *title, char *caption, char *strin, char *strout ) { LWPanelID panelID; LWControl *control; int btn; panelID = (*panfunc->create)( title, NULL ); control = STR_CTL( panfunc, panelID, caption, 40 ); SET_STR( control, strin, 255 ); btn = (*panfunc->open)( panelID, PANF_BLOCKING|PANF_CANCEL ); if (btn) { GET_STR( control, strout, 255 ); } PAN_KILL( panfunc, panelID ); return btn; }