예제 #1
0
//建立消息
int CSkinButton::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;
	SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW);
	SendMessage(WM_SETFONT,(WPARAM)CSkinResourceManager::GetDefaultFont(),TRUE);
	return 0;
}
예제 #2
0
//对象附加到现有窗口
void CSkinButton::PreSubclassWindow()
{
	__super::PreSubclassWindow();
	SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW);
	SendMessage(WM_SETFONT,(WPARAM)m_SkinAttribute.GetDefaultFont(),TRUE);
	return;
}
예제 #3
0
//对象附加到现有窗口
void CSkinButton::PreSubclassWindow()
{
	__super::PreSubclassWindow();
	SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW);
	SendMessage(WM_SETFONT,(WPARAM)CSkinResourceManager::GetDefaultFont(),TRUE);
	return;
}
예제 #4
0
bool wxCustomButton::Create(wxWindow* parent, wxWindowID id,
                            const wxString& label, const wxBitmap &bitmap,
                            const wxPoint& pos, const wxSize& size_,
                            long style, const wxValidator& val,
                            const wxString& name)
{
    m_labelString = label;
    if (bitmap.Ok()) m_bmpLabel = bitmap;
    wxSize bestSize = DoGetBestSize_(parent);
    wxSize size(size_.x<0 ? bestSize.x:size_.x, size_.y<0 ? bestSize.y:size_.y);

    //SetInitialSize(size);

    if (!wxControl::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name))
        return false;

    wxControl::SetBackgroundColour(parent->GetBackgroundColour());
    wxControl::SetForegroundColour(parent->GetForegroundColour());
    wxControl::SetFont(parent->GetFont());

    if (!SetButtonStyle(style)) return false;

    //SetBestSize(size);

    CalcLayout(true);
    return true;
}
예제 #5
0
void CToolBarXP::TrackPopupMenu (int nID, CMenu* pMenu)
{
    CRect rcTBItem;
    int nTBIndex = CommandToIndex (nID);
    TPMPARAMS tpmp = { sizeof TPMPARAMS };
    
    GetItemRect (nTBIndex, rcTBItem);
    ClientToScreen (rcTBItem);
    CopyRect (&tpmp.rcExclude, rcTBItem);
    rcTBItem.OffsetRect (4, 0);
    CMenuXP::SetMRUMenuBarItem (rcTBItem);
    SetButtonStyle (nTBIndex, GetButtonStyle (nTBIndex)|TBBS_INDETERMINATE);
    UpdateWindow();
    ::TrackPopupMenuEx (pMenu->GetSafeHmenu(), TPM_LEFTBUTTON, tpmp.rcExclude.left, tpmp.rcExclude.bottom, GetParentFrame()->GetSafeHwnd(), &tpmp);
    SetButtonStyle (nTBIndex, GetButtonStyle (nTBIndex)&~TBBS_INDETERMINATE);
}
예제 #6
0
파일: menubtn.cpp 프로젝트: erelh/gpac
bool wxCustomButton::Create(wxWindow* parent, wxWindowID id,
                            const wxString& label, const wxBitmap &bitmap,
                            const wxPoint& pos, const wxSize& size,
                            long style, const wxValidator& val,
                            const wxString& name)
{
    if (!wxControl::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name))
        return FALSE;

    wxControl::SetLabel(label);
    wxControl::SetBackgroundColour(parent->GetBackgroundColour());
    wxControl::SetForegroundColour(parent->GetForegroundColour());
    wxControl::SetFont(parent->GetFont());

    if (bitmap.Ok()) m_bmpLabel = bitmap;

    if (!SetButtonStyle(style)) return FALSE;

    wxSize bestSize = DoGetBestSize();
    SetSize(wxSize(size.x<0 ? bestSize.x:size.x, size.y<0 ? bestSize.y:size.y));
#if (wxMINOR_VERSION<8)
    SetBestSize(GetSize());
#else
    SetInitialSize(GetSize());
#endif

    CalcLayout(TRUE);
    return TRUE;
}
예제 #7
0
/**
 * Construct this widget
 *
 * @param	InArgs	The declaration data for this widget
 */
