Ejemplo n.º 1
0
void VividTree::OnPaint()
{
	CPaintDC dc(this);	// Device context for painting
	CDC dc_ff;			// Memory base device context for flicker free painting
	CBitmap bm_ff;		// The bitmap we paint into
	CBitmap *bm_old;
	CFont *font, *old_font;
	CFont fontDC;
	int old_mode;

	GetClientRect(&m_rect);
	SCROLLINFO scroll_info;
	// Determine window portal to draw into taking into account
	// scrolling position
	if ( GetScrollInfo( SB_HORZ, &scroll_info, SIF_POS | SIF_RANGE ) )
	{
		m_h_offset = -scroll_info.nPos;
		m_h_size = max( scroll_info.nMax+1, m_rect.Width());
	}
	else
	{
		m_h_offset = m_rect.left;
		m_h_size = m_rect.Width();
	}
	if ( GetScrollInfo( SB_VERT, &scroll_info, SIF_POS | SIF_RANGE ) )
	{
		if ( scroll_info.nMin == 0 && scroll_info.nMax == 100) 
			scroll_info.nMax = 0;
		m_v_offset = -scroll_info.nPos * GetItemHeight();
		m_v_size = max( (scroll_info.nMax+2)*((int)GetItemHeight()+1), m_rect.Height() );
	}
	else
	{
		m_v_offset = m_rect.top;
		m_v_size = m_rect.Height();
	}

	// Create an offscreen dc to paint with (prevents flicker issues)
	dc_ff.CreateCompatibleDC( &dc );
    bm_ff.CreateCompatibleBitmap( &dc, m_rect.Width(), m_rect.Height() );
    // Select the bitmap into the off-screen DC.
    bm_old = (CBitmap *)dc_ff.SelectObject( &bm_ff );
	// Default font in the DC is not the font used by 
	// the tree control, so grab it and select it in.
	font = GetFont();
	old_font = dc_ff.SelectObject( font );
	// We're going to draw text transparently
	old_mode = dc_ff.SetBkMode( TRANSPARENT );

	DrawBackGround( &dc_ff );
	DrawItems( &dc_ff );
	DrawItemLines(&dc_ff);

    // Now Blt the changes to the real device context - this prevents flicker.
    dc.BitBlt( m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), &dc_ff, 0, 0, SRCCOPY);

	dc_ff.SelectObject( old_font );
	dc_ff.SetBkMode( old_mode );
    dc_ff.SelectObject( bm_old );
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------
//! CBN_DROPDOWN message handler called when the CComboBox control
//! is expanded into a dropdown list. Used to restrict the width of
//! the dropdown list to the max width.
//------------------------------------------------------------------------
void CGridEditorComboBox::OnDropDown()
{
	int itemHeight = GetItemHeight(-1);
	int nNumEntries = GetCount();

	// Resize combobox according to actual element count
	int visibleItemCount = 	m_MaxHeightItems < nNumEntries ? m_MaxHeightItems : nNumEntries; // min(m_MaxHeightItems, nNumEntries);
	CRect rectExpanded;
	GetClientRect(rectExpanded);
	rectExpanded.bottom += visibleItemCount * GetItemHeight(0);
	rectExpanded.bottom += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges
	SetWindowPos(NULL,		// not relative to any other windows
				0, 0,		// TopLeft corner doesn't change
				rectExpanded.Width(), rectExpanded.Height(),   // existing width, new height
				SWP_NOMOVE | SWP_NOZORDER	// don't move box or change z-ordering.
				);

	// Resize combo-box width to fit contents
	int nMaxItemWidth = 0;
	CString str;

	// Find max-width of the elements
	CDC*	pDC = GetDC();
	CFont*	pFont = GetFont();
	CFont*	pOldFont = pDC->SelectObject(pFont);

	for (int i = 0; i < nNumEntries; i++)
	{
		GetLBText(i, str);
		int nLength = pDC->GetTextExtent(str).cx;
		nMaxItemWidth = nMaxItemWidth > nLength ? nMaxItemWidth : nLength;	// max(nMaxItemWidth, nLength);
		if (nMaxItemWidth > m_MaxWidthPixels)
		{
			nMaxItemWidth = m_MaxWidthPixels;
			break;
		}
	}

	// Check if there are so many elements that we need space for a vertical scrollbar
	CRect rect;
	GetDroppedControlRect(&rect);
	if (rect.Height() <= nNumEntries*GetItemHeight(0))
		nMaxItemWidth +=::GetSystemMetrics(SM_CXVSCROLL);

	// Add margin space to the calculations
	nMaxItemWidth += pDC->GetTextExtent(_T("0")).cx;

	pDC->SelectObject(pOldFont);
	ReleaseDC(pDC);

	SetDroppedWidth(nMaxItemWidth);
	SetItemHeight(-1, itemHeight);
}
int COXMultiComboBox::GetTotalHeight()
// --- In  : 
// --- Out : 
// --- Returns : returns the sum of hieghts of all the items in the combobox
// --- Effect : 
{
	int nTotalHeight =0;
	int nCount = GetCount();
	if(!(GetStyle()&CBS_OWNERDRAWVARIABLE))
		nTotalHeight = nCount * GetItemHeight(0);
	else
		for(int nIndex=0; nIndex < nCount; nIndex++)
			nTotalHeight+=GetItemHeight(nIndex);
	return nTotalHeight;
}
Ejemplo n.º 4
0
void CUIListWnd::DrawActiveBackFrame(const Frect& rect, CUIListItem * itm)
{
	Fvector2		_pos;
	_pos.set		(rect.left, rect.top+(itm->GetIndex()-m_iFirstShownIndex)*GetItemHeight());
	float _d		= GetItemHeight() - m_ActiveBackgroundFrame->GetHeight();
	if(_d>0)
		_pos.y		+= (float)iFloor(_d/2.0f);

	m_ActiveBackgroundFrame->SetWndPos		(_pos);
	float _w = GetWidth();
	if( m_ScrollBar->IsShown() )
		_w		-= m_ScrollBar->GetWidth();
	m_ActiveBackgroundFrame->SetWidth		(_w);
	m_ActiveBackgroundFrame->Draw			();
}
Ejemplo n.º 5
0
Point
AMUnitList::GetUnitLocation(size_t idx) const
{
	// XXX: Conversion to 'SPos' might be implementation-defined.
	return Point(0, -SPos(uTopOffset) + SPos(GetItemHeight()) * (SPos(idx)
		- SPos(vwList.GetHeadIndex())));
}
Ejemplo n.º 6
0
size_t
AMUnitList::GetLastLabelIndexClipped(SPos v_off, SDst height) const
{
	// XXX: Conversion to 'SPos' might be implementation-defined.
	return vwList.GetHeadIndex() + min(size_t((SPos(height + uTopOffset)
		- v_off - 1) / SPos(GetItemHeight()) + 1), vwList.GetValid(GetTotal()));
}
Ejemplo n.º 7
0
/// Get the overall rect of the given item
bool InstanceCtrl::GetItemRect( VisualCoord item, wxRect& rect, bool view_relative )
{
	if (item.groupIndex < GetCount())
	{
		int row, col;
		if (!GetRowCol(item, row, col))
			return false;
		GroupVisual & gv = m_groups[item.groupIndex];
		
		wxSize bsz = GetWindowBorderSize();
		int x = col * (m_itemWidth + m_spacing) + m_spacing + bsz.GetWidth() / 2;
		int y = gv.y_position + gv.row_ys[row] + m_spacing;
		
		if (view_relative)
		{
			int startX, startY;
			int xppu, yppu;
			GetScrollPixelsPerUnit(& xppu, & yppu);
			GetViewStart(& startX, & startY);
			x = x - startX * xppu;
			y = y - startY * yppu;
		}
		
		rect.x = x;
		rect.y = y;
		rect.width = m_itemWidth;
		rect.height = GetItemHeight(item);
		return true;
	}
	return false;
}
LRESULT FilteredListBox::OnDrawItem( PDRAWITEMSTRUCT pdis )
{
	if(pdis->itemID == -1)
		return 0;

	if(GetItemHeight(pdis->itemID) == 1)
		return TRUE;

	switch(pdis->itemAction)
	{
	case ODA_SELECT:
	case ODA_DRAWENTIRE:
		{
			DWORD ColorRef = GetDCBrushColor(pdis->hDC);
			FillRect(pdis->hDC,&pdis->rcItem,(HBRUSH)ColorRef);
			std::tstring text;
			text.resize(GetTextLen(pdis->itemID) + 1);
			GetText(&text,pdis->itemID);
			TextOut(pdis->hDC,pdis->rcItem.left,pdis->rcItem.top,text.c_str(),text.length());
			if(pdis->itemState & ODS_SELECTED)
			{
				RECT focusRect;
				focusRect.left = pdis->rcItem.left;
				focusRect.top = pdis->rcItem.top;
				focusRect.bottom = pdis->rcItem.bottom;
				focusRect.right = pdis->rcItem.right;
				DrawFocusRect(pdis->hDC,&focusRect);
				InvertRect(pdis->hDC,&focusRect);
			}
		}
	case ODA_FOCUS:
		break;
	}
	return TRUE;
}
Ejemplo n.º 9
0
void CPitchGraphEditor::HighlightItem(CPoint point)
{
	int MouseY = (point.y - m_GraphRect.top) - (m_GraphRect.Height() / 2);
	int ItemWidth = GetItemWidth();
	int ItemHeight = GetItemHeight();
	int ItemIndex = (point.x - GRAPH_LEFT) / ItemWidth;
	int ItemValue = -(MouseY * 255) / m_GraphRect.Height();
	int LastItem = m_iHighlightedItem;
	int LastValue = m_iHighlightedValue;

	if (ItemValue < -128)
		ItemValue = -128;
	if (ItemValue > 127)
		ItemValue = 127;

	m_iHighlightedItem = ItemIndex;
	m_iHighlightedValue = ItemValue;

	if (m_GraphRect.PtInRect(point) == 0 || ItemIndex < 0 || unsigned(ItemIndex) >= m_pSequence->GetItemCount()) {
		m_iHighlightedItem = -1;
		m_iHighlightedValue = 0;
	}
	
	if (m_iHighlightedItem != LastItem || m_iHighlightedValue != LastValue) {
		RedrawWindow(NULL);
	}
}
Ejemplo n.º 10
0
void CInPlaceList::FitDropDownToItems()
{
    if (NULL == m_ListBox.GetSafeHwnd())
        return;

    CRect rcEdit, rcDropDown, rcDropDownCli;
    GetWindowRect(rcEdit);
    m_ListBox.GetWindowRect(rcDropDown);
    m_ListBox.GetClientRect(rcDropDownCli);

    int nHeight = rcDropDown.Height() - rcDropDownCli.Height();
    const int nMaxHeight = ::GetSystemMetrics(SM_CYSCREEN) / 2;
    const int nCount = GetCount();
    for(int nIndex = 0; nIndex < nCount; ++nIndex)
    {
        nHeight += GetItemHeight(nIndex);
        if(nHeight > nMaxHeight)
            break;
    }

    CRect rcDropDownNew(rcDropDown.left,rcDropDown.top,rcDropDown.right,rcDropDown.top + nHeight);
    if(rcEdit.top > rcDropDown.top && rcEdit.top != rcDropDownNew.bottom)
        rcDropDownNew.top += (rcEdit.top - rcDropDownNew.bottom);

    m_ListBox.MoveWindow(rcDropDownNew);
}
Ejemplo n.º 11
0
int CDropListBox::GetBottomIndex()
{
	int nTop = GetTopIndex();
	CRect rc;
	GetClientRect( &rc );
	int nVisCount = rc.Height() / GetItemHeight(0);
	return nTop + nVisCount;
}
Ejemplo n.º 12
0
BOOL RingCheckList::Attach(HWND hWnd)
{
	//因为ListBox一旦创建其Style就不可改变,因此这里检测其Style
	//如果不是自绘则需要先Destroy然后再Create	
	DWORD style = GetWindowLong(hWnd,GWL_STYLE);
	style &= ~(LBS_SORT|LBS_MULTIPLESEL|LBS_MULTICOLUMN);
	DWORD st = LBS_HASSTRINGS|LBS_OWNERDRAWFIXED|LBS_NOTIFY;
	if((style & st) != st)
	{
		RECT rc;
		HWND hwnd;
		
		style |=	(st|WS_VSCROLL);
		
		DWORD exstyle = GetWindowLong(hWnd,GWL_EXSTYLE);
		
		GetWindowRect(hWnd,&rc);
		hwnd = ::GetParent(hWnd);
		
		ScreenToClient(hwnd,(LPPOINT)&rc);
		ScreenToClient(hwnd,(LPPOINT)&rc+1);
		
		m_ID = GetWindowLong(hWnd,GWL_ID);
		
		DestroyWindow(hWnd);
		
		if(RingControls::Create(style,exstyle,"",m_ID,
			rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top))
		{
			RingControls::SetOwnerDraw(FALSE,(UINT)0xFFFFFFFF);
			if(m_hbmp == NULL)
				CreateCheckBmp(NULL,GetItemHeight());
			return TRUE;
		}
	}
	else
		if(RingBaseWnd::Attach(hWnd))
		{
			RingControls::SetOwnerDraw(FALSE,(UINT)0xFFFFFFFF);
			if(m_hbmp == NULL)
				CreateCheckBmp(NULL,GetItemHeight());
			return TRUE;
		}
		
	return FALSE;
}
Ejemplo n.º 13
0
Size FileList::GetStdSize(const Value& q) const
{
	const File& m = ValueTo<File>(q);
	FontInfo fi = m.font.Info();
	int cx = GetTextSize(fi, WString(m.name)) + 2 + iconwidth + 2 + 3;
	if(!IsNull(m.desc))
		cx += GetTextSize(m.descfont.Info(), WString(m.desc)) + fi.GetHeight();
	return Size(cx, GetItemHeight());
}
Ejemplo n.º 14
0
ZStageInfoBox::ZStageInfoBox(const char* szName, MWidget* pParent, MListener* pListener)
: MListBox(szName, pParent, pListener)
{
//	LOOK_IN_CONSTRUCTOR()

	SetItemHeight(GetItemHeight()*3);
	SetAlwaysVisibleScrollbar(true);

	m_pLook=NULL;
}
Ejemplo n.º 15
0
void CProgressListBox::RecalcHeight()
{
	// new height
	int iCtlHeight=m_vItems.size()*GetItemHeight(0);

	// change control size
	CRect rcCtl;
	GetClientRect(&rcCtl);
	this->SetWindowPos(NULL, 0, 0, rcCtl.Width(), iCtlHeight, SWP_NOZORDER | SWP_NOMOVE);
}
Ejemplo n.º 16
0
void CPngListBox::DrawClient(CDC* pDC)
{
	CRect rcClient;
	GetClientRect(rcClient);

	MemPaintParentPng(this, *pDC, rcClient, m_pImgParentBk, m_bFillOrTitleParentPng);

	if(IsWindowEnabled())
	{
		::SetTextColor(pDC->GetSafeHdc(), m_textColor);
		MemPaintPng(*pDC, rcClient, m_pImgBk);
	}
	else
	{
		::SetTextColor(pDC->GetSafeHdc(), RGB(128, 128, 128));
		MemPaintPng(*pDC, rcClient, m_pImgDisable);
	}

	CRect	rcItem;
	CString	szItemString;
	BOOL	bOutSide = FALSE;
	int		itemCount = GetCount();

	CPoint	ptCursor;
	GetCursorPos(&ptCursor);
	ScreenToClient(&ptCursor);

	for (int pos = rcClient.top; pos < rcClient.bottom;)
	{
		UINT index = ItemFromPoint(CPoint(rcClient.left, pos), bOutSide);

		if(bOutSide)
			break;

		GetText(index, szItemString);
		GetItemRect(index, &rcItem);

		//左右边框除外
		CRect desRc = rcItem;

		if (GetSel(index) || rcItem.PtInRect(ptCursor))
		{	//上下边框除外
			MemPaintPng(*pDC, desRc, m_pImgListSel);
		}
		else
		{
			//MemPaintPng(memDC, desRc, m_pImgListCenter);
		}

		desRc.left += m_nTextOffsetX;
		MemDrawText(*pDC, desRc, szItemString, m_textAlignMode);

		pos += GetItemHeight(index);
	}
}
Ejemplo n.º 17
0
int CDropListBox::GetBottomIndex()
{
	int nTop = GetTopIndex();
	if(nTop == LB_ERR)
	{
		return LB_ERR;
	}
	CRect rc;
	GetClientRect( &rc );

	int nBottomIndex = LB_ERR;
	//variable height
	if((GetStyle() & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)
	{
		int i, nHeight, nCount = GetCount(), nTotalHeight = 0;
		for(i = nTop; i < nCount; i++)
		{
			if((nHeight = GetItemHeight(i)) == LB_ERR)
			{
				ASSERT(FALSE);
				break;
			}
			nTotalHeight += nHeight;
			if(nTotalHeight > rc.Height())
			{
				break;
			}
		}
		nBottomIndex = i;
	}
	else
	{
		int nVisCount = rc.Height() / GetItemHeight(0);
		nBottomIndex = nTop + nVisCount;
		if(nBottomIndex > GetCount())
		{
			nBottomIndex = GetCount();
		}
	}
	//AfxTrace(_T("GetBottomIndex=%d\n"), nBottomIndex);
	return nBottomIndex;
}
Ejemplo n.º 18
0
void ZStageInfoBox::OnDraw(MDrawContext* pDC)
{
	if(m_pLook)
	{
		MRECT r = GetInitialClientRect();

		int nShowCount=0;
		for(int i=GetStartItem(); i<GetCount(); i++){

			nShowCount++;

			if(nShowCount>=GetShowItemCount()) break;

			MRECT itemrect=MRECT(r.x,r.y+GetItemHeight()*(nShowCount-1),r.w,GetItemHeight());
			DrawBitmapFrame9(pDC, itemrect, m_pLook->m_pFrameBitmaps);
		}
	}
	
	MListBox::OnDraw(pDC);
}
Ejemplo n.º 19
0
float ComboBox::CalculateDropDownListHeight(std::size_t visible_item_count) {

    float height = 0;

    auto item_source = drop_down_list_box_->GetItemSource();

    if (item_source->HasVariableItemHeight()) {
        for (std::size_t index = 0; index < visible_item_count; ++index) {
            height += item_source->GetItemHeight(index);
        }
    }
    else {
        height = item_source->GetItemHeight(0) * visible_item_count;
    }

    if (height == 0) {
        height = GetContentSize().height;
    }

    return height;
}
Ejemplo n.º 20
0
BOOL RingCheckList::Create(DWORD dwStyle,DWORD dwExStyle,LPCTSTR szInitText,UINT uId,int x,int y,int width,int height)
{
	dwStyle |= (LBS_HASSTRINGS|LBS_OWNERDRAWFIXED|LBS_NOTIFY|WS_VSCROLL);
	
	if(RingControls::Create(dwStyle,dwExStyle,szInitText,uId,x,y,width,height))
	{
		RingControls::SetOwnerDraw(FALSE,(UINT)0xFFFFFFFF);
		if(m_hbmp == NULL)
			CreateCheckBmp(NULL,GetItemHeight());
		return TRUE;
	}
	return FALSE;
}
Ejemplo n.º 21
0
void
AMUnitList::AdjustViewForContent(SDst h)
{
	if(vwList.AdjustForContent(GetTotal()) && vwList.IsSelected())
	{
		AdjustOffsetForHeight(h,
			vwList.GetSelectedIndex() == vwList.GetHeadIndex());
		return;
	}
	if(GetFullViewHeight() < GetViewPosition() + h)
		uTopOffset = 0;
	AdjustViewLengthForHeight(GetItemHeight(), h);
}
Ejemplo n.º 22
0
int CDropListBox::GetTotalItemHeight(int nStartIndex, int nCount)
{
	ASSERT(nStartIndex >= 0);
	if(nCount < 0)
	{
		nCount = GetCount();
	}
	if(nCount - nStartIndex > GetCount())
	{
		nCount = GetCount() - nStartIndex;
	}

	int nHeight, nTotal = 0;
	//variable height
	if((GetStyle() & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)
	{
		for(int i = nStartIndex; nCount > 0; i++, nCount--)
		{
			if((nHeight = GetItemHeight(i)) == LB_ERR)
			{
				return LB_ERR;
			}
			nTotal += nHeight;
		}
		return nTotal;
	}
	//non-variable style
	else
	{
		if((nHeight = GetItemHeight(0)) == LB_ERR)
		{
			return LB_ERR;
		}
		return nHeight * nCount;
	}
}
Ejemplo n.º 23
0
void CCtrlEnumCombo::OnDropdown() 
{
  INDEX ctItems = GetCount();
  if( ctItems == CB_ERR) return;
  
  CRect rectCombo;
  GetWindowRect( &rectCombo);
  
  PIX pixScreenHeight = ::GetSystemMetrics(SM_CYSCREEN);
  PIX pixMaxHeight = pixScreenHeight - rectCombo.top;

  m_pDialog->ScreenToClient( &rectCombo);
  PIX pixNewHeight = GetItemHeight(0)*(ctItems+2);
  rectCombo.bottom = rectCombo.top + ClampUp( pixNewHeight, pixMaxHeight);
  MoveWindow( rectCombo);
}
Ejemplo n.º 24
0
BOOL CIDCombo::OnDropdown()                                         // REQ #075
{
 int n = GetCount();
 n = max(n, 2);

 int ht = GetItemHeight(0);
 CRect r;
 GetWindowRect(&r);

 CSize sz;
 sz.cx = r.Width();
 sz.cy = ht * (n + 2);

 SetWindowPos(NULL, 0, 0, sz.cx, sz.cy, SWP_NOMOVE | SWP_NOZORDER);
 return FALSE; // allow parent to handle it now                     // REQ #075
}
Ejemplo n.º 25
0
void CNoiseEditor::ModifyItem(CPoint point, bool Redraw)
{
	int ItemValue;
	int ItemWidth = GetItemWidth();
	int ItemHeight = GetItemHeight();

	int ItemIndex = (point.x - GRAPH_LEFT) / ItemWidth;

	int Offset = 36 * ItemHeight - 1;

	if (point.y >= Offset) {

		if (m_iLastIndex == ItemIndex)
			return;

		m_iLastIndex = ItemIndex;

		if (point.y >= Offset && point.y < Offset + 10) {
			// Square
			ItemValue = m_pSequence->GetItem(ItemIndex) ^ S5B_MODE_SQUARE;
		}
		else if (point.y >= Offset + 11 && point.y < Offset + 21) {
			// Noise
			ItemValue = m_pSequence->GetItem(ItemIndex) ^ S5B_MODE_NOISE;
		}
		else
			return;
	}
	else {

		ItemValue = m_iItems - (((point.y - m_GraphRect.top) + (ItemHeight / 2)) / ItemHeight);

		if (ItemValue < 0)
			ItemValue = 0;
		if (ItemValue > m_iItems)
			ItemValue = m_iItems;

		ItemValue |= m_pSequence->GetItem(ItemIndex) & 0xC0;
	}

	if (ItemIndex < 0 || ItemIndex >= (int)m_pSequence->GetItemCount())
		return;

	m_pSequence->SetItem(ItemIndex, ItemValue);

	CGraphEditor::ModifyItem(point, Redraw);
}
Ejemplo n.º 26
0
// this is a verbatim copy of CCheckListBox::DrawItem purely
// to handle the fact that the text is rendered flush with the
// left edge of the background and focus rect.
// the only thing we change is to add 2 pixels to the origin
// of the text
void CCheckListBoxEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	// You must override DrawItem and MeasureItem for LBS_OWNERDRAWVARIABLE
	ASSERT((GetStyle() & (LBS_OWNERDRAWFIXED | LBS_HASSTRINGS)) ==
		(LBS_OWNERDRAWFIXED | LBS_HASSTRINGS));

	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

	if (((LONG)(lpDrawItemStruct->itemID) >= 0) &&
		(lpDrawItemStruct->itemAction & (ODA_DRAWENTIRE | ODA_SELECT)))
	{
		int cyItem = GetItemHeight(lpDrawItemStruct->itemID);
		BOOL fDisabled = !IsWindowEnabled() || !IsEnabled(lpDrawItemStruct->itemID);

		COLORREF newTextColor = fDisabled ?
			RGB(0x80, 0x80, 0x80) : GetSysColor(COLOR_WINDOWTEXT);  // light gray
		COLORREF oldTextColor = pDC->SetTextColor(newTextColor);

		COLORREF newBkColor = GetSysColor(COLOR_WINDOW);
		COLORREF oldBkColor = pDC->SetBkColor(newBkColor);

		if (newTextColor == newBkColor)
			newTextColor = RGB(0xC0, 0xC0, 0xC0);   // dark gray

		if (!fDisabled && ((lpDrawItemStruct->itemState & ODS_SELECTED) != 0))
		{
			pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
			pDC->SetBkColor(GetSysColor(COLOR_HIGHLIGHT));
		}

		if (m_cyText == 0)
			VERIFY(cyItem >= CalcMinimumItemHeight());

		CString strText;
		GetText(lpDrawItemStruct->itemID, strText);

		pDC->ExtTextOut(lpDrawItemStruct->rcItem.left + 2,
			lpDrawItemStruct->rcItem.top + max(0, (cyItem - m_cyText) / 2),
			ETO_OPAQUE, &(lpDrawItemStruct->rcItem), strText, strText.GetLength(), NULL);

		pDC->SetTextColor(oldTextColor);
		pDC->SetBkColor(oldBkColor);
	}

	if ((lpDrawItemStruct->itemAction & ODA_FOCUS) != 0)
		pDC->DrawFocusRect(&(lpDrawItemStruct->rcItem));
}
Ejemplo n.º 27
0
void CLegend::OnDropdown() 
{
 int n = GetCount();
 n = max(n, 2);
 
 int h = GetItemHeight(0);  // get default item height
 CRect r;
 GetWindowRect(&r);

 CSize sz;
 sz.cx = r.right - r.left;
 sz.cy = h * (n + 2);

 SetWindowPos(NULL, 0, 0, sz.cx, sz.cy, SWP_NOMOVE | SWP_NOZORDER);
        
        
}
Ejemplo n.º 28
0
void CDropListBox::OnMouseMove(UINT nFlags, CPoint point) 
{
	//
	// Is mouse within listbox
	CRect rcClient;
	GetClientRect( rcClient );
	if( !rcClient.PtInRect( point ) )
	{
		ReleaseCapture();
		GetParent()->SendMessage( WM_VRC_SETCAPTURE );
	}

	//
	// Set selection item under mouse
	int nPos = point.y / GetItemHeight(0) + GetTopIndex();
	PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(nPos);
	if( (DWORD)pItem != -1 )
	{
		if( GetCurSel() != nPos && !pItem->bDisabled )
		{
			SetCurSel( nPos );
		}
	}

	//
	// Check if we have autoscrolled
	if( m_nLastTopIdx != GetTopIndex() )
	{
		int nDiff = m_nLastTopIdx - GetTopIndex();
		m_nLastTopIdx = GetTopIndex();

		SCROLLINFO info;
		info.cbSize = sizeof(SCROLLINFO);
		if( m_pScroll->GetScrollInfo( &info, SIF_ALL|SIF_DISABLENOSCROLL ) )
		{
			info.nPos = m_nLastTopIdx;
			m_pScroll->SetScrollInfo( &info );
		}
	}


//	OutputDebugString( "DropListBox MouseMove\n" );

	CListBox::OnMouseMove(nFlags, point);

}
void CTriangularisationCombo::OnDropdown() 
{
  INDEX ctItems = GetCount();
  if( ctItems == CB_ERR) return;
  
  CRect rectCombo;
  GetWindowRect( &rectCombo);
  
  PIX pixScreenHeight = ::GetSystemMetrics(SM_CYSCREEN);
  PIX pixMaxHeight = pixScreenHeight - rectCombo.top;

  CWnd *pwndParent = GetParent();
  if( pwndParent == NULL) return;
  pwndParent->ScreenToClient( &rectCombo);
  PIX pixNewHeight = GetItemHeight(0)*(ctItems+2);
  rectCombo.bottom = rectCombo.top + ClampUp( pixNewHeight, pixMaxHeight);
  MoveWindow( rectCombo);
}
Ejemplo n.º 30
0
// +++hd:  set size of dropdown list 
void CHistoryCombo::OnDropdown() 
{
	CRect rect;
	GetWindowRect(&rect);

	int nHeight = rect.Height() + 2 * ::GetSystemMetrics(SM_CXBORDER);

	int nItemHeight = GetItemHeight(0);

	// m_nDropSize = No. of items in dropdown list
	nHeight += m_nDropSize * nItemHeight;

	SetWindowPos(NULL,
				 0,
				 0,
				 rect.Width(),
				 nHeight,
				 SWP_NOMOVE | SWP_NOZORDER);
}