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


C++ BSize::SetHeight方法代码示例

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


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

示例1: CreateMenu

/*!	\brief		This function creates and updates the BPopUpMenu.
 *		\details		The created menu is updated every time the TimeRepresentation
 *						changes.
 */
void CalendarControl::CreateMenu( void ) {

	// The whole menu will be created in fixed font.
	BFont fixedFont(be_fixed_font);
	BFont plainFont(be_plain_font);
	BRect rectangle;
	BPoint	topLeftCorner( 0, 0 );
	BSize	rectSize;
	BString sb;
	
	// Which month shall we represent?
	map<int, BString> dayNames = fCalModule->GetDayNamesForLocalYearMonth(
			this->fRepresentedTime.tm_year,
			this->fRepresentedTime.tm_mon);
	map<int, DoubleNames> monthNames = fCalModule->GetMonthNamesForLocalYear(
			this->fRepresentedTime.tm_year);			
	
	int daysInMonth = dayNames.size();
	int daysInWeek = ( int )fCalModule->GetDaysInWeek();
	
	// We need to determine the bounding rectangle for the menu.
	// For this, we need to obtain the maximum bounding rectangle for a string.
	font_height fontHeightStruct;
	fixedFont.GetHeight( &fontHeightStruct );
	float fixedFontHeightString = fontHeightStruct.ascent + 
											fontHeightStruct.descent +
											fontHeightStruct.leading + SPACING;
	plainFont.GetHeight( &fontHeightStruct );
	float plainFontHeightString = fontHeightStruct.ascent + 
											fontHeightStruct.descent +
											fontHeightStruct.leading + SPACING;
	// Now fixedFontHeightString is surely big enough to enclose every string in 
	// height. How many lines will we need? One for name of month and year,
	// one for weekday names, and several more for the dates themselves. At the
	// bottom, there is an additional line for "Return to today" option.
	
	
	// tempDay is a running date in current month. Each day item will be initialized
	// from the tempDay.
	TimeRepresentation tempDay( this->fRepresentedTime );
	tempDay.tm_mday = 1;
	
	int firstDayOfMonthWD = fCalModule->GetWeekDayForLocalDateAsInt( tempDay );
	int firstDayOfWeek = ( int )fFirstDayOfEveryWeek;
	
	int firstDayOfMonthInFirstWeek =
		(firstDayOfMonthWD + daysInWeek - firstDayOfWeek) % daysInWeek;
	
	// This is the menu we're adding items to.
	if ( fDateSelector ) {
		BMenuItem* item = NULL;
		while ( fDateSelector->ItemAt( 0 ) ) {
			item = fDateSelector->RemoveItem( ( int32 )0 );
			delete item;
		}
	} else {
		fDateSelector = new BMenu("⇩", B_ITEMS_IN_MATRIX );
	}
	// Sanity check
	if ( !fDateSelector )
	{
		// Panic!
		fLastError = B_NO_MEMORY;
		return;
	}
	
	fDateSelector->SetViewColor( ui_color( B_MENU_BACKGROUND_COLOR ) );
	fDateSelector->SetFont( &fixedFont );
	
	topLeftCorner.x = SPACING + 5;
	topLeftCorner.y = SPACING;	
	
	// Build the list of months.
	BPopUpMenu* listOfMonths = CreateMonthsMenu(monthNames);
	
	//-----------------------------------------------------
	// FIRST ROW.
	//-----------------------------------------------------
	
	/*----------------------------------------------------------------------------
	 *			Adding months menu with option to scroll forward and backward
	 *----------------------------------------------------------------------------*/
	
	// Add the item to scroll list of months back
	BMessage* messageOfItem = new BMessage( kMonthDecreased );
	DayItem* itemToAdd = new DayItem("‹", messageOfItem);
	if ( !itemToAdd ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	itemToAdd->SetServiceItem( true );
	itemToAdd->SetFrontColor( fColorForServiceItems );
	itemToAdd->SetBackColor( ui_color( B_MENU_BACKGROUND_COLOR ) );
	itemToAdd->SetEnabled( true );
	rectSize.SetHeight( fixedFontHeightString );
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:haiku-pim-svn,代码行数:101,代码来源:CalendarControl.cpp


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