Пример #1
0
void Menu::CreateButtons(){
	//Amount of buttons in main menu
	const int amountOfButtons = cButtonStrings.size();
	for (int i = 0; i < amountOfButtons; i++){
		//Create textures and fonts and  save in heap
		sf::Texture* tmpUnselectedTexture = new sf::Texture();
		tmpUnselectedTexture->loadFromFile(cUnselectedTextureFilePath);

		sf::Texture* tmpSelectedTexture = new sf::Texture();
		tmpSelectedTexture->loadFromFile(cSelectedTextureFilePath);

		sf::Font* font = new sf::Font();
		font->loadFromFile(cFontFilePath);

		//Terrible constructor :D
		mButtons.push_back(new Button(
										mWindow,
										nullptr,
										new sf::String(cButtonStrings[i]),
										font,
										tmpUnselectedTexture,
										tmpSelectedTexture)); 
	};
	//Set start button position
	RepositionButtons();
};
Пример #2
0
void CStartupView::OnSize(UINT nType, int cx, int cy)
{
   BOOL bHBar, bVBar;
   CheckScrollBars(bHBar, bVBar);
   CScrollView::OnSize(nType, cx, cy);

   int iNewWidth = cx < VIEW_DEFAULT_WIDTH ? VIEW_DEFAULT_WIDTH : cx;
   int iNewHeight = cy < VIEW_DEFAULT_HEIGHT ? VIEW_DEFAULT_HEIGHT : cy;
   
   int nVOffset = 0;
   int nHOffset = 0;
   DWORD dwStyle = AfxGetApp()->GetMainWnd()->GetStyle();
   CRect rcMainWnd;
   AfxGetApp()->GetMainWnd()->GetWindowRect(&rcMainWnd);
   if((dwStyle & WS_MAXIMIZE) != 0 || m_bIsRetFromEditMode)
   {
      nVOffset =  bVBar? 17: 0;
      nHOffset =  bHBar? 17: 0;
   }
   CSize siTotal = GetTotalSize();
   CRect rcClient(0, 0, siTotal.cx, siTotal.cy);

   if (!m_bIsRetFromEditMode || ! m_rcLastMainWndRect.EqualRect(&rcMainWnd)) {
       SetScrollSizes(MM_TEXT, CSize(iNewWidth + nHOffset, iNewHeight + nVOffset));
   } else {
       SetScrollSizes(MM_TEXT, m_szLastSize);
   }

   RepositionButtons();
   UpdateBars();
}
Пример #3
0
void Menu::Draw(const sf::Event& ev){
	ChangeRoom(ev);
	if (ev.type == sf::Event::Resized){
		RepositionButtons();
		ResizeBackgrounds();
	}
	switch (mCurrentRoom){
	case MainMenu:{
		DrawMainMenu(ev);
		break;
	}
	case Library:{
		DrawLibrary(ev);
		break;
	}
	case About:{
		DrawAbout(ev);
		break;
	}
	}
};
Пример #4
0
int CStartupView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   if (CScrollView::OnCreate(lpCreateStruct) == -1)
      return -1;
   CMainFrameA* pMainFrame = CMainFrameA::GetCurrentInstance();
   if(pMainFrame!=NULL)
   {
     m_pImageManager = pMainFrame->GetCommandBars()->GetImageManager();
   }
   WCHAR *pFontName = _T("Segoe UI");
   LOGFONT logFontBtn;
   XTPPaintManager()->GetRegularFont()->GetLogFont(&logFontBtn);
   //WCHAR *pFontName = _T("Segoe UI");
   _tcscpy(logFontBtn.lfFaceName, pFontName);
   //logFontBtn.lfUnderline = true;
   logFontBtn.lfHeight = 12 + 2;
   m_btnFont.CreateFontIndirect(&logFontBtn);

   LOGFONT logFontBtn14;
   XTPPaintManager()->GetRegularFont()->GetLogFont(&logFontBtn14);
   //WCHAR *pFontName = _T("Segoe UI");
   _tcscpy(logFontBtn14.lfFaceName, pFontName);
   logFontBtn14.lfWeight = FW_BOLD;
   logFontBtn14.lfHeight = 14 + 2;
   m_btnFont14.CreateFontIndirect(&logFontBtn14);

   LOGFONT logFontBtn12;
   XTPPaintManager()->GetRegularFont()->GetLogFont(&logFontBtn12);
   //WCHAR *pFontName = _T("Segoe UI");
   _tcscpy(logFontBtn12.lfFaceName, pFontName);
   logFontBtn12.lfWeight = FW_BOLD;
   logFontBtn12.lfHeight = 12 + 2;
   m_btnFont12.CreateFontIndirect(&logFontBtn12);



   LOGFONT logFontWebBtn;
   XTPPaintManager()->GetRegularFont()->GetLogFont(&logFontWebBtn);
   //WCHAR *pFontName = _T("Segoe UI");
   _tcscpy(logFontWebBtn.lfFaceName, pFontName);
   logFontWebBtn.lfItalic = true;
   logFontWebBtn.lfWeight = FW_BOLD;
   logFontWebBtn.lfHeight = 12 + 2;
   
   m_webBtnFont.CreateFontIndirect(&logFontWebBtn);
   
   // Calculate width and height of tab title region
   LOGFONT logFont;
   ASSISTANT::FillLogFont(logFont, m_csTabFontFamily, m_iTabFontSize, 
      _T("bold"), _T("roman"), false);
   m_iTabWidth = DrawSdk::Text::GetTextWidth(m_csStartPage, m_csStartPage.GetLength(), 
      &logFont) + 3;
   m_iTabHeight = DrawSdk::Text::GetTextHeight(m_csStartPage, m_csStartPage.GetLength(), 
      &logFont);

   LoadBitmaps();

   CreateCloseButton();
   CreateWelcomeButtons();
   //CreateRecentlyOpenedButtons();
   CreateShowAgainButton();
   CreateToolTips();

   SetScrollSizes( MM_TEXT, CSize(VIEW_DEFAULT_WIDTH, VIEW_DEFAULT_HEIGHT) );

   RepositionButtons();

   ShowToolTips();

   return 0;
}
Пример #5
0
AUI_ERRCODE c3_Ranger::CreateButtonsAndThumb( MBCHAR *ldlBlock )
{
	AUI_ERRCODE errcode = AUI_ERRCODE_OK;
    MBCHAR *    patternFilename = (m_pattern) ? m_pattern->GetFilename() : NULL;

	static MBCHAR block[ k_AUI_LDL_MAXBLOCK + 1 ];

	sint32 maxButtonSize = 0;

	if ( m_type == AUI_RANGER_TYPE_SLIDER
	||   m_type == AUI_RANGER_TYPE_SCROLLER )
	{
		if ( ldlBlock )
		{
			sprintf( block, "%s.%s", ldlBlock, k_AUI_RANGER_LDL_THUMB );

			if (aui_Ldl::GetLdl()->FindDataBlock( block ) )
				m_thumb = new c3_Thumb(
					&errcode,
					aui_UniqueId(),
					block,
					RangerThumbActionCallback,
					this );
		}

		if ( !m_thumb )
			m_thumb = new c3_Thumb(
				&errcode,
				aui_UniqueId(),
				0, 0, 0, 0,
				patternFilename,
				RangerThumbActionCallback,
				this );

		Assert( AUI_NEWOK(m_thumb,errcode) );
		if ( !AUI_NEWOK(m_thumb,errcode) )
			return AUI_ERRCODE_MEMALLOCFAILED;

		AddChild( m_thumb );

		RepositionThumb( FALSE );
	}

	if ( m_type == AUI_RANGER_TYPE_SCROLLER
	||   m_type == AUI_RANGER_TYPE_SPINNER )
	{
		if ( m_orientation == AUI_RANGER_ORIENTATION_HORIZONTAL
		||   m_orientation == AUI_RANGER_ORIENTATION_BIDIRECTIONAL )
		{
			if ( ldlBlock )
			{
				sprintf( block, "%s.%s", ldlBlock, k_AUI_RANGER_LDL_INCX );

                if (aui_Ldl::GetLdl()->FindDataBlock( block ) )
					m_incXButton = new c3_Button(
						&errcode,
						aui_UniqueId(),
						block,
						RangerButtonActionCallback,
						this );
			}

			if ( !m_incXButton ) {
				m_incXButton = new c3_Button(
					&errcode,
					aui_UniqueId(),
					0, 0, 0, 0,
					patternFilename,
					RangerButtonActionCallback,
					this );
			}

			Assert( AUI_NEWOK(m_incXButton,errcode) );
			if ( !AUI_NEWOK(m_incXButton,errcode) )
				return AUI_ERRCODE_MEMALLOCFAILED;

			sint32 i = 2;
			sprintf(block, "RangerRight");
            if (aui_Ldl::GetLdl()->FindDataBlock(block))
			{
				m_arrows[ i ] = new aui_Static(
					&errcode,
					aui_UniqueId(),
					block );
				Assert( AUI_NEWOK(m_arrows[ i ],errcode) );
				if ( !AUI_NEWOK(m_arrows[ i ],errcode) )
					return AUI_ERRCODE_MEMALLOCFAILED;

				m_arrows[ i ]->SetBlindness( TRUE );
				m_incXButton->AddChild( m_arrows[ i ] );

				m_arrows[ i ]->GetDim()->SetParent( m_incXButton );
			}

			AddChild( m_incXButton );

			if ( m_incXButton->Width() > maxButtonSize )
				maxButtonSize = m_incXButton->Width();

			if ( ldlBlock )
			{
				sprintf( block, "%s.%s", ldlBlock, k_AUI_RANGER_LDL_DECX );

                if (aui_Ldl::GetLdl()->FindDataBlock( block ) )
					m_decXButton = new c3_Button(
						&errcode,
						aui_UniqueId(),
						block,
						RangerButtonActionCallback,
						this );
			}

			if ( !m_decXButton ) {
				m_decXButton = new c3_Button(
					&errcode,
					aui_UniqueId(),
					0, 0, 0, 0,
					patternFilename,
					RangerButtonActionCallback,
					this );
			}

			Assert( AUI_NEWOK(m_decXButton,errcode) );
			if ( !AUI_NEWOK(m_decXButton,errcode) )
				return AUI_ERRCODE_MEMALLOCFAILED;

			i = 3;
			sprintf( block, "RangerLeft" );
            if (aui_Ldl::GetLdl()->FindDataBlock(block))
			{
				m_arrows[ i ] = new aui_Static(
					&errcode,
					aui_UniqueId(),
					block );
				Assert( AUI_NEWOK(m_arrows[ i ],errcode) );
				if ( !AUI_NEWOK(m_arrows[ i ],errcode) )
					return AUI_ERRCODE_MEMALLOCFAILED;

				m_arrows[ i ]->SetBlindness( TRUE );
				m_decXButton->AddChild( m_arrows[ i ] );

				m_arrows[ i ]->GetDim()->SetParent( m_decXButton );
			}

			AddChild( m_decXButton );

			if ( m_decXButton->Width() > maxButtonSize )
				maxButtonSize = m_decXButton->Width();
		}

		if ( m_orientation == AUI_RANGER_ORIENTATION_VERTICAL
		||   m_orientation == AUI_RANGER_ORIENTATION_BIDIRECTIONAL )
		{
			if ( ldlBlock )
			{
				sprintf( block, "%s.%s", ldlBlock, k_AUI_RANGER_LDL_INCY );

                if (aui_Ldl::GetLdl()->FindDataBlock( block ) )
					m_incYButton = new c3_Button(
						&errcode,
						aui_UniqueId(),
						block,
						RangerButtonActionCallback,
						this );
			}

			if ( !m_incYButton )
				m_incYButton = new c3_Button(
					&errcode,
					aui_UniqueId(),
					0, 0, 0, 0,
					patternFilename,
					RangerButtonActionCallback,
					this );

			Assert( AUI_NEWOK(m_incYButton,errcode) );
			if ( !AUI_NEWOK(m_incYButton,errcode) )
				return AUI_ERRCODE_MEMALLOCFAILED;

			sint32 i = 0;
			sprintf(block, "RangerDown");
            if (aui_Ldl::GetLdl()->FindDataBlock(block))
			{
				m_arrows[ i ] = new aui_Static(
					&errcode,
					aui_UniqueId(),
					block );
				Assert( AUI_NEWOK(m_arrows[ i ],errcode) );
				if ( !AUI_NEWOK(m_arrows[ i ],errcode) )
					return AUI_ERRCODE_MEMALLOCFAILED;

				m_arrows[ i ]->SetBlindness( TRUE );
				m_incYButton->AddChild( m_arrows[ i ] );

				m_arrows[ i ]->GetDim()->SetParent( m_incYButton );
			}

			AddChild( m_incYButton );

			if ( m_incYButton->Height() > maxButtonSize )
				maxButtonSize = m_incYButton->Height();

			if ( ldlBlock )
			{
				sprintf( block, "%s.%s", ldlBlock, k_AUI_RANGER_LDL_DECY );

                if (aui_Ldl::GetLdl()->FindDataBlock( block ) )
					m_decYButton = new c3_Button(
						&errcode,
						aui_UniqueId(),
						block,
						RangerButtonActionCallback,
						this );
			}

			if ( !m_decYButton )
				m_decYButton = new c3_Button(
					&errcode,
					aui_UniqueId(),
					0, 0, 0, 0,
					patternFilename,
					RangerButtonActionCallback,
					this );

			Assert( AUI_NEWOK(m_decYButton,errcode) );
			if ( !AUI_NEWOK(m_decYButton,errcode) )
				return AUI_ERRCODE_MEMALLOCFAILED;

			i = 1;
			sprintf(block, "RangerUp");
            if (aui_Ldl::GetLdl()->FindDataBlock(block))
			{
				m_arrows[ i ] = new aui_Static(
					&errcode,
					aui_UniqueId(),
					block );
				Assert( AUI_NEWOK(m_arrows[ i ],errcode) );
				if ( !AUI_NEWOK(m_arrows[ i ],errcode) )
					return AUI_ERRCODE_MEMALLOCFAILED;

				m_arrows[ i ]->SetBlindness( TRUE );
				m_decYButton->AddChild( m_arrows[ i ] );

				m_arrows[ i ]->GetDim()->SetParent( m_decYButton );
			}

			AddChild( m_decYButton );

			if ( m_decYButton->Height() > maxButtonSize )
				maxButtonSize = m_decYButton->Height();
		}

		if ( maxButtonSize )
			SetButtonSize( maxButtonSize );
		else
			RepositionButtons();
	}

	return AUI_ERRCODE_OK;
}