当前位置: 首页>>代码示例>>C++>>正文


C++ Window::AddControl方法代码示例

本文整理汇总了C++中Window::AddControl方法的典型用法代码示例。如果您正苦于以下问题:C++ Window::AddControl方法的具体用法?C++ Window::AddControl怎么用?C++ Window::AddControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Window的用法示例。


在下文中一共展示了Window::AddControl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetWindow

/** Returns the i-th window in the Previously Loaded Stream */
Window* CHUImporter::GetWindow(unsigned int wid)
{
    ieWord WindowID, XPos, YPos, Width, Height, BackGround;
    ieWord ControlsCount, FirstControl;
    ieResRef MosFile;
    unsigned int i;

    bool found = false;
    for (unsigned int c = 0; c < WindowCount; c++) {
        str->Seek( WEOffset + ( 0x1c * c ), GEM_STREAM_START );
        str->ReadWord( &WindowID );
        if (WindowID == wid) {
            found = true;
            break;
        }
    }
    if (!found) {
        return NULL;
    }
    str->Seek( 2, GEM_CURRENT_POS );
    str->ReadWord( &XPos );
    str->ReadWord( &YPos );
    str->ReadWord( &Width );
    str->ReadWord( &Height );
    str->ReadWord( &BackGround );
    str->ReadWord( &ControlsCount );
    str->ReadResRef( MosFile );
    str->ReadWord( &FirstControl );

    Window* win = new Window( WindowID, XPos, YPos, Width, Height );
    if (BackGround == 1) {
        ResourceHolder<ImageMgr> mos(MosFile);
        if (mos != NULL) {
            win->SetBackGround( mos->GetSprite2D(), true );
        } else
            printMessage( "CHUImporter","Cannot Load BackGround, skipping\n",YELLOW );
    }
    if (!core->IsAvailable( IE_BAM_CLASS_ID )) {
        printMessage( "CHUImporter","No BAM Importer Available, skipping controls\n",LIGHT_RED );
        return win;
    }
    for (i = 0; i < ControlsCount; i++) {
        str->Seek( CTOffset + ( ( FirstControl + i ) * 8 ), GEM_STREAM_START );
        ieDword COffset, CLength, ControlID;
        ieWord XPos, YPos, Width, Height;
        ieByte ControlType, temp;
        str->ReadDword( &COffset );
        str->ReadDword( &CLength );
        str->Seek( COffset, GEM_STREAM_START );
        str->ReadDword( &ControlID );
        str->ReadWord( &XPos );
        str->ReadWord( &YPos );
        str->ReadWord( &Width );
        str->ReadWord( &Height );
        str->Read( &ControlType, 1 );
        str->Read( &temp, 1 );
        switch (ControlType) {
        case IE_GUI_BUTTON:
        {
            //Button
            Button* btn = new Button( );
            btn->ControlID = ControlID;
            btn->XPos = XPos;
            btn->YPos = YPos;
            btn->Width = Width;
            btn->Height = Height;
            btn->ControlType = ControlType;
            ieResRef BAMFile;
            ieWord Cycle, UnpressedIndex, PressedIndex,
                   SelectedIndex, DisabledIndex;
            str->ReadResRef( BAMFile );
            str->ReadWord( &Cycle );
            str->ReadWord( &UnpressedIndex );
            str->ReadWord( &PressedIndex );
            str->ReadWord( &SelectedIndex );
            str->ReadWord( &DisabledIndex );
            btn->Owner = win;
            /** Justification comes from the .chu, other bits are set by script */
            if (!Width) {
                btn->SetFlags(IE_GUI_BUTTON_NO_IMAGE, BM_OR);
            }
            if (core->HasFeature(GF_UPPER_BUTTON_TEXT)) {
                btn->SetFlags(IE_GUI_BUTTON_CAPS, BM_OR);
            }

            btn->SetFlags( Cycle&0xff00, BM_OR );
            if (strnicmp( BAMFile, "guictrl\0", 8 ) == 0) {
                if (UnpressedIndex == 0) {
                    printMessage("CHUImporter", "Special Button Control, Skipping Image Loading\n",GREEN );
                    win->AddControl( btn );
                    break;
                }
            }
            AnimationFactory* bam = ( AnimationFactory* )
                                    gamedata->GetFactoryResource( BAMFile,
                                            IE_BAM_CLASS_ID, IE_NORMAL );
            if (!bam ) {
                printMessage( "CHUImporter","Cannot Load Button Images, skipping control\n",LIGHT_RED );
                /* IceWind Dale 2 has fake BAM ResRefs for some Buttons,
//.........这里部分代码省略.........
开发者ID:NickDaly,项目名称:GemRB-MultipleConfigs,代码行数:101,代码来源:CHUImporter.cpp

示例2: GetWindow


//.........这里部分代码省略.........
				ieByte UnpressedIndex, x1;
				ieByte PressedIndex, x2;
				ieByte SelectedIndex, y1;
				ieByte DisabledIndex, y2;
				str->ReadResRef( BAMFile );
				str->Read( &Cycle, 1 );
				str->Read( &tmp, 1 );
				Flags = ((ieDword) tmp)<<8;
				str->Read( &UnpressedIndex, 1 );
				str->Read( &x1, 1 );
				str->Read( &PressedIndex, 1 );
				str->Read( &x2, 1 );
				str->Read( &SelectedIndex, 1 );
				str->Read( &y1, 1 );
				str->Read( &DisabledIndex, 1 );
				str->Read( &y2, 1 );
				btn->Owner = win;
				/** Justification comes from the .chu, other bits are set by script */
				if (!Width) {
					btn->SetFlags(IE_GUI_BUTTON_NO_IMAGE, BM_OR);
				}
				if (core->HasFeature(GF_UPPER_BUTTON_TEXT)) {
					btn->SetFlags(IE_GUI_BUTTON_CAPS, BM_OR);
				}

				btn->SetFlags( Flags, BM_OR );
				if (Flags & IE_GUI_BUTTON_ANCHOR) {
					btn->SetAnchor(x1 | (x2<<8), y1 | (y2<<8));
				}

				if (strnicmp( BAMFile, "guictrl\0", 8 ) == 0) {
					if (UnpressedIndex == 0) {
						//printMessage("CHUImporter", "Special Button Control, Skipping Image Loading\n",GREEN );
						win->AddControl( btn );
						break;
					}
				}
				AnimationFactory* bam = ( AnimationFactory* )
					gamedata->GetFactoryResource( BAMFile,
							IE_BAM_CLASS_ID, IE_NORMAL );
				if (!bam ) {
					Log(ERROR, "CHUImporter", "Cannot Load Button Images, skipping control");
					/* IceWind Dale 2 has fake BAM ResRefs for some Buttons,
					this will handle bad ResRefs */
					win->AddControl( btn );
					break;
				}
				/** Cycle is only a byte for buttons */
				Sprite2D* tspr = bam->GetFrame( UnpressedIndex, (unsigned char) Cycle );
				btn->SetImage( BUTTON_IMAGE_UNPRESSED, tspr );
				tspr = bam->GetFrame( PressedIndex, Cycle );
				btn->SetImage( BUTTON_IMAGE_PRESSED, tspr );
				//ignorebuttonframes is a terrible hack
				if (core->HasFeature( GF_IGNORE_BUTTON_FRAMES) ) {
					if (bam->GetCycleSize(Cycle) == 4 )
						SelectedIndex=2;
				}
				tspr = bam->GetFrame( SelectedIndex, (unsigned char) Cycle );
				btn->SetImage( BUTTON_IMAGE_SELECTED, tspr );
				if (core->HasFeature( GF_IGNORE_BUTTON_FRAMES) ) {
					if (bam->GetCycleSize( (unsigned char) Cycle) == 4 )
						DisabledIndex=3;
				}
				tspr = bam->GetFrame( DisabledIndex, (unsigned char) Cycle );
				btn->SetImage( BUTTON_IMAGE_DISABLED, tspr );
				win->AddControl( btn );
开发者ID:OldSnapo,项目名称:gemrb,代码行数:67,代码来源:CHUImporter.cpp


注:本文中的Window::AddControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。