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


C++ CSlider::GetHeight方法代码示例

本文整理汇总了C++中CSlider::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ CSlider::GetHeight方法的具体用法?C++ CSlider::GetHeight怎么用?C++ CSlider::GetHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSlider的用法示例。


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

示例1: Draw


//.........这里部分代码省略.........
			char* pList = new char [strlen ((char*)m_itemArray[nCurrentItem].pData) + 1];
			strcpy (pList, (char*)m_itemArray[nCurrentItem].pData);

			char* ptr = strtok (pList, "|");// put the delimeter in the string resources!!!!
			for (uint32 i = 0; i < m_itemArray[nCurrentItem].nData; i++)
			{
				ptr = strtok (NULL, "|");
				assert (ptr);
			}

			HSURFACE hSurface = CTextHelper::CreateSurfaceFromString (m_pClientDE, hFont, ptr, hForeText);
				
			delete [] pList;

			// get the source rect and clip it if necessary

			m_pClientDE->GetSurfaceDims (hSurface, &nWidth, &nHeight);
			rcSrc.right = nWidth;
			rcSrc.bottom = nHeight;

			if (m_itemArray[nCurrentItem].nSecondColumn + (int)nWidth > (Width() - (BORDERSIZE << 1) - m_nLeftMargin))
			{
				rcSrc.right -= (m_itemArray[nCurrentItem].nSecondColumn + (int)nWidth) - (Width() - (BORDERSIZE << 1) - m_nLeftMargin);
			}
			if (nCurrentY + (int)nHeight > Height() - BORDERSIZE)
			{
				rcSrc.bottom -= (nCurrentY + (int)nHeight) - (Height() - BORDERSIZE);
			}
			
			m_pClientDE->DrawSurfaceToSurface (hScreen, hSurface, &rcSrc, 
											   BORDERSIZE + m_nLeftMargin + m_nLeft + m_itemArray[nCurrentItem].nSecondColumn, 
											   nCurrentY + m_nTop);

			m_pClientDE->DeleteSurface (hSurface);
		}

		// if this item is a KeyConfig control, draw the associated key...

		if (m_itemArray[nCurrentItem].nType == KeyConfig && m_itemArray[nCurrentItem].pData)
		{
			HSURFACE hSurface = LTNULL;
			if (nCurrentItem == m_nSelection && m_bConfiguring)
			{
				hSurface = CTextHelper::CreateSurfaceFromString (m_pClientDE, hFont, "Press a key...", hForeText);
			}
			else
			{
				hSurface = CTextHelper::CreateSurfaceFromString (m_pClientDE, hFont, (char*)m_itemArray[nCurrentItem].pData, hForeText);
			}
				
			// get the source rect and clip it if necessary

			m_pClientDE->GetSurfaceDims (hSurface, &nWidth, &nHeight);
			rcSrc.right = nWidth;
			rcSrc.bottom = nHeight;

			if (m_itemArray[nCurrentItem].nSecondColumn + (int)nWidth > (Width() - (BORDERSIZE << 1) - m_nLeftMargin))
			{
				rcSrc.right -= (m_itemArray[nCurrentItem].nSecondColumn + (int)nWidth) - (Width() - (BORDERSIZE << 1) - m_nLeftMargin);
			}
			if (nCurrentY + (int)nHeight > Height() - BORDERSIZE)
			{
				rcSrc.bottom -= (nCurrentY + (int)nHeight) - (Height() - BORDERSIZE);
			}
			
			m_pClientDE->DrawSurfaceToSurface (hScreen, hSurface, &rcSrc, 
											   BORDERSIZE + m_nLeftMargin + m_nLeft + m_itemArray[nCurrentItem].nSecondColumn, 
											   nCurrentY + m_nTop);

			m_pClientDE->DeleteSurface (hSurface);
		}

		// if this item is a Slider, draw the slider...

		if (m_itemArray[nCurrentItem].nType == Slider && m_itemArray[nCurrentItem].pData)
		{
			CSlider* pSlider = (CSlider*) m_itemArray[nCurrentItem].pData;
			
			int nHeight = pSlider->GetHeight();
			int y = (m_itemArray[nCurrentItem].nHeight - nHeight) / 2;
			
			if (y + nCurrentY + nHeight <= Height() - BORDERSIZE)
			{
				pSlider->Draw (hScreen, BORDERSIZE + m_nLeftMargin + m_nLeft + m_itemArray[nCurrentItem].nSecondColumn, m_nTop + nCurrentY + y);
			}
		}

		// increment the current y value and go on to the next item...

		nCurrentY += m_itemArray[nCurrentItem].nHeight;

		if (nCurrentY < Height() - BORDERSIZE) m_nLastItem = nCurrentItem;

		nCurrentItem++;
	}

	// clean up

	m_pClientDE->DeleteFont (hFont);
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:101,代码来源:PopupMenu.cpp


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