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


C++ SetFont函数代码示例

本文整理汇总了C++中SetFont函数的典型用法代码示例。如果您正苦于以下问题:C++ SetFont函数的具体用法?C++ SetFont怎么用?C++ SetFont使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: SetFont

int SurfaceImpl::Descent(Font &font) {
    SetFont(font);
    int w, h, d, e;
    hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
    return d;
}
开发者ID:cubemoon,项目名称:game-editor,代码行数:6,代码来源:PlatWX.cpp

示例2: AttachStatProc

static MRESULT EXPENTRY AttachStatProc(HWND hwnd, ULONG message, MPARAM mp1,
                                       MPARAM mp2)
{
   extern WINDOWPOSITIONS windowpositions;
   extern WINDOWCOLORS windowcolors;
   extern WINDOWFONTS windowfonts;
   extern HWND frame;
   extern HWND hwndhelp;
   PCHECKATPAR pCheckPar=NULL;
   PFIELDINFO pFieldInfo, pFirstFieldInfo;
   FIELDINFOINSERT FieldInfoInsert;
   CNRINFO CnrInfo;
   PATTACHRECORD pRecord, pFirstRecord;
   RECORDINSERT RecordInsert;
   HWND hwndCnr;
   PFILELIST pTemp;

   static char pchTitleFile[50];
   static char pchTitleSize[50];
   static char pchTitleStatus[50];
   static char pchOK[50];
   static char pchNotFound[50];

   switch(message)
   {
      case WM_INITDLG:
         pCheckPar=(PCHECKATPAR) mp2;
         LoadString(IDST_ATT_TITLEFILE,   50, pchTitleFile);
         LoadString(IDST_ATT_TITLESIZE,   50, pchTitleSize);
         LoadString(IDST_ATT_TITLESTATUS, 50, pchTitleStatus);
         LoadString(IDST_ATT_OK,          50, pchOK);
         LoadString(IDST_ATT_NOTF,        50, pchNotFound);

         WinAssociateHelpInstance(hwndhelp, hwnd);

         hwndCnr=WinWindowFromID(hwnd, IDD_ATTACHSTAT+2);
         OldAttachContainerProc=WinSubclassWindow(hwndCnr,
                                                  NewAttachContainerProc);

         SetFont(hwndCnr, windowfonts.attachfont);
         SetForeground(hwndCnr, &windowcolors.attachfore);
         SetBackground(hwndCnr, &windowcolors.attachback);

         /* Felder des Containers vorbereiten */
         pFirstFieldInfo=(PFIELDINFO)SendMsg(hwndCnr,
                                                CM_ALLOCDETAILFIELDINFO,
                                                MPFROMLONG(3), NULL);

         pFieldInfo=pFirstFieldInfo;

         pFieldInfo->cb=sizeof(FIELDINFO);
         pFieldInfo->flData=CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
         pFieldInfo->flTitle=0;
         pFieldInfo->pTitleData= pchTitleFile;
         pFieldInfo->offStruct= FIELDOFFSET(ATTACHRECORD, pchFileName);
         pFieldInfo=pFieldInfo->pNextFieldInfo;

         pFieldInfo->cb=sizeof(FIELDINFO);
         pFieldInfo->flData=CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR |
                            CFA_RIGHT;
         pFieldInfo->flTitle=0;
         pFieldInfo->pTitleData= pchTitleSize;
         pFieldInfo->offStruct= FIELDOFFSET(ATTACHRECORD, ulSize);
         pFieldInfo=pFieldInfo->pNextFieldInfo;

         pFieldInfo->cb=sizeof(FIELDINFO);
         pFieldInfo->flData=CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR |
                            CFA_CENTER;
         pFieldInfo->flTitle=0;
         pFieldInfo->pTitleData= pchTitleStatus;
         pFieldInfo->offStruct= FIELDOFFSET(ATTACHRECORD, pchStatus);

         /* Felder des Containers einfuegen */
         FieldInfoInsert.cb=sizeof(FIELDINFOINSERT);
         FieldInfoInsert.pFieldInfoOrder=(PFIELDINFO) CMA_FIRST;
         FieldInfoInsert.fInvalidateFieldInfo=TRUE;
         FieldInfoInsert.cFieldInfoInsert=3;

         SendMsg(hwndCnr, CM_INSERTDETAILFIELDINFO,
                    pFirstFieldInfo, &FieldInfoInsert);

         /* Container-Attribute setzen */
         CnrInfo.cb=sizeof(CNRINFO);
         CnrInfo.pFieldInfoLast=NULL;
         CnrInfo.flWindowAttr=CV_DETAIL | CA_DETAILSVIEWTITLES;
         CnrInfo.xVertSplitbar=0;

         SendMsg(hwndCnr, CM_SETCNRINFO, &CnrInfo,
                    MPFROMLONG(CMA_FLWINDOWATTR));

         /* Elemente einfuegen */

         pFirstRecord=(PATTACHRECORD)SendMsg(hwndCnr, CM_ALLOCRECORD,
                           MPFROMLONG(sizeof(ATTACHRECORD)-sizeof(MINIRECORDCORE)),
                           MPFROMLONG(pCheckPar->ulCountRecords));
         pRecord=pFirstRecord;
         pTemp=pCheckPar->pFileList;
         while(pTemp)
         {
            pRecord->pchFileName=pTemp->pchFileName;
//.........这里部分代码省略.........
开发者ID:OS2World,项目名称:APP-COMM-FleetStreet,代码行数:101,代码来源:attachcheck.c

示例3: SetWindowStyle

bool wxChoice::CreateAndInit(wxWindow *parent,
                             wxWindowID id,
                             const wxPoint& pos,
                             const wxSize& size,
                             int n, const wxString choices[],
                             long style,
                             const wxValidator& validator,
                             const wxString& name)
{
    if ( !(style & wxSP_VERTICAL) )
        style |= wxSP_HORIZONTAL;

    if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
        style |= wxBORDER_SIMPLE;

    style |= wxSP_ARROW_KEYS;

    SetWindowStyle(style);

    WXDWORD exStyle = 0;
    WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;

    wxSize sizeText(size), sizeBtn(size);
    sizeBtn.x = GetBestSpinnerSize(IsVertical(style)).x;

    if ( sizeText.x == wxDefaultCoord )
    {
        // DEFAULT_ITEM_WIDTH is the default width for the text control
        sizeText.x = DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN + sizeBtn.x;
    }

    sizeText.x -= sizeBtn.x + MARGIN_BETWEEN;
    if ( sizeText.x <= 0 )
    {
        wxLogDebug(wxT("not enough space for wxSpinCtrl!"));
    }

    wxPoint posBtn(pos);
    posBtn.x += sizeText.x + MARGIN_BETWEEN;

    // we must create the list control before the spin button for the purpose
    // of the dialog navigation: if there is a static text just before the spin
    // control, activating it by Alt-letter should give focus to the text
    // control, not the spin and the dialog navigation code will give focus to
    // the next control (at Windows level), not the one after it

    // create the text window

    m_hwndBuddy = (WXHWND)::CreateWindowEx
                    (
                     exStyle,                // sunken border
                     wxT("LISTBOX"),         // window class
                     NULL,                   // no window title
                     msStyle,                // style (will be shown later)
                     pos.x, pos.y,           // position
                     0, 0,                   // size (will be set later)
                     GetHwndOf(parent),      // parent
                     (HMENU)-1,              // control id
                     wxGetInstance(),        // app instance
                     NULL                    // unused client data
                    );

    if ( !m_hwndBuddy )
    {
        wxLogLastError(wxT("CreateWindow(buddy text window)"));

        return false;
    }

    // initialize wxControl
    if ( !CreateControl(parent, id, posBtn, sizeBtn, style, validator, name) )
        return false;

    // now create the real HWND
    WXDWORD spiner_style = WS_VISIBLE |
                           UDS_ALIGNRIGHT |
                           UDS_ARROWKEYS |
                           UDS_SETBUDDYINT |
                           UDS_EXPANDABLE;

    if ( !IsVertical(style) )
        spiner_style |= UDS_HORZ;

    if ( style & wxSP_WRAP )
        spiner_style |= UDS_WRAP;

    if ( !MSWCreateControl(UPDOWN_CLASS, spiner_style, posBtn, sizeBtn, wxEmptyString, 0) )
        return false;

    // subclass the text ctrl to be able to intercept some events
    wxSetWindowUserData(GetBuddyHwnd(), this);
    m_wndProcBuddy = (WXFARPROC)wxSetWindowProc(GetBuddyHwnd(),
                                                wxBuddyChoiceWndProc);

    // set up fonts and colours  (This is nomally done in MSWCreateControl)
    InheritAttributes();
    if (!m_hasFont)
        SetFont(GetDefaultAttributes().font);

    // set the size of the text window - can do it only now, because we
//.........这里部分代码省略.........
开发者ID:chromylei,项目名称:third_party,代码行数:101,代码来源:choicece.cpp

示例4: MSWGetStyle


//.........这里部分代码省略.........

    // ... and adjust it to account for a possible parent frames toolbar
    AdjustForParentClientOrigin(x, y);

    m_hWnd = (WXHWND)::CreateWindowEx
                       (
                        exstyle,            // extended style
                        classname,          // the kind of control to create
                        label.t_str(),      // the window name
                        style,              // the window style
                        x, y, w, h,         // the window position and size
                        GetHwndOf(GetParent()),         // parent
                        (HMENU)wxUIntToPtr(GetId()),    // child id
                        wxGetInstance(),    // app instance
                        NULL                // creation parameters
                       );

    if ( !m_hWnd )
    {
        wxLogLastError(wxString::Format
                       (
                        wxT("CreateWindowEx(\"%s\", flags=%08lx, ex=%08lx)"),
                        classname, style, exstyle
                       ));

        return false;
    }

#if !wxUSE_UNICODE
    // Text labels starting with the character 0xff (which is a valid character
    // in many code pages) don't appear correctly as CreateWindowEx() has some
    // special treatment for this case, apparently the strings starting with -1
    // are not really strings but something called "ordinals". There is no
    // documentation about it but the fact is that the label gets mangled or
    // not displayed at all if we don't do this, see #9572.
    //
    // Notice that 0xffff is not a valid Unicode character so the problem
    // doesn't arise in Unicode build.
    if ( !label.empty() && label[0] == -1 )
        ::SetWindowText(GetHwnd(), label.t_str());
#endif // !wxUSE_UNICODE

    // saving the label in m_labelOrig to return it verbatim
    // later in GetLabel()
    m_labelOrig = label;

    // install wxWidgets window proc for this window
    SubclassWin(m_hWnd);

    // set up fonts and colours
    InheritAttributes();
    if ( !m_hasFont )
    {
        bool setFont = true;

        wxFont font = GetDefaultAttributes().font;

        // if we set a font for {list,tree}ctrls and the font size is changed in
        // the display properties then the font size for these controls doesn't
        // automatically adjust when they receive WM_SETTINGCHANGE

        // FIXME: replace the dynamic casts with virtual function calls!!
#if wxUSE_LISTCTRL || wxUSE_TREECTRL
        bool testFont = false;
#if wxUSE_LISTCTRL
        if ( wxDynamicCastThis(wxListCtrl) )
            testFont = true;
#endif // wxUSE_LISTCTRL
#if wxUSE_TREECTRL
        if ( wxDynamicCastThis(wxTreeCtrl) )
            testFont = true;
#endif // wxUSE_TREECTRL

        if ( testFont )
        {
            // not sure if we need to explicitly set the font here for Win95/NT4
            // but we definitely can't do it for any newer version
            // see wxGetCCDefaultFont() in src/msw/settings.cpp for explanation
            // of why this test works

            // TODO: test Win95/NT4 to see if this is needed or breaks the
            // font resizing as it does on newer versions
            if ( font != wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) )
            {
                setFont = false;
            }
        }
#endif // wxUSE_LISTCTRL || wxUSE_TREECTRL

        if ( setFont )
        {
            SetFont(GetDefaultAttributes().font);
        }
    }

    // set the size now if no initial size specified
    SetInitialSize(size);

    return true;
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:101,代码来源:control.cpp

示例5: SetFont

void WinEDA_PlotPSFrame::CreateControls()
{    
	SetFont(*g_DialogFont);
	
////@begin WinEDA_PlotPSFrame content construction
    // Generated by DialogBlocks, 04/02/2006 17:30:50 (unregistered)

    WinEDA_PlotPSFrame* itemDialog1 = this;

    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
    itemDialog1->SetSizer(itemBoxSizer2);

    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxString m_SizeOptionStrings[] = {
        _("Auto"),
        _("Page Size A4"),
        _("Page Size A")
    };
    m_SizeOption = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Plot page size:"), wxDefaultPosition, wxDefaultSize, 3, m_SizeOptionStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer3->Add(m_SizeOption, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxString m_PlotPSColorOptionStrings[] = {
        _("B/W"),
        _("Color")
    };
    m_PlotPSColorOption = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Plot Color:"), wxDefaultPosition, wxDefaultSize, 2, m_PlotPSColorOptionStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer3->Add(m_PlotPSColorOption, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer3->Add(itemBoxSizer8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxButton* itemButton9 = new wxButton( itemDialog1, ID_PLOT_PS_CURRENT_EXECUTE, _("&Plot CURRENT"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton9->SetForegroundColour(wxColour(0, 128, 0));
    itemBoxSizer8->Add(itemButton9, 0, wxGROW|wxALL, 5);

    wxButton* itemButton10 = new wxButton( itemDialog1, ID_PLOT_PS_ALL_EXECUTE, _("Plot A&LL"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton10->SetForegroundColour(wxColour(179, 0, 0));
    itemBoxSizer8->Add(itemButton10, 0, wxGROW|wxALL, 5);

    wxButton* itemButton11 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton11->SetForegroundColour(wxColour(0, 0, 255));
    itemBoxSizer8->Add(itemButton11, 0, wxGROW|wxALL, 5);

    m_Plot_Sheet_Ref = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Print Sheet Ref"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_Plot_Sheet_Ref->SetValue(false);
    itemBoxSizer2->Add(m_Plot_Sheet_Ref, 0, wxALIGN_LEFT|wxALL, 5);

    wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _("Messages :"), wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer2->Add(itemStaticText13, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_MsgBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE );
    itemBoxSizer2->Add(m_MsgBox, 0, wxGROW|wxALL|wxFIXED_MINSIZE, 5);

    // Set validators
    m_SizeOption->SetValidator( wxGenericValidator(& PS_SizeSelect) );
    m_PlotPSColorOption->SetValidator( wxGenericValidator(& g_PlotPSColorOpt) );
    m_Plot_Sheet_Ref->SetValidator( wxGenericValidator(& Plot_Sheet_Ref) );
////@end WinEDA_PlotPSFrame content construction
}
开发者ID:BackupTheBerlios,项目名称:kicad-svn,代码行数:65,代码来源:plotps.cpp

示例6: AddString

CInPlaceList::CInPlaceList(CWnd* pParent, CRect& rect, DWORD dwStyle, UINT nID,
                           int nRow, int nColumn, 
                           COLORREF crFore, COLORREF crBack,
						   CStringArray& Items, CString sInitText, 
						   UINT nFirstChar)
{
    m_crForeClr = crFore;
    m_crBackClr = crBack;

	m_nNumLines = 4;
	m_sInitText = sInitText;
 	m_nRow		= nRow;
 	m_nCol      = nColumn;
 	m_nLastChar = 0; 
	m_bExitOnArrows = FALSE; //(nFirstChar != VK_LBUTTON);	// If mouse click brought us here,

	// Create the combobox
 	DWORD dwComboStyle = WS_BORDER|WS_CHILD|WS_VISIBLE|WS_VSCROLL|
 					     CBS_AUTOHSCROLL | dwStyle;
	int nHeight = rect.Height();
	rect.bottom = rect.bottom + m_nNumLines*nHeight + ::GetSystemMetrics(SM_CYHSCROLL);
	if (!Create(dwComboStyle, rect, pParent, nID)) return;

	// Add the strings
	for (int i = 0; i < Items.GetSize(); i++) 
		AddString(Items[i]);

	SetFont(pParent->GetFont());
	SetItemHeight(-1, nHeight);

    int nMaxLength = GetCorrectDropWidth();
    /*
    if (nMaxLength > rect.Width())
	    rect.right = rect.left + nMaxLength;
	// Resize the edit window and the drop down window
	MoveWindow(rect);
    */

	SetDroppedWidth(nMaxLength);

	SetHorizontalExtent(0); // no horz scrolling

	// Set the initial text to m_sInitText
    if (::IsWindow(m_hWnd) && SelectString(-1, m_sInitText) == CB_ERR) 
		SetWindowText(m_sInitText);		// No text selected, so restore what was there before

    ShowDropDown();

    // Subclass the combobox edit control if style includes CBS_DROPDOWN
    if ((dwStyle & CBS_DROPDOWNLIST) != CBS_DROPDOWNLIST)
    {
        m_edit.SubclassDlgItem(IDC_COMBOEDIT, this);
 	    SetFocus();
        switch (nFirstChar)
        {
            case VK_LBUTTON: 
            case VK_RETURN:   m_edit.SetSel((int)_tcslen(m_sInitText), -1); return;
            case VK_BACK:     m_edit.SetSel((int)_tcslen(m_sInitText), -1); break;
            case VK_DOWN: 
            case VK_UP:   
            case VK_RIGHT:
            case VK_LEFT:  
            case VK_NEXT:  
            case VK_PRIOR: 
            case VK_HOME:  
            case VK_END:      m_edit.SetSel(0,-1); return;
            default:          m_edit.SetSel(0,-1);
        }
        SendMessage(WM_CHAR, nFirstChar);
    }
    else
 	    SetFocus();
}
开发者ID:hyundo32,项目名称:WS_MicroScoper,代码行数:73,代码来源:GridCellCombo.cpp

示例7: SetDrawingMode

/*=============================================================================================*\
|	Draw																						|
+-----------------------------------------------------------------------------------------------+
|	Effet: Redessiner une partie de la view.													|
|	Entre: 																						|
|		BRect frame: Rectagle qui a besoin d'etre redessine.									|
\*=============================================================================================*/
void ShrinkView::Draw(BRect updateRect)
{
	BPoint pPointList[8];		//Utilise pour dessiner les polygone.
	rgb_color color = {0,0,0,0};
	rgb_color colorHigh = {0,0,0,0};
	
	SetDrawingMode(B_OP_COPY);
	if(m_pBmp)
	{
		uint32 * uiBits = (uint32*)m_pBmp->Bits();
		uint32 uiColor = uiBits[141];
		uint32 uiColorHigh = uiBits[289];
		
		color.red = ( uiColor & 0xFF0000) / 0x10000;
		color.green = (uiColor & 0xFF00) / 0x100;
		color.blue = (uiColor & 0xFF) ;
		colorHigh.red = ( uiColorHigh & 0xFF0000) / 0x10000;
		colorHigh.green = (uiColorHigh & 0xFF00) / 0x100;
		colorHigh.blue = (uiColorHigh & 0xFF) ;
			
	}

	//if(updateRect.left < 10)
	{
		if(m_pBmp)
		{
			DrawBitmap(m_pBmp, BRect(140,15,147,15), BRect(Bounds().Width() - 7, 16, Bounds().Width(), Bounds().Height() - 7));				 
		}

	}
	//if(updateRect.right > Bounds().Width()-10)
	{
		if(m_pBmp)
		{
			DrawBitmap(m_pBmp, BRect(140,14,147,14), BRect(0, 16, 7, Bounds().Height() - 7));

		}
	}
	
	
	//Dessiner l'etiquette si necessaire.
	if(updateRect.top < 16 && updateRect.right >= 16)
	{
		
		if(m_pBmp)
		{
			
			if(m_bShrink && m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(80,0,95,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(137,0,137,15), BRect(16, 0, Bounds().Width() - 15, 15)); 
			}
			else if(m_bShrink)
			{
				DrawBitmap(m_pBmp, BRect(64,0,79,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(136,0,136,15), BRect(16, 0, Bounds().Width() - 15, 15)); 
			}
			else if(m_bMouseOver)
			{
				DrawBitmap(m_pBmp, BRect(112,0,127,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(139,0,139,15), BRect(16, 0, Bounds().Width() - 15, 15)); 
			}
			else
			{
				DrawBitmap(m_pBmp, BRect(96,0,111,15), BRect(Bounds().Width() - 15,0,Bounds().Width(),15));
				DrawBitmap(m_pBmp, BRect(138,0,138,15), BRect(16, 0, Bounds().Width() - 15 , 15)); 
			}
			SetFont(be_bold_font);
					
			if(m_bMouseOver)
			{
				SetHighColor(colorHigh);
			}
			else
			{
				SetHighColor(color);
			}	
			SetDrawingMode(B_OP_OVER);
			DrawString(m_pzLabel, BPoint(18,12), NULL);	
			SetDrawingMode(B_OP_COPY);	
		}
		else
		{
			if(m_bShrink)
			{
				DrawDegrader(BRect(16,0,Bounds().Width(),4), 255, 192);
				DrawDegrader(BRect(16,11,Bounds().Width(),15), 192, 128);
			
				//Remplir le milieu de l'etiquette en gris
				SetHighColor(192, 192, 192, 0);
				FillRect(BRect(16, 5, Bounds().Width(), 10));
			}
			else	//Degrader du blanc au gris
//.........这里部分代码省略.........
开发者ID:tgkokk,项目名称:WhisperBeNet,代码行数:101,代码来源:ShrinkView.cpp

示例8: RenderText

static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
                       subpicture_region_t *p_region_in )
{
    filter_sys_t *p_sys = p_filter->p_sys;
    int i_font_color, i_font_alpha, i_font_size;
    uint8_t *p_bitmap;
    TCHAR *psz_string;
    int i, i_width, i_height;
    HBITMAP bitmap, bitmap_bak;
    BITMAPINFO *p_bmi;
    RECT rect = { 0, 0, 0, 0 };

    /* Sanity check */
    if( !p_region_in || !p_region_out ) return VLC_EGENERIC;
    if( !p_region_in->psz_text || !*p_region_in->psz_text )
        return VLC_EGENERIC;

    psz_string = malloc( (strlen( p_region_in->psz_text )+1) * sizeof(TCHAR) );
    if( !psz_string )
        return VLC_ENOMEM;
#ifdef UNICODE
    if( mbstowcs( psz_string, p_region_in->psz_text,
                  strlen( p_region_in->psz_text ) * sizeof(TCHAR) ) < 0 )
    {
        free( psz_string );
        return VLC_EGENERIC;
    }
#else
    strcpy( psz_string, p_region_in->psz_text );
#endif
    if( !*psz_string )
    {
        free( psz_string );
        return VLC_EGENERIC;
    }

    if( p_region_in->p_style )
    {
        i_font_color = __MAX( __MIN( p_region_in->p_style->i_font_color, 0xFFFFFF ), 0 );
        i_font_alpha = __MAX( __MIN( p_region_in->p_style->i_font_alpha, 255 ), 0 );
        i_font_size  = __MAX( __MIN( p_region_in->p_style->i_font_size, 255 ), 0 );
    }
    else
    {
        i_font_color = p_sys->i_font_color;
        i_font_alpha = 255 - p_sys->i_font_opacity;
        i_font_size = p_sys->i_default_font_size;
    }

    SetFont( p_filter, i_font_size );

    SetTextColor( p_sys->hcdc, RGB( (i_font_color >> 16) & 0xff,
                  (i_font_color >> 8) & 0xff, i_font_color & 0xff) );

    DrawText( p_sys->hcdc, psz_string, -1, &rect,
              DT_CALCRECT | DT_CENTER | DT_NOPREFIX );
    i_width = rect.right; i_height = rect.bottom;

    p_bmi = malloc(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*16);
    memset( p_bmi, 0, sizeof(BITMAPINFOHEADER) );
    p_bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    p_bmi->bmiHeader.biWidth = (i_width+3) & ~3;
    p_bmi->bmiHeader.biHeight = - i_height;
    p_bmi->bmiHeader.biPlanes = 1;
    p_bmi->bmiHeader.biBitCount = 8;
    p_bmi->bmiHeader.biCompression = BI_RGB;
    p_bmi->bmiHeader.biClrUsed = 16;

    for( i = 0; i < 16; i++ )
    {
        p_bmi->bmiColors[i].rgbBlue =
            p_bmi->bmiColors[i].rgbGreen =
                p_bmi->bmiColors[i].rgbRed = pi_gamma[i];
    }

    bitmap = CreateDIBSection( p_sys->hcdc, p_bmi, DIB_RGB_COLORS,
                               (void **)&p_bitmap, NULL, 0 );
    if( !bitmap )
    {
        msg_Err( p_filter, "could not create bitmap" );
        free( psz_string );
        return VLC_EGENERIC;
    }

    bitmap_bak = SelectObject( p_sys->hcdc, bitmap );
    FillRect( p_sys->hcdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) );

    if( !DrawText( p_sys->hcdc, psz_string, -1, &rect,
                   DT_CENTER | DT_NOPREFIX ) )
    {
        msg_Err( p_filter, "could not draw text" );
    }

    p_region_out->i_x = p_region_in->i_x;
    p_region_out->i_y = p_region_in->i_y;
    Render( p_filter, p_region_out, p_bitmap, i_width, i_height );

    SelectObject( p_sys->hcdc, bitmap_bak );
    DeleteObject( bitmap );
    free( psz_string );
//.........这里部分代码省略.........
开发者ID:Italianmoose,项目名称:Stereoscopic-VLC,代码行数:101,代码来源:win32text.c

示例9: if

	void CLabelUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcscmp(pstrName, _T("align")) == 0 ) {
			if( _tcsstr(pstrValue, _T("left")) != NULL ) {
				m_uTextStyle &= ~(DT_CENTER | DT_RIGHT | DT_SINGLELINE);
				m_uTextStyle |= DT_LEFT;
			}
			if( _tcsstr(pstrValue, _T("center")) != NULL ) {
				m_uTextStyle &= ~(DT_LEFT | DT_RIGHT );
				m_uTextStyle |= DT_CENTER;
			}
			if( _tcsstr(pstrValue, _T("right")) != NULL ) {
				m_uTextStyle &= ~(DT_LEFT | DT_CENTER | DT_SINGLELINE);
				m_uTextStyle |= DT_RIGHT;
			}
		}
		else if (_tcscmp(pstrName, _T("valign")) == 0)
		{
		    if (_tcsstr(pstrValue, _T("top")) != NULL) {
		        m_uTextStyle &= ~(DT_BOTTOM | DT_VCENTER);
		        m_uTextStyle |= (DT_TOP | DT_SINGLELINE);
		    }
		    if (_tcsstr(pstrValue, _T("vcenter")) != NULL) {
		        m_uTextStyle &= ~(DT_TOP | DT_BOTTOM);
		        m_uTextStyle |= (DT_VCENTER | DT_SINGLELINE);
		    }
		    if (_tcsstr(pstrValue, _T("bottom")) != NULL) {
		        m_uTextStyle &= ~(DT_TOP | DT_VCENTER);
		        m_uTextStyle |= (DT_BOTTOM | DT_SINGLELINE);
		    }
		}
		else if( _tcscmp(pstrName, _T("endellipsis")) == 0 ) {
			if( _tcscmp(pstrValue, _T("true")) == 0 ) m_uTextStyle |= DT_END_ELLIPSIS;
			else m_uTextStyle &= ~DT_END_ELLIPSIS;
		}    
		else if( _tcscmp(pstrName, _T("font")) == 0 ) SetFont(_ttoi(pstrValue));
		else if( _tcscmp(pstrName, _T("textcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetTextColor(clrColor);
		}
		else if( _tcscmp(pstrName, _T("disabledtextcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetDisabledTextColor(clrColor);
		}
		else if( _tcscmp(pstrName, _T("textpadding")) == 0 ) {
			RECT rcTextPadding = { 0 };
			LPTSTR pstr = NULL;
			rcTextPadding.left = _tcstol(pstrValue, &pstr, 10);  ASSERT(pstr);    
			rcTextPadding.top = _tcstol(pstr + 1, &pstr, 10);    ASSERT(pstr);    
			rcTextPadding.right = _tcstol(pstr + 1, &pstr, 10);  ASSERT(pstr);    
			rcTextPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);    
			SetTextPadding(rcTextPadding);
		}
		else if( _tcscmp(pstrName, _T("showhtml")) == 0 ) SetShowHtml(_tcscmp(pstrValue, _T("true")) == 0);
		else if( _tcscmp(pstrName, _T("enabledeffect")) == 0 ) SetEnabledEffect(_tcscmp(pstrValue, _T("true")) == 0);
		else if( _tcscmp(pstrName, _T("enabledluminous")) == 0 ) SetEnabledLuminous(_tcscmp(pstrValue, _T("true")) == 0);
		else if( _tcscmp(pstrName, _T("luminousfuzzy")) == 0 ) SetLuminousFuzzy((float)_tstof(pstrValue));
		else if( _tcscmp(pstrName, _T("gradientangle")) == 0 ) SetGradientAngle(_ttoi(pstrValue));
		else if( _tcscmp(pstrName, _T("enabledstroke")) == 0 ) SetEnabledStroke(_tcscmp(pstrValue, _T("true")) == 0);
		else if( _tcscmp(pstrName, _T("enabledshadow")) == 0 ) SetEnabledShadow(_tcscmp(pstrValue, _T("true")) == 0);
		else if( _tcscmp(pstrName, _T("gradientlength")) == 0 ) SetGradientLength(_ttoi(pstrValue));
		else if( _tcscmp(pstrName, _T("shadowoffset")) == 0 ){
			LPTSTR pstr = NULL;
			int offsetx = _tcstol(pstrValue, &pstr, 10);	ASSERT(pstr);    
			int offsety = _tcstol(pstr + 1, &pstr, 10);		ASSERT(pstr);
			SetShadowOffset(offsetx,offsety);
		}
		else if( _tcscmp(pstrName, _T("textcolor1")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetTextColor1(clrColor);
		}
		else if( _tcscmp(pstrName, _T("textshadowcolora")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetTextShadowColorA(clrColor);
		}
		else if( _tcscmp(pstrName, _T("textshadowcolorb")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetTextShadowColorB(clrColor);
		}
		else if( _tcscmp(pstrName, _T("strokecolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetStrokeColor(clrColor);
		}
		else CControlUI::SetAttribute(pstrName, pstrValue);
	}
开发者ID:1suming,项目名称:duilibLearn,代码行数:97,代码来源:UILabel.cpp

示例10: SetFont

void WinEDA_SetOptionsFrame::CreateControls()
{    
	SetFont(*g_DialogFont);
////@begin WinEDA_SetOptionsFrame content construction
    // Generated by DialogBlocks, 21/02/2006 11:38:20 (unregistered)

    WinEDA_SetOptionsFrame* itemDialog1 = this;

    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
    itemDialog1->SetSizer(itemBoxSizer2);

    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    m_ShowGridOpt = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Show grid"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_ShowGridOpt->SetValue(false);
    itemBoxSizer3->Add(m_ShowGridOpt, 0, wxALIGN_LEFT|wxALL, 5);

    wxString m_SelGridSizeStrings[] = {
        _("Normal (50 mils)"),
        _("Small (25 mils)"),
        _("Very small (10 mils)"),
        _("Special (5 mils)"),
        _("Special (2 mils)"),
        _("Special (1 mil)")
    };
    m_SelGridSize = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Grid Size"), wxDefaultPosition, wxDefaultSize, 6, m_SelGridSizeStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer3->Add(m_SelGridSize, 0, wxGROW|wxALL, 5);

    wxString m_SelShowPinsStrings[] = {
        _("Normal"),
        _("Show alls")
    };
    m_SelShowPins = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Show pins"), wxDefaultPosition, wxDefaultSize, 2, m_SelShowPinsStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer3->Add(m_SelShowPins, 0, wxGROW|wxALL, 5);

    wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    m_AutoPANOpt = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Auto PAN"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_AutoPANOpt->SetValue(false);
    m_AutoPANOpt->SetForegroundColour(wxColour(0, 0, 255));
    itemBoxSizer7->Add(m_AutoPANOpt, 0, wxGROW|wxALL, 5);

    wxString m_SelunitsStrings[] = {
        _("millimeter"),
        _("inches")
    };
    m_Selunits = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Units"), wxDefaultPosition, wxDefaultSize, 2, m_SelunitsStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer7->Add(m_Selunits, 0, wxGROW|wxALL, 5);

    wxString m_SelDirWiresStrings[] = {
        _("Horiz/Vertical"),
        _("Any")
    };
    m_SelDirWires = new wxRadioBox( itemDialog1, ID_RADIOBOX3, _("Wires - Bus orient"), wxDefaultPosition, wxDefaultSize, 2, m_SelDirWiresStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer7->Add(m_SelDirWires, 0, wxGROW|wxALL, 5);

    wxString m_Show_Page_LimitsStrings[] = {
        _("Yes"),
        _("No")
    };
    m_Show_Page_Limits = new wxRadioBox( itemDialog1, ID_RADIOBOX4, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 2, m_Show_Page_LimitsStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer7->Add(m_Show_Page_Limits, 0, wxGROW|wxALL, 5);

    wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    wxButton* itemButton13 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton13->SetForegroundColour(wxColour(202, 0, 0));
    itemBoxSizer12->Add(itemButton13, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxButton* itemButton14 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton14->SetForegroundColour(wxColour(0, 0, 255));
    itemBoxSizer12->Add(itemButton14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxStaticBox* itemStaticBoxSizer15Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Auto increment params"));
    wxStaticBoxSizer* itemStaticBoxSizer15 = new wxStaticBoxSizer(itemStaticBoxSizer15Static, wxVERTICAL);
    itemBoxSizer12->Add(itemStaticBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    wxStaticText* itemStaticText16 = new wxStaticText( itemDialog1, wxID_STATIC, _("Delta Step X"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer15->Add(itemStaticText16, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_DeltaStepCtrl_X = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer15->Add(m_DeltaStepCtrl_X, 0, wxGROW|wxALL, 5);

    wxStaticText* itemStaticText18 = new wxStaticText( itemDialog1, wxID_STATIC, _("Delta Step Y"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer15->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_DeltaStepCtrl_Y = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer15->Add(m_DeltaStepCtrl_Y, 0, wxGROW|wxALL, 5);

    wxStaticText* itemStaticText20 = new wxStaticText( itemDialog1, wxID_STATIC, _("Delta Label:"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer15->Add(itemStaticText20, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_DeltaLabelCtrl = new wxSpinCtrl( itemDialog1, ID_SPINCTRL, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -16, 16, 0 );
    itemStaticBoxSizer15->Add(m_DeltaLabelCtrl, 0, wxGROW|wxALL, 5);

////@end WinEDA_SetOptionsFrame content construction
}
开发者ID:BackupTheBerlios,项目名称:kicad-svn,代码行数:100,代码来源:dialog_options.cpp

示例11: DrawConnectionScreen

static void DrawConnectionScreen()
{
	unsigned char const* pSwash;
	/* this is part of the idle update
	 * timing is controlled by the idle update timer
	 * buffer was already cleared when drawing the time
	 */
	etConnectionState cs = QueryConnectionState();
	switch (cs)
	{
	case RadioOn:
		if (QueryValidPairingInfo())
		{
			pSwash = pBootPageConnectionSwash;
		}
		else
		{
			pSwash = pBootPagePairingSwash;
		}
		break;
	case Paired:
		pSwash = pBootPageConnectionSwash;
		break;
	case Connected:
		//pSwash = pBootPageConnectionSwash;
		//break;
		// Think we should do something here?
		pSwash = pBootPageUnknownSwash;
		break;
	case Initializing:
	case ServerFailure:
	case RadioOff:
	case RadioOffLowBattery:
	case ShippingMode:
	default:
		pSwash = pBootPageBluetoothOffSwash;
		break;
	}

  CopyRowsIntoMyBuffer(pSwash,WATCH_DRAWN_IDLE_BUFFER_ROWS+1,32);

#ifdef XXFONT_TESTING

  gRow = 65;
  gColumn = 0;
  gBitColumnMask = BIT0;

  SetFont(MetaWatch5);
  WriteFontString("Peanut Butter");

  gRow = 72;
  gColumn = 0;
  gBitColumnMask = BIT0;

  SetFont(MetaWatch7);
  //WriteFontString("ABCDEFGHIJKLMNOP");
  WriteFontString("Peanut Butter W");

  gRow = 80;
  gColumn = 0;
  gBitColumnMask = BIT0;
  SetFont(MetaWatch16);
  WriteFontString("ABC pqr StuVw");

#else

  unsigned char row;
  unsigned char col;

  /* characters are 10h then add space of 2 lines */
  row = 65;
  col = 0;
  col = WriteString(GetLocalBluetoothAddressString(),row,col,DONT_ADD_SPACE_AT_END);

  /* add the firmware version */
  row = 75;
  col = 0;
  col = WriteString("App",row,col,ADD_SPACE_AT_END);
  col = WriteString(VERSION_STRING,row,col,ADD_SPACE_AT_END);

  /* and the stack version */
  row = 85;
  col = 0;
  col = WriteString("Stack",row,col,ADD_SPACE_AT_END);
  col = WriteString(GetStackVersion(),row,col,ADD_SPACE_AT_END);

#endif

}
开发者ID:Rodini,项目名称:MetaWatch-WDS11x-IAR,代码行数:89,代码来源:IdlePageMain.c

示例12: SetBackgroundColour

bool wxToolBar::Create( wxWindow* pParent,
                        wxWindowID vId,
                        const wxPoint& rPos,
                        const wxSize& rSize,
                        long lStyle,
                        const wxString& rsName )
{
    if ( !wxWindow::Create( pParent
                           ,vId
                           ,rPos
                           ,rSize
                           ,lStyle
                           ,rsName
                          ))
        return false;

    // Set it to grey (or other 3D face colour)
    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR));
    SetFont(*wxSMALL_FONT);

    if (GetWindowStyleFlag() & (wxTB_LEFT | wxTB_RIGHT))
    {
        m_vLastX = 7;
        m_vLastY = 3;

        m_maxRows = 32000;      // a lot
        m_maxCols = 1;
    }
    else
    {
        m_vLastX = 3;
        m_vLastY = 7;

        m_maxRows = 1;
        m_maxCols = 32000;      // a lot
    }
    SetCursor(*wxSTANDARD_CURSOR);

    //
    // The toolbar's tools, if they have labels and the winTB_TEXT
    // style is set, then we need to take into account the size of
    // the text when drawing tool bitmaps and the text
    //
    if (HasFlag(wxTB_TEXT))
    {
        wxClientDC                  vDC(this);

        vDC.SetFont(GetFont());
        vDC.GetTextExtent( wxT("XXXX")
                          ,&m_vTextX
                          ,&m_vTextY
                         );
    }

    //
    // Position it
    //
    int                             nX      = rPos.x;
    int                             nY      = rPos.y;
    int                             nWidth  = rSize.x;
    int                             nHeight = rSize.y;

    if (lStyle & (wxTB_TOP | wxTB_BOTTOM))
    {
        if (nWidth <= 0)
        {
            nWidth = pParent->GetClientSize().x;
        }
        if (nHeight <= 0)
        {
            if (lStyle & wxTB_TEXT)
                nHeight = m_defaultHeight + m_vTextY;
            else
                nHeight = m_defaultHeight;
        }
    }
    else
    {
        if (nHeight <= 0)
        {
            nHeight = pParent->GetClientSize().y;
        }
        if (nWidth <= 0)
        {
            if (lStyle & wxTB_TEXT)
                nWidth = m_vTextX + (int)(m_vTextX/2); // a little margin
            else
                nWidth = m_defaultWidth + (int)(m_defaultWidth/2); // a little margin
        }
    }
    if (nX < 0)
        nX = 0;
    if (nY < 0)
        nY = 0;

    SetSize( nX
            ,nY
            ,nWidth
            ,nHeight
           );
//.........这里部分代码省略.........
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:101,代码来源:toolbar.cpp

示例13: SetAttribute

void CSysButtonUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
{
	if(_tcscmp(pstrName, _T("font")) == 0)			SetFont(_ttoi(pstrValue));

	else __super::SetAttribute(pstrName, pstrValue);
}
开发者ID:asdlei00,项目名称:duilib-1,代码行数:6,代码来源:SysButton.cpp

示例14: SetFont

void
TWindowMenu::AttachedToWindow()
{
	SetFont(be_plain_font);

	RemoveItems(0, CountItems(), true);

	int32 miniCount = 0;

	bool dragging = false;
	TBarView* barview =(static_cast<TBarApp*>(be_app))->BarView();
	if (barview && barview->LockLooper()) {
		//	'dragging' mode set in BarView::CacheDragData
		//		invoke in MouseEnter in ExpandoMenuBar
		dragging = barview->Dragging();
		if (dragging) {
			// We don't want to show the menu when dragging, but it's not
			// possible to remove a submenu once it exists, so we simply hide it
			// Don't call BMenu::Hide(), it causes the menu to pop up every now
			// and then.
			Window()->Hide();
			//	if in expando (horizontal or vertical)
			if (barview->Expando()) {
				SetTrackingHook(barview->MenuTrackingHook,
					barview->GetTrackingHookData());
			}
			barview->DragStart();
		}
		barview->UnlockLooper();
	}

	int32 parentMenuItems = 0;

	int32 numTeams = fTeam->CountItems();
	for (int32 i = 0; i < numTeams; i++) {
		team_id	theTeam = (team_id)fTeam->ItemAt(i);
		int32 count = 0;
		int32* tokens = get_token_list(theTeam, &count);

		for (int32 j = 0; j < count; j++) {
			client_window_info* wInfo = get_window_info(tokens[j]);
			if (wInfo == NULL)
				continue;

			if (WindowShouldBeListed(wInfo->feel)
				&& (wInfo->show_hide_level <= 0 || wInfo->is_mini)) {
				// Don't add new items if we're expanded. We've already done
				// this, they've just been moved.
				int32 numItems = CountItems();
				int32 addIndex = 0;
				for (; addIndex < numItems; addIndex++)
					if (strcasecmp(ItemAt(addIndex)->Label(), wInfo->name) > 0)
						break;

				if (!fExpanded) {
					TWindowMenuItem* item = new TWindowMenuItem(wInfo->name,
						wInfo->server_token, wInfo->is_mini,
						((1 << current_workspace()) & wInfo->workspaces) != 0,
						dragging);

					// disable app's window dropping for now
					if (dragging)
						item->SetEnabled(false);

					AddItem(item,
						TWindowMenuItem::InsertIndexFor(this, 0, item));
				} else {
					TTeamMenuItem* parentItem
						= static_cast<TTeamMenuItem*>(Superitem());
					if (parentItem->ExpandedWindowItem(wInfo->server_token)) {
						TWindowMenuItem* item = parentItem->ExpandedWindowItem(
							wInfo->server_token);
						if (item == NULL)
							continue;

						item->SetTo(wInfo->name, wInfo->server_token,
							wInfo->is_mini,
							((1 << current_workspace()) & wInfo->workspaces)
								!= 0, dragging);
						parentMenuItems++;
					}
				}

				if (wInfo->is_mini)
					miniCount++;
			}
			free(wInfo);
		}
		free(tokens);
	}

	int32 itemCount = CountItems() + parentMenuItems;
	if (itemCount < 1) {
		TWindowMenuItem* noWindowsItem =
 			new TWindowMenuItem(B_TRANSLATE("No windows"), -1, false, false);

		noWindowsItem->SetEnabled(false);

		AddItem(noWindowsItem);

//.........这里部分代码省略.........
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:WindowMenu.cpp

示例15: SetFont

BOOL CFavUrlMenuDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	SetFont(&m_font);
	if (m_bAddFav)
	{
		ITEM item;
		item.type = ITEM_TYPE_BTN_ADD;
		item.strName = "添加到收藏夹";
		item.strPath = m_strParentPath;
		m_arrItems.Add(item);
		item.type = ITEM_TYPE_SEPARATOR;
		m_arrItems.Add(item);
		GetUrls(m_strParentPath, m_arrItems);
	}else 
	{
		ITEM item;
		item.type = ITEM_TYPE_BTN_OPEN;
		item.strName = "打开";
		item.strPath = m_strParentPath;
		m_arrItems.Add(item);

		item.type = ITEM_TYPE_BTN_REMOE;
		item.strName = "删除";
		item.strPath = m_strParentPath;
		m_arrItems.Add(item);
	}
	// 获取最长字符串所占宽度
	CClientDC dc(this);
	int nTextWidthMax = 0;
	CSize size;
	dc.SelectObject(&m_font);
	for (INT_PTR i=0; i<m_arrItems.GetSize(); i++)
	{
		CString strText = m_arrItems.GetAt(i).strName;
		size = dc.GetTextExtent(strText);
		if (size.cx > nTextWidthMax)
			nTextWidthMax = size.cx;
	}
	nTextWidthMax = nTextWidthMax < 90 ? nTextWidthMax+100: nTextWidthMax+30;
	size.cx = nTextWidthMax;

	m_rctFirsItem = CRect(CPoint(m_nBorderWidth, m_nBorderWidth), CSize(size.cx+m_nSpacingHeigth*2, size.cy+m_nSpacingHeigth));
	m_rctFirsItem.top += 6;
	m_rctFirsItem.bottom +=10;

	CRect rctWnd(0, 0, 0, 0);
	rctWnd.right = m_nBorderWidth*2 + m_rctFirsItem.Width();
	rctWnd.bottom= m_nBorderWidth*2 + m_rctFirsItem.Height()*m_arrItems.GetSize() ;
	if (m_nBorderWidth % 2)
	{
		rctWnd.right += 2;
		rctWnd.bottom += 2;
	}
 	dc.BeginPath();
 	dc.RoundRect(rctWnd, CPoint(m_nBorderWidth, m_nBorderWidth));
 	dc.EndPath();
  	HRGN hRgn = PathToRegion(dc.m_hDC);
 	SetWindowRgn(hRgn, FALSE);
	GetRgnBox(hRgn, &rctWnd);
	SetWindowPos(NULL, 0, 0, rctWnd.Width(), rctWnd.Height(), SWP_NOMOVE);
 	return TRUE;  // 除非设置了控件的焦点,否则返回 TRUE
}
开发者ID:linjianbjfu,项目名称:PlayBox,代码行数:63,代码来源:FavUrlMenuDlg.cpp


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