Exemplo n.º 1
0
void CIETabBar::AdjustTabWidth(void)
{
	CRect winrect;
	this->GetWindowRect(&winrect);
	int itemcount=this->GetItemCount();
	if (itemcount > 0)
	{
		UINT width=((float)(winrect.Width()-tabrightOffset))/((float)itemcount);

		if(width>=maxWidht)
		{
			width=maxWidht;
		}
		else if(width > minWidht)
		{
			width=(winrect.Width()-tabrightOffset)/itemcount;
		}else
		{
			width=minWidht;
		}

		SetItemSize(CSize(width,winrect.Height()));

	}
}
Exemplo n.º 2
0
DwellingsBar::DwellingsBar(Castle & cstl, const Size & sz, const RGBA & fill) : castle(cstl)
{
    for(u32 dw = DWELLING_MONSTER1; dw <= DWELLING_MONSTER6; dw <<= 1)
        content.push_back(DwellingItem(castle, dw));

    SetContent(content);
    backsf.Set(sz.w, sz.h, false);
    backsf.DrawBorder(RGBA(0xd0, 0xc0, 0x48));
    SetItemSize(sz.w, sz.h);
}
Exemplo n.º 3
0
	void CTileLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcscmp(pstrName, _T("itemsize")) == 0 ) {
			SIZE szItem = { 0 };
			LPTSTR pstr = NULL;
			szItem.cx = _tcstol(pstrValue, &pstr, 10);  ASSERT(pstr);    
			szItem.cy = _tcstol(pstr + 1, &pstr, 10);   ASSERT(pstr);     
			SetItemSize(szItem);
		}
		else if( _tcscmp(pstrName, _T("columns")) == 0 ) SetColumns(_ttoi(pstrValue));
		else CContainerUI::SetAttribute(pstrName, pstrValue);
	}
	void TextList::DataRefresh()
	{
		if ( !valid )
		{
			valid = true;
			GC gc( this );
			gc.Set( GetFont() );
			int X = 0;

			int cnt = list.count();

			for ( int i = 0; i < cnt; i++ )
			{
				if ( list[i].pixelWidth < 0 )
				{
					list[i].pixelWidth = gc.GetTextExtents( list[i].str.data() ).x;
				}

				if ( list[i].pixelWidth > X )
				{
					X = list[i].pixelWidth;
				}
			}

			if ( GetCount() != list.count() )
			{
				SetCount( list.count() );
			}

			if ( X != this->GetItemWidth() )
			{
				SetItemSize( GetItemHeight(), X );
			}

			CalcScroll();
			Invalidate();
		}
	}
