Exemplo n.º 1
0
BOOL CToolBarEx::Create(CWnd* pParent)
{
	if (!CreateEx (pParent, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT
			,
			WS_CHILD | WS_VISIBLE | CBRS_TOOLTIPS | CBRS_ALIGN_TOP)
			)
		return FALSE;

	m_bar = &GetToolBarCtrl ();

	m_bar->SetBitmapSize (CSize (_TB_SIZE_X, _TB_SIZE_Y));

	SetSizes (CSize (_TB_SIZE_X+7, _TB_SIZE_Y+7),
		CSize (_TB_SIZE_X, _TB_SIZE_Y));

 	if (!m_images.Create (_TB_SIZE_X, _TB_SIZE_Y, ILC_COLOR32 | ILC_MASK, 30, 5))
		return FALSE;

	m_dimages.Create (_TB_SIZE_X, _TB_SIZE_Y, ILC_COLOR32 | ILC_MASK, 30, 5);

	m_bar->SetImageList (&m_images);
	m_bar->SetDisabledImageList (&m_dimages);

	return TRUE;
}
Exemplo n.º 2
0
//***********************************************************************************
void CGuiToolBarWnd::OnSysColorChange( )
{
	CToolBar::OnSysColorChange( );
	if(!(m_dwStyle & CBRS_FLOATING))  
		SetSizes(m_sizeButton, m_sizeImage);
	Invalidate(TRUE);
	GetParentFrame()->RecalcLayout();
}
Exemplo n.º 3
0
void GridLayouter::SetRowSizes(unsigned row, unsigned minimum_size, unsigned preferred_size, unsigned margin)
{
    OP_ASSERT(row < m_row_count);

    m_minimum_height += minimum_size + margin;
    SetSizes(m_row_info, row, minimum_size, preferred_size, margin);

    m_calculated_rows = FALSE;
}
Exemplo n.º 4
0
void GridLayouter::SetColumnSizes(unsigned col, unsigned minimum_size, unsigned preferred_size, unsigned margin)
{
    OP_ASSERT(col < m_col_count);

    m_minimum_width += minimum_size + margin;
    SetSizes(m_column_info, col, minimum_size, preferred_size, margin);

    m_calculated_columns = FALSE;
}
Exemplo n.º 5
0
//***********************************************************************************
void CGuiToolBarWnd::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) 
{
	CToolBar::OnWindowPosChanging(lpwndpos);
	if(!(m_dwStyle & CBRS_FLOATING))  
		SetSizes(m_sizeButton, m_sizeImage);
	
	if( !(lpwndpos->flags & SWP_NOMOVE) )
		Invalidate(FALSE);
}
Exemplo n.º 6
0
// Hinzufügen einer Bitmap zur Toolbar, liefert Index des ersten Buttons der 
// Bitmap
HRESULT CTRiASToolBar::AddBitmap (HINSTANCE hInst, UINT uiRsc, int nNumButtons, int *piOffset)
{
	AFX_MANAGE_STATE(AfxGetModuleState());
    ASSERT_VALID(this);
    ASSERT(::IsWindow(m_hWnd));

	if (NULL != piOffset) *piOffset = -1;	// für alle Fälle

#if !defined(_USE_SEC_CLASSES)
// Größen für das Control ausrechnen
HBITMAP hBmp = NULL;

	if (NULL == hInst)
		hBmp = (HBITMAP)uiRsc;
	else {
	HRSRC hRsrcImageWell = ::FindResource(hInst, (LPCSTR)uiRsc, RT_BITMAP);
	
		if (hRsrcImageWell == NULL)
			return E_FAIL;		// Bitmap not found

		hBmp = AfxLoadSysColorBitmap(hInst, hRsrcImageWell);
	}
	if (NULL == hBmp) return E_FAIL;

// need complete bitmap size to determine size of images
BITMAP bitmap;

	VERIFY(::GetObject(hBmp, sizeof(BITMAP), &bitmap));

int iWidth = bitmap.bmWidth / nNumButtons;
int iHeight = bitmap.bmHeight;

CSize sizeImage(iWidth, iHeight+1);
CSize sizeButton(iWidth + 7, iHeight + 7);

	SetSizes(sizeButton, sizeImage);

// Bitmap zu Control hinzufügen
TBADDBITMAP tbab;

	tbab.hInst = NULL;
	tbab.nID = (UINT)hBmp;

int iOffset = (int) DefWindowProc(TB_ADDBITMAP, (WPARAM)nNumButtons, (LPARAM)&tbab);

	if (NULL != piOffset) *piOffset = iOffset;

	return NOERROR;
#else
// einfach weiterreichen
	return m_pMainFrm -> AddBitmap (hInst, uiRsc, nNumButtons, piOffset);
#endif // _USE_SEC_CLASSES
}
Exemplo n.º 7
0
void CGuiToolBarWnd::SetTextButton(int IdButton,CString sztexto)
{
//	CToolBarCtrl &tbc=GetToolBarCtrl();
//	tbc.SetStyle(tbc.GetStyle()| TBSTYLE_LIST | CCS_ADJUSTABLE);
	
	sztexto+=sztexto.Find( '&' ) == -1 ?"   ":"    ";
	CClientDC dc(this);
	SetButtonText(IdButton,sztexto);
	SetButtonStyle(IdButton,TBSTYLE_AUTOSIZE);
	SetSizes(m_sizeButton, m_sizeImage);
            
}
Exemplo n.º 8
0
// Support loading a toolbar from a resource
BOOL CFlatToolbar::LoadToolBar(LPCTSTR lpszResourceName)
{
	ASSERT_VALID(this);
	ASSERT(lpszResourceName != NULL);

	// determine location of the bitmap in resource fork
	HINSTANCE hInst = AfxFindResourceHandle(lpszResourceName, RT_TOOLBAR);
	HRSRC hRsrc = ::FindResource(hInst, lpszResourceName, RT_TOOLBAR);
	if (hRsrc == NULL)
		return FALSE;

	HGLOBAL hGlobal = LoadResource(hInst, hRsrc);
	if (hGlobal == NULL)
		return FALSE;

	CToolBarData* pData = (CToolBarData*)LockResource(hGlobal);
	if (pData == NULL)
		return FALSE;
	ASSERT(pData->wVersion == 1);

	UINT* pItems = new UINT[pData->wItemCount];
	for (int i = 0; i < pData->wItemCount; i++)
		pItems[i] = pData->items()[i];
	BOOL bResult = SetButtons(pItems, pData->wItemCount);
	delete[] pItems;

	if (bResult)
	{
		// set new sizes of the buttons
		CSize sizeImage(pData->wWidth, pData->wHeight);
		CSize sizeButton(pData->wWidth + 7, pData->wHeight + 7);
		SetSizes(sizeButton, sizeImage);

		// load bitmap now that sizes are known by the toolbar control
		bResult = LoadBitmap(lpszResourceName);
	}

	UnlockResource(hGlobal);
	FreeResource(hGlobal);

	return bResult;
}
Exemplo n.º 9
0
BOOL CFormatBar::create(CWnd *parent)
{
	if (!CreateEx(parent, TBSTYLE_FLAT,
		WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_SIZE_FIXED) ||
		!LoadBitmap(IDB_FORMATBAR) ||
		!SetButtons(format, sizeof(format)/sizeof(UINT)))
	{
		return FALSE;      // fail to create
	}

	for (int i = 0; i < 3; ++i) {
		UINT id, style;
		int image;
		GetButtonInfo(i, id, style, image);
		SetButtonInfo(i, id, style | TBBS_CHECKBOX, image);
	}

	SetSizes(CSize(23,22), CSize(16,16));
	PositionCombos();

	return TRUE;
}
void CCoder2::SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes)
{
  SetSizes(inSizes, InSizes, InSizePointers, NumInStreams);
  SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
}
Exemplo n.º 11
0
BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
{
    VERIFY(__super::CreateEx(pParentWnd,
                             TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_AUTOSIZE | TBSTYLE_CUSTOMERASE,
                             WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_TOOLTIPS,
                             CRect(2, 2, 0, 1)));

    VERIFY(LoadToolBar(IDB_PLAYERTOOLBAR));

    // Should never be RTLed
    ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);

    CToolBarCtrl& tb = GetToolBarCtrl();
    tb.DeleteButton(tb.GetButtonCount() - 1);
    tb.DeleteButton(tb.GetButtonCount() - 1);

    SetMute(AfxGetAppSettings().fMute);

    UINT styles[] = {
        TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_CHECKGROUP,
        TBBS_SEPARATOR,
        TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON,
        TBBS_SEPARATOR,
        TBBS_BUTTON,
        TBBS_SEPARATOR,
        TBBS_SEPARATOR,
        TBBS_CHECKBOX,
    };

    for (int i = 0; i < _countof(styles); ++i) {
        // This fixes missing separator in Win 7
        if (styles[i] & TBBS_SEPARATOR) {
            SetButtonInfo(i, GetItemID(i), styles[i], -1);
        } else {
            SetButtonStyle(i, styles[i] | TBBS_DISABLED);
        }
    }

    m_volctrl.Create(this);
    m_volctrl.SetRange(0, 100);

    m_nButtonHeight = 16; // reset m_nButtonHeight
    CImage image;
    if (LoadExternalToolBar(&image)) {
        CBitmap* bmp = CBitmap::FromHandle(image);
        int width = image.GetWidth();
        int height = image.GetHeight();
        int bpp = image.GetBPP();
        if (width == height * 15) {
            // the manual specifies that sizeButton should be sizeImage inflated by (7, 6)
            SetSizes(CSize(height + 7, height + 6), CSize(height, height));

            m_pButtonsImages = DEBUG_NEW CImageList();
            if (bpp == 32) {
                m_pButtonsImages->Create(height, height, ILC_COLOR32 | ILC_MASK, 1, 0);
                m_pButtonsImages->Add(bmp, nullptr); // alpha is the mask
            } else {
                m_pButtonsImages->Create(height, height, ILC_COLOR24 | ILC_MASK, 1, 0);
                m_pButtonsImages->Add(bmp, RGB(255, 0, 255));
            }
            m_nButtonHeight = height;
            GetToolBarCtrl().SetImageList(m_pButtonsImages);
        }
        image.Destroy();
    }

    return TRUE;
}
int StVKReducedInternalForces::LoadFromStream(FILE * fin, int rTarget, int bigEndianMachine) 
{
  if (verbose)
    printf("Loading polynomials assuming little endian machine: %s.", (!bigEndianMachine) ? "TRUE" : "FALSE");

  int header[4];

  if ((int)(fread(header, sizeof(int), 4, fin)) < 4)
  {
    printf("Error: couldn't read from input cubic polynomial file.\n");
    throw 1;
  }
  
  r = header[0];

  int buffer;
  if (bigEndianMachine)
  {
    little2big(&r, &buffer, sizeof(int));
    r = buffer;
  }

  if (rTarget > r)
  {
    printf("Error: the input cubic polynomial file has r=%d, but you requested %d > %d.\n", r, rTarget, r);
    throw 2;
  }

  // first read in the coefficients as if all modes requested
  if (verbose)
    printf(" r=%d\n", r);
  
  r2 = r * r;

  linearSize = header[1];

  if (bigEndianMachine)
  {
    little2big(&linearSize, &buffer, sizeof(int));
    linearSize = buffer;
  }

  quadraticSize = header[2];

  if (bigEndianMachine)
  {
    little2big(&quadraticSize, &buffer, sizeof(int));
    quadraticSize = buffer;
  }

  cubicSize = header[3];

  if (bigEndianMachine)
  {
    little2big(&cubicSize, &buffer, sizeof(int));
    cubicSize = buffer;
  }

  linearCoef_ = (double*) malloc (sizeof(double) * r * linearSize);

  if ((int)(fread(linearCoef_,sizeof(double),r*linearSize,fin)) < r*linearSize)
  {
    printf("Error: couldn't read from input cubic polynomial file.\n");
    throw 1;
  }

  double bufferd;
  if (bigEndianMachine)
  {
    for(int i=0; i<r*linearSize; i++)
    {
      little2big(&linearCoef_[i], &bufferd, sizeof(double));
      linearCoef_[i] = bufferd;
    }
  }

  quadraticCoef_ = (double*) malloc (sizeof(double) * r * quadraticSize);

  if ((int)(fread(quadraticCoef_,sizeof(double),r*quadraticSize,fin)) < r*quadraticSize)
  {
    printf("Error: couldn't read from input cubic polynomial file.\n");
    throw 1;
  }

  if (bigEndianMachine)
  {
    for(int i=0; i<r*quadraticSize; i++)
    {
      little2big(&quadraticCoef_[i], &bufferd, sizeof(double));
      quadraticCoef_[i] = bufferd;
    }
  }

  cubicCoef_ = (double*) malloc (sizeof(double) * r * cubicSize);

  if ((int)(fread(cubicCoef_,sizeof(double),r*cubicSize,fin)) < r*cubicSize)
  {
    printf("Error: couldn't read from input cubic polynomial file.\n");
    throw 1;
  }

  if (bigEndianMachine)
  {
    for(int i=0; i<r*cubicSize; i++)
    {
      little2big(&cubicCoef_[i], &bufferd, sizeof(double));
      cubicCoef_[i] = bufferd;
    }
  }

  if (rTarget >= 0)
  {
    int linearSizeTarget, quadraticSizeTarget, cubicSizeTarget;
    GetSizes(rTarget, &linearSizeTarget, &quadraticSizeTarget, &cubicSizeTarget);

    double * linearCoefTemp_ = 
      (double*) malloc (sizeof(double) * rTarget * linearSizeTarget);

    double * quadraticCoefTemp_ = 
      (double*) malloc (sizeof(double) * rTarget * quadraticSizeTarget);

    double * cubicCoefTemp_ = 
      (double*) malloc (sizeof(double) * rTarget * cubicSizeTarget);

    for(int output=0; output<rTarget; output++)
      for(int i=0; i<rTarget; i++)
      {
        SetSizes(rTarget);
        int positionTarget = linearCoefPos(output, i); 
        SetSizes(r);
        int position = linearCoefPos(output, i); 
        linearCoefTemp_[positionTarget] = linearCoef_[position];
      }
 
    for(int output=0; output<rTarget; output++)
      for(int i=0; i<rTarget; i++)
        for(int j=i; j<rTarget; j++)
        {
          SetSizes(rTarget);
          int positionTarget = quadraticCoefPos(output, i, j); 
          SetSizes(r);
          int position = quadraticCoefPos(output, i, j); 
          quadraticCoefTemp_[positionTarget] = quadraticCoef_[position];
        }

    for(int output=0; output<rTarget; output++)
      for(int i=0; i<rTarget; i++)
        for(int j=i; j<rTarget; j++)
          for(int k=j; k<rTarget; k++)
          {
            SetSizes(rTarget);
            int positionTarget = cubicCoefPos(output, i, j, k); 
            SetSizes(r);
            int position = cubicCoefPos(output, i, j, k); 
            cubicCoefTemp_[positionTarget] = cubicCoef_[position];
          }

    r = rTarget;
    SetSizes(r);

    free(linearCoef_);
    free(quadraticCoef_);
    free(cubicCoef_);

    linearCoef_ = linearCoefTemp_;
    quadraticCoef_ = quadraticCoefTemp_;
    cubicCoef_ = cubicCoefTemp_;
  }

  volumetricMesh = NULL;
  U = NULL;
  reducedGravityForce = NULL;
  precomputedIntegrals = NULL;
  numElementVertices = 0;
  muLame = NULL;

  InitBuffers();

  addGravity = false;

  useSingleThread = 0;
  shallowCopy = 0;
  g=9.81; 

  return 0;
}
Exemplo n.º 13
0
void CPlayerToolBar::SwitchTheme()
{
	AppSettings& s = AfxGetAppSettings();

	CToolBarCtrl& tb = GetToolBarCtrl();
	m_nButtonHeight = 16;

	if (iDisableXPToolbars != (__int64)s.fDisableXPToolbars) {
		VERIFY(LoadToolBar(IDB_PLAYERTOOLBAR));

		ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);

		tb.SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
		tb.DeleteButton(1);
		tb.DeleteButton(tb.GetButtonCount()-2);

		SetMute(s.fMute);

		UINT styles[] = {
			TBBS_CHECKGROUP, TBBS_CHECKGROUP,
			TBBS_SEPARATOR,
			TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON,
			TBBS_SEPARATOR,
			TBBS_BUTTON,
			TBBS_BUTTON,
			TBBS_SEPARATOR,
			TBBS_SEPARATOR,
			TBBS_CHECKBOX,
		};

		for (int i = 0; i < _countof(styles); i++) {
			SetButtonStyle(i, styles[i] | TBBS_DISABLED);
		}

		iDisableXPToolbars = s.fDisableXPToolbars;
	}

	if (s.fDisableXPToolbars) {
		if (HMODULE h = LoadLibrary(_T("uxtheme.dll"))) {
			SetWindowThemeFunct f = (SetWindowThemeFunct)GetProcAddress(h, "SetWindowTheme");

			if (f) {
				f(m_hWnd, L" ", L" ");
			}

			FreeLibrary(h);
		}

		SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 0);// 0 Remap Active

		COLORSCHEME cs;
		cs.dwSize		= sizeof(COLORSCHEME);
		cs.clrBtnHighlight	= 0x0046413c;
		cs.clrBtnShadow		= 0x0037322d;

		tb.SetColorScheme(&cs);
		tb.SetIndent(5);
	} else {
		if (HMODULE h = LoadLibrary(_T("uxtheme.dll"))) {
			SetWindowThemeFunct f = (SetWindowThemeFunct)GetProcAddress(h, "SetWindowTheme");

			if (f) {
				f(m_hWnd, L"Explorer", NULL);
			}

			FreeLibrary(h);
		}

		SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 2);// 2 Undo  Active

		COLORSCHEME cs;
		cs.dwSize		= sizeof(COLORSCHEME);
		cs.clrBtnHighlight	= GetSysColor(COLOR_BTNFACE);
		cs.clrBtnShadow		= GetSysColor(COLOR_BTNSHADOW);

		tb.SetColorScheme(&cs);
		tb.SetIndent(0);
	}

	HBITMAP hBmp = NULL;
	bool fp = CMPCPngImage::FileExists(CString(L"toolbar"));
	if (s.fDisableXPToolbars && !fp) {
		/*
		int col = s.clrFaceABGR;
		int r, g, b, R, G, B;
		r = col & 0xFF;
		g = (col >> 8) & 0xFF;
		b = col >> 16;
		*/
		hBmp = CMPCPngImage::LoadExternalImage(L"toolbar", IDB_PLAYERTOOLBAR_PNG, IMG_TYPE::PNG, s.nThemeBrightness, s.nThemeRed, s.nThemeGreen, s.nThemeBlue);
	} else if (fp) {
		hBmp = CMPCPngImage::LoadExternalImage(L"toolbar", 0, IMG_TYPE::UNDEF);
	}

	BITMAP bitmapBmp;
	if (NULL != hBmp) {
		::GetObject(hBmp, sizeof(bitmapBmp), &bitmapBmp);

		if (fp && bitmapBmp.bmWidth != bitmapBmp.bmHeight * 15) {
			if (s.fDisableXPToolbars) {
				hBmp = CMPCPngImage::LoadExternalImage(L"", IDB_PLAYERTOOLBAR_PNG, IMG_TYPE::PNG, s.nThemeBrightness, s.nThemeRed, s.nThemeGreen, s.nThemeBlue);
				::GetObject(hBmp, sizeof(bitmapBmp), &bitmapBmp);
			} else {
				DeleteObject(hBmp);
				hBmp = NULL;
			}
		}
	}

	if (NULL != hBmp) {
		CBitmap *bmp = DNew CBitmap();
		bmp->Attach(hBmp);

		SetSizes(CSize(bitmapBmp.bmHeight + 7, bitmapBmp.bmHeight + 6), CSize(bitmapBmp.bmHeight, bitmapBmp.bmHeight));

		SAFE_DELETE(m_pButtonsImages);

		m_pButtonsImages = DNew CImageList();

		if (32 == bitmapBmp.bmBitsPixel) {
			m_pButtonsImages->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
			m_pButtonsImages->Add(bmp, static_cast<CBitmap*>(0));
		} else {
			m_pButtonsImages->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR24 | ILC_MASK, 1, 0);
			m_pButtonsImages->Add(bmp, RGB(255, 0, 255));
		}

		m_nButtonHeight = bitmapBmp.bmHeight;
		tb.SetImageList(m_pButtonsImages);
		fDisableImgListRemap = true;

		delete bmp;
		DeleteObject(hBmp);
	}

	if (s.fDisableXPToolbars) {
		if (!fDisableImgListRemap) {
			SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 0);// 0 Remap Active
			SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 1);// 1 Remap Disabled
		}
	} else {
		fDisableImgListRemap = true;

		if (NULL == fp) {
			SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 2);// 2 Undo  Active

			if (!fDisableImgListRemap) {
				SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 3);// 3 Undo  Disabled
			}
		}
	}

	if (::IsWindow(m_volctrl.GetSafeHwnd())) {
		m_volctrl.Invalidate();
	}

	CMainFrame* pFrame	= (CMainFrame*)GetParentFrame();
	OAFilterState fs	= pFrame->GetMediaState();

	TBBUTTONINFO bi;
	bi.cbSize = sizeof(bi);
	bi.dwMask = TBIF_IMAGE;

	if (fs == State_Running) {
		bi.iImage = 1;
	} else {
		bi.iImage = 0;
	}

	tb.SetButtonInfo(ID_PLAY_PLAY, &bi);
}
Exemplo n.º 14
0
BOOL CFormatBar::Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID)
{
	m_uID = nID;
	if (!CPmwToolBar::Create(pParentWnd, dwStyle))
	{
		return FALSE;
	}

   CSize czButton = CSize(16+7, 15+7);
   CSize czImage = CSize(16, 15);
   SetSizes(czButton, czImage);

/*
// Create the two "edit text" combo boxes.
*/

	CRect rect;

	rect.top = 3;
	rect.bottom = rect.top + DropHeight;
	rect.left = 0;
	rect.right = 150;

	if (!m_TypefaceBox.Create(CBS_DROPDOWN
										| CBS_SORT
										| CBS_AUTOHSCROLL
										| WS_VSCROLL
										| WS_CLIPSIBLINGS,
									  rect,
									  this,
									  IDC_TEXT_TYPEFACE))
	{
		TRACE0("Failed to create typeface combo-box\n");
		return FALSE;
	}

	m_TypefaceBox.LimitText(100);

	if (!m_SizeBox.Create(CBS_DROPDOWN
									| CBS_AUTOHSCROLL
									| WS_VSCROLL
									| WS_CLIPSIBLINGS,
								 rect,
								 this,
								 IDC_TEXT_SIZE))
	{
		TRACE0("Failed to create size combo-box\n");
		return FALSE;
	}

	m_SizeBox.LimitText(4);

	if (!m_RotateBox.Create(CBS_DROPDOWN
									| WS_VSCROLL
									| WS_CLIPSIBLINGS,
								 rect,
								 this,
								 IDC_ROTATE))
	{
		TRACE0("Failed to rotate combo-box\n");
		return FALSE;
	}
	
	m_RotateBox.LimitText(8);

	//  Create a font for the comboboxes
	LOGFONT logFont;
	memset(&logFont, 0, sizeof(logFont));

	if (!::GetSystemMetrics(SM_DBCSENABLED))
	{
		// Since design guide says toolbars are fixed height so is the font.
		logFont.lfHeight = -10;
		logFont.lfWeight = FW_BOLD;
		logFont.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
		CString strDefaultFont;
//		strDefaultFont.LoadString(IDS_DEFAULT_FONT);
		strDefaultFont = "MS Sans Serif";			// Cheat a little (for now!)
		lstrcpy(logFont.lfFaceName, strDefaultFont);
		if (!m_font.CreateFontIndirect(&logFont))
		{
			TRACE0("Could not create font for combo boxes\n");
		}
		else
		{
			m_TypefaceBox.SetFont(&m_font);
			m_SizeBox.SetFont(&m_font);
			m_RotateBox.SetFont(&m_font);
		}
	}
	else
	{
		m_font.Attach(::GetStockObject(SYSTEM_FONT));
		m_TypefaceBox.SetFont(&m_font);
		m_SizeBox.SetFont(&m_font);
		m_RotateBox.SetFont(&m_font);
	}
	
	m_nFontAverageWidth = 8;
	
	if (m_font.GetObject(sizeof(logFont), &logFont) == sizeof(logFont))
	{
		m_nFontAverageWidth = logFont.lfHeight;
		if (m_nFontAverageWidth < 0)
		{
			m_nFontAverageWidth = -m_nFontAverageWidth;
		}
		m_nFontAverageWidth = (m_nFontAverageWidth*3)/4;
		if (m_nFontAverageWidth < 4)
		{
			m_nFontAverageWidth = 4;
		}
	}

	BuildTypefaceList();
	BuildPointSizeList();
	BuildRotateList();

	return TRUE;
}
Exemplo n.º 15
0
//***************************************************************************
CSize  CGuiToolBarWnd::CalcSize(TBBUTTON* pData, int nCount)
{
	ASSERT(pData != NULL && nCount > 0);
	BOOL bDrow=FALSE;
	int  nNumDrow=0;
	CPoint cur(0,0);
	CSize sizeResult(0,0);
	CClientDC dc(this);
	int xSizeMin=32;
	if(m_dwStyle & CBRS_FLOATING )  
		SetSizes(m_sizeButton, m_sizeImage);
	if (bVertDocked)
	 ::SendMessage(m_hWnd, TB_SETMAXTEXTROWS, 0, 0);
	else
	 ::SendMessage(m_hWnd, TB_SETMAXTEXTROWS, 1, 0);
	//CFont* m_fontOld=dc.SelectObject(&m_cfont);
//	SetRealSize();
	DWORD dwExtendedStyle = DefWindowProc(TB_GETEXTENDEDSTYLE, 0, 0);
	for (int i = 0; i < nCount; i++)
	{
		
		if ((pData[i].fsStyle &  TBSTYLE_SEP) &&(pData[i].idCommand!=0))
		{
		    if (bVertDocked)
			{
				 CWnd * pWnd =GetDlgItem(pData[i].idCommand);
				 ASSERT_VALID(pWnd);
				 pWnd->ShowWindow( SW_HIDE   );
				 pData[i].fsState |= TBSTATE_HIDDEN;
				 continue;
				
			}
			else
			{
				
					CWnd * pWnd =GetDlgItem(pData[i].idCommand);
					ASSERT_VALID(pWnd);
					pData[i].fsState &= ~TBSTATE_HIDDEN;
					pWnd->ShowWindow( SW_SHOW   );
					
								
			}
		}
		
		int cySep = pData[i].iBitmap;
		cySep = cySep * 2 / 3;
		CRect rci;
		GetItemRect(i, &rci);
		int cx=rci.Width();
		xSizeMin=min(xSizeMin,cx);
		if (pData[i].fsStyle & TBSTYLE_SEP)
		{
			// a separator represents either a height or width
			if (pData[i].fsState & TBSTATE_WRAP)
				sizeResult.cy = max(cur.y + m_sizeButton.cy + cySep, sizeResult.cy);
			else
				sizeResult.cx = max(cur.x + pData[i].iBitmap, sizeResult.cx);
		}
		else
		{
			// check for dropdown style, but only if the buttons are being drawn
			if ((pData[i].fsStyle & TBSTYLE_DROPDOWN) &&
				(dwExtendedStyle & TBSTYLE_EX_DRAWDDARROWS))
			{
				// add size of drop down
				cx += (_afxDropDownWidth);
				nNumDrow++;
				bDrow=TRUE;
			}
			sizeResult.cx = max(cur.x + cx, sizeResult.cx);
			sizeResult.cy = max(cur.y + m_sizeButton.cy, sizeResult.cy);
		}

			

		if (pData[i].fsStyle & TBSTYLE_SEP)
			cur.x += pData[i].iBitmap;
		else
			cur.x += cx - CX_OVERLAP;

		if (pData[i].fsState & TBSTATE_WRAP)
		{
			cur.x = 0;
			cur.y += m_sizeButton.cy;
			if (pData[i].fsStyle & TBSTYLE_SEP)
				cur.y += cySep;
		}
	}
	if (bDrow == TRUE)
	{
		
		if (bVertDocked)
		{
			sizeResult.cx-=_afxDropDownWidth;
			sizeResult.cy+=_afxDropDownWidth-2;//*nNumDrow;
		}
		else
		{
			sizeResult.cx-=_afxDropDownWidth*nNumDrow;
		}
	}
	else
	{
		if (bVertDocked)
			sizeResult.cy+=_afxDropDownWidth/2;
	}
	return sizeResult;
}