示例#1
0
/* Replacement for FntLineHeight() that takes into account subscript and
   superscript text */
extern Int16 FontLineHeight( void )
{
    Int16 height;

    if ( currentStyle == SUPSTYLE ) {
        height = FntLineHeight() / 4 + GetPrevFontHeight();
    }
    else
        height = FntLineHeight();

    return height;
}
示例#2
0
文件: Window.c 项目: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    WinDrawTitleChars
//
// DESCRIPTION: This routine draw the specified characters inverted 
//					 (background color) in the draw window.
//
// PARAMETERS:  (const Char *) chars - Pointer to the characters to draw
//					 (Int16) len - Length in bytes of the characters to draw.
//					 (Coord) x - x coordinate of the location where the
//							characters is to be drawn.
//					 (Coord) y - y coordinate of the location where the
//							characters is to be drawn.
//
// RETURNED:    Returns nothing.
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	5/29/01	Initial Revision
//			Jerry 8/08/01	Modify call VDrawString to draw the invert color
////////////////////////////////////////////////////////////////////////
void WinDrawTitleChars (const Char *chars, Int16 len, Coord x, Coord y)
{
	RectangleType	srcRect;

	srcRect.topLeft.x = x;
	srcRect.topLeft.y = y;
	srcRect.extent.x = FntCharsWidth (chars, len)+4;
	srcRect.extent.y = VPDAToSysYRes(FntLineHeight());

	VDrawRect (&srcRect, PS_SOLID, 0, CL_FOREGROUND, COORD_PARTSTRETCH, DRAW_SET);
	VDrawString ((Coord)(x+1), (Coord)(y+FntLineHeight()/4), 
					chars, len, SINGLELINE, CL_BACKGROUND, COORD_STRETCH);
}
示例#3
0
文件: gadget.c 项目: timn/unimatrix
/*****************************************************************************
* Function: GadgetDrawWeekdays
*
* Description: Draws the weekdays, extra function since called in
*              GadgetDrawTimeline
*****************************************************************************/
void
GadgetDrawWeekdays(void)
{
  UInt8 i;
  MemHandle mh;
  Char *text;
  RGBColorType color, prevColor;
  DateTimeType now;
  Int16 dow;
  RectangleType bounds, rect;
  UInt16 gadgetIndex;

  // Get info about Gadget
  gadgetIndex = FrmGetObjectIndex(gForm, gGadgetID);
  FrmGetObjectBounds(gForm, gadgetIndex, &bounds);

  // Initialize time constants
  TimSecondsToDateTime(TimGetSeconds(), &now);
  dow = DayOfWeek(now.month, now.day, now.year);
  
  RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y,
                         130, FntLineHeight()+2);

  // Erase background
  WinEraseRectangle(&rect, 0);

  for (i=0; i < gGadgetDaysNum; ++i) {
    Int16 leftoff;
    mh = DmGetResource(strRsc, GADGET_STRINGS_WDAYSTART+i);
    text = MemHandleLock(mh);
    leftoff = (gGadgetDaysWidth+2 - FntLineWidth(text, MemPtrSize(text))) / 2;
    if (TNisColored() && (dow == i+1)) {
      color.r = 0xFF;  color.g = 0x00;  color.b = 0x00;
      TNSetTextColorRGB(&color, &prevColor);
    }
    WinDrawChars(text, StrLen(text), bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+i+leftoff+2, bounds.topLeft.y);
    if (dow == i+1) {
      if (TNisColored()) {
        TNSetTextColorRGB(&prevColor, NULL);
      } else {
        // Draw some kind of underline to determine current day
        Int16 lineWidth=FntLineWidth(text, StrLen(text));
        WinDrawLine(rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1, rect.topLeft.y+FntLineHeight(),
                    rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1+lineWidth, rect.topLeft.y+FntLineHeight());
      }
    }
    MemHandleUnlock(mh);
  }
}
示例#4
0
文件: gadget.c 项目: timn/unimatrix
/*****************************************************************************
* Function: GadgetDrawHint
*
* Description: Draw the hintbox with the hint
*****************************************************************************/
void
GadgetDrawHint(const char *toptext, const char *bottext, UInt16 note)
{
  RectangleType bounds;
  UInt16 gadgetIndex;
  RectangleType rect, textbox_top, textbox_bot;
  FontID oldFont;
  ControlType *ctl;
  Char noteSymb[2] = { GADGET_NOTESYMBOL, 0 };
  // Not needed any longer, the hint now has its own Gadget
  // UInt16 top = GADGET_TOP + (GADGET_STRINGS_NUM-1) * GADGET_STRINGS_OFFSET + 5;  // 6 - const = VALUE BELOW

  if (! gForm) return;

  gadgetIndex = FrmGetObjectIndex(gForm, gHintGadgetID);
  FrmGetObjectBounds(gForm, gadgetIndex, &bounds);

  WinEraseRectangle(&bounds, 0);

  RctSetRectangle(&rect,
                  bounds.topLeft.x+1,  // +1 for border
                  bounds.topLeft.y+1, // Put VALUE BELOW here.... +top+1 removed because of own Gadget
                  bounds.extent.x-3, bounds.extent.y - 3); // -4 for bottom border

  // Erase Gadget area
  WinSetForeColor(UIColorGetTableEntryIndex(UIObjectFrame));
  WinDrawRectangleFrame(popupFrame, &rect);

  RctSetRectangle(&textbox_top, rect.topLeft.x+2, rect.topLeft.y,
                                rect.extent.x-2,(Int16)((rect.extent.y-2)/2));
  RctSetRectangle(&textbox_bot, textbox_top.topLeft.x, textbox_top.topLeft.y+textbox_top.extent.y+1,
                                textbox_top.extent.x, textbox_top.extent.y);

  oldFont=FntSetFont(boldFont);
  TNDrawCharsToFitWidth(toptext, &textbox_top);
  FntSetFont(oldFont);
  TNDrawCharsToFitWidth(bottext, &textbox_bot);


  gHintNote = note;
  if (note) {
    // This time has a note
    oldFont = FntSetFont(symbolFont);
    RctSetRectangle(&rect, rect.topLeft.x+rect.extent.x-8,
                           rect.topLeft.y+rect.extent.y-12,
                           FntLineWidth(noteSymb, 1), FntLineHeight());
  
    TNDrawCharsToFitWidth(noteSymb, &rect);
    FntSetFont(oldFont);
  }

  ctl=GetObjectPtr(BUTTON_edit);
  CtlShowControl(ctl);
  ctl=GetObjectPtr(BUTTON_beam);
  CtlShowControl(ctl);
}
示例#5
0
文件: gadget.c 项目: timn/unimatrix
/*****************************************************************************
* Function: GadgetDrawTime
*
* Description: Show a time in the grid
*****************************************************************************/
void
GadgetDrawTime(TimeType begin, TimeType end, UInt8 day, RGBColorType *color, UInt16 courseID, UInt8 num_times, UInt8 pos)
{
  RectangleType rect;
  RGBColorType prevColor, inverted;

  // Sort out bogus requests, could be more intelligent, maybe later...
  if (day >= gGadgetDaysNum) return;

  // do nothing if Gadget has not yet been GadgetSet
  if (! gForm) return;
  if (! gGadgetID) return;

  GadgetTimeSetRect(&rect, begin, end, day, num_times, pos);


  TNSetForeColorRGB(color, &prevColor);
  WinDrawRectangle(&rect, 0);

  if ( (gPrefs.showTypes || gPrefs.showShortNames) && (rect.extent.y >= FntLineHeight())) {

    RGBColorType oldBack, oldText;

    // Get inverted color
    inverted.r = 255 - color->r;
    inverted.g = 255 - color->g;
    inverted.b = 255 - color->b;

    RctSetRectangle(&rect, rect.topLeft.x+2, rect.topLeft.y, rect.extent.x-4, rect.extent.y);

    TNSetTextColorRGB(&inverted, &oldText);
    TNSetBackColorRGB(color, &oldBack);

    if (gPrefs.showTypes) {
      MemHandle shortName=MemHandleNew(1);;
      CourseTypeGetShortByCourseID(&shortName, courseID);
      TNDrawCharsToFitWidth((Char *)MemHandleLock(shortName), &rect);
      MemHandleUnlock(shortName);
      MemHandleFree(shortName);
    } else if (gPrefs.showShortNames) {
      MemHandle courseName=MemHandleNew(1);
      CourseGetName(courseID, &courseName, false);

      TNDrawCharsToFitWidth((Char *)MemHandleLock(courseName), &rect);

      MemHandleUnlock(courseName);
      MemHandleFree(courseName);
    }

    TNSetBackColorRGB(&oldBack, NULL);
    TNSetTextColorRGB(&oldText, NULL);
  }

  TNSetForeColorRGB(&prevColor, NULL);
}
示例#6
0
文件: Window.c 项目: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    WinDrawInvertedChars
//
// DESCRIPTION: This routine draw the specified characters inverted 
//					 (background color) in the draw window.
//
// PARAMETERS:  (const Char *) chars - Pointer to the characters to draw
//					 (Int16) len - Length in bytes of the characters to draw.
//					 (Coord) x - x coordinate of the location where the
//							characters is to be drawn.
//					 (Coord) y - y coordinate of the location where the
//							characters is to be drawn.
//
// RETURNED:    Returns nothing.
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	5/29/01	Initial Revision
//			Jerry 8/08/01	Modify call VDrawString to draw the invert color
////////////////////////////////////////////////////////////////////////
void WinDrawInvertedChars (const Char *chars, Int16 len, Coord x, Coord y)
{
	RectangleType	srcRect;

	srcRect.topLeft.x = x;
	srcRect.topLeft.y = y;
	srcRect.extent.x = FntCharsWidth (chars, len)+4;
	srcRect.extent.y = FntLineHeight();

	VDrawRect (&srcRect, PS_SOLID, 0, CL_FOREGROUND, COORD_PARTSTRETCH, DRAW_SET);
	VDrawString ((Coord)(VPDAToSysXCoord(x)+2), (Coord)(VPDAToSysYCoord(y)+1), 
			chars, len, SINGLELINE, CL_BACKGROUND, COORD_NORMAL);
}
示例#7
0
/* Get the default style font height */
Int16 GetDefaultMainStyleHeight( void )
{
    FontID oldFont;
    Int16  height;
    UInt16 prevCoordSys;

    prevCoordSys = PalmSetCoordinateSystem( NATIVE );

    oldFont = FntGetFont();
    FntSetFont( StylesMain[ DEFAULTSTYLE ] );
    height = FntLineHeight() + Prefs()->lineSpacing;
    FntSetFont( oldFont );

    PalmSetCoordinateSystem( prevCoordSys );
    
    return height;
}
示例#8
0
bool PreferencesForm::handleOpen()
{
    bool result = MoriartyForm::handleOpen();
    
    ArsRectangle rect;
    modulesTable_.bounds(rect);
    modulesTable_.setColumnWidth(tableItemModuleName, rect.width()-16);
    modulesTable_.setColumnSpacing(tableItemModuleName, 2);
    modulesTable_.setColumnWidth(tableItemCheckbox, 12);
    modulesTable_.setColumnSpacing(tableItemCheckbox, 2);

    MoriartyModule* modules = application().modules();
    UInt16 rowsCount = modulesTable_.rowsCount();
    FontID oldFont = FntSetFont(stdFont);
    UInt16 lineHeight = FntLineHeight();
    FntSetFont(oldFont);
    assert(MORIARTY_MODULES_COUNT < rowsCount);    
    for (uint_t i = 0; i<MORIARTY_MODULES_COUNT; ++i)
    {
        MoriartyModule& module = modules[i];
        modulesTable_.setItemStyle(i, tableItemModuleName, customTableItem);
        char* text = const_cast<char*>(module.displayName);
        modulesTable_.setItemPtr(i, tableItemModuleName, text);
        modulesTable_.setItemStyle(i, tableItemCheckbox, checkboxTableItem);
        modulesTable_.setItemInt(i, tableItemCheckbox, !module.disabledByUser);
        modulesTable_.setRowHeight(i, lineHeight);
    }
    for (uint_t i = MORIARTY_MODULES_COUNT; i<rowsCount; ++i)
        modulesTable_.setRowHeight(i, lineHeight);

    modulesTable_.setColumnUsable(tableItemModuleName, true);
    modulesTable_.setColumnUsable(tableItemCheckbox, true);
    modulesTable_.setCustomDrawFunction(tableItemModuleName, ModuleNameDrawFunction);
    modulesTable_.setItemsCount(MORIARTY_MODULES_COUNT);
    modulesTable_.setTopItem(0, true);

    Preferences* prefs = &application().preferences();
    layoutPopupIndex_ = prefs->mainFormView;
    assert(layoutPopupIndex_ >= 0 && layoutPopupIndex_ < layoutNamesCount);
    layoutPopupTrigger_.setLabel(layoutNames[layoutPopupIndex_]);
    setDisplayPage(displayPage_);
    
    return result;
}
示例#9
0
文件: Category.c 项目: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    CategoryCreateList
//
// DESCRIPTION: This routine read a database's categories and store them
//				in a list.
//
// PARAMETERS:  (DmOpenRef) db - Opened database containing category info.
//				(ListType *) listP - A pointer to the list of category
//								names.
//				(UInt16) currentCategory - Category to select
//				(Boolean) showAll - true to have an "ALL" categories
//				(Boolean) showUneditables - true to show uneditable
//								categories.
//				(UInt8) numUneditableCategories - This is the number of
//								categories, starting with the first one
//								at zero.
//				(UInt32) editingStrID - The resource ID os a string to
//								use with the "Edit Categories" list item.
//				(Boolean) resizeList - true to resize the list to the
//								number of categories. Set to true for 
//								pop-ups, false otherwise
//	
// RETURNED:    Nothing
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	3/13/01		Initial Revision
////////////////////////////////////////////////////////////////////////
void CategoryCreateList (DmOpenRef db, ListType *listP, UInt16 currentCategory,
						 Boolean showAll, Boolean showUneditables, 
						 UInt8 numUneditableCategories,
						 UInt32 editingStrID, Boolean resizeList)
{
	UInt16	index=0, k, offset=0;
	Char		word[16];

	if ( !VGetCategoryName (db, 0, word) ) {
		for ( ; index < listP->numItems; index++ ) {
			VWriteCategory ( db, index, listP->itemsText[index], Vstrlen(listP->itemsText[index]) ) ;
		}
	} else {
		// release old listP text memory
		for ( k = 0; k < listP->numItems; k++ ) {
			if ( listP->itemsText[k]);
				Vfree (listP->itemsText[k]);
		}
		if ( listP->itemsText )
			Vfree (listP->itemsText);
		listP->itemsText = NULL;

		// if showAll, add the "ALL" item to the list
		listP->itemsText = (Char **) Vrealloc (listP->itemsText,
								(sizeof(Char *)*(listP->numItems+1)));
		if (showAll) {
			listP->itemsText[index] = (Char*) Vmalloc (4);
			Vstrcpy (listP->itemsText[index++], "All");
			offset = 1;
		}

		do {
			listP->itemsText[index] = (Char*) Vmalloc (Vstrlen(word)+1);
			Vstrcpy (listP->itemsText[index++], word);
		} while ( VGetCategoryName (db, (UInt16)(index-offset), word) );
		listP->numItems = index;
		if ( resizeList ) {
			listP->bounds.extent.y = listP->numItems*FntLineHeight();
		}
	}
}
示例#10
0
Graphics::Font_t Graphics::setFont(const Graphics::Font_t& font)
{
    Font_t oldOne = font_;
    font_ = font;
    FontID id = font_.withEffects();
    bool wantsScaling = 0 != (id & fontScalingDisabled);
    disableFontScaling_ = wantsScaling && useFontScaling();
    if (wantsScaling && !disableFontScaling_)
        id =stdFont;
    ScalingSetter setScaling(*this);
    FntSetFont(FontID(id & ~fontScalingDisabled));
    effectiveLineHeight_ = lineHeight_ = FntLineHeight();
    FontEffects fx=font_.effects();
    if (fx.superscript() || fx.subscript())
    {
        effectiveLineHeight_*=4;
        effectiveLineHeight_/=3;
    }
    effectiveBaseline_=baseline_ = FntBaseLine();
    if (font_.effects().superscript())
        effectiveBaseline_ += (lineHeight_/3);
    return oldOne;
}
示例#11
0
void CScoringForm::OnDraw() {

	HostTraceOutputTL(sysErrorClass, "OnDraw");

	Boolean won_bid = false;
	Int16 high_p = -1, low_p = -1, jack_p = -1, game_p = -1;
	Card::face_t high_c, low_c;

	Int16 points[3];
	Int16 old_points[3];
	
	points[0] = gManager->scores[0];
	points[1] = gManager->scores[1];
	points[2] = gManager->scores[2];

	old_points[0] = gManager->scores[0];
	old_points[1] = gManager->scores[1];
	old_points[2] = gManager->scores[2];



	Boolean smudge = false;

	won_bid = gManager->trk->CalculateGamePoints(&high_p, &low_p, &jack_p, &game_p, 
									&high_c, &low_c, &smudge );


	if ( gManager->CutThroat() == false ) {
	
		if ( smudge ) {
			switch ( (*gManager->tbl->winning_bidder)->playerIndex ) {
				case 0:
				case 2:
					points[0]++;
					break;
				case 1:
				case 3:
					points[1]++;
					break;
			}
		}
	
		switch( high_p ) {
			case 0:
			case 2:
				points[0]++;
				break;
			case 1:
			case 3:
				points[1]++;
				break;
		}
		
		switch( low_p ) {
			case 0:
			case 2:
				points[0]++;
				break;
			case 1:
			case 3:
				points[1]++;
				break;
		}
		
		switch( game_p ) {
			case 0:
			case 2:
				points[0]++;
				break;
			case 1:
			case 3:
				points[1]++;
				break;
		}
		
		switch( jack_p ) {
			case 0:
			case 2:
				points[0]++;
				break;
			case 1:
			case 3:
				points[1]++;
				break;
		}
	}
	else {
	
		points[high_p]++;
		points[low_p]++;
		
		if ( game_p != -1 ) {
			points[game_p]++;
		}
		
		if ( jack_p != -1 ) {
			points[jack_p]++;
		}
		

	}


	if ( high_p != -1 ) {
		high_field.Replace( (const char *)gManager->getPlayer(high_p)->getName() );
	}

	if ( low_p != -1 ) {
		low_field.Replace( (const char *)gManager->getPlayer(low_p)->getName() );
	}

	if ( jack_p != -1 ) {
		jack_field.Replace( (const char *)gManager->getPlayer(jack_p)->getName() );
	}
	else {
		jack_field.Replace("none");
	}


	Card foo(gManager->trk->getTrump(), high_c);
	Card foo2(gManager->trk->getTrump(), low_c);

	FormPtr frmP = FrmGetActiveForm();

	RectangleType  bounds;
	UInt16 gadgetIndex = FrmGetObjectIndex(frmP, HighCardGadget );
	FrmGetObjectBounds(frmP, gadgetIndex, &bounds);
	foo.Draw(bounds.topLeft.x, bounds.topLeft.y, CPlayerHandGadget::card_width, CPlayerHandGadget::card_height);

	gadgetIndex = FrmGetObjectIndex(frmP, LowCardGadget );
	FrmGetObjectBounds(frmP, gadgetIndex, &bounds);
	foo2.Draw(bounds.topLeft.x, bounds.topLeft.y, CPlayerHandGadget::card_width, CPlayerHandGadget::card_height);


	char gamestr[80];

	if ( gManager->CutThroat() == false ) {
		if ( game_p == 1 ) {
			StrPrintF(gamestr, "E/W team wins, %d - %d", 
				gManager->GetTeamPoints('b'), gManager->GetTeamPoints('a') );
		}
		else if ( game_p == 0 ) {
			StrPrintF(gamestr, "N/S team wins, %d - %d",
				gManager->GetTeamPoints('a'), gManager->GetTeamPoints('b') );
		}
		else {
			StrPrintF(gamestr, "teams tied on points at %d",
				gManager->GetTeamPoints('a') );
		}
	}
	else {
		if ( game_p == 2 ) {
			StrPrintF(gamestr, "%s wins, %d - %d - %d",
				(const char *)gManager->players[2]->getName(),
				gManager->GetTeamPoints('c'), 
				gManager->GetTeamPoints('a'),
				gManager->GetTeamPoints('b') );
		}
		else if ( game_p == 1 ) {
			StrPrintF(gamestr, "%s wins, %d - %d - %d",
				(const char *)gManager->players[1]->getName(),
				gManager->GetTeamPoints('b'), 
				gManager->GetTeamPoints('a'),
				gManager->GetTeamPoints('c') );
		}
		else if ( game_p == 0 ) {
			StrPrintF(gamestr, "%s wins, %d - %d - %d",
				(const char *)gManager->players[0]->getName(),
				gManager->GetTeamPoints('a'), 
				gManager->GetTeamPoints('b'),
				gManager->GetTeamPoints('c') );
		}
		else {
			StrPrintF(gamestr, "tied on points at %d",
				gManager->GetTeamPoints('a') );

		}

	}

	game_field.Replace( gamestr );


	char bid_results_str[255];

	char bidval[10];
	if ( gManager->tbl->bid != 5 ) {
		StrPrintF(bidval, "%d", gManager->tbl->bid);
	}
	else {
		StrCopy(bidval, "smudge");
	}

	Int16 score_diff;
	Int16 bidder_score = 0;

	char other_results[80];
	other_results[0] = 0;


	if ( gManager->CutThroat() == false ) {

		if ( (*gManager->tbl->winning_bidder)->playerIndex == 1 || 
			(*gManager->tbl->winning_bidder)->playerIndex == 3 ) {
			score_diff = points[0] - old_points[0];
			bidder_score = points[1] - old_points[1];
		}
		else {
			score_diff = points[1] - old_points[1];
			bidder_score = points[0] - old_points[0];
		}

	}
	else {

		bidder_score = points[(*gManager->tbl->winning_bidder)->playerIndex] - 
					old_points[(*gManager->tbl->winning_bidder)->playerIndex];
	}

	if ( won_bid ) {

		StrPrintF(bid_results_str, 
			"%s bid %s and won %d\n", 
			(const char *)(*gManager->tbl->winning_bidder)->getName(), 
			bidval, bidder_score );
	}
	else {
		StrPrintF(bid_results_str, 
			"%s bid %s and lost\n", 
			(const char *)(*gManager->tbl->winning_bidder)->getName(), bidval );

		
		if ( gManager->CutThroat() == false ) {

			switch ( (*gManager->tbl->winning_bidder)->playerIndex ) {
				case 0:
				case 2:
//					points[0] += (-1 * gManager->tbl->bid);
					points[0] = old_points[0] + (-1 * gManager->tbl->bid);
					break;
				case 1:
				case 3:
//					points[1] += (-1 * gManager->tbl->bid);
					points[1] = old_points[1] + (-1 * gManager->tbl->bid);
					break;
			}
		}
		else {
//			points[(*gManager->tbl->winning_bidder)->playerIndex] = -1 * gManager->tbl->bid;
			points[(*gManager->tbl->winning_bidder)->playerIndex] = 
				old_points[(*gManager->tbl->winning_bidder)->playerIndex] +
					(-1 * gManager->tbl->bid);
		}
	}


	if ( gManager->CutThroat() == false ) {

		char other_team[4];

		if ( (*gManager->tbl->winning_bidder)->playerIndex == 1 || 
				(*gManager->tbl->winning_bidder)->playerIndex == 3 ) {
			StrCopy(other_team, "N/S");
		}
		else {
			StrCopy(other_team, "E/W");
		}

		if ( score_diff == 0 ) {
			StrPrintF(other_results, "%s team scored no points", other_team);
		} else if ( score_diff == 1 ) {
			StrPrintF(other_results, "%s team scored 1 point", other_team);
		}
		else {
			StrPrintF(other_results, "%s team scored %d points", other_team, score_diff);	
		}
		
		StrCat(bid_results_str, other_results);

	}
	else {


		bidder_score = points[(*gManager->tbl->winning_bidder)->playerIndex] - 
				old_points[(*gManager->tbl->winning_bidder)->playerIndex];

		if ((*gManager->tbl->winning_bidder)->playerIndex != 0 ) {
			score_diff = points[0] - old_points[0];

			if ( score_diff == 0 ) {
				StrPrintF(other_results, "%s scored no points\n", (const char *)gManager->players[0]->getName() );
			} else if ( score_diff == 1 ) {
				StrPrintF(other_results, "%s scored 1 point\n", (const char *)gManager->players[0]->getName() );
			}
			else {
				StrPrintF(other_results, "%s scored %d points\n", (const char *)gManager->players[0]->getName(), score_diff );
			}

			StrCat(bid_results_str, other_results);
		}


		if ((*gManager->tbl->winning_bidder)->playerIndex != 1 ) {
			score_diff = points[1] - old_points[1];

			char tmpstr[40];

			if ( score_diff == 0 ) {
				StrPrintF(tmpstr, "%s scored no points\n", (const char *)gManager->players[1]->getName() );
			} else if ( score_diff == 1 ) {
				StrPrintF(tmpstr, "%s scored 1 point\n", (const char *)gManager->players[1]->getName() );
			}
			else {
				StrPrintF(tmpstr, "%s scored %d points\n", (const char *)gManager->players[1]->getName(), score_diff );
			}

			StrCat(bid_results_str, tmpstr);

		}
		


		if ((*gManager->tbl->winning_bidder)->playerIndex != 2 ) {
			score_diff = points[2] - old_points[2];

			char tmpstr[60];

			if ( score_diff == 0 ) {
				StrPrintF(tmpstr, "%s scored no points", (const char *)gManager->players[2]->getName() );
			} else if ( score_diff == 1 ) {
				StrPrintF(tmpstr, "%s scored 1 point", (const char *)gManager->players[2]->getName() );
			}
			else {
				StrPrintF(tmpstr, "%s scored %d points", (const char *)gManager->players[2]->getName(), score_diff );
			}

			StrCat(bid_results_str, tmpstr);
		}

	}

	bid_results.Replace( bid_results_str );


	RectangleType  score_bounds;
	gadgetIndex = FrmGetObjectIndex(frmP, ScoreDisplayGadget );
	FrmGetObjectBounds(frmP, gadgetIndex, &score_bounds);

	Int16 y = score_bounds.topLeft.y;

	if ( gManager->CutThroat() ) {
		CString scores[3];
		CString tmp;

		for ( int i = 0; i < 3; i++ ) {
//			tmp.Format("%d", gManager->scores[i] + points[i] - old_points[i]);
			tmp.Format("%d", points[i]);
			scores[i] = gManager->players[i]->getName() + ": " + tmp + " points";

			WinPaintChars(scores[i], StrLen(scores[i]), score_bounds.topLeft.x + 2, y);
			y += FntLineHeight() + 2;
		}
	
	}
	else {

		CString ew_score_str;
		CString ns_score_str;

//		ew_score_str.Format("E/W: %d points", gManager->scores[1] + points[1] - old_points[1]);
//		ns_score_str.Format("N/S: %d points", gManager->scores[0] + points[0] - old_points[0]);

		ns_score_str.Format("N/S: %d points", points[0]);
		ew_score_str.Format("E/W: %d points", points[1]);

		WinPaintChars(ns_score_str, StrLen(ns_score_str), 
			score_bounds.topLeft.x + 2, y );

		y += FntLineHeight() + 2;

		WinPaintChars(ew_score_str, StrLen(ew_score_str), 
			score_bounds.topLeft.x + 2, y);


	}

	HostTraceOutputTL(sysErrorClass, "OnDraw done");

}
示例#12
0
文件: gadget.c 项目: timn/unimatrix
/*****************************************************************************
* Function: GadgetHintTap
*
* Description: Handles penDown events (taps) on the hint gadget
*****************************************************************************/
void
GadgetHintTap(FormGadgetType *pGadget, EventType *event)
{
  //you may find it useful to track if they
  //lift the pen still within the boundaries of the gadget
  Boolean isPenDown = true;
  Int16 newPointX, newPointY, startPointX, startPointY;
  UInt16 index;
  RectangleType bounds, rect;
  Char noteSymb[2] = { GADGET_NOTESYMBOL, 0 };
  FontID oldFont;
  Boolean drawn=false;
  IndexedColorType curForeColor, curBackColor, curTextColor;

  // This is just needed since we do not want to access internal structure
  // data directly in FormGadgetType (need rect field below)
  index = TNGetObjectIndexFromPtr(FrmGetActiveForm(), pGadget);
  FrmGetObjectBounds(FrmGetActiveForm(), index, &bounds);

  oldFont = FntSetFont(symbolFont);
  RctSetRectangle(&rect,
                  bounds.topLeft.x+1,  // +1 for border
                  bounds.topLeft.y+1, // Put VALUE BELOW here.... +top+1 removed because of own Gadget
                  bounds.extent.x-3, bounds.extent.y - 3); // -4 for bottom border
  RctSetRectangle(&rect, rect.topLeft.x+rect.extent.x-8,
                         rect.topLeft.y+rect.extent.y-12,
                         FntLineWidth(noteSymb, 1), FntLineHeight());


  //track the pen down event
  EvtGetPen(&newPointX, &newPointY, &isPenDown);
  startPointX = newPointX;
  startPointY = newPointY;
  while (isPenDown){
    EvtGetPen(&newPointX, &newPointY, &isPenDown);

    if (gHintNote) {
      if (! drawn && RctPtInRectangle(newPointX, newPointY, &rect)) {
        curForeColor = WinSetForeColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground));
        curBackColor = WinSetBackColor(UIColorGetTableEntryIndex(UIObjectSelectedFill));
        curTextColor = WinSetTextColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground));
        TNDrawCharsToFitWidth(noteSymb, &rect);
        WinSetForeColor(curForeColor);
        WinSetForeColor(curBackColor);
        WinSetForeColor(curTextColor);
        drawn = true;
      } else if (drawn && ! RctPtInRectangle(newPointX, newPointY, &rect)) {
        curForeColor = WinSetForeColor(UIColorGetTableEntryIndex(UIObjectForeground));
        curBackColor = WinSetBackColor(UIColorGetTableEntryIndex(UIObjectFill));
        curTextColor = WinSetTextColor(UIColorGetTableEntryIndex(UIObjectForeground));
        TNDrawCharsToFitWidth(noteSymb, &rect);
        WinSetForeColor(curForeColor);
        WinSetForeColor(curBackColor);
        WinSetForeColor(curTextColor);
        drawn = false;
      }
    }

  }

  FntSetFont(oldFont);

  if (gHintNote && RctPtInRectangle(newPointX, newPointY, &rect)) {
    NoteSet(GadgetGetHintTimeIndex(), FORM_main);
    FrmPopupForm(NewNoteView);
  } // else outside gadget bounds -> do nothing
}
static void UpdateDisplay(void) {

	UInt16 j;
	const char timer[] = "\024";

	PFScreenLock(false);
	
	GUIFormDraw();
	/*
	 * make sure that the selected waypoint is kept high-lighted i.e.
	 * move the list selector if the waypoint moves position in the list
	 *
	 */


	if (selectedWaypointID != UNSELECTED && proxList.waypoints[currentSelection].id != selectedWaypointID) {

		/*
		 * look for the waypoint ID in the list
		 *
		 */

		for (j=0;j<proxList.numWaypoints;j++) {
			if (proxList.waypoints[j].id == selectedWaypointID) {
				currentSelection = j;
				break;
			}
		}

		/*
		 * didn't find it? Clear the list selection
		 *
		 */

		if (j == proxList.numWaypoints) {
			currentSelection = noListSelection;
			selectedWaypointID = UNSELECTED;
		}
	}
	if (GUIMenuIsDisplayed()) return;

	SetupScrollbar();

	for (j=0;j<numProxWaypointsToDisplay;j++) {

		DrawWaypoint(j);

	}
	
	if (newProxList == &proxList) {
		
		FntSetFont(symbolFont);
		PFDrawChars(timer,1, StandardPageWidth-20,0);

	} else {

		FntSetFont(stdFont);
		PFDrawChars("    ",4, StandardPageWidth-20,0);
		
	}
	
	if (HSIMiniPanel) HSIMiniPanelDraw(HSIMiniPanel);

	PFScreenUnlock();


#ifdef ALTERNATE

	if (newProxList == &proxList) {

		PFScreenRectType r;
		FormPtr       f = FrmGetActiveForm();

		FrmGetObjectBounds(f, FrmGetObjectIndex(f, displayFilter + DvAirfieldPushbutton),
				&r);

		DrawAlignedChars(timer, ALIGNCENTRE, r.x1+r.extent.x/2,
				r.y1+r.extent.y/2 - FntLineHeight()/2);

	} else {

		CtlDrawControl(GetObjectPtr(FrmGetActiveForm(), displayFilter+DvAirfieldPushbutton));

	}

#endif
	PFSendSimpleEvent(evtScreenRedrawn);

}