Пример #1
0
void ZMeshViewList::RecalcBounds(void)
{
    MRECT r = GetClientRect();

    //m_pLeft->SetBounds(r.x, r.y, LEFTRIGHT_WIDTH, r.h);
    //m_pRight->SetBounds(r.x+r.w-LEFTRIGHT_WIDTH, r.y, LEFTRIGHT_WIDTH, r.h);
    m_pBmLeft->SetBounds(r.x, r.y, LEFTRIGHT_WIDTH, r.h);
    m_pBmRight->SetBounds(r.x+r.w-LEFTRIGHT_WIDTH, r.y, LEFTRIGHT_WIDTH, r.h);

    int nVisibleCount = GetVisibleCount();
    int nItemWidth = GetItemWidth();
    int nItemCount = GetItemCount();
    if(m_nItemStartIndex+nVisibleCount>nItemCount) {
        m_nItemStartIndex = nItemCount - nVisibleCount;
        if(m_nItemStartIndex<0) m_nItemStartIndex = 0;
    }

    int nCount = GetItemCount();

    if(m_nItemStartIndex>0) m_pBmLeft->Enable(true);
    else m_pBmLeft->Enable(false);
    //if(m_nItemStartIndex+nVisibleCount<nCount) m_pRight->Enable(true);
    //else m_pRight->Enable(false);
    if(m_nItemStartIndex+nVisibleCount<nCount) m_pBmRight->Enable(true);
    else m_pBmRight->Enable(false);

    for(int i=0; i<nCount; i++) {
        MWidget* pChild = GetItem(i);
        pChild->SetBounds(r.x+LEFTRIGHT_WIDTH+(i-m_nItemStartIndex)*nItemWidth, r.y, nItemWidth, r.h);
        if(i-m_nItemStartIndex<0 || i-m_nItemStartIndex>=nVisibleCount) pChild->Show(false);
        else pChild->Show(true);
    }
}
void ZShopEquipInterface::SelectEquipmentFrameList( const char* szName, bool bOpen)
{
	if (szName == NULL)
	{
		SelectEquipmentFrameList("Shop", bOpen);
		SelectEquipmentFrameList("Equip", bOpen);
		return;
	}

	char szTemp[256];

	ZIDLResource* pResource = GetIDLResource();


	// Frame open/close background image
	MPicture* pPicture;
	strcpy( szTemp, szName);
	strcat( szTemp, "_ArmorBGListFrameOpen");
	pPicture = (MPicture*)pResource->FindWidget( szTemp);
	if(pPicture != NULL) {
		if( bOpen && GetArmorWeaponTabIndex() == 0 )  { pPicture->Show(true); } 
		else										{ pPicture->Show(false);}		
	}

	strcpy( szTemp, szName);
	strcat( szTemp, "_ArmorBGListFrameClose");
	pPicture = (MPicture*)pResource->FindWidget( szTemp);
	if(pPicture != NULL) {
		if( !bOpen && GetArmorWeaponTabIndex() == 0 ) { pPicture->Show(true); } 
		else										{ pPicture->Show(false);}		
	}


	// Frame open/close background image
	strcpy( szTemp, szName);
	strcat( szTemp, "_WeaponBGListFrameOpen");
	pPicture = (MPicture*)pResource->FindWidget( szTemp);
	if(pPicture != NULL) {
		if( bOpen && GetArmorWeaponTabIndex() == 1 )  { pPicture->Show(true); } 
		else										{ pPicture->Show(false);}		
	}

	strcpy( szTemp, szName);
	strcat( szTemp, "_WeaponBGListFrameClose");
	pPicture = (MPicture*)pResource->FindWidget( szTemp);
	if(pPicture != NULL) {
		if( !bOpen && GetArmorWeaponTabIndex() == 1 )  { pPicture->Show(true); } 
		else										 { pPicture->Show(false);}		
	}


	// Frame open/close image
	MButton* pButton;
	strcpy( szTemp, szName);
	strcat( szTemp, "_EquipListFrameCloseButton");
	pButton = (MButton*)pResource->FindWidget( szTemp);
	if ( pButton != NULL) pButton->Show( bOpen);

	strcpy( szTemp, szName);
	strcat( szTemp, "_EquipListFrameOpenButton");
	pButton = (MButton*)pResource->FindWidget( szTemp);
	if ( pButton != NULL) pButton->Show( !bOpen);

	// Resize item slot
	char szWidgetName[ 256];
	sprintf( szWidgetName, "%s_EquipmentSlot_Head", szName);
	MWidget* itemSlot = (MWidget*)pResource->FindWidget( szWidgetName);
	if (itemSlot) {
		MRECT rect = itemSlot->GetRect();

		int nWidth;
		if ( bOpen) nWidth = 220.0f * (float)RGetScreenWidth() / 800.0f;
		else		nWidth = min( rect.w, rect.h);

		for ( int i = 0;  i < MMCIP_END;  i++) {
			itemSlot = (MWidget*)pResource->FindWidget( GetItemSlotName( szName, i));

			if (itemSlot) {
				if(GetArmorWeaponTabIndex() == GetArmorWeaponTabIndexContainItemParts((MMatchCharItemParts)i)) {					
					rect = itemSlot->GetRect();

					itemSlot->SetBounds( rect.x, rect.y, nWidth, rect.h);
					itemSlot->Show(true);
				} 
				else {
					itemSlot->Show(false);
				}
			}
		}
	}

	// 상점과 장비창의 탭 버튼 눌림 상태를 동기화해주자 -_-;
	MBmButton* pTabBtn;
	if (GetArmorWeaponTabIndex() == 0)
	{
		pTabBtn = (MBmButton*)pResource->FindWidget("Shop_ArmorEquipmentTab");
		if (pTabBtn) pTabBtn->SetCheck(true);
		pTabBtn = (MBmButton*)pResource->FindWidget("Equip_ArmorEquipmentTab");
		if (pTabBtn) pTabBtn->SetCheck(true);
	}
	else if (GetArmorWeaponTabIndex() == 1)
	{
		pTabBtn = (MBmButton*)pResource->FindWidget("Shop_WeaponEquipmentTab");
		if (pTabBtn) pTabBtn->SetCheck(true);
		pTabBtn = (MBmButton*)pResource->FindWidget("Equip_WeaponEquipmentTab");
		if (pTabBtn) pTabBtn->SetCheck(true);
	}
}
Пример #3
0
void MCreateSample(void)
{
	MWidget* pMainFrame = Mint::GetInstance()->GetMainFrame();
	MWidget* pNew = new MFileDialog("*.*", pMainFrame, pMainFrame);
	//pNew->SetBounds(10, 10, 300, 300);
	pNew->Show(true);

	class MFrameBitmap : public MFrame{
		int			m_nBitmap;
	protected:
		virtual void OnDraw(MDrawContext* pDC){
			MFrame::OnDraw(pDC);

			MRECT r = GetClientRect();

			if(MBitmapManager::GetCount()==0) return;
			m_nBitmap %= MBitmapManager::GetCount();
			pDC->SetBitmap(MBitmapManager::Get(m_nBitmap));
			m_nBitmap++;
			pDC->Draw(r.x, r.y);
			//pDC->Draw(r);
		}
	public:
		MFrameBitmap(const char* szName=NULL, MWidget* pParent=NULL, MListener* pListener=NULL)
			: MFrame(szName, pParent, pListener){
			m_nBitmap = 0;
		}
		virtual ~MFrameBitmap(void){
		}
	};

	MWidget* pNewFrame = new MFrameBitmap("Bitmap Test", pMainFrame, pMainFrame);
	pNewFrame->SetBounds(0, 20, 200, 200);
	pNewFrame->Show(true);

	class MFrameInfo : public MFrame{
		int m_nRenderCount;
		DWORD m_nPrevTime;
		int	m_nFPS;
	protected:
		virtual void OnDraw(MDrawContext* pDC){
			MFrame::OnDraw(pDC);

			MRECT r = GetClientRect();
			char temp[256];

			pDC->SetColor(MCOLOR(255,255,255));

			// FPS
			DWORD nCurrTime = timeGetTime();
			if(nCurrTime-m_nPrevTime>1000){
				m_nFPS = m_nRenderCount;
				m_nPrevTime = nCurrTime;
				m_nRenderCount = 0;
			}
			m_nRenderCount++;
			sprintf(temp, "FPS = %d", m_nFPS);
			pDC->Text(r.x, r.y, temp);

			// Cursor Pos
			/*
			POINT p;
			GetCursorPos(&p);
			ScreenToClient(m_hWnd, &p);
			*/
			MPOINT p = MEvent::GetMousePos();
			sprintf(temp, "Cursor Pos = %d, %d", p.x, p.y);
			pDC->Text(r.x, r.y+GetFont()->GetHeight(), temp);

		}
	public:
		MFrameInfo(const char* szName=NULL, MWidget* pParent=NULL, MListener* pListener=NULL)
			: MFrame(szName, pParent, pListener){
			m_nRenderCount = 0;
			m_nPrevTime = timeGetTime();
			m_nFPS = 0;
		}
		virtual ~MFrameInfo(void){
		}
	};

	MWidget* pNewCursorInfo = new MFrameInfo("Á¤º¸", pMainFrame, pMainFrame);
	pNewCursorInfo->SetBounds(400, 0, 200, 200);
	pNewCursorInfo->Show(true);

	class MFrameStar : public MFrame{
	protected:
		virtual void OnDraw(MDrawContext* pDC){
			MFrame::OnDraw(pDC);

			MRECT r = GetClientRect();
			int nRawSize = sizeof(szStar)/sizeof(char*);
			static int nRaw = 0;
			pDC->SetColor(MCOLOR(128,128,255));
			for(int i=0; i<20; i++){
				pDC->Text(r.x, r.y+i*(GetFont()->GetHeight()+2), szStar[(nRaw+i)%nRawSize]);
			}
			nRaw++;
			nRaw%=nRawSize;
		}
		virtual bool OnCommand(MWidget* pWidget, const char* szMessage){
			/*
			if(pWidget->GetID()==MGetResourceID("ID_OK") && IsMsg(szMessage, MBTN_CLK_MSG)==true){
				Hide();
			}
			*/
			return false;
		}
	public:
		MFrameStar(const char* szName=NULL, MWidget* pParent=NULL, MListener* pListener=NULL)
			: MFrame(szName, pParent, pListener){
		}
		virtual ~MFrameStar(void){
		}
	};

	MWidget* pNewStar = new MFrameStar("º° Çì´Â ¹ã", pMainFrame, pMainFrame);
	pNewStar->SetBounds(30, 250, 500, 200);
	pNewStar->Show(true);

	MPopupMenu* pNewMenu = new MPopupMenu("SampleMenu", pMainFrame, pMainFrame, MPMT_HORIZONTAL);
	MMenuItem* pFile = pNewMenu->AddMenuItem("File");
	MMenuItem* pWidget = pNewMenu->AddMenuItem("Widget");
	MPopupMenu* pFileMenu = pFile->CreateSubMenu();
	MPopupMenu* pWidgetMenu = pWidget->CreateSubMenu();
	pFileMenu->AddMenuItem("Open");
	pFileMenu->AddMenuItem("Exit");
	pWidgetMenu->AddMenuItem("Info");
	pWidgetMenu->AddMenuItem("º°Çì´Â¹ã");

	pNewMenu->SetBounds(0, 0, MGetWorkspaceWidth(), 16);
	pNewMenu->Show(0, 0, true);
	pNewMenu->Show(true);
}