int main(void) { Object *wnd; Object *img; Object *a, *b, *c, *d; app = ApplicationObject, SubWindow, wnd = WindowObject, MUIA_Window_Title, "col", MUIA_Window_Activate, TRUE, WindowContents, d = HGroup, GroupFrameT("Background"), Child, c = VGroup, Child, a = PopimageObject, End, Child, b = MakeLabel("Window"), End, Child, VGroup, Child, PopimageObject, End, Child, MakeLabel("Requester"), End, End, End, End; if (app) { ULONG sigs = 0; DoMethod(wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit); set(wnd, MUIA_Window_Open, TRUE); printf("%d[%p] %d[%p] %d[%p] %d\n", _maxwidth(a), a, _maxwidth(b), b, _maxwidth(c), c, _maxwidth(d)); while((LONG) DoMethod(app, MUIM_Application_NewInput, &sigs) != MUIV_Application_ReturnID_Quit) { if (sigs) { sigs = Wait(sigs | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D); if (sigs & SIGBREAKF_CTRL_C) break; } } set(wnd, MUIA_Window_Open, FALSE); MUI_DisposeObject(app); } return 0; }
static void ChangeMenuTitle( gui_window *root, int index ) { char name[MAX_LENGTH]; char label[MAX_LENGTH]; MakeLabel( index, name, label ); GUISetMenuText( root, MDIWIN2ID( index ), label, false ); MakeHintText( index, name ); }
static void InitLineSegBck( void ){ /*************************************/ segment_id old; back_handle bck; old = SetOP( DwarfSegs[DW_DEBUG_LINE].seg ); bck = MakeLabel(); bck->seg = DwarfSegs[DW_DEBUG_LINE].seg; DwarfSegs[DW_DEBUG_LINE].bck = bck; DataLabel( bck->lbl ); SetOP( old ); }
static void InitSegBck( void ){ /*********************************/ dw_sectnum i; segment_id old; back_handle bck; for( i = DW_DEBUG_INFO; i < DW_DEBUG_MAX; ++i ){ old = SetOP( DwarfSegs[i].seg ); bck = MakeLabel(); bck->seg = DwarfSegs[i].seg; DwarfSegs[i].bck = bck; DataLabel( bck->lbl ); SetOP( old ); } }
void init_display(int argc, char **argv, MyProgram *me) { Widget w[5]; if (OpenDisplay(argc, argv) == FALSE) return; w[0] = MakeButton("Pattern #1", pattern1, me); w[1] = MakeButton("Pattern #2", pattern2, me); w[2] = MakeButton("Quit!", quit, me); w[3] = MakeLabel("Bitmap demo program"); w[4] = MakeDrawArea(X_SIZE, Y_SIZE, redisplay, me); SetWidgetPos(w[1], PLACE_RIGHT, w[0], NO_CARE, NULL); SetWidgetPos(w[2], PLACE_RIGHT, w[1], NO_CARE, NULL); SetWidgetPos(w[3], PLACE_RIGHT, w[2], NO_CARE, NULL); SetWidgetPos(w[4], PLACE_UNDER, w[0], NO_CARE, NULL); /* This call actually causes the whole thing to be displayed on the * screen. You have to call this function before doing any drawing * into the window. */ ShowDisplay(); /* Get standard (red, blue, green, yellow, black, white) colors for * drawing stuff. Check libsx.h for more info. */ GetStandardColors(); /* If you wanted to get all the colors in the colormap, you'd do the * following : * * GetAllColors(); * SetColorMap(GREY_SCALE_1); * * You can wait to do it till later if you want. There's no need * to do it here if you don't need to (because it wacks out the * colormap). Check libsx.h for other colormap types you can * ask for (like RAINBOW_{1,2} or GREY_SCALE_{1,2}). */ }
static ret_code GetAndExpression( hll_list * hll, int *i, int ilabel, bool is_true, char * buffer, char **lastjmp, expr_list *opndx ) /***********************************************************************************************************************************/ { c_bop op; int cur_pos; char * ptr = buffer; char * truelabel = NULL; //char * nlabel; //char * olabel; DebugMsg(("GetAndExpression(buffer=%s) enter\n", buffer )); while (1) { ptr = ptr + strlen( ptr ); cur_pos = *i; if ( ERROR == GetSimpleExpression( hll, i, ilabel, is_true, ptr, lastjmp, opndx ) ) return( ERROR ); cur_pos = *i; op = GetCOp(i); if (op != COP_AND) break; /* v2.02: query is_true var instead of cmd field! * this is important if the '!' operator was used. */ //if ( hll->cmd == HLL_WHILE || hll->cmd == HLL_BREAK ) { if ( is_true ) { /* todo: please describe what's done here and why! */ if (*lastjmp) { char * p = *lastjmp; InvertJmp( p+1 ); /* step 1 */ if ( truelabel == NULL ) /* step 2 */ truelabel = MakeAnonymousLabel(); ReplaceLabel( buffer, GetLabel( hll, ilabel ), truelabel ); *lastjmp = NULL; } } }; if ( truelabel ) { MakeLabel( ptr+strlen(ptr), truelabel ); strcpy( ptr+strlen( ptr ), "\n" ); AsmFree( truelabel ); *lastjmp = NULL; } *i = cur_pos; return( NOT_ERROR ); }
extern void DFSegRange( void ) { /****************************/ /* do arange for the current segment */ back_handle bck; offset off; offset size; if( !_IsModel( DBG_LOCALS | DBG_TYPES ) )return; size = AskMaxSize(); if( size > 0 ) { bck = MakeLabel(); off = AskLocation(); SetLocation( 0 ); DataLabel( bck->lbl ); SetLocation( off ); ARange = bck; DWAddress( Client, size ); BEFreeBack( bck ); } }
static void InsertMenuForWindow( gui_window *root, int index, int offset ) { char name[MAX_LENGTH]; char label[MAX_LENGTH]; gui_menu_struct menu; MakeLabel( index, name, label ); menu.label = label; menu.id = MDIWIN2ID( index ); menu.style = GUI_ENABLED; if( index == CurrMDIWindow ) { menu.style |= GUI_CHECKED; } menu.num_child_menus = 0; menu.child = NULL; MakeHintText( index, name ); menu.hinttext = MenuHint[index]; if( GUIMDIMenuID != NO_SELECT ) { GUIInsertMenuToPopup( root, GUIMDIMenuID, offset, &menu, false ); } }
void Compiler::DefineFunction( const yy::location& location, int type, const std::string* pName, ArgList* pArgs ) { std::auto_ptr < const std::string > name( pName ); std::auto_ptr < ArgList > args( pArgs ); const FunctionTag* pTag = m_Functions.Find( *pName ); if( pTag ){ if( !pTag->CheckArgList( pArgs ) ){ error( location, "Function " + *pName + " has different type of argument." ); return; } } else{ FunctionTag func( type ); func.SetArgs( pArgs ); // Set arguments. func.SetDeclaration(); // Set declared flag. func.SetIndex( MakeLabel() ); // Set label. if( m_Functions.Add( *pName, func ) == 0 ){ error( location, "Internal Error : Failed to register to function table." ); } } }
extern void DFLineNum( cue_state *state, offset lc ){ /*******************************************************/ char *fname; if( NeedBaseSet() ){ back_handle bck; bck = MakeLabel(); OutLabel( bck->lbl ); DWLineAddr( Client, (dw_sym_handle)bck, lc ); #if _TARGET & ( _TARG_IAPX86 | _TARG_80386 ) if( _IsntTargetModel( FLAT_MODEL ) ) { DWLineSeg( Client, (dw_sym_handle)bck ); } #endif BEFreeBack( bck ); } if( state->fno != CurrFNo ){ fname = SrcFNoFind( state->fno ); DWSetFile( Client, fname ); CurrFNo = state->fno; } DWLineNum( Client, DW_LN_STMT, state->line, state->col, lc ); }
void MyFrame::Test_All_1( wxCommandEvent& event ) { RemoveAll(); SetTestName( "Test_All_1" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new GridBagLayout() ); GridBagConstraints c; c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints::BOTH; c.gridwidth = GridBagConstraints::REMAINDER; Container* sortPanel = MakeStaticBox( "Filtering options: (in GridBagLayout)" ); Container* btnPanel = new Container(); parent->add( sortPanel, &c ); c.weighty = 0.0; parent->add( btnPanel, &c ); btnPanel->setLayout( new FlowLayout() ); btnPanel->setInsets( Insets( 10,10, 10,10 ) ); btnPanel->add( MakeLabel( "Buttons:" ) ); btnPanel->add( MakeButton( "&Apply" ) ); btnPanel->add( MakeButton( "&Cancel" ) ); btnPanel->add( MakeButton( "&Help" ) ); btnPanel->add( MakeLabel( "in a FlowLayout" ) ); SetCurrentContainer( sortPanel ); sortPanel->setInsets( GetInsetsForStaticBox( sortPanel ) ); // creating "Resolution" panel sortPanel->setLayout( new GridBagLayout() ); char* resValues[] = { "FIXED", "INVALID", "WONTFIX", "LATER", "REMIND", "DUPLICATE", "WORKSFORME" }; char* pltfValues[] = { "All", "DEC", "HP", "Macintosh", "PC", "SGI", "Sun", "Other" }; char* opSysValues[] = { "All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac Sys7", "Mac Sys7.5", "Mac Sys7.6.1", "Mac Sys8.0", "Mac Sys7", "Mac Sys8.5", "Mac Sys8.6", "Aix", "BSD", "IRIX", "Linux", "FreeBSD", "NetBSD", "OSF/1", "SOLARIS", "SunOS", "Neutrino", "OS/2", "OpenVMS", "other" }; char* compValues[] = { "Not applied", "wxGrid", "wxHTML", "wxMedia", "wxLayout", "wxDialupManager", "wxFrameLayout" }; char* severValues[] = { "Blocker", "Critical", "Major", "Minor", "Trivial", "Enhancement", "Showstopper" }; char* priValues[] = { "P1", "P2", "P3", "P4", "P5" }; int resCnt = sizeof( resValues ) / sizeof(char*); int pltfCnt = sizeof( pltfValues ) / sizeof(char*); int opSysCnt = sizeof( opSysValues ) / sizeof(char*); int compCnt = sizeof( compValues ) / sizeof(char*); int svrCnt = sizeof( severValues ) / sizeof(char*); int priCnt = sizeof( priValues ) / sizeof(char*); c.weightx = 1.0; c.fill = GridBagConstraints::BOTH; c = GridBagConstraints(); // reset defauls c.fill = GridBagConstraints::BOTH; int rel = GridBagConstraints::RELATIVE; c.weightx = 1.0; c.insets.left = 2; c.insets.right = 2; c.gridx = 1; c.gridy = 1; sortPanel->add( MakeListBox ( resValues, resCnt ), &c ); c.gridx = 2; c.gridwidth = 2; sortPanel->add( MakeListBox ( severValues, svrCnt ), &c ); c.gridx = 4; c.gridwidth = 1; sortPanel->add( MakeListBox ( priValues, priCnt ), &c ); c.gridy = 3; c.gridx = 1; c.weighty = 1.0; c.gridwidth = 2; sortPanel->add( MakeListBox ( compValues, compCnt ), &c ); c.gridx = 3; sortPanel->add( MakeListBox ( pltfValues, pltfCnt ), &c ); c.gridwidth = 1; c.gridx = 0; c.gridy = 1; c.weighty = 1.0; c.gridheight = GridBagConstraints::REMAINDER; sortPanel->add( MakeListBox ( opSysValues, opSysCnt ), &c ); c.gridx = 0; c.gridy = 0; c.gridheight = 1; c.weighty = 0.0; sortPanel->add( MakeCheckBox( "OpSys" ), &c ); c.gridx = 1; sortPanel->add( MakeCheckBox( "Resolution" ), &c ); c.gridx = 2; c.gridwidth = 2; sortPanel->add( MakeCheckBox( "Severity" ), &c ); c.gridx = 4; c.gridwidth = 0; sortPanel->add( MakeCheckBox( "Priority" ), &c ); c.gridx = 1; c.gridy = 2; c.gridwidth = 2; sortPanel->add( MakeCheckBox( "Component" ), &c ); c.gridx = 3; sortPanel->add( MakeCheckBox( "Platform" ), &c ); c.gridwidth = 0; Container* keywordsPanel = MakeStaticBox( "Contain Keywords: (in another grid-bag)" ); keywordsPanel->setInsets( GetInsetsForStaticBox( keywordsPanel ) ); c.gridx = 1; c.gridy = 4; c.insets.top = 5; c.gridwidth = GridBagConstraints::REMAINDER; c.weighty = 0.0; sortPanel->add( keywordsPanel, &c ); keywordsPanel->setLayout( new GridBagLayout() ); SetCurrentContainer( keywordsPanel ); c = GridBagConstraints(); // reset defauls c.anchor = GridBagConstraints::NORTHWEST; c.gridx = 0; c.gridy = 0; keywordsPanel->add( MakeRadioButton( "Up", TRUE ), &c ); c.gridx = 0; c.gridy = 1; keywordsPanel->add( MakeRadioButton( "Down" ), &c ); c.gridx = 0; c.gridy = 2; keywordsPanel->add( MakeRadioButton( "Start" ), &c ); c.fill = GridBagConstraints::BOTH; c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.weighty = 1.0; c.gridheight = 3; keywordsPanel->add( MakeTextField( "p1, fixed, bcc" ), &c ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
void init_display(int argc, char **argv, MyProgram *me) { Widget w[MAX_WIDGETS]; if (OpenDisplay(argc, argv) == FALSE) return; /* declare all the widgets */ w[FILE_MENU_IDX] = MakeMenu(" File "); w[OPTIONS_MENU_IDX] = MakeMenu(" Options "); w[DISPLAY_MENU_IDX] = MakeMenu(" Display "); w[CONTROL_MENU_IDX] = MakeMenu(" Control "); w[HELP_MENU_IDX] = MakeMenu(" Help "); w[LABEL_IDX] = MakeLabel(" "); w[DRAW_AREA_IDX] = MakeDrawArea(SCREEN_X_SIZE, SCREEN_Y_SIZE, redisplay, me); w[STATUS_AREA_IDX] = MakeDrawArea(STATUS_X_SIZE, STATUS_Y_SIZE, redisplay_status, me); /* add menu items to 'file' menu */ w[FILE_LOAD_IDX] = MakeMenuItem(w[FILE_MENU_IDX], "Load Image ...", file_load, me); w[FILE_SAVE_IDX] = MakeMenuItem(w[FILE_MENU_IDX], "Save Image ...", file_save, me); w[FILE_QUIT_IDX] = MakeMenuItem(w[FILE_MENU_IDX], "Quit", file_quit, me); /* add menu items to 'options' menu */ w[OPT_ROM_IDX] = MakeMenuItem(w[OPTIONS_MENU_IDX], "ROM Setup ...", options_rom_setup, me); w[OPT_RAM_IDX] = MakeMenuItem(w[OPTIONS_MENU_IDX], "RAM Setup ...", options_ram_setup, me); w[OPT_CLOCK_IDX] = MakeMenuItem(w[OPTIONS_MENU_IDX], "Clock Setup ...", options_clock_setup, me); w[OPT_STAT_IDX] = MakeMenuItem(w[OPTIONS_MENU_IDX], "Status ...", options_status, me); /* add menu items to 'display' menu */ w[DIS_MPU_IDX] = MakeMenuItem(w[DISPLAY_MENU_IDX], "MPU", display_mpu, me); w[DIS_SYS_IDX] = MakeMenuItem(w[DISPLAY_MENU_IDX], "System", display_system, me); w[DIS_BOTH_IDX] = MakeMenuItem(w[DISPLAY_MENU_IDX], "MPU & System", display_both, me); w[DIS_IMAGE_IDX] = MakeMenuItem(w[DISPLAY_MENU_IDX], "Code Image", display_image, me); /* add menu items to 'control' menu */ w[CON_RESET_IDX] = MakeMenuItem(w[CONTROL_MENU_IDX], "Reset", control_reset, me); w[CON_STEP_IDX] = MakeMenuItem(w[CONTROL_MENU_IDX], "Step", control_step, me); w[CON_GO_IDX] = MakeMenuItem(w[CONTROL_MENU_IDX], "Go", control_go, me); w[CON_HALT_IDX] = MakeMenuItem(w[CONTROL_MENU_IDX], "Halt", control_halt, me); /* add menu items to 'help' menu */ w[HELP_ABOUT_IDX] = MakeMenuItem(w[HELP_MENU_IDX], "About ...", help_about, me); w[HELP_MENUS_IDX] = MakeMenuItem(w[HELP_MENU_IDX], "Menu Help ...", help_menu, me); w[HELP_KEYS_IDX] = MakeMenuItem(w[HELP_MENU_IDX], "Keys Help ...", help_keys, me); /* callbacks for draw area */ SetButtonDownCB(w[DRAW_AREA_IDX], button_down); SetButtonUpCB(w[DRAW_AREA_IDX], button_up); SetMouseMotionCB(w[DRAW_AREA_IDX], motion); SetKeypressCB(w[DRAW_AREA_IDX], keypress); /* set all the widgets' positions */ SetWidgetPos(w[OPTIONS_MENU_IDX], PLACE_RIGHT, w[FILE_MENU_IDX], NO_CARE, NULL); SetWidgetPos(w[DISPLAY_MENU_IDX], PLACE_RIGHT, w[OPTIONS_MENU_IDX], NO_CARE, NULL); SetWidgetPos(w[CONTROL_MENU_IDX], PLACE_RIGHT, w[DISPLAY_MENU_IDX], NO_CARE, NULL); SetWidgetPos(w[HELP_MENU_IDX], PLACE_RIGHT, w[CONTROL_MENU_IDX], NO_CARE, NULL); SetWidgetPos(w[LABEL_IDX], PLACE_RIGHT, w[HELP_MENU_IDX], NO_CARE, NULL); SetWidgetPos(w[DRAW_AREA_IDX], PLACE_UNDER, w[FILE_MENU_IDX], NO_CARE, NULL); SetWidgetPos(w[STATUS_AREA_IDX], PLACE_UNDER, w[DRAW_AREA_IDX], NO_CARE, NULL); /* This call actually causes the whole thing to be displayed on the * screen. You have to call this function before doing any drawing * into the window. */ ShowDisplay(); /* Get standard (red, blue, green, yellow, black, white) colors for * drawing stuff. Check libsx.h for more info. */ GetStandardColors(); SetFgColor(w[FILE_MENU_IDX], WHITE); SetBgColor(w[FILE_MENU_IDX], BLUE); SetFgColor(w[OPTIONS_MENU_IDX], WHITE); SetBgColor(w[OPTIONS_MENU_IDX], BLUE); SetFgColor(w[DISPLAY_MENU_IDX], WHITE); SetBgColor(w[DISPLAY_MENU_IDX], BLUE); SetFgColor(w[CONTROL_MENU_IDX], WHITE); SetBgColor(w[CONTROL_MENU_IDX], BLUE); SetFgColor(w[HELP_MENU_IDX], WHITE); SetBgColor(w[HELP_MENU_IDX], BLUE); SetFgColor(w[LABEL_IDX], BLACK); SetFgColor(w[DRAW_AREA_IDX], WHITE); SetBgColor(w[DRAW_AREA_IDX], BLACK); SetFgColor(w[STATUS_AREA_IDX], WHITE); SetBgColor(w[STATUS_AREA_IDX], BLACK); SetFgColor(w[FILE_LOAD_IDX], WHITE); SetFgColor(w[FILE_SAVE_IDX], WHITE); SetFgColor(w[FILE_QUIT_IDX], WHITE); SetBgColor(w[FILE_LOAD_IDX], BLUE); SetFgColor(w[OPT_ROM_IDX], WHITE); SetFgColor(w[OPT_RAM_IDX], WHITE); SetFgColor(w[OPT_CLOCK_IDX], WHITE); SetFgColor(w[OPT_STAT_IDX], WHITE); SetBgColor(w[OPT_RAM_IDX], BLUE); SetFgColor(w[DIS_MPU_IDX], WHITE); SetFgColor(w[DIS_SYS_IDX], WHITE); SetFgColor(w[DIS_BOTH_IDX], WHITE); SetFgColor(w[DIS_IMAGE_IDX], WHITE); SetBgColor(w[DIS_MPU_IDX], BLUE); SetFgColor(w[CON_RESET_IDX], WHITE); SetFgColor(w[CON_STEP_IDX], WHITE); SetFgColor(w[CON_GO_IDX], WHITE); SetFgColor(w[CON_HALT_IDX], WHITE); SetBgColor(w[CON_RESET_IDX], BLUE); SetFgColor(w[HELP_ABOUT_IDX], WHITE); SetFgColor(w[HELP_MENUS_IDX], WHITE); SetFgColor(w[HELP_KEYS_IDX], WHITE); SetBgColor(w[HELP_ABOUT_IDX], BLUE); /* save drawing area widget */ me->draw_area_widget = w[DRAW_AREA_IDX]; me->status_area_widget = w[STATUS_AREA_IDX]; /* If you wanted to get all the colors in the colormap, you'd do the * following : * * GetAllColors(); * SetColorMap(GREY_SCALE_1); * * You can wait to do it till later if you want. There's no need * to do it here if you don't need to (because it wacks out the * colormap). */ }
extern void DFBegCCU( segment_id code, dw_sym_handle dbg_pch ) /****************************************************************/ // Call when codeseg hase been defined { dw_cu_info cu; back_handle bck; segment_id old; type_def *tipe_addr; if( _IsntModel( DBG_LOCALS | DBG_TYPES ) ) { return; } if( CcuDef ) { cu.source_filename = FEAuxInfo( NULL, SOURCE_NAME ); cu.directory = ""; cu.dbg_pch = dbg_pch; cu.inc_list = NULL; cu.inc_list_len = 0; old = SetOP( code ); #if _TARGET & ( _TARG_IAPX86 | _TARG_80386 ) if( _IsTargetModel( FLAT_MODEL ) ) { bck = MakeLabel(); OutLabel( bck->lbl ); Pc_Low = bck; Pc_High = MakeLabel(); // Emitting DW_AT_low_pc and DW_AT_high_pc is valid *only* if the // compilation unit's code is in a single contiguous block (see // DWARF 2, section 3.1). // I don't know how to find out at the time of this call if there's // only one code segment or not, hence these attributes are always // disabled. The low/high pc attribs should probably be handled by // the linker. cu.flags = false; cu.segment_size = 0; } else { bck = NULL; cu.flags = false; Pc_Low = NULL; Pc_High = NULL; cu.segment_size = 2; } #else bck = MakeLabel(); OutLabel( bck->lbl ); Pc_Low = bck; Pc_High = MakeLabel(); cu.flags = true; cu.segment_size = 0; #endif SetOP( old ); Comp_High = Pc_High; tipe_addr = TypeAddress( TY_NEAR_POINTER ); cu.offset_size = tipe_addr->length; switch( GetMemModel() ) { case 'h': cu.model = DW_MODEL_HUGE; break; case 'l': cu.model = DW_MODEL_LARGE; break; case 'f': cu.model = DW_MODEL_FLAT; break; case 's': cu.model = DW_MODEL_SMALL; break; default: cu.model = DW_MODEL_NONE; break; } DWBeginCompileUnit( Client, &cu ); if( cu.flags ) { BEFreeBack( bck ); } } else { CcuDef = true; } }
void ToolCodeGen::Emit(ToolCodeSnip *snip) { PageOp *op; sInt i,j; sInt comma; sInt column; if(snip->Flags & TCS_LOAD) { if(snip->OutputCount>1) { Error = 1; return; } Emit(" load %s;\n",snip->Name); } else if(snip->Flags & TCS_STORE) { if(snip->InputCount!=1) { Error = 1; return; } Emit(" store %s;\n",snip->Name); } else if(snip->CodeObject && snip->CodeObject->GetClass()==sCID_TOOL_PAGEOP) { if(snip->OutputCount>1) { Error = 1; return; } op = (PageOp *) snip->CodeObject; column = SourceUsed; Emit(" %s(",op->Class->Name); comma = 0; for(i=0;i<op->Class->ParaCount;i++) { if(comma) { Emit(","); if(SourceUsed-column>60) { Emit("\n "); column = SourceUsed-4; } } comma = sTRUE; if(op->Data[i].Anim) { if(op->Class->Para[i].Cycle && sCmpString(op->Class->Para[i].Cycle,"1234")==0) Emit("%d",MakeLabel(op->Data[i].Anim)); else Emit("\"%s\"",op->Data[i].Anim); } else { switch(op->Class->Para[i].Type) { case sCT_LABEL: comma = sFALSE; break; case sCT_FIXED: if(op->Class->Para[i].Zones<2) { Emit("%H",op->Data[i].Data[0]); } else { Emit("["); for(j=0;j<op->Class->Para[i].Zones;j++) { if(j>0) Emit(","); Emit("%H",op->Data[i].Data[j]); } Emit("]"); } break; case sCT_INT: if(op->Class->Para[i].Zones<2) { if(sCmpString(op->Class->Para[i].Name,"ocount")==0) Emit("%d",snip->FXViewport ? -snip->OriginalOutputCount : snip->OriginalOutputCount); else Emit("%d",op->Data[i].Data[0]); } else { Emit("["); for(j=0;j<op->Class->Para[i].Zones;j++) { if(j>0) Emit(","); Emit("%d",op->Data[i].Data[j]); } Emit("]"); } break; case sCT_RGBA: Emit("#%02x%02x%02x%02x", sRange(op->Data[i].Data[3]>>8,255,0), sRange(op->Data[i].Data[0]>>8,255,0), sRange(op->Data[i].Data[1]>>8,255,0), sRange(op->Data[i].Data[2]>>8,255,0)); break; case sCT_RGB: Emit("#%02x%02x%02x", sRange(op->Data[i].Data[0]>>8,255,0), sRange(op->Data[i].Data[1]>>8,255,0), sRange(op->Data[i].Data[2]>>8,255,0)); break; case sCT_CYCLE: case sCT_CHOICE: Emit("%d",op->Data[i].Data[0]); break; case sCT_MASK: Emit("%h",op->Data[i].Data[0]); break; default: sVERIFYFALSE; break; } } } Emit(");\n"); } }
/** * Initialize the filter window. */ static void init_filter(void) { static struct Hook filter_construct_hook; static struct Hook filter_destruct_hook; static struct Hook filter_display_hook; static struct Hook move_objstr_hook, move_strobj_hook; Object *ok_button, *cancel_button, *save_button; Object *filter_move_popobject, *filter_remote_label; init_hook(&filter_construct_hook,(HOOKFUNC)filter_construct); init_hook(&filter_destruct_hook,(HOOKFUNC)filter_destruct); init_hook(&filter_display_hook,(HOOKFUNC)filter_display); init_hook(&move_objstr_hook, (HOOKFUNC)move_objstr); init_hook(&move_strobj_hook, (HOOKFUNC)move_strobj); filter_wnd = WindowObject, MUIA_Window_ID, MAKE_ID('F','I','L','T'), MUIA_Window_Title, _("SimpleMail - Edit Filter"), WindowContents, VGroup, Child, VGroup, Child, HGroup, Child, VGroup, MUIA_HorizWeight,40, Child, VGroup, MUIA_Group_Spacing, 0, Child, NListviewObject, MUIA_NListview_NList, filter_list = FilterListObject, MUIA_NList_AutoVisible, 1, /* keep the active filter visible */ MUIA_NList_ConstructHook, &filter_construct_hook, MUIA_NList_DestructHook, &filter_destruct_hook, MUIA_NList_DisplayHook, &filter_display_hook, End, End, Child, HGroup, Child, filter_name_string = UTF8StringObject, StringFrame, End, End, End, Child, ColGroup(2), Child, filter_new_button = MakeButton(_("_New")), Child, filter_remove_button = MakeButton(_("_Remove")), Child, filter_moveup_button = MakeButton(_("Move up")), Child, filter_movedown_button = MakeButton(_("Move Down")), End, End, Child, BalanceObject, End, Child, VGroup, Child, HorizLineTextObject(_("Activity")), Child, HGroup, Child, RectangleObject,MUIA_Weight,25,End, Child, ColGroup(5), Child, MakeLabel(_("On request")), Child, filter_request_check = MakeCheck(NULL,FALSE), Child, RectangleObject,MUIA_Weight,200,End, Child, MakeLabel(_("On sent mails")), Child, filter_sent_check = MakeCheck(NULL,FALSE), Child, filter_remote_label = MakeLabel(_("Remotly on POP3 server")), Child, filter_remote_check = MakeCheck(NULL,FALSE), Child, RectangleObject,MUIA_Weight,200,End, Child, MakeLabel(_("On new mails")), Child, filter_new_check = MakeCheck(NULL,FALSE), End, Child, RectangleObject,MUIA_Weight,25,End, End, Child, HorizLineTextObject(_("Rules")), Child, VGroupV, Child, filter_rule_group = ColGroup(2), Child, HVSpace, Child, HVSpace, End, End, Child, HGroup, Child, filter_add_rule_button = MakeButton(_("Add new rule")), Child, filter_apply_now_button = MakeButton(_("Apply now")), End, Child, HorizLineTextObject(_("Action")), Child, VGroup, Child, ColGroup(3), Child, MakeLabel(_("Move to Folder")), Child, filter_move_check = MakeCheck(_("Move to Folder"),FALSE), Child, filter_move_popobject = PopobjectObject, MUIA_Disabled, TRUE, MUIA_Popstring_Button, PopButton(MUII_PopUp), MUIA_Popstring_String, filter_move_text = TextObject, TextFrame, MUIA_Background, MUII_TextBack, End, MUIA_Popobject_ObjStrHook, &move_objstr_hook, MUIA_Popobject_StrObjHook, &move_strobj_hook, MUIA_Popobject_Object, NListviewObject, MUIA_NListview_NList, filter_folder_list = FolderTreelistObject, End, End, End, Child, MakeLabel(_("Execute ARexx Script")), Child, filter_arexx_check = MakeCheck(_("Execute ARexx Script"),FALSE), Child, filter_arexx_popasl = PopaslObject, MUIA_Disabled, TRUE, MUIA_Popstring_Button, PopButton(MUII_PopFile), MUIA_Popstring_String, filter_arexx_string = BetterStringObject, StringFrame, MUIA_CycleChain,1, MUIA_String_Acknowledge, TRUE, End, End, Child, MakeLabel(_("Play Sound")), Child, filter_sound_check = MakeCheck(_("Play Sound"),FALSE), Child, filter_sound_string = AudioSelectGroupObject, MUIA_Disabled, TRUE, End, End, End, End, End, End, Child, HorizLineObject, Child, HGroup, Child, save_button = MakeButton(Q_("?filter:_Save")), Child, ok_button = MakeButton(_("_Use")), Child, cancel_button = MakeButton(_("_Cancel")), End, End, End; if (filter_wnd) { char *short_help_txt = _("If activated the filter will be used remotly on POP3 servers\n" "which support the TOP command. Mails which matches the filter\n" "are presented to the user and automatically marked as to be ignored."); set(filter_remote_label, MUIA_ShortHelp, short_help_txt); set(filter_remote_check, MUIA_ShortHelp, short_help_txt); DoMethod(App, OM_ADDMEMBER, (ULONG)filter_wnd); DoMethod(filter_wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_cancel); DoMethod(ok_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_ok); DoMethod(save_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_ok); DoMethod(save_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)save_filter); DoMethod(cancel_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_cancel); DoMethod(filter_new_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_new); DoMethod(filter_remove_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_remove); DoMethod(filter_moveup_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_list, 3, MUIM_NList_Move, MUIV_NList_Move_Active, MUIV_NList_Move_Previous); DoMethod(filter_movedown_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_list, 3, MUIM_NList_Move, MUIV_NList_Move_Active, MUIV_NList_Move_Next); set(filter_name_string, MUIA_String_AttachedList, (ULONG)filter_list); DoMethod(filter_list, MUIM_Notify, MUIA_NList_Active, MUIV_EveryTime, (ULONG)filter_list, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_active); DoMethod(filter_name_string, MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, (ULONG)filter_list, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_name); DoMethod(filter_add_rule_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_add_rule_gui); DoMethod(filter_apply_now_button, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)filter_wnd, 3, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)filter_apply); DoMethod(filter_move_check, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, (ULONG)filter_move_popobject, 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue); DoMethod(filter_sound_check, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, (ULONG)filter_sound_string, 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue); DoMethod(filter_arexx_check, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, (ULONG)filter_arexx_popasl, 3, MUIM_Set, MUIA_Disabled, MUIV_NotTriggerValue); DoMethod(filter_folder_list, MUIM_Notify, MUIA_NList_DoubleClick, TRUE, (ULONG)filter_move_popobject, 2, MUIM_Popstring_Close, 1); filter_update_folder_list(); } }
void MyFrame::Test_All_2( wxCommandEvent& event ) { RemoveAll(); SetTestName( "Test_All_2" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new GridBagLayout() ); GridBagConstraints c; c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints::BOTH; c.gridwidth = GridBagConstraints::REMAINDER; c.insets = Insets( 5,10,2,10 ); Container* imagePanel = new Container(); parent->add( imagePanel, &c ); imagePanel->setLayout( new FlowLayout() ); for( int i = 0; i != 15; ++i ) { Component* pComp = MakeButton( "< " + IntToStr( i + 1 ) + " >" ); pComp->setMinimumSize( Dimension( 60,60 ) ); imagePanel->add( pComp ); } c.weighty = 0.0; c.fill = GridBagConstraints::VERTICAL; c.insets.top = 2; parent->add( MakeLabel( "---- Purchase A Fine Image Today -----" ), &c ); c.insets.top = 5; c.fill = GridBagConstraints::BOTH; Container* infoPanel = MakeStaticBox( "" ); Container* btnPanel = new Container(); parent->add( infoPanel, &c ); parent->add( btnPanel, &c ); btnPanel->setLayout( new FlowLayout() ); btnPanel->add( MakeButton( "&Purchase" ) ); btnPanel->add( MakeButton( "&Cancel" ) ); infoPanel->setLayout( new GridBagLayout() ); infoPanel->setInsets( GetInsetsForStaticBox( infoPanel ) ); SetCurrentContainer( infoPanel ); int rmd = GridBagConstraints::REMAINDER; c.insets = Insets( 5,5, 0,0 ); c.fill = GridBagConstraints::HORIZONTAL; c.weightx = 0.0; c.gridx = 0; c.gridy = 0; infoPanel->add( MakeLabel( "Name:" ), &c ); c.gridwidth = rmd; c.weightx = 1.0; c.gridwidth = 3; infoPanel->add( MakeTextField( "" ), &c ); c.gridwidth = 0; c.weightx = 0.0; c.gridx = 0; c.gridy = 1; infoPanel->add( MakeLabel( "Address:" ), &c ); c.gridwidth = rmd; c.weightx = 1.0; c.gridwidth = 3; infoPanel->add( MakeTextField( "" ), &c ); c.gridwidth = 0; c.weightx = 0.0; c.gridx = 0; c.gridy = 2; infoPanel->add( MakeLabel( "City:" ), &c ); c.weightx = 1.0; infoPanel->add( MakeTextField( "" ), &c ); c.weightx = 0.0; infoPanel->add( MakeLabel( "State:" ), &c ); infoPanel->add( MakeTextField( "" ), &c ); char* methods[] = { "Visa", "MasterCard", "Check" }; c.weightx = 0.0; c.gridx = 0; c.gridy = 3; infoPanel->add( MakeLabel( "Payment:" ), &c ); c.weightx = 0.0; c.fill = GridBagConstraints::NONE; c.anchor = GridBagConstraints::WEST; infoPanel->add( MakeComboBox( methods, sizeof(methods)/sizeof(char*) ), &c ); // no auto-packing for this panel... // (so many images in flow-layout may cause default width to be too big) parent->doLayout(); }
STATIC ULONG transwnd_New(struct IClass *cl, Object *obj, struct opSet *msg) { Object *gauge1,/* *gauge2,*/*status,*abort,*mail_listview, *mail_list, *mail_group, *start, *ignore, *down, *del, *downdel, *ignore_check,*all,*none, *skip; Object *head; obj = (Object *) DoSuperNew(cl, obj, WindowContents, VGroup, Child, head = TextObject,End, Child, RectangleObject, MUIA_Weight, 1, End, Child, mail_group = VGroup, MUIA_ShowMe, FALSE, Child, mail_listview = NListviewObject, MUIA_NListview_NList, mail_list = NListObject, MUIA_NList_Title, TRUE, MUIA_NList_Format, "P=\033r,,,", End, End, Child, HGroup, Child, ignore = MakeButton(_("Ignore")), Child, down = MakeButton(_("Download")), Child, del = MakeButton(_("Delete")), Child, downdel = MakeButton(_("Download & Delete")), Child, start = MakeButton(_("_Start")), End, Child, HGroup, Child, all = MakeButton(_("Select All")), Child, none = MakeButton(_("Select None")), Child, MakeLabel(_("Ignore not listed mails")), Child, ignore_check = MakeCheck(_("Ignore not listed mails"),FALSE), Child, HVSpace, End, End, Child, gauge1 = GaugeObject, GaugeFrame, MUIA_Gauge_InfoText, _("Waiting..."), MUIA_Gauge_Horiz, TRUE, End, /* Child, gauge2 = GaugeObject, GaugeFrame, MUIA_Gauge_InfoText, _("Waiting..."), MUIA_Gauge_Horiz, TRUE, End,*/ Child, HGroup, Child, status = TextObject, TextFrame, MUIA_Text_Contents, "", MUIA_Background, MUII_TextBack, End, Child, skip = MakeButton(_("_Skip")), Child, abort = MakeButton(_("_Abort")), End, End, TAG_MORE, msg->ops_AttrList); if (obj != NULL) { struct transwnd_Data *data = (struct transwnd_Data *) INST_DATA(cl, obj); data->gauge1 = gauge1; /* data->gauge2 = gauge2; */ data->status = status; data->abort = abort; data->skip = skip; data->head = head; data->mail_listview = mail_listview; data->mail_list = mail_list; data->mail_group = mail_group; data->start = start; data->ignore_check = ignore_check; data->status_download = PictureButtonObject, MUIA_PictureButton_Directory, gui_get_images_directory(), MUIA_PictureButton_Filename, "status_download", End; data->status_trashcan = PictureButtonObject, MUIA_PictureButton_Directory, gui_get_images_directory(), MUIA_PictureButton_Filename, "status_trashcan", End; init_hook_with_data(&data->construct_hook, (HOOKFUNC)mail_construct, data); init_hook_with_data(&data->destruct_hook, (HOOKFUNC)mail_destruct, data); init_hook_with_data(&data->display_hook, (HOOKFUNC)mail_display, data); SetAttrs(mail_list, MUIA_NList_ConstructHook, &data->construct_hook, MUIA_NList_DestructHook, &data->destruct_hook, MUIA_NList_DisplayHook, &data->display_hook, MUIA_NList_MultiSelect, MUIV_NList_MultiSelect_Default, TAG_DONE); set(skip, MUIA_Weight, 0); set(abort, MUIA_Weight, 0); DoMethod(abort, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)obj, 3, MUIM_Set, MUIA_transwnd_Aborted, TRUE); DoMethod(skip, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)obj, 3, MUIM_Set, MUIA_transwnd_Skipped, TRUE); DoMethod(start, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)App, 3, MUIM_WriteLong, (1<<0), (ULONG)&data->start_pressed); DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (ULONG)obj, 3, MUIM_Set, MUIA_transwnd_Aborted, TRUE); DoMethod(ignore, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)App, 5, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)transwnd_set_mail_flags, (ULONG)data, 0); DoMethod(down, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)App, 5, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)transwnd_set_mail_flags, (ULONG)data, MAILF_DOWNLOAD); DoMethod(del, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)App, 5, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)transwnd_set_mail_flags, (ULONG)data, MAILF_DELETE); DoMethod(downdel, MUIM_Notify, MUIA_Pressed, FALSE, (ULONG)App, 5, MUIM_CallHook, (ULONG)&hook_standard, (ULONG)transwnd_set_mail_flags, (ULONG)data, MAILF_DOWNLOAD|MAILF_DELETE); DoMethod(all,MUIM_Notify,MUIA_Pressed, FALSE, (ULONG)mail_list, 4, MUIM_NList_Select, MUIV_NList_Select_All, MUIV_NList_Select_On, NULL); DoMethod(none,MUIM_Notify,MUIA_Pressed, FALSE, (ULONG)mail_list, 4, MUIM_NList_Select, MUIV_NList_Select_All, MUIV_NList_Select_Off, NULL); } return((ULONG) obj); }
bool Polish::Write(const std::string& filename, const std::multimap<int, Airspace>& airspaces) { if (airspaces.empty()) { AirspaceConverter::LogMessage("Polish output: no airspace, nothing to write", false); return false; } // Check if has the right extension if (!boost::iequals(boost::filesystem::path(filename).extension().string(), ".mp")) { AirspaceConverter::LogMessage("ERROR: Expected MP extension but found: " + boost::filesystem::path(filename).extension().string(), true); return false; } if (file.is_open()) file.close(); file.open(filename, std::ios::out | std::ios::trunc | std::ios::binary); if (!file.is_open() || file.bad()) { AirspaceConverter::LogMessage("ERROR: Unable to open output file: " + filename, true); return false; } AirspaceConverter::LogMessage("Writing output file: " + filename, false); WriteHeader(filename); // Go trough all airspaces for (const std::pair<const int,Airspace>& pair : airspaces) { // Get the airspace const Airspace& a = pair.second; // Just a couple if assertions assert(a.GetNumberOfPoints() > 3); assert(a.GetFirstPoint()==a.GetLastPoint()); // Determine if it's a POLYGON or a POLYLINE if (a.GetType() == Airspace::PROHIBITED || a.GetType() == Airspace::CTR || a.GetType() == Airspace::DANGER) { file << "[POLYGON]\n" //<< "Type="<< types[a.GetType()] <<"\n"; //TODO... << "Type=0x18" <<"\n"; } else { file << "[POLYLINE]\n" << "Type=0x07\n"; //TODO.... } // Add the label file << "Label="<<MakeLabel(a)<<"\n"; file << "Levels=3\n"; // Insert all the points file << "Data0="; double lat,lon; for (unsigned int i=0; i<a.GetNumberOfPoints()-1; i++) { a.GetPointAt(i).GetLatLon(lat,lon); file << "(" << lat << "," << lon << "),"; } a.GetLastPoint().GetLatLon(lat,lon); file << "(" << lat << "," << lon << ")\n"; //file<< "EndLevel=4\n"; // Close the element file << "[END]\n\n"; } file.close(); return true; }
OLD_MAIN(QWidget* pParent = nullptr) : QMainWindow(pParent) { Q_INIT_RESOURCE(Resources); // Settings persistence ReadSettings(); // Appearance LUT PlayerApperances appearances; // Build player table model from file PlayerTableModel* playerTableModel = new PlayerTableModel(this); playerTableModel->LoadHittingProjections(appearances); playerTableModel->LoadPitchingProjections(appearances); playerTableModel->CalculateHittingScores(); playerTableModel->CalculatePitchingScores(); playerTableModel->InitializeTargetValues(); // Draft delegate DraftDelegate* draftDelegate = new DraftDelegate(playerTableModel); LinkDelegate* linkDelegate = new LinkDelegate(this); TagDelegate* tagDelegate = new TagDelegate(this); // Hitter sort-model PlayerSortFilterProxyModel* hitterSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Hitter); hitterSortFilterProxyModel->setSourceModel(playerTableModel); hitterSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole); // Hitter table view QTableView* hitterTableView = MakeTableView(hitterSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z); hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate); hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate); hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate); hitterTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked); // Context menu QMenu* contextMenu = new QMenu(); contextMenu->addAction("&Remove Player"); // Apply to hitter table view hitterTableView->setContextMenuPolicy(Qt::CustomContextMenu); connect(hitterTableView, &QWidget::customContextMenuRequested, [=](const QPoint& pos) { QPoint globalPos = hitterTableView->mapToGlobal(pos); QAction* selectedItem = contextMenu->exec(globalPos); if (selectedItem) { auto proxyIndex = hitterTableView->indexAt(pos); auto srcIndex = hitterSortFilterProxyModel->mapToSource(proxyIndex); playerTableModel->RemovePlayer(srcIndex.row()); } }); // Pitcher sort-model PlayerSortFilterProxyModel* pitcherSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Pitcher); pitcherSortFilterProxyModel->setSourceModel(playerTableModel); pitcherSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole); // Pitcher table view QTableView* pitcherTableView = MakeTableView(pitcherSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z); pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate); pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate); pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate); pitcherTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked); // Top/Bottom splitter QSplitter* topBottomSplitter = new QSplitter(Qt::Vertical); topBottomSplitter->setContentsMargins(5, 5, 5, 5); // Hitter/Pitcher tab View enum PlayerTableTabs { Hitters, Pitchers, Unknown }; QTabWidget* hitterPitcherTabs = new QTabWidget(this); hitterPitcherTabs->insertTab(PlayerTableTabs::Hitters, hitterTableView, "Hitters"); hitterPitcherTabs->insertTab(PlayerTableTabs::Pitchers, pitcherTableView, "Pitchers"); topBottomSplitter->addWidget(hitterPitcherTabs); // Tab lookup helper auto CaterogyToTab = [](uint32_t catergory) { switch (catergory) { case Player::Hitter: return PlayerTableTabs::Hitters; case Player::Pitcher: return PlayerTableTabs::Pitchers; default: return PlayerTableTabs::Unknown; } }; // Drafted filter action QAction* filterDrafted = new QAction(this); connect(filterDrafted, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted); connect(filterDrafted, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted); filterDrafted->setText(tr("Drafted")); filterDrafted->setToolTip("Toggle Drafted Players"); filterDrafted->setCheckable(true); filterDrafted->toggle(); QAction* filterReplacement = new QAction(this); connect(filterReplacement, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterReplacement); connect(filterReplacement, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterReplacement); filterReplacement->setText(tr("($1)")); filterReplacement->setToolTip("Toggle replacements players with value under $1"); filterReplacement->setCheckable(true); filterReplacement->toggle(); // NL filter action QAction* filterNL = new QAction(this); connect(filterNL, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterNL); connect(filterNL, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterNL); filterNL->setText(tr("NL")); filterNL->setToolTip("Toggle National Leauge"); filterNL->setCheckable(true); filterNL->toggle(); // AL filter action QAction* filterAL = new QAction(this); connect(filterAL, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterAL); connect(filterAL, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterAL); filterAL->setText(tr("AL")); filterAL->setToolTip("Toggle American Leauge"); filterAL->setCheckable(true); filterAL->toggle(); // FA filter action QAction* filterFA = new QAction(this); connect(filterFA, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterFA); connect(filterFA, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterFA); filterFA->setText(tr("FA")); filterFA->setToolTip("Toggle Free Agents"); filterFA->setCheckable(true); filterAL->toggle(); filterAL->toggle(); // General filter group QActionGroup* generalFilters = new QActionGroup(this); generalFilters->addAction(filterAL); generalFilters->addAction(filterNL); generalFilters->addAction(filterFA); generalFilters->setExclusive(false); // Starter filter action QAction* filterStarter = new QAction(this); connect(filterStarter, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterSP); filterStarter->setText(tr("SP")); filterStarter->setToolTip("Toggle Starting Pitchers"); filterStarter->setCheckable(true); filterStarter->toggle(); // Relief filter action QAction* filterRelief = new QAction(this); connect(filterRelief, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterRP); filterRelief->setText(tr("RP")); filterRelief->setToolTip("Toggle Relief Pitchers"); filterRelief->setCheckable(true); filterRelief->toggle(); // Pitching filter group QActionGroup* pitchingFilters = new QActionGroup(this); pitchingFilters->addAction(filterStarter); pitchingFilters->addAction(filterRelief); pitchingFilters->setExclusive(false); // Hitting filter group QActionGroup* hittingFilters = new QActionGroup(this); hittingFilters->setExclusive(false); // Filter helper auto MakeHitterFilter = [=](QString text, QString toolTip, const auto& onFilterFn) -> QAction* { QAction* action = new QAction(this); connect(action, &QAction::toggled, hitterSortFilterProxyModel, onFilterFn); action->setText(text); action->setToolTip(toolTip); action->setCheckable(true); action->toggle(); hittingFilters->addAction(action); return action; }; // Hitter filters QAction* filterC = MakeHitterFilter("C", "Filter Catchers", &PlayerSortFilterProxyModel::OnFilterC); QAction* filter1B = MakeHitterFilter("1B", "Filter 1B", &PlayerSortFilterProxyModel::OnFilter1B); QAction* filter2B = MakeHitterFilter("2B", "Filter 2B", &PlayerSortFilterProxyModel::OnFilter2B); QAction* filterSS = MakeHitterFilter("SS", "Filter SS", &PlayerSortFilterProxyModel::OnFilterSS); QAction* filter3B = MakeHitterFilter("3B", "Filter 3B", &PlayerSortFilterProxyModel::OnFilter3B); QAction* filterOF = MakeHitterFilter("OF", "Filter Outfielders", &PlayerSortFilterProxyModel::OnFilterOF); QAction* filterCI = MakeHitterFilter("CI", "Filter Corner Infielders", &PlayerSortFilterProxyModel::OnFilterCI); QAction* filterMI = MakeHitterFilter("MI", "Filter Middle Infielders", &PlayerSortFilterProxyModel::OnFilterMI); QAction* filterDH = MakeHitterFilter("DH", "Filter Designated Hitters", &PlayerSortFilterProxyModel::OnFilterDH); QAction* filterU = MakeHitterFilter("U", "Filter Utility", &PlayerSortFilterProxyModel::OnFilterU); // Menu spacer QWidget* spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // Completion Widget QCompleter* completer = new QCompleter(this); completer->setModel(playerTableModel); completer->setCompletionColumn(PlayerTableModel::COLUMN_NAME); completer->setFilterMode(Qt::MatchContains); completer->setCaseSensitivity(Qt::CaseInsensitive); // Select auto HighlightPlayerInTable = [=](const QModelIndex& srcIdx) { // Lookup catergory auto catergoryIdx = srcIdx.model()->index(srcIdx.row(), PlayerTableModel::COLUMN_CATERGORY); auto catergory = srcIdx.model()->data(catergoryIdx).toUInt(); // Change to tab hitterPitcherTabs->setCurrentIndex(CaterogyToTab(catergory)); // Select row if (catergory == Player::Catergory::Hitter) { auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(hitterTableView->model()); auto proxyIdx = proxyModel->mapFromSource(srcIdx); hitterTableView->selectRow(proxyIdx.row()); hitterTableView->setFocus(); } else if (catergory == Player::Catergory::Pitcher) { auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(pitcherTableView->model()); auto proxyIdx = proxyModel->mapFromSource(srcIdx); pitcherTableView->selectRow(proxyIdx.row()); pitcherTableView->setFocus(); } }; // Select the target connect(completer, static_cast<void (QCompleter::*)(const QModelIndex&)>(&QCompleter::activated), [=](const QModelIndex& index) { // Get player index QAbstractProxyModel* proxyModel = dynamic_cast<QAbstractProxyModel*>(completer->completionModel()); auto srcIdx = proxyModel->mapToSource(index); // Highlight this player HighlightPlayerInTable(srcIdx); }); // Search widget QLineEdit* playerSearch = new QLineEdit(this); playerSearch->setCompleter(completer); // Main toolbar QToolBar* toolbar = new QToolBar("Toolbar"); toolbar->addWidget(new QLabel(" Status: ", this)); toolbar->addActions(QList<QAction*>{filterDrafted, filterReplacement}); toolbar->addSeparator(); toolbar->addWidget(new QLabel(" Leagues: ", this)); toolbar->addActions(QList<QAction*>{filterAL, filterNL, filterFA}); toolbar->addSeparator(); toolbar->addWidget(new QLabel(" Positions: ", this)); toolbar->addActions(QList<QAction*>{filterStarter, filterRelief}); toolbar->addActions(QList<QAction*>{filterC, filter1B, filter2B, filterSS, filter3B, filterOF, filterCI, filterMI, filterDH, filterU}); toolbar->addWidget(spacer); toolbar->addWidget(new QLabel("Player Search: ", this)); toolbar->addWidget(playerSearch); toolbar->setFloatable(false); toolbar->setMovable(false); QMainWindow::addToolBar(toolbar); // Helper to adjust filters auto ToggleFilterGroups = [=](int index) { switch (index) { case uint32_t(PlayerTableTabs::Hitters): pitchingFilters->setVisible(false); hittingFilters->setVisible(true); break; case uint32_t(PlayerTableTabs::Pitchers): pitchingFilters->setVisible(true); hittingFilters->setVisible(false); break; default: break; } }; // Set default filter group ToggleFilterGroups(hitterPitcherTabs->currentIndex()); //--------------------------------------------------------------------- // Bottom Section //--------------------------------------------------------------------- // Owner widget QHBoxLayout* ownersLayout = new QHBoxLayout(this); ownersLayout->setSizeConstraint(QLayout::SetNoConstraint); // Owner models std::vector<OwnerSortFilterProxyModel*> vecOwnerSortFilterProxyModels; // Owner labels QList<QLabel*>* pVecOwnerLabels; pVecOwnerLabels = new QList<QLabel*>(); pVecOwnerLabels->append(new QLabel("--")); for (auto i = 1u; i <= DraftSettings::Get().OwnerCount; i++) { pVecOwnerLabels->append(new QLabel(DraftSettings::Get().OwnerNames[i])); } // Update label helper auto UpdateOwnerLabels = [=]() { for (auto i = 1u; i <= DraftSettings::Get().OwnerCount; i++) { pVecOwnerLabels->at(i)->setText(DraftSettings::Get().OwnerNames[i]); } }; // Initialize UpdateOwnerLabels(); // Loop owners for (uint32_t ownerId = 1; ownerId <= DraftSettings::Get().OwnerCount; ownerId++) { // V-Layout per owner QVBoxLayout* perOwnerLayout = new QVBoxLayout(this); ownersLayout->addLayout(perOwnerLayout); perOwnerLayout->setSizeConstraint(QLayout::SetNoConstraint); // Proxy model for this owner OwnerSortFilterProxyModel* ownerSortFilterProxyModel = new OwnerSortFilterProxyModel(ownerId, playerTableModel, this); vecOwnerSortFilterProxyModels.push_back(ownerSortFilterProxyModel); // Owner name label pVecOwnerLabels->at(ownerId)->setAlignment(Qt::AlignCenter); perOwnerLayout->addWidget(pVecOwnerLabels->at(ownerId)); // Per-owner roster table view const uint32_t tableWidth = 225; QTableView* ownerRosterTableView = MakeTableView(ownerSortFilterProxyModel, true, 0); ownerRosterTableView->setMinimumSize(tableWidth, 65); ownerRosterTableView->setMaximumSize(tableWidth, 4096); ownerRosterTableView->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); perOwnerLayout->addWidget(ownerRosterTableView); // XXX: This should be a form layout... QGridLayout* ownerSummaryGridLayout = new QGridLayout(this); ownerSummaryGridLayout->setSpacing(0); ownerSummaryGridLayout->addWidget(MakeLabel("Budget: "), 0, 0); ownerSummaryGridLayout->addWidget(MakeLabel("# Hitters: "), 1, 0); ownerSummaryGridLayout->addWidget(MakeLabel("# Pitchers: "), 2, 0); ownerSummaryGridLayout->addWidget(MakeLabel("Max Bid: "), 3, 0); QLabel* budgetLabel = MakeLabel(); QLabel* numHittersLabel = MakeLabel(); QLabel* numPitchersLabel = MakeLabel(); QLabel* maxBidLabel = MakeLabel(); // Helper auto UpdateLabels = [=]() { budgetLabel->setText(QString("$%1").arg(ownerSortFilterProxyModel->GetRemainingBudget())); numHittersLabel->setText(QString("%1 / %2").arg(ownerSortFilterProxyModel->Count(Player::Hitter)).arg(DraftSettings::Get().HitterCount)); numPitchersLabel->setText(QString("%1 / %2").arg(ownerSortFilterProxyModel->Count(Player::Pitcher)).arg(DraftSettings::Get().PitcherCount)); maxBidLabel->setText(QString("$%1").arg(ownerSortFilterProxyModel->GetMaxBid())); }; // Update labels when a draft event happens connect(playerTableModel, &PlayerTableModel::DraftedEnd, [=]() { UpdateLabels(); }); UpdateLabels(); ownerSummaryGridLayout->addWidget(budgetLabel, 0, 1); ownerSummaryGridLayout->addWidget(numHittersLabel, 1, 1); ownerSummaryGridLayout->addWidget(numPitchersLabel, 2, 1); ownerSummaryGridLayout->addWidget(maxBidLabel, 3, 1); QSpacerItem* spacer = new QSpacerItem(1, 1, QSizePolicy::Preferred, QSizePolicy::Preferred); ownerSummaryGridLayout->addItem(spacer, 0, 2); ownerSummaryGridLayout->addItem(spacer, 1, 2); ownerSummaryGridLayout->addItem(spacer, 2, 2); ownerSummaryGridLayout->addItem(spacer, 3, 2); perOwnerLayout->addLayout(ownerSummaryGridLayout); perOwnerLayout->addSpacerItem(spacer); } // Owner widget QWidget* scrollAreaWidgetContents = new QWidget(this); scrollAreaWidgetContents->setLayout(ownersLayout); scrollAreaWidgetContents->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); // Owner scroll area QScrollArea* ownerScrollArea = new QScrollArea(this); ownerScrollArea->setWidget(scrollAreaWidgetContents); ownerScrollArea->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); ownerScrollArea->setBackgroundRole(QPalette::Light); ownerScrollArea->setFrameShape(QFrame::NoFrame); ownerScrollArea->setWidgetResizable(true); // Target value widget QWidget* targetValueWidget = new QWidget(this); QFormLayout* targetValueLayout = new QFormLayout(this); targetValueWidget->setLayout(targetValueLayout); auto values = { PlayerTableModel::COLUMN_AVG, PlayerTableModel::COLUMN_HR, PlayerTableModel::COLUMN_R, PlayerTableModel::COLUMN_RBI, PlayerTableModel::COLUMN_SB, PlayerTableModel::COLUMN_SO, PlayerTableModel::COLUMN_ERA, PlayerTableModel::COLUMN_WHIP, PlayerTableModel::COLUMN_W, PlayerTableModel::COLUMN_SV, }; for (auto value : values) { auto name = playerTableModel->headerData(value, Qt::Horizontal, Qt::DisplayRole).toString(); auto target = QString::number(playerTableModel->GetTargetValue(value), 'f', 3); targetValueLayout->addRow(name, new QLabel(target)); } // Player scatter plot PlayerScatterPlotChart* chartView = new PlayerScatterPlotChart(playerTableModel, hitterSortFilterProxyModel, this); connect(hitterSortFilterProxyModel, &QSortFilterProxyModel::layoutChanged, chartView, &PlayerScatterPlotChart::Update); connect(pitcherSortFilterProxyModel, &QSortFilterProxyModel::layoutChanged, chartView, &PlayerScatterPlotChart::Update); connect(playerTableModel, &QAbstractItemModel::dataChanged, chartView, &PlayerScatterPlotChart::Update); // Summary view SummaryWidget* summary = new SummaryWidget(playerTableModel, vecOwnerSortFilterProxyModels, this); // Bottom tabs enum BottomSectionTabs { Rosters, Summary, Targets, ChartView, Log }; QTabWidget* bottomTabs = new QTabWidget(this); topBottomSplitter->addWidget(bottomTabs); bottomTabs->insertTab(BottomSectionTabs::Rosters, ownerScrollArea, "Rosters"); bottomTabs->insertTab(BottomSectionTabs::Summary, summary, "Summary"); bottomTabs->insertTab(BottomSectionTabs::Targets, targetValueWidget, "Targets"); bottomTabs->insertTab(BottomSectionTabs::ChartView, chartView, "Scatter Chart"); bottomTabs->insertTab(BottomSectionTabs::Log, GlobalLogger::Get(), "Log"); // Make top section 3x the size of the bottom topBottomSplitter->setStretchFactor(0, 3); topBottomSplitter->setStretchFactor(1, 1); //---------------------------------------------------------------------- // Connections //---------------------------------------------------------------------- // Connect tab filters connect(hitterPitcherTabs, &QTabWidget::currentChanged, this, [=](int index) { // Update filters ToggleFilterGroups(index); // Update chart view switch (index) { case PlayerTableTabs::Hitters: chartView->SetProxyModel(hitterSortFilterProxyModel); break; case PlayerTableTabs::Pitchers: chartView->SetProxyModel(pitcherSortFilterProxyModel); break; default: break; } }); // Connect chart click connect(chartView, &PlayerScatterPlotChart::PlayerClicked, this, [=](const QModelIndex& index) { HighlightPlayerInTable(index); }); // Connect summary model connect(playerTableModel, &PlayerTableModel::DraftedEnd, summary, &SummaryWidget::OnDraftedEnd); //---------------------------------------------------------------------- // Main //---------------------------------------------------------------------- // Set as main window QMainWindow::setCentralWidget(topBottomSplitter); // Create main menu bar QMenuBar* mainMenuBar = new QMenuBar(); QMainWindow::setMenuBar(mainMenuBar); // Main Menu > File menu QMenu* fileMenu = mainMenuBar->addMenu("&File"); // File dialog helper auto GetFileDialog = [&](QFileDialog::AcceptMode mode) -> QFileDialog* { QFileDialog* dialog = new QFileDialog(this); dialog->setWindowModality(Qt::WindowModal); dialog->setAcceptMode(mode); dialog->setNameFilter("CSV files (*.csv)"); return dialog; }; // Ask for the save location auto SetSaveAsFile = [=]() { QStringList files; auto dialog = GetFileDialog(QFileDialog::AcceptSave); if (dialog->exec()) { files = dialog->selectedFiles(); } else { return false; } m_currentFile = files.at(0); return true; }; // Update title bar auto UpdateApplicationName = [this]() { auto name = QString("fbb -- %1").arg(QFileInfo(m_currentFile).fileName()); QCoreApplication::setApplicationName(name); setWindowTitle(name); }; // Main Menu > File menu > Save action QAction* saveResultsAction = new QAction("&Save Results", this); connect(saveResultsAction, &QAction::triggered, [=](bool checked) { if (m_currentFile.isEmpty()) { SetSaveAsFile(); } GlobalLogger::AppendMessage(QString("Saving file: %1...").arg(m_currentFile)); UpdateApplicationName(); return playerTableModel->SaveDraftStatus(m_currentFile); }); fileMenu->addAction(saveResultsAction); // Main Menu > File menu > Save As action QAction* saveResultsAsAction = new QAction("Save Results &As...", this); connect(saveResultsAsAction, &QAction::triggered, [=](bool checked) { SetSaveAsFile(); GlobalLogger::AppendMessage(QString("Saving file: %1...").arg(m_currentFile)); UpdateApplicationName(); return playerTableModel->SaveDraftStatus(m_currentFile); }); fileMenu->addAction(saveResultsAsAction); // Main Menu > File menu > Load action QAction* loadResultsAction = new QAction("&Load Results...", this); connect(loadResultsAction, &QAction::triggered, [=](bool checked) { auto dialog = GetFileDialog(QFileDialog::AcceptOpen); QStringList files; if (dialog->exec()) { files = dialog->selectedFiles(); } else { return false; } m_currentFile = files.at(0); GlobalLogger::AppendMessage(QString("Loading file: %1...").arg(m_currentFile)); UpdateApplicationName(); return playerTableModel->LoadDraftStatus(m_currentFile); }); fileMenu->addAction(loadResultsAction); // Main Menu > File menu QMenu* settingsMenu = mainMenuBar->addMenu("&Settings"); // Main Menu > Settings menu > Options action QAction* settingsAction = new QAction("&Settings...", this); connect(settingsAction, &QAction::triggered, [=](bool checked) { DraftSettingsDialog draftSettingsDialog; if (draftSettingsDialog.exec()) { UpdateOwnerLabels(); } }); settingsMenu->addAction(settingsAction); // Main Menu > Settings menu > Options action QAction* demoDataAction = new QAction("&DemoData...", this); connect(demoDataAction, &QAction::triggered, [=](bool checked) { playerTableModel->DraftRandom(); }); settingsMenu->addAction(demoDataAction); // show me QMainWindow::show(); }
ret_code HllEndDef( int i ) /*************************/ { //struct asm_sym *sym; struct hll_list *hll; int cmd = AsmBuffer[i]->value; char buffer[MAX_ID_LEN+1+64]; DebugMsg(("HllEndDef(%s) enter\n", AsmBuffer[i]->string_ptr )); if ( HllStack == NULL ) { DebugMsg(("HllEndDef: hll stack is empty\n")); AsmError( DIRECTIVE_MUST_BE_IN_CONTROL_BLOCK ); return( ERROR ); } hll = HllStack; HllStack = hll->next; PushLineQueue(); switch (cmd) { case T_DOT_ENDIF: if ( hll->cmd != HLL_IF ) { DebugMsg(("HllEndDef no .IF on the hll stack\n")); AsmErr( BLOCK_NESTING_ERROR, AsmBuffer[i]->string_ptr ); return( ERROR ); } /* if a test label isn't created yet, create it */ if ( hll->symtest ) { MakeLabel( buffer, hll->symtest ); AddLineQueue( buffer ); } /* create the exit label if it exists */ if ( hll->symexit ) { MakeLabel( buffer, hll->symexit ); AddLineQueue( buffer ); } i++; break; case T_DOT_ENDW: if ( hll->cmd != HLL_WHILE ) { DebugMsg(("HllEndDef no .WHILE on the hll stack\n")); AsmErr( BLOCK_NESTING_ERROR, AsmBuffer[i]->string_ptr ); return( ERROR ); } /* create test label */ if ( hll->symtest ) { MakeLabel( buffer, hll->symtest ); DebugMsg(("HllEndDef: created: %s\n", buffer)); AddLineQueue( buffer ); } HllPushTestLines( hll ); MakeLabel( buffer, hll->symexit ); AddLineQueue( buffer ); i++; break; case T_DOT_UNTILCXZ: if ( hll->cmd != HLL_REPEAT ) { DebugMsg(("HllEndDef no .REPEAT on the hll stack\n")); AsmErr( BLOCK_NESTING_ERROR, AsmBuffer[i]->string_ptr ); return( ERROR ); } MakeLabel( buffer, hll->symtest ); AddLineQueue( buffer ); i++; /* read in optional (simple) expression */ if ( AsmBuffer[i]->token != T_FINAL ) { if ( ERROR == EvaluateHllExpression( hll, &i, LABELFIRST, FALSE ) ) { return( ERROR ); } if ( HllCheckTestLines(hll) == ERROR ) { AsmError( EXPR_TOO_COMPLEX_FOR_UNTILCXZ ); return( ERROR ); } /* write condition lines */ HllPushTestLines( hll ); } else { sprintf( buffer, " loop %s", hll->symfirst ); AddLineQueue( buffer ); } MakeLabel( buffer, hll->symexit ); AddLineQueue( buffer ); break; case T_DOT_UNTIL: if ( hll->cmd != HLL_REPEAT ) { DebugMsg(("HllEndDef no .REPEAT on the hll stack\n")); AsmErr( BLOCK_NESTING_ERROR, AsmBuffer[i]->string_ptr ); return( ERROR ); } MakeLabel( buffer, hll->symtest ); AddLineQueue( buffer ); i++; /* read in (optional) expression */ /* if expression is missing, just generate nothing */ if ( AsmBuffer[i]->token != T_FINAL ) { if ( ERROR == EvaluateHllExpression( hll, &i, LABELFIRST, FALSE ) ) { return( ERROR ); } /* write condition lines */ HllPushTestLines( hll ); } #if 0 sprintf( buffer, " jmp %s", hll->symfirst ); AddLineQueue( buffer ); #endif MakeLabel( buffer, hll->symexit ); AddLineQueue( buffer ); break; } AsmFree( hll->symfirst ); AsmFree( hll->symtest ); AsmFree( hll->symexit ); AsmFree( hll->condlines ); AsmFree( hll ); if ( AsmBuffer[i]->token != T_FINAL ) { AsmErr( SYNTAX_ERROR_EX, AsmBuffer[i]->string_ptr ); return( ERROR ); } if ( ModuleInfo.list ) LstWrite( LSTTYPE_DIRECTIVE, GetCurrOffset(), NULL ); if ( line_queue ) RunLineQueue(); return( NOT_ERROR ); }
ret_code HllStartDef( int i ) /***************************/ { struct hll_list *hll; int cmd = AsmBuffer[i]->value; char buffer[MAX_ID_LEN+1+64]; DebugMsg(("HllStartDef(%u [=%s]) enter\n", i, AsmBuffer[i]->string_ptr )); #if FASTPASS /* make sure the directive is stored */ if ( StoreState == FALSE && Parse_Pass == PASS_1 ) { SaveState(); } #endif switch (cmd) { case T_DOT_REPEAT: if ( AsmBuffer[i+1]->token != T_FINAL ) { DebugMsg(("HllStartDef: unexpected tokens behind .REPEAT\n" )); AsmError( SYNTAX_ERROR ); return( ERROR ); } break; case T_DOT_IF: case T_DOT_WHILE: #if 0 /* Masm allows a missing expression! */ if ( AsmBuffer[i+1]->token == T_FINAL ) { AsmError( SYNTAX_ERROR ); return( ERROR ); } #endif break; } hll = AsmAlloc( sizeof(hll_list) ); hll->cmd = HLL_UNDEF; /* create labels which are always needed */ /* for .IF -.ENDIF without .ELSE no symexit label is needed. */ hll->symfirst = NULL; hll->symexit = NULL; hll->symtest = MakeAnonymousLabel(); hll->condlines = NULL; // structure for .IF .ELSE .ENDIF // cond jump to symtest // ... // jmp symexit // symtest: // ... // symexit: // structure for .IF .ELSEIF // cond jump to symtest // ... // jmp symexit // symtest: // cond jump to (new) symtest // ... // jmp symexit // symtest: // ... // structure for .WHILE and .REPEAT: // jmp symtest (for .WHILE only) // symfirst: // ... // symtest: (jumped to by .continue) // test end condition, cond jump to symfirst // symexit: (jumped to by .break) PushLineQueue(); switch (cmd) { case T_DOT_IF: hll->cmd = HLL_IF; /* get the C-style expression, convert to ASM code lines */ i++; if ( ERROR == EvaluateHllExpression( hll, &i, LABELTEST, FALSE ) ) { return( ERROR ); } HllPushTestLines( hll ); #if 1 /* if no lines have been created, the symtest label isn't needed */ if ( line_queue == NULL ) { AsmFree( hll->symtest ); hll->symtest = NULL; } #endif break; case T_DOT_WHILE: case T_DOT_REPEAT: /* create the label to loop start */ hll->symfirst = MakeAnonymousLabel(); hll->symexit = MakeAnonymousLabel(); if ( cmd == T_DOT_WHILE ) { i++; hll->cmd = HLL_WHILE; if ( AsmBuffer[i]->token != T_FINAL ) { if ( ERROR == EvaluateHllExpression( hll, &i, LABELFIRST, TRUE ) ) { return( ERROR ); } } else hll->condlines = ""; /* create a jump to second label */ /* optimisation: if second label is just a jump, dont jump! */ if ( hll->condlines && _memicmp(hll->condlines, "jmp", 3) ) { sprintf( buffer, " jmp %s", hll->symtest ); AddLineQueue( buffer ); } else { AsmFree( hll->symtest ); hll->symtest = NULL; } } else { i++; hll->cmd = HLL_REPEAT; } MakeLabel( buffer, hll->symfirst ); AddLineQueue( buffer ); break; } if ( AsmBuffer[i]->token != T_FINAL ) { DebugMsg(("HllStartDef: unexpected token %u [%s]\n", AsmBuffer[i]->token, AsmBuffer[i]->string_ptr )); AsmErr( SYNTAX_ERROR_EX, AsmBuffer[i]->string_ptr ); return( ERROR ); } hll->next = HllStack; HllStack = hll; if ( ModuleInfo.list ) LstWrite( LSTTYPE_DIRECTIVE, GetCurrOffset(), NULL ); if ( line_queue ) /* might be NULL! (".if 1") */ RunLineQueue(); return( NOT_ERROR ); }
ret_code HllExitDef( int i ) /**************************/ { //int level; //struct asm_sym *sym; struct hll_list *hll; char *savedlines; hll_cmd savedcmd; int cmd = AsmBuffer[i]->value; char buffer[MAX_ID_LEN+1+64]; DebugMsg(("HllExitDef(%s) enter\n", AsmBuffer[i]->string_ptr )); hll = HllStack; if ( hll == NULL ) { DebugMsg(("HllExitDef stack error\n")); AsmError( DIRECTIVE_MUST_BE_IN_CONTROL_BLOCK ); return( ERROR ); } PushLineQueue(); switch (cmd) { case T_DOT_ELSE: case T_DOT_ELSEIF: if ( hll->cmd != HLL_IF ) { DebugMsg(("HllExitDef(%s): symtest=%X\n", AsmBuffer[i]->string_ptr, hll->symtest)); AsmErr( BLOCK_NESTING_ERROR, AsmBuffer[i]->string_ptr ); return( ERROR ); } /* the "symexit" label is only needed if an .ELSE branch exists. That's why it is created delayed. */ if ( hll->symexit == NULL) hll->symexit = MakeAnonymousLabel(); sprintf( buffer," jmp %s", hll->symexit ); AddLineQueue( buffer ); if ( hll->symtest ) { MakeLabel( buffer, hll->symtest ); AddLineQueue( buffer ); AsmFree( hll->symtest ); hll->symtest = NULL; } i++; if (cmd == T_DOT_ELSEIF) { /* create new symtest label */ hll->symtest = MakeAnonymousLabel(); if ( ERROR == EvaluateHllExpression( hll, &i, LABELTEST, FALSE ) ) { return( ERROR ); } HllPushTestLines( hll ); } break; case T_DOT_BREAK: case T_DOT_CONTINUE: for ( ; hll && hll->cmd == HLL_IF; hll = hll->next ); if ( hll == NULL ) { AsmError( DIRECTIVE_MUST_BE_IN_CONTROL_BLOCK ); return( ERROR ); } /* .BREAK .IF ... or .CONTINUE .IF ? */ i++; if ( AsmBuffer[i]->token != T_FINAL ) { if ( AsmBuffer[i]->token == T_DIRECTIVE && AsmBuffer[i]->value == T_DOT_IF ) { savedlines = hll->condlines; savedcmd = hll->cmd; hll->condlines = NULL; hll->cmd = HLL_BREAK; i++; if ( cmd == T_DOT_BREAK ) { if ( ERROR == EvaluateHllExpression( hll, &i, LABELEXIT, TRUE ) ) { return( ERROR ); } } else { /* T_DOT_CONTINUE */ if ( ERROR == EvaluateHllExpression( hll, &i, LABELTEST, TRUE ) ) { return( ERROR ); } } HllPushTestLines( hll ); AsmFree( hll->condlines ); hll->condlines = savedlines; hll->cmd = savedcmd; } } else { if ( cmd == T_DOT_BREAK ) { sprintf( buffer," jmp %s", hll->symexit ); } else { if ( hll->symtest ) sprintf( buffer," jmp %s", hll->symtest ); else sprintf( buffer," jmp %s", hll->symfirst ); } AddLineQueue( buffer ); } break; } if ( AsmBuffer[i]->token != T_FINAL ) { AsmErr( SYNTAX_ERROR_EX, AsmBuffer[i]->string_ptr ); return( ERROR ); } if ( ModuleInfo.list ) LstWrite( LSTTYPE_DIRECTIVE, GetCurrOffset(), NULL ); RunLineQueue(); return( NOT_ERROR ); }
//////////////////////////////////////////////////////////////////////////////// /// Main /// //////////////////////////////////////////////////////////////////////////////// void TrainRegressionFJ(TString myMethodList="") { gROOT->SetBatch(1); gROOT->LoadMacro("HelperFunctions.h" ); // make functions visible to TTreeFormula if (!TString(gROOT->GetVersion()).Contains("5.34")) { std::cout << "INCORRECT ROOT VERSION! Please use 5.34:" << std::endl; std::cout << "source /uscmst1/prod/sw/cms/slc5_amd64_gcc462/lcg/root/5.34.02-cms/bin/thisroot.csh" << std::endl; std::cout << "Return without doing anything." << std::endl; return; } //TString curDynamicPath( gSystem->GetDynamicPath() ); //gSystem->SetDynamicPath( "../lib:" + curDynamicPath ); //TString curIncludePath(gSystem->GetIncludePath()); //gSystem->SetIncludePath( " -I../include " + curIncludePath ); // Load the library TMVA::Tools::Instance(); //-------------------------------------------------------------------------- // Default MVA methods to be trained + tested std::map<std::string, int> Use; // --- Mutidimensional likelihood and Nearest-Neighbour methods Use["PDERS"] = 0; Use["PDEFoam"] = 1; Use["KNN"] = 1; // // --- Linear Discriminant Analysis Use["LD"] = 1; // // --- Function Discriminant analysis Use["FDA_GA"] = 1; Use["FDA_MC"] = 0; Use["FDA_MT"] = 0; Use["FDA_GAMT"] = 0; // // --- Neural Network Use["MLP"] = 1; // // --- Support Vector Machine Use["SVM"] = 0; // // --- Boosted Decision Trees Use["BDT"] = 1; Use["BDT1"] = 0; Use["BDTG"] = 0; Use["BDTG1"] = 0; //-------------------------------------------------------------------------- std::cout << std::endl; std::cout << "==> Start TMVARegression" << std::endl; // Select methods (don't look at this code - not of interest) if (myMethodList != "") { for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0; std::vector<TString> mlist = TMVA::gTools().SplitString( myMethodList, ',' ); for (UInt_t i=0; i<mlist.size(); i++) { std::string regMethod(mlist[i]); if (Use.find(regMethod) == Use.end()) { std::cout << "Method \"" << regMethod << "\" not known in TMVA under this name. Choose among the following:" << std::endl; for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first << " "; std::cout << std::endl; return; } Use[regMethod] = 1; } } //-------------------------------------------------------------------------- // Create a ROOT output file where TMVA will store ntuples, histograms, etc. TString outfileName( "TMVARegFJ.root" ); TFile* outputFile = TFile::Open( outfileName, "RECREATE" ); // Create the factory object. Later you can choose the methods // whose performance you'd like to investigate. The factory will // then run the performance analysis for you. // // The first argument is the base of the name of all the // weightfiles in the directory weights/ // // The second argument is the output file for the training results // All TMVA output can be suppressed by removing the "!" (not) in // front of the "Silent" argument in the option string TMVA::Factory *factory = new TMVA::Factory( "TMVARegressionFJ", outputFile, "!V:!Silent:!Color:!DrawProgressBar:Transformations=I:AnalysisType=Regression" ); // If you wish to modify default settings // (please check "src/Config.h" to see all available global options) // (TMVA::gConfig().GetVariablePlotting()).fTimesRMS = 8.0; // (TMVA::gConfig().GetIONames()).fWeightFileDir = "myWeightDirectory"; const std::vector<std::string> & inputExpressions = GetInputExpressionsFJReg(); const std::vector<std::string> & inputExpressionLabels = GetInputExpressionLabelsFJReg(); assert(inputExpressions.size() == inputExpressionLabels.size()); // Define the input variables that shall be used for the MVA training // note that you may also use variable expressions, such as: "3*var1/var2*abs(var3)" // [all types of expressions that can also be parsed by TTree::Draw( "expression" )] //factory->AddVariable( "var1", "Variable 1", "units", 'F' ); //factory->AddVariable( "var2", "Variable 2", "units", 'F' ); for (UInt_t iexpr=0; iexpr!=inputExpressions.size(); iexpr++){ Label label = MakeLabel(inputExpressionLabels.at(iexpr)); TString expr = inputExpressions.at(iexpr); factory->AddVariable(expr, label.xlabel, label.unit, label.type); } // You can add so-called "Spectator variables", which are not used in the MVA training, // but will appear in the final "TestTree" produced by TMVA. This TestTree will contain the // input variables, the response values of all trained MVAs, and the spectator variables //factory->AddSpectator( "spec1 := var1*2", "Spectator 1", "units", 'F' ); //factory->AddSpectator( "spec2 := var1*3", "Spectator 2", "units", 'F' ); // Add the variable carrying the regression target //factory->AddTarget( "fvalue" ); factory->AddTarget( "fathFilterJets_genPt" ); // It is also possible to declare additional targets for multi-dimensional regression, ie: // -- factory->AddTarget( "fvalue2" ); // BUT: this is currently ONLY implemented for MLP //-------------------------------------------------------------------------- // Read training and test data TFile *input(0); TString dirname = "skim_ZnnH_regression_fj/"; TString prefix = "skim_"; TString suffix = ".root"; TTree *regTrainTree(0), *regTestTree(0); std::vector<std::string> processes; processes.push_back("ZnnH110"); processes.push_back("ZnnH115"); processes.push_back("ZnnH120"); processes.push_back("ZnnH125"); processes.push_back("ZnnH130"); processes.push_back("ZnnH135"); processes.push_back("ZnnH140"); processes.push_back("ZnnH145"); processes.push_back("ZnnH150"); #ifdef USE_WH processes.push_back("WlnH110"); processes.push_back("WlnH115"); processes.push_back("WlnH120"); processes.push_back("WlnH125"); processes.push_back("WlnH130"); processes.push_back("WlnH135"); processes.push_back("WlnH140"); processes.push_back("WlnH145"); processes.push_back("WlnH150"); #endif std::vector<TFile *> files; for (UInt_t i=0; i<processes.size(); i++){ std::string process = processes.at(i); input = (TFile*) TFile::Open(dirname + prefix + process + suffix, "READ"); if (!input) { std::cout << "ERROR: Could not open input file." << std::endl; exit(1); } std::cout << "--- TMVARegression : Using input file: " << input->GetName() << std::endl; files.push_back(input); // --- Register the regression tree regTrainTree = (TTree*) input->Get("tree_train"); regTestTree = (TTree*) input->Get("tree_test"); // Global event weights per tree (see below for setting event-wise weights) Double_t regWeight = 1.0; // You can add an arbitrary number of regression trees factory->AddRegressionTree(regTrainTree, regWeight, TMVA::Types::kTraining); factory->AddRegressionTree(regTestTree , regWeight, TMVA::Types::kTesting ); } // Set individual event weights (the variables must exist in the original TTree) //factory->SetWeightExpression( "var1", "Regression" ); // Apply additional cuts on the signal and background samples (can be different) TCut mycut = "fathFilterJets_genPt>10 && fathFilterJets_pt>15 && abs(fathFilterJets_eta)<2.5"; // this is to avoid 3rd filter jet without gen match //TCut mycut = "hJet_genPt[0] > 0. && hJet_genPt[1] > 0. && hJet_csv[0] > 0. && hJet_csv[1] > 0. && hJet_pt[0] > 20. && hJet_pt[1] > 20. && abs(hJet_eta[0])<2.5 && abs(hJet_eta[1])<2.5"; // Tell the factory to use all remaining events in the trees after training for testing: factory->PrepareTrainingAndTestTree( mycut, "V:nTrain_Regression=0:nTest_Regression=0:SplitMode=Random:NormMode=NumEvents" ); // If no numbers of events are given, half of the events in the tree are used // for training, and the other half for testing: // factory->PrepareTrainingAndTestTree( mycut, "SplitMode=Random:!V" ); // --- Book MVA methods // // Please lookup the various method configuration options in the corresponding cxx files, eg: // src/MethodCuts.cxx, etc, or here: http://tmva.sourceforge.net/optionRef.html // it is possible to preset ranges in the option string in which the cut optimisation should be done: // "...:CutRangeMin[2]=-1:CutRangeMax[2]=1"...", where [2] is the third input variable // PDE - RS method if (Use["PDERS"]) factory->BookMethod( TMVA::Types::kPDERS, "PDERS", "!H:!V:NormTree=T:VolumeRangeMode=Adaptive:KernelEstimator=Gauss:GaussSigma=0.3:NEventsMin=40:NEventsMax=60:VarTransform=None" ); // And the options strings for the MinMax and RMS methods, respectively: // "!H:!V:VolumeRangeMode=MinMax:DeltaFrac=0.2:KernelEstimator=Gauss:GaussSigma=0.3" ); // "!H:!V:VolumeRangeMode=RMS:DeltaFrac=3:KernelEstimator=Gauss:GaussSigma=0.3" ); if (Use["PDEFoam"]) factory->BookMethod( TMVA::Types::kPDEFoam, "PDEFoam", "!H:!V:MultiTargetRegression=F:TargetSelection=Mpv:TailCut=0.001:VolFrac=0.0666:nActiveCells=500:nSampl=2000:nBin=5:Compress=T:Kernel=None:Nmin=10:VarTransform=None" ); // K-Nearest Neighbour classifier (KNN) if (Use["KNN"]) factory->BookMethod( TMVA::Types::kKNN, "KNN", "nkNN=20:ScaleFrac=0.8:SigmaFact=1.0:Kernel=Gaus:UseKernel=F:UseWeight=T:!Trim" ); // Linear discriminant if (Use["LD"]) factory->BookMethod( TMVA::Types::kLD, "LD", "!H:!V:VarTransform=None" ); // Function discrimination analysis (FDA) -- test of various fitters - the recommended one is Minuit (or GA or SA) if (Use["FDA_MC"]) factory->BookMethod( TMVA::Types::kFDA, "FDA_MC", "!H:!V:Formula=(0)+(1)*x0+(2)*x1:ParRanges=(-100,100);(-100,100);(-100,100):FitMethod=MC:SampleSize=100000:Sigma=0.1:VarTransform=D" ); if (Use["FDA_GA"]) // can also use Simulated Annealing (SA) algorithm (see Cuts_SA options) .. the formula of this example is good for parabolas factory->BookMethod( TMVA::Types::kFDA, "FDA_GA", "!H:!V:Formula=(0)+(1)*x0+(2)*x1:ParRanges=(-100,100);(-100,100);(-100,100):FitMethod=GA:PopSize=100:Cycles=3:Steps=30:Trim=True:SaveBestGen=1:VarTransform=Norm" ); if (Use["FDA_MT"]) factory->BookMethod( TMVA::Types::kFDA, "FDA_MT", "!H:!V:Formula=(0)+(1)*x0+(2)*x1:ParRanges=(-100,100);(-100,100);(-100,100);(-10,10):FitMethod=MINUIT:ErrorLevel=1:PrintLevel=-1:FitStrategy=2:UseImprove:UseMinos:SetBatch" ); if (Use["FDA_GAMT"]) factory->BookMethod( TMVA::Types::kFDA, "FDA_GAMT", "!H:!V:Formula=(0)+(1)*x0+(2)*x1:ParRanges=(-100,100);(-100,100);(-100,100):FitMethod=GA:Converger=MINUIT:ErrorLevel=1:PrintLevel=-1:FitStrategy=0:!UseImprove:!UseMinos:SetBatch:Cycles=1:PopSize=5:Steps=5:Trim" ); // Neural network (MLP) if (Use["MLP"]) factory->BookMethod( TMVA::Types::kMLP, "MLP", "!H:!V:VarTransform=Norm:NeuronType=tanh:NCycles=20000:HiddenLayers=N+20:TestRate=6:TrainingMethod=BFGS:Sampling=0.3:SamplingEpoch=0.8:ConvergenceImprove=1e-6:ConvergenceTests=15:!UseRegulator" ); // Support Vector Machine if (Use["SVM"]) factory->BookMethod( TMVA::Types::kSVM, "SVM", "Gamma=0.25:Tol=0.001:VarTransform=Norm" ); // Boosted Decision Trees if (Use["BDT"]) factory->BookMethod( TMVA::Types::kBDT, "BDT", "!H:V:NTrees=100:nEventsMin=30:NodePurityLimit=0.5:BoostType=AdaBoostR2:SeparationType=RegressionVariance:nCuts=20:PruneMethod=CostComplexity:PruneStrength=30" ); //"!H:V:NTrees=60:nEventsMin=20:NodePurityLimit=0.5:BoostType=AdaBoostR2:SeparationType=RegressionVariance:nCuts=20:PruneMethod=CostComplexity:PruneStrength=30:DoBoostMonitor" ); if (Use["BDT1"]) factory->BookMethod( TMVA::Types::kBDT, "BDT1", "!H:V:NTrees=100:nEventsMin=5:BoostType=AdaBoostR2:SeparationType=RegressionVariance:nCuts=20:PruneMethod=CostComplexity:PruneStrength=30" ); if (Use["BDTG"]) factory->BookMethod( TMVA::Types::kBDT, "BDTG", "!H:V:NTrees=2000:BoostType=Grad:Shrinkage=0.10:UseBaggedGrad:GradBaggingFraction=0.7:nCuts=200:MaxDepth=3:NNodesMax=15" ); if (Use["BDTG1"]) factory->BookMethod( TMVA::Types::kBDT, "BDTG1", "!H:V:NTrees=1000:BoostType=Grad:Shrinkage=0.10:UseBaggedGrad:GradBaggingFraction=0.5:nCuts=20:MaxDepth=3:NNodesMax=15" ); //-------------------------------------------------------------------------- // Train MVAs using the set of training events factory->TrainAllMethods(); // --- Evaluate all MVAs using the set of test events factory->TestAllMethods(); // --- Evaluate and compare performance of all configured MVAs factory->EvaluateAllMethods(); //-------------------------------------------------------------------------- // Save the output outputFile->Close(); std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl; std::cout << "==> TMVARegression is done!" << std::endl; for (UInt_t i=0; i<files.size(); i++) files.at(i)->Close(); delete outputFile; delete factory; // Launch the GUI for the root macros //gROOT->SetMacroPath( "$ROOTSYS/tmva/macros/" ); //gROOT->Macro( "$ROOTSYS/tmva/macros/TMVAlogon.C" ); //gROOT->LoadMacro( "$ROOTSYS/tmva/macros/TMVAGui.C" ); //if (!gROOT->IsBatch()) TMVARegGui( outfileName ); }
/****************************************************************** Opens a group window *******************************************************************/ static void group_window_open(struct addressbook_entry *entry) { Object *wnd; Object *alias_string, *ok_button, *cancel_button; Object *description_string; int num; for (num=0; num < MAX_GROUP_OPEN; num++) if (!group_open[num]) break; wnd = WindowObject, (num < MAX_GROUP_OPEN)?MUIA_Window_ID:TAG_IGNORE, MAKE_ID('G','R','P',num), MUIA_Window_Title, "SimpleMail - Edit Group", WindowContents, VGroup, Child, VGroup, Child, ColGroup(2), Child, MakeLabel("Alias"), Child, alias_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, End, Child, MakeLabel("Description"), Child, description_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, End, End, End, Child, HorizLineObject, Child, HGroup, Child, ok_button = MakeButton("Ok"), Child, cancel_button = MakeButton("Cancel"), End, End, End; if (wnd) { struct Group_Data *data = (struct Group_Data*)malloc(sizeof(struct Group_Data)); if (data) { data->wnd = wnd; data->alias_string = alias_string; data->description_string = description_string; data->group = entry; data->num = num; /* mark the window as opened */ group_open[num] = 1; DoMethod(wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 7, MUIM_Application_PushMethod, App, 4, MUIM_CallHook, &hook_standard, group_window_close, data); DoMethod(cancel_button, MUIM_Notify, MUIA_Pressed, FALSE, App, 7, MUIM_Application_PushMethod, App, 4, MUIM_CallHook, &hook_standard, group_window_close, data); DoMethod(ok_button, MUIM_Notify, MUIA_Pressed, FALSE, App, 7, MUIM_Application_PushMethod, App, 4, MUIM_CallHook, &hook_standard, group_window_ok, data); DoMethod(App,OM_ADDMEMBER,wnd); /* A group must be changed */ if (entry && entry->type == ADDRESSBOOK_ENTRY_GROUP) { set(alias_string, MUIA_String_Contents, entry->u.group.alias); set(description_string, MUIA_String_Contents, entry->u.group.description); } set(wnd,MUIA_Window_ActiveObject,alias_string); set(wnd,MUIA_Window_Open,TRUE); return; } MUI_DisposeObject(wnd); } }
StartWindow::StartWindow(void) : DWindow(BRect(0,0,400,300),"Paladin",B_DOCUMENT_WINDOW, B_NOT_ZOOMABLE) { RegisterWindow(); AddShortcut('O',B_COMMAND_KEY, new BMessage(M_SHOW_OPEN_PROJECT)); AddShortcut('N',B_COMMAND_KEY, new BMessage(M_NEW_PROJECT)); AddShortcut('I',B_COMMAND_KEY, new BMessage(M_SHOW_IMPORT)); AddCommonFilter(new EscapeCancelFilter()); MakeCenteredOnShow(true); BView *top = GetBackgroundView(); fNewButton = MakeButton("new","NewProjectButtonUp.png","NewProjectButtonDown.png", M_NEW_PROJECT); top->AddChild(fNewButton); fNewButton->MoveTo(10,10); ClickableStringView *label = MakeLabel(fNewButton,TR("Create a new project")); top->AddChild(label); label->SetMessage(new BMessage(M_NEW_PROJECT)); fOpenButton = MakeButton("open","OpenProjectButtonUp.png", "OpenProjectButtonDown.png", M_SHOW_OPEN_PROJECT); top->AddChild(fOpenButton); fOpenButton->MoveTo(10,fNewButton->Frame().bottom + 10.0); label = MakeLabel(fOpenButton,"Open a project"); top->AddChild(label); label->SetMessage(new BMessage(M_SHOW_OPEN_PROJECT)); fOpenRecentButton = MakeButton("openrecent","OpenRecentButtonUp.png", "OpenRecentButtonDown.png", M_OPEN_SELECTION); top->AddChild(fOpenRecentButton); fOpenRecentButton->MoveTo(10,fOpenButton->Frame().bottom + 10.0); SetToolTip(fOpenRecentButton,TR("Open a project in the list on the right. You " "can also press Command + a number key.")); label = MakeLabel(fOpenRecentButton,TR("Open the selected project")); top->AddChild(label); label->SetMessage(new BMessage(M_OPEN_SELECTION)); BRect r(Bounds()); r.left = label->Frame().right + 20.0; r.right -= B_V_SCROLL_BAR_WIDTH + 10.0; r.top += 10.0; r.bottom -= 10.0; fListView = new StartWindowList(r); BScrollView *scrollView = new BScrollView("scroller",fListView,0, B_FOLLOW_ALL, false, true); top->AddChild(scrollView); fListView->SetInvocationMessage(new BMessage(M_OPEN_SELECTION)); SetToolTip(fListView, "Open a recent project. You can also press Command + a number key."); fQuickImportButton = MakeButton("quickimport","QuickImportButtonUp.png", "QuickImportButtonDown.png",M_SHOW_IMPORT); top->AddChild(fQuickImportButton); fQuickImportButton->MoveTo(10,fOpenRecentButton->Frame().bottom + 10.0); label = MakeLabel(fQuickImportButton,"Import an existing project"); top->AddChild(label); label->SetMessage(new BMessage(M_SHOW_IMPORT)); SetToolTip(label,TR("Quickly make a project by importing all source files and resource files.\n" "You can also import a BeIDE project.")); SetToolTip(fQuickImportButton, TR("Quickly make a project by importing all source files and resource files.\n" "You can also import a BeIDE project.")); fOnlineImportButton = MakeButton("onlineimport","OnlineImportButtonUp.png", "OnlineImportButtonDown.png",M_ONLINE_IMPORT); top->AddChild(fOnlineImportButton); fOnlineImportButton->MoveTo(10,fQuickImportButton->Frame().bottom + 10.0); label = MakeLabel(fOnlineImportButton,"Import a project from online"); top->AddChild(label); label->SetMessage(new BMessage(M_ONLINE_IMPORT)); SetToolTip(label,TR("Import a project from an online repository")); SetToolTip(fQuickImportButton, TR("Import a project from an online repository")); #ifdef DISABLE_ONLINE_IMPORT fOnlineImportButton->Hide(); SetSizeLimits(scrollView->Frame().left + 110.0,30000, fQuickImportButton->Frame().bottom + 10.0,30000); ResizeTo(scrollView->Frame().left + 160.0,fQuickImportButton->Frame().bottom + 10.0); #else SetSizeLimits(scrollView->Frame().left + 110.0,30000, fOnlineImportButton->Frame().bottom + 10.0,30000); ResizeTo(scrollView->Frame().left + 160.0,fOnlineImportButton->Frame().bottom + 10.0); #endif BMessenger msgr(this); BEntry entry(gProjectPath.GetFullPath()); entry_ref ref; entry.GetRef(&ref); fOpenPanel = new BFilePanel(B_OPEN_PANEL,&msgr,&ref,B_FILE_NODE,true, new BMessage(M_OPEN_PROJECT)); BString titleString(TR("Open Project")); titleString.Prepend("Paladin: "); fOpenPanel->Window()->SetTitle(titleString.String()); fImportPanel = new BFilePanel(B_OPEN_PANEL,&msgr,&ref,B_DIRECTORY_NODE,true, new BMessage(M_QUICK_IMPORT)); titleString = TR("Choose Project Folder"); titleString.Prepend("Paladin: "); fImportPanel->Window()->SetTitle(titleString.String()); gSettings.Lock(); int32 index = 0; while (gSettings.FindRef("recentitems",index++,&ref) == B_OK) { if (!BEntry(&ref).Exists()) { index--; gSettings.RemoveData("recentitems",index); } else fListView->AddItem(new RefStringItem(ref),0); } gSettings.Unlock(); // Alt + number opens that number project from the list int32 count = (fListView->CountItems() > 9) ? 9 : fListView->CountItems(); for (int32 i = 0; i < count; i++) { BMessage *listMsg = new BMessage(M_OPEN_FROM_LIST); listMsg->AddInt32("index", i); AddShortcut('1' + i, B_COMMAND_KEY, listMsg); } fNewButton->MakeFocus(true); }
int init_display(int argc, char **argv, MyProgram *me) { Widget w[25]; argc = OpenDisplay(argc, argv); if (argc == FALSE) return argc; w[0] = MakeMenu("File"); w[1] = MakeMenuItem(w[0], "Load...", load, me); w[2] = MakeMenuItem(w[0], "Save...", save, me); w[3] = MakeMenuItem(w[0], "Quit", quit, me); w[4] = MakeMenu("Edit"); w[5] = MakeMenuItem(w[4], "Check me", check_me, me); w[6] = MakeMenuItem(w[4], "Copy", NULL, NULL); w[7] = MakeMenuItem(w[4], "Paste", NULL, NULL); w[8] = MakeButton("Color Stuff", do_stuff, me); w[9] = MakeButton("More Stuff", more_stuff, me); w[10] = MakeButton("Quit!", quit, me); w[11] = MakeDrawArea(X_SIZE, Y_SIZE, redisplay, me); w[12] = MakeScrollList(string_table, 125, 275, list_callback, NULL); w[13] = MakeHorizScrollbar(X_SIZE, scroll_func, me); w[14] = MakeHorizScrollbar(X_SIZE, scroll_func, me); w[15] = MakeVertScrollbar(Y_SIZE, scroll_func, me); w[16] = MakeToggle("Slow", TRUE, NULL, toggle1, me); w[17] = MakeToggle("Fast", FALSE, w[16], toggle2, me); w[18] = MakeToggle("Faster", FALSE, w[16], toggle3, me); w[19] = MakeToggle("Fastest", FALSE, w[16], toggle4, me); w[20] = MakeToggle("Toggle me", FALSE, NULL, other_toggle, me); w[21] = MakeStringEntry("button.c", 435, string_func, me); w[22] = MakeTextWidget("button.c", TRUE, TRUE, 435, 200); w[23] = MakeLabel(" A Sample Libsx Demo Program (cool huh?)"); SetWidgetPos(w[4], PLACE_RIGHT, w[0], NO_CARE, NULL); SetWidgetPos(w[8], PLACE_UNDER, w[0], NO_CARE, NULL); SetWidgetPos(w[9], PLACE_UNDER, w[0], PLACE_RIGHT, w[8]); SetWidgetPos(w[10], PLACE_UNDER, w[0], PLACE_RIGHT, w[9]); SetWidgetPos(w[11], PLACE_UNDER, w[8], NO_CARE, NULL); SetWidgetPos(w[13], PLACE_UNDER, w[11], NO_CARE, NULL); SetWidgetPos(w[14], PLACE_UNDER, w[13], NO_CARE, NULL); SetWidgetPos(w[15], PLACE_RIGHT, w[11], PLACE_UNDER, w[8]); SetWidgetPos(w[12], PLACE_RIGHT, w[15], PLACE_UNDER, w[8]); SetWidgetPos(w[16], PLACE_RIGHT, w[13], PLACE_UNDER, w[15]); SetWidgetPos(w[17], PLACE_RIGHT, w[16], PLACE_UNDER, w[15]); SetWidgetPos(w[18], PLACE_RIGHT, w[13], PLACE_UNDER, w[16]); SetWidgetPos(w[19], PLACE_RIGHT, w[18], PLACE_UNDER, w[16]); SetWidgetPos(w[20], PLACE_RIGHT, w[10], PLACE_UNDER, w[0]); SetWidgetPos(w[21], PLACE_UNDER, w[18], NO_CARE, NULL); SetWidgetPos(w[22], PLACE_UNDER, w[21], NO_CARE, NULL); SetWidgetPos(w[23], PLACE_RIGHT, w[4], NO_CARE, NULL); /* * initialize the state of the toggle variables. */ me->toggle1 = TRUE; me->toggle2 = me->toggle3 = me->toggle4 = me->other_toggle = FALSE; me->list = w[12]; /* save these widget values for later */ me->str_entry = w[21]; me->text_widget = w[22]; me->draw_widget = w[11]; me->quit = w[10]; me->color_widget = w[8]; me->draw_font = GetFont("10x20"); if (me->draw_font == NULL) me->draw_font = GetFont("fixed"); SetWidgetFont(me->draw_widget, me->draw_font); SetButtonDownCB(w[11], button_down); SetButtonUpCB(w[11], button_up); SetKeypressCB(w[11], keypress); SetScrollbar(w[13], 3.0, 14.0, 14.0); SetScrollbar(w[14], 250.0, 255.0, 1.0); SetScrollbar(w[15], 30.0, 100.0, 25.0); /* * Now actually put the display on the screen. */ ShowDisplay(); /* * Get some colors for drawing with. */ GetStandardColors(); me->col1 = GetNamedColor("peachpuff2"); if (me->col1 == -1) fprintf(stderr, "Error getting color peachpuff\n"); me->col2 = GetRGBColor(255, 0, 255); if (me->col2 == -1) fprintf(stderr, "Error getting RGB color 0 255 255\n"); return argc; }
/****************************************************************** Opens a person window *******************************************************************/ void person_window_open(struct addressbook_entry *entry) { Object *wnd, *add_button, *rem_button, *email_list, *email_string; Object *alias_string, *realname_string, *ok_button, *cancel_button; Object *homepage_string, *street_string, *city_string, *country_string, *phone1_string, *phone2_string; Object *description_string; int num; for (num=0; num < MAX_PERSON_OPEN; num++) if (!person_open[num]) break; wnd = WindowObject, (num < MAX_PERSON_OPEN)?MUIA_Window_ID:TAG_IGNORE, MAKE_ID('P','E','R',num), MUIA_Window_Title, "SimpleMail - Edit Person", WindowContents, VGroup, Child, VGroup, Child, HorizLineTextObject("Electronic mail"), Child, HGroup, Child, VGroup, Child, ColGroup(2), Child, MakeLabel("Alias"), Child, alias_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, Child, MakeLabel("Real Name"), Child, realname_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, Child, MakeLabel("PGP Key-ID"), Child, BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, Child, MakeLabel("Homepage"), Child, homepage_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, End, Child, HVSpace, End, Child, VGroup, Child, NListviewObject, MUIA_CycleChain, 1, MUIA_NListview_NList, email_list = NListObject, MUIA_NList_DragSortable, TRUE, MUIA_NList_ConstructHook, MUIV_NList_ConstructHook_String, MUIA_NList_DestructHook, MUIV_NList_DestructHook_String, End, End, Child, HGroup, Child, email_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, End, Child, HGroup, MUIA_Group_Spacing, 0, Child, add_button = MakeButton("Add"), Child, rem_button = MakeButton("Rem"), End, End, End, End, End, Child, HGroup, Child, ColGroup(2), Child, HorizLineTextObject("Snail mail"), Child, HorizLineTextObject("Miscellanous"), /* Child, HorizLineTextObject("Portrait"),*/ Child, ColGroup(2), Child, MakeLabel("Street"), Child, street_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, Child, MakeLabel("City/ZIP"), Child, city_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, Child, MakeLabel("State/Country"), Child, country_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, Child, MakeLabel("Phone numbers"), Child, phone1_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, Child, HSpace(0), Child, phone2_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, End, Child, VGroup, Child, ColGroup(2), Child, MakeLabel("Description"), Child, description_string = BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, Child, MakeLabel("Date of birth"), Child, BetterStringObject, StringFrame, MUIA_CycleChain, 1, MUIA_String_AdvanceOnCR, TRUE, End, End, Child, HGroup, Child, VGroup, Child, MakeLabel("Notepad"), Child, VSpace(0), End, Child, TextEditorObject, InputListFrame, MUIA_CycleChain,1, End, End, End, End, End, Child, HorizLineObject, Child, HGroup, Child, ok_button = MakeButton("_Ok"), Child, cancel_button = MakeButton("_Cancel"), End, End, End; if (wnd) { struct Person_Data *data = (struct Person_Data*)malloc(sizeof(struct Person_Data)); if (data) { data->wnd = wnd; data->rem_button = rem_button; data->alias_string = alias_string; data->email_list = email_list; data->email_string = email_string; data->realname_string = realname_string; data->description_string = description_string; data->homepage_string = homepage_string; data->street_string = street_string; data->city_string = city_string; data->country_string = country_string; data->phone1_string = phone1_string; data->phone2_string = phone2_string; data->person = entry; data->num = num; /* mark the window as opened */ person_open[num] = 1; set(email_string, MUIA_String_AttachedList, email_list); set(add_button, MUIA_Weight,0); set(rem_button, MUIA_Weight,0); DoMethod(wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 7, MUIM_Application_PushMethod, App, 4, MUIM_CallHook, &hook_standard, person_window_close, data); DoMethod(cancel_button, MUIM_Notify, MUIA_Pressed, FALSE, App, 7, MUIM_Application_PushMethod, App, 4, MUIM_CallHook, &hook_standard, person_window_close, data); DoMethod(ok_button, MUIM_Notify, MUIA_Pressed, FALSE, App, 7, MUIM_Application_PushMethod, App, 4, MUIM_CallHook, &hook_standard, person_window_ok, data); DoMethod(add_button, MUIM_Notify, MUIA_Pressed, FALSE, App, 4, MUIM_CallHook, &hook_standard, person_add_email, data); DoMethod(rem_button, MUIM_Notify, MUIA_Pressed, FALSE, email_list, 2, MUIM_NList_Remove, MUIV_NList_Remove_Active); DoMethod(email_list, MUIM_Notify, MUIA_NList_Active, MUIV_EveryTime, App, 4, MUIM_CallHook, &hook_standard, person_email_list_active, data); DoMethod(email_string, MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, App, 4, MUIM_CallHook, &hook_standard, person_email_string_contents, data); DoMethod(App,OM_ADDMEMBER,wnd); /* A person must be changed */ if (entry && entry->type == ADDRESSBOOK_ENTRY_PERSON) { int i; for (i=0;i<entry->u.person.num_emails;i++) { DoMethod(email_list, MUIM_NList_InsertSingle, entry->u.person.emails[i], MUIV_NList_Insert_Bottom); } set(realname_string, MUIA_String_Contents, entry->u.person.realname); set(description_string, MUIA_String_Contents, entry->u.person.description); set(alias_string, MUIA_String_Contents, entry->u.person.alias); set(phone1_string, MUIA_String_Contents, entry->u.person.phone1); set(phone2_string, MUIA_String_Contents, entry->u.person.phone2); set(street_string, MUIA_String_Contents, entry->u.person.street); set(city_string, MUIA_String_Contents, entry->u.person.city); set(country_string, MUIA_String_Contents, entry->u.person.country); set(homepage_string, MUIA_String_Contents, entry->u.person.homepage); } person_email_list_active(&data); set(wnd,MUIA_Window_ActiveObject,alias_string); set(wnd,MUIA_Window_Open,TRUE); return; } MUI_DisposeObject(wnd); } }
void Compiler::AddFunction( const yy::location& location, int type, const std::string* pName, ArgList* pArgs, StateBlock* pBlock ) { std::auto_ptr < const std::string > name( pName ); std::auto_ptr < ArgList > args( pArgs ); std::auto_ptr < StateBlock > block( pBlock ); FunctionTag* pTag = m_Functions.Find( *pName ); if( pTag ){ if( pTag->IsDefinition() ){ error( location, "Function : " + *pName + " is already registered." ); return; } if( pTag->IsDeclaration() && !pTag->CheckArgList( pArgs ) ){ error( location, "Function : " + *pName + " has different argument type." ); return; } pTag->SetDefinition(); } else{ FunctionTag func( type ); func.SetArgs( pArgs ); func.SetDefinition(); func.SetIndex( MakeLabel() ); pTag = m_Functions.Add( *pName, func ); if( pTag == 0 ){ error( location, "Internal error : The function can not be registered." ); } } m_CurFunctionName = *pName; m_CurFunctionType = type; SetLabel( pTag->GetIndex() ); // Entry point of the function. BlockIn(); // Increase the stack for variables. // Register arguments. if( pArgs ){ pArgs->ForEachReverse( AddVal( this, m_Variables.back() ) ); } // Analyze block. if( pBlock ){ pBlock->Analyze( this ); } const VMCode& code = m_Statement.back(); if( type == TYPE_VOID ){ if( code.m_OP != VM_RETURN ){ OpReturn(); } } else{ if( code.m_OP != VM_RETURNV ){ error( location, "Function : " + *pName + " has no return." ); } } BlockOut(); m_CurFunctionName.clear(); }