Exemplo n.º 5
0
void CClosableTabCtrl::OnPaint(){
	//CTabCtrl::OnPaint();
	ModifyStyle(0, WS_CLIPCHILDREN);
	if( !m_pSpinCtrl )
    {
      CWnd * pWnd = FindWindowEx( GetSafeHwnd(), 0, _T("msctls_updown32"), 0 );
      if( pWnd )
      {
        m_pSpinCtrl = new CSpinButtonCtrl;
        m_pSpinCtrl->Attach(pWnd->GetSafeHwnd());
      }
    }

	BOOL aero=false;
	HMODULE hm=LoadLibrary(L"dwmapi.dll");
	if(hm){
		DWMISCOMPOSITIONENABLED* ic=(DWMISCOMPOSITIONENABLED*)GetProcAddress(hm, "DwmIsCompositionEnabled");
		(ic)(&aero);
		FreeLibrary(hm);
	}

	RECT wrect;
	GetWindowRect(&wrect);
	int w=wrect.right-wrect.left;
	int h=TAB_HEIGHT+TAB_TOP_MARGIN;
	CPaintDC _dc(this);
	if(!_dc.m_hDC)return;
	CDC dc;
	dc.CreateCompatibleDC(&_dc);
	if(!dc.m_hDC){
		ReleaseDC(&_dc);
		return;
	}
	CBitmap bmp;
	bmp.CreateCompatibleBitmap(&_dc, w, h);
	if(!bmp.m_hObject){
		ReleaseDC(&_dc);
		ReleaseDC(&dc);
		return;
	}
	CBitmap* obmp=dc.SelectObject(&bmp);

	
	CFont fnt;
	fnt.CreateFontW(-11, 0, 0, 0, 0, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, L"Tahoma"); 
	CFont* ofnt=dc.SelectObject(&fnt);
	
	

	dc.SetBkMode(TRANSPARENT);

	//skin.tabbarBG.bmp.DrawStretched(&dc, 0, 0, w, 20, 0, 0, 0, 0);
	if(!aero){
		COLORREF bgcol=IsTopParentActive()?GetSysColor(COLOR_ACTIVECAPTION):GetSysColor(COLOR_INACTIVECAPTION);
		dc.FillSolidRect(0, 0, w, h, bgcol);
	}

	int offset=5;

	if(m_pSpinCtrl){
		int p=LOWORD(m_pSpinCtrl->GetPos());
		for(int i=0;i<p;i++){
			offset-=itemWidths[i];
		}
	}

	itemWidths.clear();
	int totalWidth=5;

	for(int i=0;i<GetItemCount();i++){
		TC_ITEM item;
		memset(&item, 0, sizeof(TC_ITEM));
		item.mask=TCIF_TEXT|TCIF_IMAGE|TCIF_PARAM;
		item.pszText=new wchar_t[512];
		item.cchTextMax=512;
		GetItem(i, &item);
		int tw=dc.GetTextExtent(item.pszText, wcslen(item.pszText)).cx+40;
		RECT rect;
		rect.top=TAB_TOP_MARGIN;
		rect.bottom=h;
		rect.left=offset;
		rect.right=offset+tw;
		CTalkTab* tab=(CTalkTab*)item.lParam;

		totalWidth+=tw;

		if(i==this->GetCurSel()){
			skin.tabActive.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			dc.SetTextColor(skin.tabActiveTextColor);
		}else if(over_idx==i){
			skin.tabOver.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			//dc.SetTextColor(skin.tabOverTextColor);
			dc.SetTextColor(IsTopParentActive()?GetSysColor(COLOR_CAPTIONTEXT):GetSysColor(COLOR_INACTIVECAPTIONTEXT));
		}else{
			skin.tabInactive.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			//dc.SetTextColor(skin.tabIncativeTextColor);
			dc.SetTextColor(IsTopParentActive()?GetSysColor(COLOR_CAPTIONTEXT):GetSysColor(COLOR_INACTIVECAPTIONTEXT));
		}

		HICON hIcon=skin.iconUnknown;

		bool newmsg=false;
		if(tab){
			newmsg=tab->hasNewMsg;
			if(newmsg){
				hIcon=skin.iconNewMsg;
			}
		}

		if(item.iImage>0 && !newmsg){
			bool inList=false;
			for(int j=0;j<con.clDlg->friendList.items.size();j++){
				if(con.clDlg->friendList.items[j].uid==item.iImage){
					inList=true;
					break;
				}
			}
			if(inList){
				if(con.clDlg->friendList.items[con.clDlg->friendList.GetItemByUID(item.iImage)].online){
					hIcon=skin.iconOnline;
				}else{
					hIcon=skin.iconOffline;
				}
			}
		}

		if(tab){
			if(tab->tabProxy)tab->tabProxy->SetIcon(hIcon, false);
		}

		DrawIconEx(dc.GetSafeHdc(), offset+2, TAB_HEIGHT/2+TAB_TOP_MARGIN-8, hIcon, 16, 16, 0, NULL, DI_NORMAL);

		if(i==this->GetCurSel()){
			skin.tabCloseAct.DrawUnscaled(&dc, offset+tw-18, TAB_HEIGHT/2+TAB_TOP_MARGIN-8, 15, 15, 0, 0);
		}else{
			skin.tabCloseInact.DrawUnscaled(&dc, offset+tw-18, TAB_HEIGHT/2+TAB_TOP_MARGIN-8, 15, 15, 0, 0);
		}

		if(!aero){
		dc.DrawText(item.pszText, wcslen(item.pszText), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		}else{
			if(i==this->GetCurSel()){
				CUtils::DrawAeroText(rect, &dc, 0, DT_CENTER|DT_VCENTER|DT_SINGLELINE, &fnt, item.pszText);
			}else{
				CUtils::DrawAeroText(rect, &dc, 3, DT_CENTER|DT_VCENTER|DT_SINGLELINE, &fnt, item.pszText);
			}
		}

		delete item.pszText;
		offset+=tw+TAB_SPACING;
		itemWidths.push_back(tw);
	}

	_dc.BitBlt(0, 0, w, h, &dc, 0, 0, SRCCOPY);
	dc.SelectObject(obmp);
	dc.SelectObject(ofnt);
	ReleaseDC(&dc);
	ReleaseDC(&_dc);
	SetItemSize(CSize(totalWidth/GetItemCount(), 20));
}
Exemplo n.º 6
0
CBookClient::CBookClient(CPaintManagerUI& paint_manager)
: m_pm(paint_manager)
, m_bEdit(false)
{
	SetItemSize(CSize(130, 100));
}