Example #1
0
bool CDockingBar::Create(CWnd* parent, CFramePages* pages, bool show)
{
	ASSERT(parent);
	ASSERT(pages);

	pages_ = pages;

	if (wnd_class_.IsEmpty())
		wnd_class_ = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW));

	CDC dc;
	dc.CreateIC(_T("DISPLAY"), 0, 0, 0);
	dc.SelectStockObject(DEFAULT_GUI_FONT);
	TEXTMETRIC tm;
	dc.GetTextMetrics(&tm);
	int line_height= tm.tmHeight + tm.tmInternalLeading + tm.tmExternalLeading;
	int bar_height= ((line_height + 6) & ~1) + 1;	// ensure height is odd

	// create docking bar; width will be reset by frame wnd
	if (!CWnd::CreateEx(0, wnd_class_, _T(""), WS_CHILD | (show ? WS_VISIBLE : 0) | WS_CLIPCHILDREN,
		CRect(0, 0, 200, bar_height), parent, -1))
		return false;

	HINSTANCE inst= AfxFindResourceHandle(MAKEINTRESOURCE(IDB_DOCK_BAR), RT_BITMAP);
	image_list_.Attach(ImageList_LoadImage(inst, MAKEINTRESOURCE(IDB_DOCK_BAR),
		16, 0, RGB(192,192,192), IMAGE_BITMAP, LR_CREATEDIBSECTION));

	image_list_.SetBkColor(CLR_NONE);

	Refresh(true);

	return true;
}
Example #2
0
void ATMFontMan::FindClosestFont()
{
	CDC Screen;
	if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
	{
		EnumFontFamilies(Screen.m_hDC,
						 NULL,
						 (FONTENUMPROC) ATMFontMan_CallBackFindClosestFont,
						 NULL);
		Screen.DeleteDC();
	}
}
Example #3
0
void ATMFontMan::ValidateCache()
{
	CDC Screen;
	if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
	{
		EnumFontFamilies(Screen.m_hDC,
						 NULL,
						 (FONTENUMPROC) ATMFontMan_CallBackValidateFont,
						 NULL);
		Screen.DeleteDC();
	}
}
Example #4
0
void ATMFontMan::EnumAllFonts(OILEnumFonts* pClass)
{
	CDC Screen;
	if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
	{
		EnumFontFamilies(Screen.m_hDC,
						 NULL,
						 (FONTENUMPROC) ATMFontMan_CallBackDispatchFont,
						 (LPARAM)pClass);
		Screen.DeleteDC();
	}
}
Example #5
0
void CSUIButton::CountDPI(){
	if(!nLogDPIX){
		CDC ScreenDC;
		ScreenDC.CreateIC(_T("DISPLAY"), NULL, NULL, NULL);
		nLogDPIX = ScreenDC.GetDeviceCaps(LOGPIXELSX), nLogDPIY = ScreenDC.GetDeviceCaps(LOGPIXELSY);
	}

	m_orgbtnSize = m_btnSize;

	m_btnSize.cx = nLogDPIX  * m_orgbtnSize.cx / 96;
	m_btnSize.cy = nLogDPIY * m_orgbtnSize.cy / 96;
}
Example #6
0
/*static*/ CPalette*
CAppPalette::GetAppPalette(BOOL do_realize /*= TRUE*/)
{
    if (s_cur_palette_ptr == UNINITIALIZED)
    {
        if (s_default_palette.GetSafeHandle() != NULL)
        {
            // The default palette has already been created.
            s_cur_palette_ptr = &s_default_palette;
        }
        else
        {
            // If the display device supports palettes,
            // create the default palette.
            // If not, or if creating the default palette
            // fails, set s_cur_palette_ptr to NULL.
            s_cur_palette_ptr = NULL;

            CDC ic;
            ic.CreateIC("DISPLAY", NULL, NULL, NULL);

            if (ic.GetDeviceCaps(RASTERCAPS) & RC_PALETTE)	// Bit-wise AND
            {
                // Attempt to load the default palette from a resource.
                HPALETTE palette_handle = ::LoadPalette(s_default_palette_res);
                if (palette_handle != NULL)
                {
                    s_default_palette.Attach(palette_handle);
                    s_cur_palette_ptr = &s_default_palette;

                    // Realize the palette (if the main window has been created).
                    // CMainFrame::OnQueryNewPalette()'s call to GetAppPalette()
                    // is the only one that passes us FALSE for do_realize.
                    if (do_realize)
                    {
                        CWnd* main_wnd_ptr = AfxGetMainWnd();
                        if (main_wnd_ptr != NULL)
                        {
                            main_wnd_ptr->SendMessage(WM_QUERYNEWPALETTE);
                        }
                    }
                }
            }
        }
    }

    return s_cur_palette_ptr;
}
Example #7
0
BOOL ATMFontMan::CacheNamedFont(String_64* pFontName)
{
	CDC Screen;						 					// and create a new one
	if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
	{	
		FontManager* pFontMan = GetApplication()->GetFontManager();
		ERROR2IF(pFontMan == NULL,FALSE,"NULL FontManager ptr");
		pFontMan->ClearTempFont();
		EnumFontFamilies(Screen.m_hDC,
						 NULL,
						 (FONTENUMPROC) ATMFontMan_CallBackCacheNamedFont,
						 (LPARAM)pFontName);
		Screen.DeleteDC();
		return pFontMan->TempFontValid();
	}
	return FALSE;
}
Example #8
0
void SUIVoteStar::CountDPI(){
	if(!nLogDPIX){
		CDC ScreenDC;
		ScreenDC.CreateIC(_T("DISPLAY"), NULL, NULL, NULL);
		nLogDPIX = ScreenDC.GetDeviceCaps(LOGPIXELSX), nLogDPIY = ScreenDC.GetDeviceCaps(LOGPIXELSY);
	}

	m_StarBmpYellowSizeOrg = m_StarBmpYellowSize;
	m_StarBmpYellowSize.cx = nLogDPIX  * m_StarBmpYellowSizeOrg.cx / 96;
	m_StarBmpYellowSize.cy = nLogDPIY * m_StarBmpYellowSizeOrg.cy / 96;

	m_StarBmpNullSizeOrg = m_StarBmpNullSize;
	m_StarBmpNullSize.cx = nLogDPIX  * m_StarBmpNullSizeOrg.cx / 96;
	m_StarBmpNullSize.cy = nLogDPIY * m_StarBmpNullSizeOrg.cy / 96;

	m_StarBmpRedSizeOrg = m_StarBmpRedSize;
	m_StarBmpRedSize.cx = nLogDPIX  * m_StarBmpRedSizeOrg.cx / 96;
	m_StarBmpRedSize.cy = nLogDPIY * m_StarBmpRedSizeOrg.cy / 96;
}
Example #9
0
OUTLINETEXTMETRIC *TTFontMan::GetOutlineTextMetric(LOGFONT *pLogFont)
{
	ERROR2IF(pLogFont==NULL, FALSE, "Parameter pLogFont==NULL.");

	// watch closely now - it gets fairly involved down here

	OUTLINETEXTMETRIC *pOutlineTextMetric = NULL;
	INT32 Value;

	CDC DisplayDC;
	if (DisplayDC.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
	{
		CFont *pNewCFont = new CFont;

		if (pNewCFont->CreateFontIndirect(pLogFont) != NULL)
		{
			//		**	**													**   **
			//		 ** **		must remember to select the old CFont		 ** **
			//		  ***		back in again when we've					  ***
			//		 ** **		finished using this new CFont!				 ** **
			//		**   **													**   **
			
			CFont *pOldCFont = DisplayDC.SelectObject(pNewCFont);
			
			if (pOldCFont != NULL)
			{
				TEXTMETRIC MyTextMetric;

				if (DisplayDC.GetTextMetrics(&MyTextMetric) != 0)
				{
					if (MyTextMetric.tmPitchAndFamily & TMPF_TRUETYPE == TMPF_TRUETYPE)
					{
						// its a TrueType font, so get the OUTLINETEXTMETRIC structure and run

						Value = DisplayDC.GetOutlineTextMetrics(NULL, NULL);

						// claim a block of memory for the OUTLINETEXTMETRIC class
						pOutlineTextMetric = (OUTLINETEXTMETRIC *) malloc(Value);

						// now get the OUTLINETEXTMETRIC structure itself
						Value = DisplayDC.GetOutlineTextMetrics(Value, pOutlineTextMetric);

						if (Value==FALSE)
						{
							// failed to get the outline text metrics, so free the memory we claimed
							free(pOutlineTextMetric);
							pOutlineTextMetric=NULL;
						}
					}
					else
					{
						// not a truetype font, so do nothing.
					}
				}
				else
				{
					DisplayDC.SelectObject(pOldCFont);
					DisplayDC.DeleteDC();
					delete pNewCFont;
					ERROR2(NULL, "Unable to retrieve TEXTMETRIC structure from DisplayDC.")
				}

				//		**	**													**   **
				//		 ** **		select the old CFont back into the			 ** **
				//		  ***		DC now we've finished using the 			  ***
				//		 ** **		new CFont!									 ** **
				//		**   **													**   **

				DisplayDC.SelectObject(pOldCFont);
			}
Example #10
0
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
	CCreateContext* pContext)
{
	RECT rt;
    GetClientRect(&rt);

#ifdef _BAR_DLGPANE // bardlg in pane

    m_wndSplitterS.CreateStatic(this, 1, 2);

    m_wndSplitter.CreateStatic(&m_wndSplitterS, 2, 2, WS_CHILD | WS_VISIBLE | WS_BORDER, 
                              m_wndSplitterS.IdFromRowCol(0, 1));



    CDC ScreenDC;
    VERIFY(ScreenDC.CreateIC(_T("DISPLAY"), NULL, NULL, NULL));
    const int nLogDPIX = ScreenDC.GetDeviceCaps(LOGPIXELSX);
    const int nLogDPIY = ScreenDC.GetDeviceCaps(LOGPIXELSY);

    int obw = BARWIDTH ;
    if (nLogDPIX == 96 && nLogDPIY == 96)
    {
        ;
    }
    else
    {
        if (nLogDPIX == 120 && nLogDPIY == 120)
        {
            REAL bw = (REAL)BARWIDTH;
            bw *= (REAL)(120.0/96.0);
            BARWIDTH = bw + 8;
        }
        else
        {
            REAL bw = (REAL)BARWIDTH;
            bw *= (REAL)(nLogDPIX/96.0);
            BARWIDTH = bw + 8;
        }
    }
    if(BARWIDTH < obw )
        BARWIDTH=obw;


    if (!m_wndSplitterS.CreateView(0, 0, RUNTIME_CLASS(CDlgBar), CSize(BARWIDTH, 0), pContext))
	{
		return FALSE;
	}
    rt.right-=BARWIDTH;
    rt.bottom -= 24;

#else
    rt.bottom -= 25;
   
    m_barDlg.Create(IDR_MAINFRAMEMDS, 0);
    m_wndSplitter.CreateStatic(this, 2, 2);

#endif //


	if (!m_wndSplitter.CreateView(0, 0,
		RUNTIME_CLASS(z_ed3View), CSize(rt.right/2, rt.bottom/2), pContext))
	{
		return FALSE;
	}


	if (!m_wndSplitter.CreateView(0, 1,
		RUNTIME_CLASS(CZ_ed2View), CSize(rt.right/2, rt.bottom/2), pContext))
	{
		return FALSE;
	}

	if (!m_wndSplitter.CreateView(1, 0,
		RUNTIME_CLASS(CZ_ed2View), CSize(rt.right/2, rt.bottom/2), pContext))
	{
		return FALSE;
	}

	if (!m_wndSplitter.CreateView(1, 1,
		RUNTIME_CLASS(CZ_ed2View), CSize(rt.right/2, rt.bottom/2), pContext))
	{
		return FALSE;
    }

    CZ_ed2View* ptx = (CZ_ed2View *)m_wndSplitter.GetPane(1,0);
	CZ_ed2View* pty = (CZ_ed2View *)m_wndSplitter.GetPane(0,1);
	CZ_ed2View* ptz = (CZ_ed2View *)m_wndSplitter.GetPane(1,1);

    DWORD defStyle = TBSTYLE_FLAT;
    DWORD styl  = WS_CHILD | WS_VISIBLE | CBRS_ALIGN_BOTTOM;
	

    ptx->_vt = 'x';
    ptx->_viewrot=90;
    
    pty->_vt = 'y';
    pty->_viewrot=90;

    ptz->_vt = 'z';
    ptz->_viewrot=0;
	
	return TRUE;
}