void SButton::Construct( const FArguments& InArgs )
{
	bIsPressed = false;

	// Text overrides button content. If nothing is specified, put an null widget in the button.
	// Null content makes the button enter a special mode where it will ask to be as big as the image used for its border.
	struct
	{
		TSharedRef<SWidget> operator()( const FArguments& InOpArgs ) const
		{
			if ((InOpArgs._Content.Widget == SNullWidget::NullWidget) && (InOpArgs._Text.IsBound() || !InOpArgs._Text.Get().IsEmpty()) )
			{
				return SNew(STextBlock)
					.Text( InOpArgs._Text )
					.TextStyle( InOpArgs._TextStyle )
					.TextShapingMethod( InOpArgs._TextShapingMethod )
					.TextFlowDirection( InOpArgs._TextFlowDirection );
			}
			else
			{
				return InOpArgs._Content.Widget;
			}
		}
	} DetermineContent; 

	SBorder::Construct( SBorder::FArguments()
		.ContentScale(InArgs._ContentScale)
		.DesiredSizeScale(InArgs._DesiredSizeScale)
		.BorderBackgroundColor(InArgs._ButtonColorAndOpacity)
		.ForegroundColor(InArgs._ForegroundColor)
		.BorderImage( this, &SButton::GetBorder )
		.HAlign( InArgs._HAlign )
		.VAlign( InArgs._VAlign )
		.Padding( TAttribute<FMargin>(this, &SButton::GetCombinedPadding) )
		.ShowEffectWhenDisabled( TAttribute<bool>(this, &SButton::GetShowDisabledEffect) )
		[
			DetermineContent(InArgs)
		]
	);

	ContentPadding = InArgs._ContentPadding;

	SetButtonStyle(InArgs._ButtonStyle);

	bIsFocusable = InArgs._IsFocusable;

	OnClicked = InArgs._OnClicked;
	OnPressed = InArgs._OnPressed;
	OnReleased = InArgs._OnReleased;
	OnHovered = InArgs._OnHovered;
	OnUnhovered = InArgs._OnUnhovered;

	ClickMethod = InArgs._ClickMethod;
	TouchMethod = InArgs._TouchMethod;
	PressMethod = InArgs._PressMethod;

	HoveredSound = InArgs._HoveredSoundOverride.Get(Style->HoveredSlateSound);
	PressedSound = InArgs._PressedSoundOverride.Get(Style->PressedSlateSound);
}
예제 #8
0
//对象附加到现有窗口
void CRgnButton::PreSubclassWindow()
{
	__super::PreSubclassWindow();
	SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW);
	SetClassLong(m_hWnd,GCL_HBRBACKGROUND,NULL);
	SendMessage(WM_SETFONT,(WPARAM)CSkinResourceManager::GetDefaultFont(),TRUE);
	return;
}
예제 #9
0
//建立消息
int CRgnButton::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;
	SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW);
	SetClassLong(m_hWnd,GCL_HBRBACKGROUND,NULL);
	SendMessage(WM_SETFONT,(WPARAM)CSkinResourceManager::GetDefaultFont(),TRUE);
	return 0;
}
예제 #10
0
//建立消息
int CButtonEx::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;
	
	SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW);

	return 0;
}
예제 #11
0
파일: ctrl.cpp 프로젝트: BlackMoon/logread
void CToolBarEx::dropArrow(UINT nID, UINT nMenu)
{
	menuID = nMenu;
	SendMessage(TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_DRAWDDARROWS);	
	
	DWORD dw = GetButtonStyle(CommandToIndex(nID));
	dw |= TBSTYLE_DROPDOWN;
	SetButtonStyle(CommandToIndex(nID), dw);	
}
예제 #12
0
void CStartupView::CreateCloseButton()
{
   CRect rcButton;
   rcButton.SetRect(0, 0, 10, 10);
   m_btnClose.Create(_T("Close Startup page"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, rcButton, this, IDC_CLOSESTARTPAGE);
   SetButtonImage(&m_btnClose,IDR_CLOSE_STARTUP_PAGE, CSize(10,10));
   SetButtonStyle(&m_btnClose, xtThemeOffice2003, BS_XT_XPFLAT | BS_XT_TRANSPARENT, &m_webBtnFont, RGB(233, 243, 249));
   //SetButtonStyle(&m_btnClose, xtThemeOffice2003, BS_XT_XPFLAT, &m_webBtnFont, RGB(190, 217, 239));
   
   m_btnClose.SetImageGap(0);
   m_btnClose.SetTheme(xtThemeOffice2003);
}
예제 #13
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);
            
}
예제 #14
0
void CFlatToolbar::OnLButtonUp(UINT nFlags, CPoint point)
{
	if (m_iButtonCapture < 0)
	{
		CControlBar::OnLButtonUp(nFlags, point);
		return;     // not captured
	}

	AFX_TBBUTTON* pTBB = _GetButtonPtr(m_iButtonCapture);
	ASSERT(!(pTBB->nStyle & TBBS_SEPARATOR));
	UINT nIDCmd = 0;

	UINT nNewStyle = (pTBB->nStyle & ~TBBS_PRESSED);
	if (GetCapture() == this)
	{
		// we did not lose the capture
		ReleaseCapture();
		if (HitTest(point) == m_iButtonCapture)
		{
			// give button a chance to update
			UpdateButton(m_iButtonCapture);

			// then check for disabled state
			if (!(pTBB->nStyle & TBBS_DISABLED))
			{
				// pressed, will send command notification
				nIDCmd = pTBB->nID;

				if (pTBB->nStyle & TBBS_CHECKBOX)
				{
					// auto check: three state => down
					if (nNewStyle & TBBS_INDETERMINATE)
						nNewStyle &= ~TBBS_INDETERMINATE;

					nNewStyle ^= TBBS_CHECKED;
				}
			}
		}
	}

	GetOwner()->SendMessage(WM_SETMESSAGESTRING, AFX_IDS_IDLEMESSAGE);

	int iButtonCapture = m_iButtonCapture;
	m_iButtonCapture = -1;
	if (nIDCmd != 0)
		GetOwner()->SendMessage(WM_COMMAND, nIDCmd);    // send command

	SetButtonStyle(iButtonCapture, nNewStyle);
	UpdateButton(iButtonCapture);

	UpdateWindow(); // immediate feedback
}
예제 #15
0
파일: ScribFrm.cpp 프로젝트: assafyariv/PSG
BOOL CScribbleBar::Create(CWnd* pParentWnd)
{
    //if (!CToolBar::Create(pParentWnd) || !LoadToolBar(IDR_MAINFRAME))
      //  return FALSE;

    // Remove this if you don't want tool tips

    SetBarStyle(GetBarStyle() |    CBRS_TOOLTIPS |
        CBRS_FLYBY | CBRS_SIZE_FIXED);

    // By setting the button style of each the marker color buttons
    // to TBBS_CHECKGROUP, we ensure that only one may be depressed
    // at a time.

    SetButtonStyle(0, TBBS_CHECKGROUP);
    SetButtonStyle(1, TBBS_CHECKGROUP);
    SetButtonStyle(2, TBBS_CHECKGROUP);
    SetButtonStyle(3, TBBS_CHECKGROUP);
    //GetToolBarCtrl().CheckButton(IDB_BLACK_MARKER);

    return TRUE;
}
예제 #16
0
void CButtonST::PreSubclassWindow() 
{
  CRect rect;
  GetClientRect ( &rect );

  // Add BS_OWNERDRAW style
  SetButtonStyle(GetButtonStyle() | BS_OWNERDRAW);
  // Create tooltips
  m_ctrlToolTip.Create ( this );
  m_ctrlToolTip.AddTool ( this, m_strToolTip, rect, TOOLTIP_ID );
  
  CButton::PreSubclassWindow();
} // End of PreSubclassWindow
예제 #17
0
void CButtonST::PreSubclassWindow() 
{
	UINT nBS;

	nBS = GetButtonStyle();

	// Check if this is the default button
	if (nBS & BS_DEFPUSHBUTTON) m_bIsDefault = TRUE;

	// Add BS_OWNERDRAW style
	SetButtonStyle(nBS | BS_OWNERDRAW);

	CButton::PreSubclassWindow();
} // End of PreSubclassWindow
예제 #18
0
void CCheckButton::PreSubclassWindow()
{
	__super::PreSubclassWindow();

	SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW);
	SendMessage(WM_SETFONT,(WPARAM)CSkinResourceManager::GetDefaultFont(),TRUE);

	//调整和图片一样大小
	CRect rcClient;
	GetClientRect(&rcClient);
	SetWindowPos(NULL, 0, 0, rcClient.Width(), 17, SWP_NOMOVE);

	return;
}
예제 #19
0
void CTrueColorToolBar::AddDropDownButton(CWnd* pParent, UINT uButtonID, UINT uMenuID)
{
	if (!m_bDropDown) {
		GetToolBarCtrl().SendMessage(TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_DRAWDDARROWS);
		m_bDropDown = TRUE;
	}

	SetButtonStyle(CommandToIndex(uButtonID), TBSTYLE_DROPDOWN);

	stDropDownInfo DropDownInfo;
	DropDownInfo.pParent	= pParent;
	DropDownInfo.uButtonID	= uButtonID;
	DropDownInfo.uMenuID	= uMenuID;
	m_lstDropDownButton.Add(DropDownInfo);
}
예제 #20
0
void CExtButton::PreSubclassWindow() 
{
	CButton::PreSubclassWindow();
UINT nBS = GetButtonStyle();
	if( nBS & BS_DEFPUSHBUTTON )
		m_bIsDefault = TRUE;
	if( nBS & BS_OWNERDRAW )
		SetButtonStyle( nBS & ~(BS_OWNERDRAW) );
	SetFont(
		m_bIsDefault?
			&g_PaintManager->m_FontBold
			:
			&g_PaintManager->m_FontNormal
			);
}
예제 #21
0
void CFlatToolbar::OnCancelMode()
{
	CControlBar::OnCancelMode();

	if (m_iButtonCapture >= 0)
	{
		AFX_TBBUTTON* pTBB = _GetButtonPtr(m_iButtonCapture);
		ASSERT(!(pTBB->nStyle & TBBS_SEPARATOR));
		UINT nNewStyle = (pTBB->nStyle & ~TBBS_PRESSED);
		if (GetCapture() == this)
			ReleaseCapture();
		SetButtonStyle(m_iButtonCapture, nNewStyle);
		m_iButtonCapture = -1;
		UpdateWindow();
	}
}
예제 #22
0
파일: palette.cpp 프로젝트: uesoft/AutoPFA
void CPaletteBar::SetColumns(UINT nColumns)
{
	m_nColumns = nColumns;
	int nCount = GetToolBarCtrl().GetButtonCount();

	for (int i = 0; i < nCount; i++)
	{
		UINT nStyle = GetButtonStyle(i);
		BOOL bWrap = (((i + 1) % nColumns) == 0);
		if (bWrap)
			nStyle |= TBBS_WRAPPED;
		else
			nStyle &= ~TBBS_WRAPPED;
		SetButtonStyle(i, nStyle);
	}

	Invalidate();
	GetParentFrame()->RecalcLayout();
}
예제 #23
0
bool wxBitmapComboBox::Create( wxWindow* parent, wxWindowID id,
                               const wxPoint& pos, const wxSize& size,
                               long style, const wxValidator& val,
                               const wxString& name)
{
    if (!DropDownBase::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name))
        return false;

    m_labelWin = new wxBitmapComboLabel(this);
    m_win_border = m_labelWin->GetSize().x - m_labelWin->GetClientSize().x;

    SetBackgroundColour(*wxWHITE);

    m_frozen = false;
    CalcLayout();

    wxSize bestSize = DoGetBestSize();
    SetSize( wxSize(size.x < 0 ? bestSize.x : size.x,
                    size.y < 0 ? bestSize.y : size.y) );

    return SetButtonStyle(style);
}
예제 #24
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;
}
예제 #25
0
//对象附加到现有窗口
void CButtonEx::PreSubclassWindow()
{
	__super::PreSubclassWindow();

	SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW);
}
예제 #26
0
BOOL CRRECToolBar::Create( CWnd* parent)
{
    if (CreateEx(parent, TBSTYLE_FLAT | TBSTYLE_WRAPABLE, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_SIZE_DYNAMIC/* | WS_CLIPCHILDREN*/,
                 CRect(0, 0, 0, 0), TOOLBAR_CONTROL) && LoadToolBar(TOOLBAR_CONTROL))
    {
        SetImage(IDB_TOOLBAR, RGB(255, 0, 255));

        // very important - turn OFF all the auto positioning and sizing
        // by default have no borders
        UINT nStyle = GetBarStyle();
        //	nStyle &= ~(CCS_NORESIZE | CCS_NOPARENTALIGN | CBRS_BORDER_ANY);
        nStyle |= (/*CBRS_SIZE_FIXED | */CBRS_TOOLTIPS | CBRS_FLYBY);
        SetBarStyle(nStyle);

        SetOwner(parent);
        GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);

        // colour drop buttons
        int nIndex = CommandToIndex(BUTTON_BACKCOLOR);
        SetButtonStyle(nIndex, GetButtonStyle(nIndex) | TBSTYLE_DROPDOWN);

        nIndex = CommandToIndex(BUTTON_TEXTCOLOR);
        SetButtonStyle(nIndex, GetButtonStyle(nIndex) | TBSTYLE_DROPDOWN);

        /////////////////////////////////////
        // Map in combo boxes
        //

        TBBUTTON buttons[] =
        {
            { 0, FONT_NAME_ID, 0, TBSTYLE_SEP, 0, NULL },
            { 0, -1, 0, TBSTYLE_SEP, 0, NULL },
            { 0, FONT_SIZE_ID, 0, TBSTYLE_SEP, 0, NULL },
            { 0, -1, 0, TBSTYLE_SEP, 0, NULL },
        };
        const int BTNCOUNT = sizeof(buttons) / sizeof(TBBUTTON);

        for (int nBtn = 0; nBtn < BTNCOUNT; nBtn++)
            GetToolBarCtrl().InsertButton(nBtn, &buttons[nBtn]);

        CRect rect;

        TBBUTTONINFO tbi;
        tbi.cbSize = sizeof( TBBUTTONINFO );
        tbi.cx = FONT_COMBO_WIDTH;
        tbi.dwMask = TBIF_SIZE;  // By index

        // The font name combo
        GetToolBarCtrl().SetButtonInfo( FONT_NAME_ID, &tbi );
        GetItemRect( FONT_NAME_POS, &rect );

        rect.left++;
        rect.top++;
        rect.bottom += COMBO_HEIGHT;

        if (!m_font.Create( WS_CHILD | WS_VSCROLL |	WS_VISIBLE | CBS_AUTOHSCROLL |
                            CBS_DROPDOWNLIST | CBS_SORT, rect, this, DROPDOWN_FONT ))
            return FALSE;

        m_font.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( DEFAULT_GUI_FONT ) ) );
        m_font.FillCombo();

        // The font size combo
        tbi.cx = COMBO_WIDTH;
        GetToolBarCtrl().SetButtonInfo( FONT_SIZE_ID, &tbi );
        GetItemRect( FONT_SIZE_POS, &rect );

        rect.top++;
        rect.bottom += COMBO_HEIGHT;

        if (!m_size.Create(WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST |
                           CBS_HASSTRINGS, rect, this, DROPDOWN_SIZE ))
            return FALSE;

        m_size.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( DEFAULT_GUI_FONT ) ) );
        m_size.FillCombo();

        return TRUE;
    }

    return FALSE;
}
예제 #27
0
void CSkinButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	ASSERT(lpDrawItemStruct != NULL);

	CDC		*pDC,
			dcmem,
			dcSkin;
	CBitmap bmpMem,
			*pOldbmpMem,
			*pOldbmpSkin;
	CString str,
			str2,
			strSkinPath,
			strFile;
	CRect	rect,
			rect2(0,0,1,1);
	UINT	nState,
			nXStart,
			nSpriteYStart,
			nDownDecal;
	register int	i;

	if (bIni)
	{
		bIni = FALSE;

		// Donne caption
		GetWindowText(m_strCaption.GetBuffer(20), 20);

		// Charge le skin / options
		if (m_strCaption == "ICQ Clan")
			str = "ButtonICQClanImages";
		else if (m_strCaption == "Add clan")
			str = "ButtonAdduserImages";
		else if (m_strCaption == "System")
			str = "ButtonSysmessageImages";
		else if (m_strCaption == "x")
			str = "ButtonCloseImages";
		strSkinPath = AfxGetApp()->GetProfileString("Options", "Skin", "");
		strFile.ReleaseBuffer( ::GetPrivateProfileString("Buttons", str, "", strFile.GetBuffer(255), 255, strSkinPath+"Skin.ini") );
		pBmpSkin = NULL;
		if (strFile != "")
		{
			HBITMAP hBitmap = NULL; 
			hBitmap = (HBITMAP)LoadImage(NULL, strSkinPath+strFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
			pBmpSkin = new CBitmap;
			if (hBitmap == NULL || pBmpSkin->Attach(hBitmap) == 0)
			{
				delete pBmpSkin;
				pBmpSkin = NULL;
			}
		}

		// Add
		if (m_strCaption == "Add clan")
			str = "Adduser";
		// Sys
		else if (m_strCaption == "System")
			str = "Sysmessage";
		if (m_strCaption == "Add clan" || m_strCaption == "System")
		{
			nButtonWidth1 = ::GetPrivateProfileInt("Buttons", "Button"+str+"LeftFixWidth", 4, strSkinPath+"skin.ini");
			nButtonWidth2 = ::GetPrivateProfileInt("Buttons", "Button"+str+"MidleWidth", 45, strSkinPath+"skin.ini");
			str2.ReleaseBuffer( ::GetPrivateProfileString("Buttons", "Button"+str+"MidleMode", "Stretch", str2.GetBuffer(20), 20, strSkinPath+"skin.ini") );
			str2.MakeUpper();
			nButtonWidth2Mode = str2 == "STRETCH" ? 0 : 1;
			nButtonWidth3 = ::GetPrivateProfileInt("Buttons", "Button"+str+"RightFixWidth", 4, strSkinPath+"skin.ini");
			nButtonSpriteWidth = ::GetPrivateProfileInt("Buttons", "Button"+str+"SpriteWidth", 99, strSkinPath+"skin.ini");
		}
	}

	if (pBmpSkin == NULL)
	{
		SetButtonStyle( GetButtonStyle() & ~BS_OWNERDRAW, TRUE);
		return;
	}

	GetWindowRect(rect);
	nState = lpDrawItemStruct->itemState;
	pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

	// Créé un dc mem
	dcmem.CreateCompatibleDC(pDC);
	bmpMem.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
	pOldbmpMem = dcmem.SelectObject(&bmpMem);
	
	// Créé un dc mem avec le skin
	dcSkin.CreateCompatibleDC(pDC);
	pOldbmpSkin = dcSkin.SelectObject(pBmpSkin);

	// Place le skin ds le dcmem (1/2)
	// ICQ Clan
	if (m_strCaption == "ICQ Clan")
	{
		// Selon l'état
		if (nState & ODS_SELECTED)		// Down
			nXStart = BTC_ICQ_X + 2*BTC_ICQ_WIDTH;
		else if (nState & ODS_FOCUS)	// Focus
			nXStart = BTC_ICQ_X + BTC_ICQ_WIDTH;
		else							// Normal
			nXStart = BTC_ICQ_X;
		dcmem.BitBlt(0,0, BTC_ICQ_WIDTH, BTC_ICQ_HEIGHT, &dcSkin, nXStart+BTC_ICQ_X, BTC_ICQ_Y, SRCCOPY);
	}
	// Add / Sys
	else if (m_strCaption == "Add clan" || m_strCaption == "System")
	{
		// Selon l'état
		if (nState & ODS_SELECTED)		// Down
		{
			nXStart = BTC_X + 2*BTC_WIDTH;
			nSpriteYStart = BTC_SPRITE_Y + 2*BTC_SPRITE_HEIGHT;
		}
		else if (nState & ODS_FOCUS)	// Focus
		{
			nXStart = BTC_X + BTC_WIDTH;
			nSpriteYStart = BTC_SPRITE_Y + BTC_SPRITE_HEIGHT;
		}
		else if (nState & ODS_DISABLED)	// Disabled
		{
			nXStart = BTC_X + 3*BTC_WIDTH;
			nSpriteYStart = BTC_SPRITE_Y + 3*BTC_SPRITE_HEIGHT;
		}
		else							// Normal
		{
			nXStart = BTC_X;
			nSpriteYStart = BTC_SPRITE_Y;
		}
		// En mode répété ou étiré
		if (nButtonWidth2Mode == 0)
			dcmem.StretchBlt(BTC_WIDTH1,0, rect.Width()-BTC_WIDTH1-BTC_WIDTH3, BTC_HEIGHT, &dcSkin, nXStart+BTC_X+BTC_WIDTH1, BTC_Y, BTC_WIDTH2, BTC_HEIGHT, SRCCOPY);
		else
			for (i=BTC_WIDTH1; i<rect.Width()-BTC_WIDTH1-BTC_WIDTH3; i+=BTC_WIDTH2)
				dcmem.BitBlt(i,0, rect.Width()-BTC_WIDTH1-BTC_WIDTH3, BTC_HEIGHT, &dcSkin, nXStart+BTC_X+BTC_WIDTH1, BTC_Y, SRCCOPY);
	}
	// Close
	else if (m_strCaption == "x")
	{
		// Selon l'état
		if (nState & ODS_SELECTED)		// Down
			nXStart = 2*BTC_X_WIDTH;
		else if (nState & ODS_FOCUS)	// Focus
			nXStart = BTC_X_WIDTH;
		else							// Normal
			nXStart = 0;
		dcmem.BitBlt(0, 0, BTC_X_WIDTH, BTC_X_HEIGHT, &dcSkin, nXStart, 0, SRCCOPY);
	}

	// Place le sprite
	if (m_strCaption == "Add clan" || m_strCaption == "System")
	{
		// Down ?
		if (nState & ODS_SELECTED)
			nDownDecal=1;
		else
			nDownDecal=0;

		GetWindowText(str);										// Txt à afficher
		// Prépare l'affichage
		rect2 = CRect(BTC_WIDTH1, 0, rect.Width()-BTC_WIDTH3, rect.Height());		// Zone de texte
		// Applique l'image en tenant compte de la couche alpha
		dcmem.BitBlt(rect.Width()/2-BTC_SPRITE_WIDTH/2+nDownDecal, nDownDecal, BTC_SPRITE_WIDTH, BTC_SPRITE_HEIGHT, &dcSkin, BTC_SPRITE_A_X, nSpriteYStart, SRCPAINT);
		dcmem.BitBlt(rect.Width()/2-BTC_SPRITE_WIDTH/2+nDownDecal, nDownDecal, BTC_SPRITE_WIDTH, BTC_SPRITE_HEIGHT, &dcSkin, BTC_SPRITE_A_X, nSpriteYStart, SRCINVERT);
		dcSkin.BitBlt(BTC_SPRITE_X, nSpriteYStart, BTC_SPRITE_WIDTH, BTC_SPRITE_HEIGHT, &dcSkin, BTC_SPRITE_A_X, nSpriteYStart, SRCAND);
		dcmem.BitBlt(rect.Width()/2-BTC_SPRITE_WIDTH/2+nDownDecal, nDownDecal, BTC_SPRITE_WIDTH, BTC_SPRITE_HEIGHT, &dcSkin, BTC_SPRITE_X, nSpriteYStart, SRCPAINT);
	}

	// Place le skin ds le dcmem (2/2)
	// Add / Sys
	if (m_strCaption == "Add clan" || m_strCaption == "System")
	{
		dcmem.BitBlt(0,0, BTC_WIDTH1, BTC_HEIGHT, &dcSkin, nXStart+BTC_X, BTC_Y, SRCCOPY);
		dcmem.BitBlt(rect.Width()-BTC_WIDTH3,0, BTC_WIDTH3, BTC_HEIGHT, &dcSkin, nXStart+BTC_X+BTC_WIDTH1+BTC_WIDTH2, 0, SRCCOPY);
	}

	// Affiche à l'écran
	pDC->BitBlt(0,0, rect.Width(), rect.Height(), &dcmem, 0,0, SRCCOPY);

	// Clear la memoire
	dcmem.SelectObject(pOldbmpMem);
	dcmem.DeleteDC();
	dcSkin.SelectObject(pOldbmpSkin);
	dcSkin.DeleteDC();
}
예제 #28
0
void CMyCheckBox::PreSubclassWindow()
{
    SetButtonStyle(GetButtonStyle()|BS_OWNERDRAW|WS_VISIBLE);
    CButton::PreSubclassWindow();
}
예제 #29
0
void CStartMenuView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();

	// TODO: Fügen Sie hier Ihren spezialisierten Code ein, und/oder rufen Sie die Basisklasse auf.
	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);

	m_pBkgndImg = pDoc->GetGraphicPool()->GetGDIGraphic("Events\\Startmenu.boj");
	AssertBotE(m_pBkgndImg);

	m_pChooseRaceView = dynamic_cast<CChooseRaceView*>(resources::pMainFrame->GetView(RUNTIME_CLASS(CChooseRaceView)));
	AssertBotE(m_pChooseRaceView);

	m_pNewGameView = dynamic_cast<CNewGameView*>(resources::pMainFrame->GetView(RUNTIME_CLASS(CNewGameView)));
	AssertBotE(m_pNewGameView);

	// Immer im Vollbild anzeigen
	resources::pMainFrame->FullScreenMainView(true);

	// Menü zu Beginn nicht anzeigen
	GetTopLevelFrame()->SetMenuBarState(AFX_MBS_HIDDEN);

	m_TotalSize = CSize(1280, 1024);

	CRect clientRect;
	GetDesktopWindow()->GetClientRect(clientRect);

	double nButtonSizeX = 300.0;
	double nButtonSizeY = 40.0;

	double nXPos = clientRect.Width() / 2.0 - nButtonSizeX / 2.0;
	double nYPos = clientRect.Height() / 2.0 - 150.0;

	double nGab = 10.0;

	// Structure containing Style
	tButtonStyle tStyle;
	//////////////////////////////////////////////////////////////////////////

	// Get default Style
	m_tButtonStyle.GetButtonStyle(&tStyle);
	// Change Radius of Button
	tStyle.m_dRadius = 1.0;

	// Change Color Schema of Button
	tStyle.m_tColorFace.m_tEnabled		= RGB(100, 100, 100);
	tStyle.m_tColorBorder.m_tEnabled	= RGB(220, 220, 220);

	tStyle.m_tColorFace.m_tClicked		= RGB(75, 75, 75);
	tStyle.m_tColorBorder.m_tClicked	= RGB(25, 25, 25);

	tStyle.m_tColorFace.m_tPressed		= RGB(75, 75, 75);
	tStyle.m_tColorBorder.m_tPressed	= RGB(25, 25, 25);

	tStyle.m_tColorFace.m_tHot			= RGB(0x80, 0x80, 0xFF);
	tStyle.m_tColorBorder.m_tHot		= RGB(0x40, 0x40, 0xFF);

	// Set Style again
	m_tButtonStyle.SetButtonStyle(&tStyle);

	// Create a push button.
	m_btNewGame.Create(_T(CLoc::GetString("NEWGAME")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos, nXPos + nButtonSizeX, nYPos + nButtonSizeY), this, NEWGAME);
	m_btMultiplayer.Create(_T(CLoc::GetString("MULTIPLAYER")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 1, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 1 + nButtonSizeY), this, MULTIPLAYER);
	m_btLoadGame.Create(_T(CLoc::GetString("LOADGAME")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 2, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 2 + nButtonSizeY), this, LOADGAME);
	m_btTutorial.Create(_T(CLoc::GetString("TUTORIAL")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 3, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 3 + nButtonSizeY), this, TUTORIAL);
	m_btOptions.Create(_T(CLoc::GetString("SETTINGS")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 4, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 4 + nButtonSizeY), this, OPTIONS);
	m_btExit.Create(_T(CLoc::GetString("LEAVE")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 5, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 5 + nButtonSizeY), this, EXITGAME);

	m_btMPServer.Create(_T(CLoc::GetString("CREATEGAME")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 1, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 1 + nButtonSizeY), this, MP_CREATE);
	m_btMPClient.Create(_T(CLoc::GetString("JOINGAME")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 2, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 2 + nButtonSizeY), this, MP_JOIN);

	// Buttonstyle zuweisen
	for (int i = NEWGAME; i <= TUTORIAL; i++)
	{
		CRoundButton2* pBtn = dynamic_cast<CRoundButton2*>(GetDlgItem(i));
		if (!pBtn)
			continue;

		SetButtonStyle(pBtn);
	}

	// Für Tooltips registrieren
	CString sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("NEWGAMETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(NEWGAME), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("MULTIPLAYERTT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(MULTIPLAYER), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("LOADGAMETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(LOADGAME), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("SETTINGSTT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(OPTIONS), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("LEAVETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(EXITGAME), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("TUTORIALTT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(TUTORIAL), sTooltip);

	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("CREATEGAMETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(MP_CREATE), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("JOINGAMETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(MP_JOIN), sTooltip);

	this->SetTimer(1,1000,NULL);
}
예제 #30
0
void CColorButton::PreSubclassWindow() 
{
	CButton::PreSubclassWindow();
	SetButtonStyle( BS_PUSHBUTTON | BS_OWNERDRAW );
}