示例#1
0
//************************************************************************
// CLCDGfx::DrawText
//************************************************************************
void CLCDGfx::DrawText(int nX,int nY,int nWidth,tstring strText)
{
	SIZE sizeLine =  {0, 0};
	SIZE sizeCutOff = {0, 0};

	GetTextExtentPoint(GetHDC(),_T("..."),3,&sizeCutOff);

	int *piWidths = new int[strText.length()];
	int iMaxChars = 0;

	GetTextExtentExPoint(GetHDC(), strText.c_str(), (int)strText.length(), nWidth, &iMaxChars, piWidths, &sizeLine);

	if(iMaxChars < strText.length()) {
		for(iMaxChars--;iMaxChars>0;iMaxChars--)
			if(piWidths[iMaxChars] + sizeCutOff.cx <= nWidth)
				break;

		DrawText(nX,nY,(strText.substr(0,iMaxChars) + _T("...")).c_str());
	}
	else DrawText(nX,nY,strText.c_str());
	delete[] piWidths;
}
示例#2
0
static walk_result CreateAllRegLists( const mad_reg_set_data *data, void *_crld )
{
    CreateRegListData *crld = _crld;
    HWND        list;
    HWND        combo;
    HDC         dc;
    SIZE        size;
    char        *p;
    char        TxtBuff[TXT_LEN];
    unsigned    len;

    p = TxtBuff + MADCliString( MADRegSetName( data ), TxtBuff, TXT_LEN );
    *p++ = ' ';
    *p++ = '(';
    len = MADRegSetLevel( data, p, TXT_LEN - ( p - TxtBuff ) );
    if( len == 0 ) {
        p -= 2;
    } else {
        p += len;
        *p++ = ')';
    }
    *p++ = '\0';
    combo = GetDlgItem( crld->parent, STAT_REGISTER_COMBO );
    SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)TxtBuff );
    dc = GetDC( combo );
    GetTextExtentPoint( dc, TxtBuff, strlen( TxtBuff ), &size );
    ReleaseDC( combo, dc );
    crld->max_len = size.cx;
    if( crld->max_len < crld->max_len )
        crld->max_len = crld->max_len;
    crld->reg_set = (mad_reg_set_data *)data;
    list=CreateRegList( crld );

    if( crld->index != 0 ) {
        ShowWindow( list, SW_HIDE );
    }
    crld->index++;
    return( WR_CONTINUE );
}
示例#3
0
/* returns the row for placing next node      */
static INT local addClassToGraph(HDC hDC, INT Column, INT startRow, Class ThisClass)
{
  Node newNode = LastNode++;
  SIZE Size;
  INT  row = startRow;

  /* Get size of class name on the screen */
  fprintf(stdstr, "%s\n",textToStr(cclass(ThisClass).text));
  GetTextExtentPoint(hDC,(LPSTR)stdstrbuff, (INT)strlen(stdstrbuff), &Size);

  Nodes[newNode].Class      = ThisClass;
  Nodes[newNode].Pos.left   = Column;
  Nodes[newNode].Pos.top    = startRow;
  Nodes[newNode].Pos.right  = Nodes[newNode].Pos.left + Size.cx;
  Nodes[newNode].Pos.bottom = Nodes[newNode].Pos.top  + Size.cy;

  /* Add subclasses of ThisClass */
  { Class cls;
    INT   col   = Nodes[newNode].Pos.right+HORIZONTAL_SEPARATION;
    INT   child = 0;
    for(cls=CLASSMIN; cls<classMax(); cls++) {
      if (-1 == findClassInNodes(cls) /* Check for cycles in graph */
	  && isParentOf(ThisClass, cls)) {
	if (child++ > 0) {
	  row += VERTICAL_SEPARATION;
	}
	row = addClassToGraph(hDC, col, row, cls);
      }
    }
  }
  /* Set to average position of children */
  { INT height = row-startRow;
    Nodes[newNode].Pos.top    += height/2;
    Nodes[newNode].Pos.bottom += height/2;
  }
  return row;
}
示例#4
0
void MapWindow::DrawThermalHistory(HDC hdc, RECT rc) {

  SIZE WPTextSize, DSTextSize, BETextSize, RETextSize, AATextSize, HLTextSize, MITextSize;
  TCHAR Buffer[LKSIZEBUFFERLARGE];
  static RECT s_sortBox[6]; 
  static TCHAR Buffer1[MAXTHISTORY][MAXTHISTORYNUMPAGES][24], Buffer2[MAXTHISTORY][MAXTHISTORYNUMPAGES][10];
  static TCHAR Buffer3[MAXTHISTORY][MAXTHISTORYNUMPAGES][10];
  static TCHAR Buffer4[MAXTHISTORY][MAXTHISTORYNUMPAGES][12], Buffer5[MAXTHISTORY][MAXTHISTORYNUMPAGES][12];
  static short s_maxnlname;
  char text[30];
  short i, k, iRaw, wlen, rli=0, curpage, drawn_items_onpage;
  double value;
  COLORREF rcolor;

  // column0 starts after writing 1:2 (ModeIndex:CURTYPE+1) with a different font..
  static short Column0;
  static short Column1, Column2, Column3, Column4, Column5;
  static POINT p1, p2;
  static short s_rawspace;
  // Printable area for live nearest values
  static short left,right,bottom;
  // one for each mapspace, no matter if 0 and 1 are unused

  short curmapspace=MapSpaceMode;
  static int thistoryNumraws=0;
  // Vertical and horizontal spaces
  #define INTERRAW	1
  #define HEADRAW	NIBLSCALE(6)	
  HBRUSH sortbrush;
  RECT invsel;

  if (INVERTCOLORS) {
  	sortbrush=LKBrush_LightGreen;
  } else {
  	sortbrush=LKBrush_DarkGreen;
  }

  if (DoInit[MDI_DRAWTHERMALHISTORY]) {

  if ( ScreenSize < (ScreenSize_t)sslandscape ) {
	left=rc.left+NIBLSCALE(1);
	right=rc.right-NIBLSCALE(1);
  	bottom=rc.bottom-BottomSize-NIBLSCALE(2);
	s_maxnlname=MAXNLNAME-5; // 7 chars max, 8 sized
  	_stprintf(Buffer,TEXT("MAKSJSMM"));  
  } else {
	left=rc.left+NIBLSCALE(5);
	right=rc.right-NIBLSCALE(5);
  	bottom=rc.bottom-BottomSize;
	s_maxnlname=MAXNLNAME-3; // 9 chars, sized 10
  	_stprintf(Buffer,TEXT("ABCDEFGHMx")); 
  }


  SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest  was LK8Title
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &WPTextSize);

  _stprintf(Buffer,TEXT("000.0")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &DSTextSize);

  _stprintf(Buffer,TEXT("<<123")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &BETextSize);

  _stprintf(Buffer,TEXT("5299")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &RETextSize);

  _stprintf(Buffer,TEXT("+9999")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &AATextSize);

  SelectObject(hdc, LK8InfoNormalFont); // Heading line  was MapWindow QUI
  _stprintf(Buffer,TEXT("MMMM")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &HLTextSize);

  SelectObject(hdc, LK8PanelMediumFont);  
  _stprintf(Buffer,TEXT("1.1")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &MITextSize);

  short afterwpname=left+WPTextSize.cx+NIBLSCALE(5);
  short intercolumn=(right-afterwpname- DSTextSize.cx-BETextSize.cx-RETextSize.cx-AATextSize.cx)/3; 

  Column0=MITextSize.cx+LEFTLIMITER+NIBLSCALE(5);
  Column1=left;							// WP align left
  Column2=afterwpname+DSTextSize.cx;						// DS align right
  Column3=Column2+intercolumn+BETextSize.cx;			// BE align right
  Column4=Column3+intercolumn+RETextSize.cx;			// RE align right
  Column5=Column4+intercolumn+AATextSize.cx;			// AA align right


  if ( ScreenSize < (ScreenSize_t)sslandscape ) {
  	TopSize=rc.top+HEADRAW*2+HLTextSize.cy;
  	p1.x=0; p1.y=TopSize; p2.x=rc.right; p2.y=p1.y;
  	TopSize+=HEADRAW;
  	thistoryNumraws=(bottom - TopSize) / (WPTextSize.cy+(INTERRAW*2));
  	if (thistoryNumraws>MAXTHISTORY) thistoryNumraws=MAXTHISTORY;
  	s_rawspace=(WPTextSize.cy+INTERRAW);
  } else {
  	TopSize=rc.top+HEADRAW*2+HLTextSize.cy;
  	p1.x=0; p1.y=TopSize; p2.x=rc.right; p2.y=p1.y;
  	TopSize+=HEADRAW/2;
  	thistoryNumraws=(bottom - TopSize) / (WPTextSize.cy+INTERRAW);
  	if (thistoryNumraws>MAXTHISTORY) thistoryNumraws=MAXTHISTORY;
  	s_rawspace=(WPTextSize.cy+INTERRAW);
  }

#define INTERBOX intercolumn/2

  // Thermal name
  s_sortBox[0].left=Column0; // FIX 090925 era solo 0
  if ( ScreenSize < (ScreenSize_t)sslandscape ) s_sortBox[0].right=left+WPTextSize.cx-NIBLSCALE(2);
  else s_sortBox[0].right=left+WPTextSize.cx-NIBLSCALE(10);
  s_sortBox[0].top=2;
  s_sortBox[0].bottom=p1.y;
  SortBoxX[MSM_THERMALS][0]=s_sortBox[0].right;

  // Distance
  if ( ScreenSize < (ScreenSize_t)sslandscape ) s_sortBox[1].left=Column1+afterwpname-INTERBOX;
  else s_sortBox[1].left=Column1+afterwpname-INTERBOX-NIBLSCALE(2);
  s_sortBox[1].right=Column2+INTERBOX;
  s_sortBox[1].top=2;
  s_sortBox[1].bottom=p1.y;
  SortBoxX[MSM_THERMALS][1]=s_sortBox[1].right;

  // Bearing
  s_sortBox[2].left=Column2+INTERBOX;
  s_sortBox[2].right=Column3+INTERBOX;
  s_sortBox[2].top=2;
  s_sortBox[2].bottom=p1.y;
  SortBoxX[MSM_THERMALS][2]=s_sortBox[2].right;

  // Vario
  s_sortBox[3].left=Column3+INTERBOX;
  s_sortBox[3].right=Column4+INTERBOX;
  s_sortBox[3].top=2;
  s_sortBox[3].bottom=p1.y;
  SortBoxX[MSM_THERMALS][3]=s_sortBox[3].right;

  // Altitude
  s_sortBox[4].left=Column4+INTERBOX;
  //s_sortBox[4].right=Column5+INTERBOX;
  s_sortBox[4].right=rc.right-1;
  s_sortBox[4].top=2;
  s_sortBox[4].bottom=p1.y;
  SortBoxX[MSM_THERMALS][4]=s_sortBox[4].right;

  SortBoxY[MSM_THERMALS]=p1.y;

  THistoryNumpages=roundupdivision(MAXTHISTORY, thistoryNumraws);
  if (THistoryNumpages>MAXTHISTORYNUMPAGES) THistoryNumpages=MAXTHISTORYNUMPAGES;
  else if (THistoryNumpages<1) THistoryNumpages=1;

  SelectedRaw[MSM_THERMALS]=0;
  SelectedPage[MSM_THERMALS]=0;

  DoInit[MDI_DRAWTHERMALHISTORY]=false;
  return;
  } // doinit

  DoThermalHistory(&GPS_INFO,  &CALCULATED_INFO);

  THistoryNumpages=roundupdivision(LKNumThermals, thistoryNumraws);
  if (THistoryNumpages>MAXTHISTORYNUMPAGES) THistoryNumpages=MAXTHISTORYNUMPAGES;
  else if (THistoryNumpages<1) THistoryNumpages=1;

  curpage=SelectedPage[curmapspace];
  if (curpage<0||curpage>=MAXTHISTORYNUMPAGES) {
	#if TESTBENCH
	DoStatusMessage(_T("ERR-041 thermals curpage invalid"));  // selection while waiting for data ready
	#endif
	SelectedPage[curmapspace]=0;
	LKevent=LKEVENT_NONE;
	return;
  }

  switch (LKevent) {
	case LKEVENT_NONE:
		break;
	case LKEVENT_ENTER:
		LKevent=LKEVENT_NONE;
		i=LKSortedThermals[SelectedRaw[curmapspace]+(curpage*thistoryNumraws)];

		if ( (i<0) || (i>=MAXTHISTORY) || (CopyThermalHistory[i].Valid != true) ) {
			#if 0 // selection while waiting for data ready
			if (LKNumThermals>0)
				DoStatusMessage(_T("ERR-045 Invalid selection")); 
			#endif
			break;
		}
		LKevent=LKEVENT_NONE; 
		// Do not update while in details mode, max 10m
		LastDoThermalH=GPS_INFO.Time+600;
		dlgThermalDetails(i);
		LastDoThermalH=0;
		break;
	case LKEVENT_DOWN:
		if (++SelectedRaw[curmapspace] >=thistoryNumraws) SelectedRaw[curmapspace]=0;
		// Reset LastDoThermalH so that it wont be updated while selecting an item
		LastDoThermalH=GPS_INFO.Time+PAGINGTIMEOUT-1.0;
		break;
	case LKEVENT_UP:
		if (--SelectedRaw[curmapspace] <0) SelectedRaw[curmapspace]=thistoryNumraws-1;
		LastDoThermalH=GPS_INFO.Time+PAGINGTIMEOUT-1.0;
		break;
	case LKEVENT_PAGEUP:
		LKevent=LKEVENT_NONE;
		break;
	case LKEVENT_PAGEDOWN:
		LKevent=LKEVENT_NONE;
		break;
	case LKEVENT_NEWRUN:
		for (i=0; i<MAXTHISTORY; i++) {
			for (k=0; k<MAXTHISTORYNUMPAGES; k++) {
				_stprintf(Buffer1[i][k],_T("------------")); // 12 chars
				_stprintf(Buffer2[i][k],_T("----"));
				_stprintf(Buffer3[i][k],_T("----"));
				_stprintf(Buffer4[i][k],_T("----"));
				_stprintf(Buffer5[i][k],_T("----"));
			}
		}
		break;
	case LKEVENT_NEWPAGE:
		break;
	default:
		LKevent=LKEVENT_NONE;
		break;
  }


  if (INVERTCOLORS)
	  _DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p1, p2, RGB_GREEN, rc);
  else
	  _DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p1, p2, RGB_DARKGREEN, rc);

  SelectObject(hdc, LK8InfoNormalFont); // Heading line

  short cursortbox=SortedMode[curmapspace];

  if ( ScreenSize < (ScreenSize_t)sslandscape ) { // portrait mode
	FillRect(hdc,&s_sortBox[cursortbox], sortbrush); 
	_stprintf(Buffer,TEXT("%d.%d"),ModeIndex,CURTYPE+1);
  	SelectObject(hdc, LK8PanelMediumFont); 
	LKWriteText(hdc, Buffer, LEFTLIMITER, rc.top+TOPLIMITER , 0,  WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);
  	SelectObject(hdc, LK8InfoNormalFont); 

	_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1670_")), curpage+1,THistoryNumpages); 
	if (cursortbox==0)
 		LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_BLACK, false);
	else
 		LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);

	// LKTOKEN _@M1300_ "Dist"
	 _stprintf(Buffer, gettext(TEXT("_@M1300_"))); 
	if (cursortbox==1)
		LKWriteText(hdc, Buffer, Column2, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
	else
		LKWriteText(hdc, Buffer, Column2, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

	// LKTOKEN _@M1301_ "Dir"
	_stprintf(Buffer, gettext(TEXT("_@M1301_"))); 
	if (cursortbox==2)
		LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
	else
		LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

	_stprintf(Buffer, gettext(TEXT("_@M1673_")));  // Avg
	if (cursortbox==3)
		LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
	else
		LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

	_stprintf(Buffer, gettext(TEXT("_@M1307_")));  // AltArr
	if (cursortbox==4)
		LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
	else
		LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);


  } else {
	FillRect(hdc,&s_sortBox[cursortbox], sortbrush); 

	if ( (ScreenSize == (ScreenSize_t)ss640x480) || (ScreenSize == (ScreenSize_t)ss320x240)|| ScreenSize==ss896x672 ) {

		_stprintf(Buffer,TEXT("%d.%d"),ModeIndex,CURTYPE+1);
  		SelectObject(hdc, LK8PanelMediumFont); 
		LKWriteText(hdc, Buffer, LEFTLIMITER, rc.top+TOPLIMITER , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);
  		SelectObject(hdc, LK8InfoNormalFont); 

		_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1670_")), curpage+1,THistoryNumpages);  // THE
		if (cursortbox==0)
			LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0,WTMODE_NORMAL, WTALIGN_LEFT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0,WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);

		// LKTOKEN _@M1300_ "Dist"
		 _stprintf(Buffer, gettext(TEXT("_@M1300_"))); 
		if (cursortbox==1)
			LKWriteText(hdc, Buffer, Column2, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column2, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1301_ "Dir"
		_stprintf(Buffer, gettext(TEXT("_@M1301_"))); 
		if (cursortbox==2)
			LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		_stprintf(Buffer, gettext(TEXT("_@M1673_")));  // Avg
		if (cursortbox==3)
			LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		_stprintf(Buffer, gettext(TEXT("_@M1307_")));  // AltArr
		if (cursortbox==4)
			LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);
	} else {
		_stprintf(Buffer,TEXT("%d.%d"),ModeIndex,CURTYPE+1);
  		SelectObject(hdc, LK8PanelMediumFont); 
		LKWriteText(hdc, Buffer, LEFTLIMITER, rc.top+TOPLIMITER , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);
  		SelectObject(hdc, LK8InfoNormalFont); 

 		// LKTOKEN _@M1670_ "THE"
		_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1670_")), curpage+1,THistoryNumpages); 
		if (cursortbox==0)
			LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0,WTMODE_NORMAL, WTALIGN_LEFT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0,WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);

		// LKTOKEN _@M1304_ "Distance"
		_stprintf(Buffer, gettext(TEXT("_@M1304_"))); 
		if (cursortbox==1)
			LKWriteText(hdc, Buffer, Column2, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column2, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1305_ "Direction"
		_stprintf(Buffer, gettext(TEXT("_@M1305_"))); 
		if (cursortbox==2)
			LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		_stprintf(Buffer, gettext(TEXT("_@M1673_")));  // Avg
		if (cursortbox==3)
			LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		_stprintf(Buffer, gettext(TEXT("_@M1307_")));  // AltArr
		if (cursortbox==4)
			LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);
	}
	

  } // landscape mode


  SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest

  #ifdef DEBUG_LKT_DRAWTHISTORY
  TCHAR v2buf[100]; 
  wsprintf(v2buf,_T("MAXTHISTORY=%d LKNumTherm=%d / thistoryNumraws=%d THistoryNumpages=%d calc=%d\n"),MAXTHISTORY, LKNumThermals,thistoryNumraws, THistoryNumpages, (short)(ceil(MAXTHISTORY/thistoryNumraws)));
  StartupStore(v2buf);
  #endif

  for (i=0, drawn_items_onpage=0; i<thistoryNumraws; i++) {
	iRaw=TopSize+(s_rawspace*i);
	short curraw=(curpage*thistoryNumraws)+i;
	if (curraw>=MAXTHISTORY) break;
	rli=LKSortedThermals[curraw];

	#ifdef DEBUG_LKT_DRAWTHISTORY
	StartupStore(_T("..LKDrawThistory page=%d curraw=%d rli=%d \n"),
		curpage,curraw,rli);
	#endif

	if ( (rli>=0) && (CopyThermalHistory[rli].Valid==true) ) {

		// Thermal name
		wlen=wcslen(CopyThermalHistory[rli].Name);

                if (wlen>s_maxnlname) {
                        LKASSERT(CopyThermalHistory[rli].Name);
                        _tcsncpy(Buffer, CopyThermalHistory[rli].Name, s_maxnlname); Buffer[s_maxnlname]='\0';
                }
                else {
                        LKASSERT(CopyThermalHistory[rli].Name);
                        _tcsncpy(Buffer, CopyThermalHistory[rli].Name, wlen); Buffer[wlen]='\0';
                }
		if (IsThermalMultitarget(rli)) {
			TCHAR Buffer2[40];
			_stprintf(Buffer2,_T(">%s"),Buffer);
			wcscpy(Buffer,Buffer2);
		}
                ConvToUpper(Buffer);

		_tcscpy(Buffer1[i][curpage],Buffer); 

		// Distance
		value=CopyThermalHistory[rli].Distance*DISTANCEMODIFY;
         	_stprintf(Buffer2[i][curpage],TEXT("%0.1lf"),value);

		// relative bearing

		if (!MapWindow::mode.Is(MapWindow::Mode::MODE_CIRCLING)) {
			value = CopyThermalHistory[rli].Bearing -  GPS_INFO.TrackBearing;

			if (value < -180.0)
				value += 360.0;
			else
				if (value > 180.0)
					value -= 360.0;

#ifndef __MINGW32__
			if (value > 1)
				_stprintf(Buffer3[i][curpage], TEXT("%2.0f\xB0\xBB"), value);
			else
				if (value < -1)
					_stprintf(Buffer3[i][curpage], TEXT("\xAB%2.0f\xB0"), -value);
				else
					_tcscpy(Buffer3[i][curpage], TEXT("\xAB\xBB"));
#else
			if (value > 1)
				_stprintf(Buffer3[i][curpage], TEXT("%2.0f°»"), value);
			else
				if (value < -1)
					_stprintf(Buffer3[i][curpage], TEXT("«%2.0f°"), -value);
				else
					_tcscpy(Buffer3[i][curpage], TEXT("«»"));
#endif
		} else {
			_stprintf(Buffer3[i][curpage], _T("%2.0f°"), CopyThermalHistory[rli].Bearing);
		}
			

		// Average lift
		value=LIFTMODIFY*CopyThermalHistory[rli].Lift;
		if (value<-99 || value>99) 
			_stprintf(Buffer4[i][curpage],_T("---"));
		else {
			sprintf(text,"%+.1f",value);
			_stprintf(Buffer4[i][curpage],_T("%S"),text);
		}

		// Altitude
		value=ALTITUDEMODIFY*CopyThermalHistory[rli].Arrival;
		if (value<-1000 || value >45000 )
			strcpy(text,"---");
		else
			sprintf(text,"%.0f",value);
		wsprintf(Buffer5[i][curpage], TEXT("%S"),text);

	} else {
		// Empty thermals, fill in all empty data and maybe break loop
		_stprintf(Buffer1[i][curpage],_T("------------"));
		_stprintf(Buffer2[i][curpage],_T("---"));
		_stprintf(Buffer3[i][curpage],_T("---"));
		_stprintf(Buffer4[i][curpage],_T("---"));
		_stprintf(Buffer5[i][curpage],_T("---"));
	}


	if ((rli>=0) && (CopyThermalHistory[rli].Valid==true)) {
		drawn_items_onpage++;

		if (CopyThermalHistory[rli].Arrival >=0) {
			rcolor=RGB_WHITE;
  			SelectObject(hdc, LK8InfoBigFont);
		} else {
			rcolor=RGB_LIGHTRED;
  			SelectObject(hdc, LK8InfoBigItalicFont);
		}

	} else 
		rcolor=RGB_GREY;

	LKWriteText(hdc, Buffer1[i][curpage], Column1, iRaw , 0, WTMODE_NORMAL, WTALIGN_LEFT, rcolor, false);
	
  	SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest
	LKWriteText(hdc, Buffer2[i][curpage], Column2, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

	LKWriteText(hdc, Buffer3[i][curpage], Column3, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

	LKWriteText(hdc, Buffer4[i][curpage], Column4, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

	LKWriteText(hdc, Buffer5[i][curpage], Column5, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

  }  // for


  if (LKevent==LKEVENT_NEWRUN || LKevent==LKEVENT_NEWPAGE ) {
		LKevent=LKEVENT_NONE;
		return;
  }

  if (drawn_items_onpage>0) {

	if (SelectedRaw[curmapspace] <0 || SelectedRaw[curmapspace]>(thistoryNumraws-1)) {
  		LKevent=LKEVENT_NONE; // 100328
		return;
	}
	if (SelectedRaw[curmapspace] >= drawn_items_onpage) {
		if (LKevent==LKEVENT_DOWN) SelectedRaw[curmapspace]=0;
		else 
		if (LKevent==LKEVENT_UP) SelectedRaw[curmapspace]=drawn_items_onpage-1;
		else {
			SelectedRaw[curmapspace]=0;
		}
	}
	invsel.left=left;
	invsel.right=right;
	invsel.top=TopSize+(s_rawspace*SelectedRaw[curmapspace])+NIBLSCALE(2);
	invsel.bottom=TopSize+(s_rawspace*(SelectedRaw[curmapspace]+1))-NIBLSCALE(1);
	InvertRect(hdc,&invsel);

  } 

  LKevent=LKEVENT_NONE;
  return;
}
示例#5
0
void InitUIGlobalData(void)
{
    HDC     hDC;
    HFONT   hSysFont, hOldFont;
    LOGFONT lfFont;
    SIZE    lSize;
    TCHAR   szCandChar[2] = {0x4E2D,0};
    TCHAR   szFraction[6] = {'9','9','/','9','9',0};
    int     i;
/* Read reg. settings
    HKEY    hkey;
    if (RegOpenKeyEx(HKEY_CURRENT_USER, g_szChineseIMEUI, 0, 0, &hkey) == ERROR_SUCCESS) {
        DWORD   cb = sizeof(DWORD);
        DWORD   dw = 1;
        RegQueryValueEx(hkey, g_szShowState, NULL, NULL, (LPBYTE)&dw, &cb);
        g_sImeUIG.bNoStatus = ( dw == 0 );
        cb = sizeof(DWORD);
        dw = 0;
        RegQueryValueEx(hkey, g_szAutoCandAccel, NULL, NULL, (LPBYTE)&dw, &cb);
        g_sImeUIG.bAutoCandAccel = ( dw != 0 );
    }
    else {
        g_sImeUIG.bNoStatus = g_sImeUIG.bAutoCandAccel = FALSE;
    }
*/
    g_sImeUIG.cxBorder = GetSystemMetrics(SM_CXBORDER);
    g_sImeUIG.cyBorder = GetSystemMetrics(SM_CYBORDER);

    g_sImeUIG.cxVScroll = GetSystemMetrics(SM_CXVSCROLL);

    g_sImeUIG.crWindow = GetSysColor(COLOR_WINDOW);
    g_sImeUIG.crWindowText = GetSysColor(COLOR_WINDOWTEXT);
    g_sImeUIG.crHighlight = GetSysColor(COLOR_HIGHLIGHT);
    g_sImeUIG.crHighlightText = GetSysColor(COLOR_HIGHLIGHTTEXT);
    g_sImeUIG.crBtnFace = GetSysColor(COLOR_BTNFACE);
    g_sImeUIG.crBtnText = GetSysColor(COLOR_BTNTEXT);

// Get candtext width and height
    hDC = GetDC(NULL);
    GetTextExtentPoint(hDC, szCandChar, lstrlen(szCandChar), &lSize);
    g_sImeUIG.nCandCharWi = lSize.cx;
    g_sImeUIG.nCandLineWi = lSize.cx*2 + CAND_TEXTMARGIN * 2;
    g_sImeUIG.nCandLineHi = lSize.cy + CAND_LINEGAP;

    g_sImeUIG.nCandDx = CAND_TEXTMARGIN;
    for (i=0; i <= MAX_PAGESIZE; i++) {
        g_sImeUIG.nCandDy[i] = g_sImeUIG.nCandLineHi * i + CAND_LINEGAP;
    }

    hSysFont = (HFONT)GetStockObject(SYSTEM_FONT);
    GetObject(hSysFont, sizeof(LOGFONT), &lfFont);

    double scaleY;
    #define SCALEY(argY) ((int) ((argY) * scaleY))

    HDC screen = GetDC(0);
    scaleY = GetDeviceCaps(screen, LOGPIXELSY) / 96.0;
    ReleaseDC(0, screen);

    lfFont.lfWidth = 0;
    lfFont.lfHeight = SCALEY(11);
    lfFont.lfWeight = FW_EXTRALIGHT;

// Get frac text width and height
	g_sImeUIG.hFracFont = CreateFontIndirect(&lfFont);
    hOldFont = (HFONT)SelectObject(hDC, g_sImeUIG.hFracFont);
    GetTextExtentPoint(hDC, szFraction, lstrlen(szFraction), &lSize);
    g_sImeUIG.nCandFracWi = lSize.cx + CAND_LINEGAP * 2;
    g_sImeUIG.nCandFracHi = lSize.cy + CAND_LINEGAP * 2;
    SelectObject(hDC, hOldFont);
    ReleaseDC(NULL, hDC);

    return;
}
示例#6
0
void CDlgInput::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);

	if ( GetDlgItem(IDC_LABEL) == NULL || ! ::IsWindow( GetDlgItem(IDC_LABEL)->m_hWnd ) ) return;

	CRect pos;
    int   infoBottom;

	GetDlgItem( IDC_LABEL )->GetWindowRect( &pos );
	ScreenToClient( pos );
	if ( m_Label.IsEmpty() )
	{
		GetDlgItem( IDC_LABEL )->ShowWindow( SW_HIDE );
		infoBottom = 0;
	}
	else
	{
		HDC dc = ::GetWindowDC( GetDlgItem(IDC_LABEL)->m_hWnd );
		CStrArray lines;
		if ( m_Label.IsEmpty() )
		{
			lines.Add( L"" );
			GetDlgItem( IDC_LABEL )->SetWindowText(L"");
		}
		else
		{
			SplitLines( dc, (LPCTSTR)m_Label, lines, pos.Width() );
			CString infoWrapped;
			for ( int i=0; i<lines.GetSize(); i++ )
			{
				infoWrapped += lines[i];
				if ( i<lines.GetSize()-1 ) infoWrapped += "\n";
			}
			GetDlgItem( IDC_LABEL )->SetWindowText(infoWrapped);
			//UpdateData(FALSE);
		}
		SIZE size;
		GetTextExtentPoint( dc, L"W", 1, &size );
		pos.top   = 4;
		pos.left  = 4;
		pos.right = cx - 8;
		infoBottom = pos.bottom = pos.top + size.cy * lines.GetSize();
		::ReleaseDC( GetDlgItem(IDC_LABEL)->m_hWnd, dc );
		GetDlgItem( IDC_LABEL )->MoveWindow( pos );
		GetDlgItem( IDC_LABEL )->Invalidate();
	}


	//GetDlgItem(IDC_LABEL)->GetWindowRect( &pos );
	//ScreenToClient( &pos );
	//GetDlgItem(IDC_LABEL)->MoveWindow( &pos );

	if ( Multiline )
	{
		int height;

		GetDlgItem(IDOK)->GetWindowRect( &pos );
		ScreenToClient( &pos );
		height = pos.bottom-pos.top;
		pos.top = cy - height - 4;
		pos.bottom = cy - 4;
		pos.left  = 4;
		pos.right = cx/2 - 4;
		GetDlgItem(IDOK)->MoveWindow( &pos );

		GetDlgItem(IDCANCEL)->GetWindowRect( &pos );
		ScreenToClient( &pos );
		pos.top = cy - height - 4;
		pos.bottom = cy - 4;
		pos.left = cx/2 + 4;
		pos.right = cx - 8;
		GetDlgItem(IDCANCEL)->MoveWindow( &pos );

		GetDlgItem(IDC_EDIT)->GetWindowRect( &pos );
		ScreenToClient( &pos );
		pos.top   = infoBottom + 4;
		pos.bottom = cy - height - 8;
		pos.left  = 4;
		pos.right = cx - 8;
		GetDlgItem(IDC_EDIT)->MoveWindow( &pos );
	}
	else
	{
		int height;

		GetDlgItem(IDC_EDIT)->GetWindowRect( &pos );
		ScreenToClient( &pos );
		height = pos.Height();
		pos.top   = infoBottom + 4;
		pos.bottom = pos.top + height;
		pos.left  = 4;
		pos.right = cx - 8;
		GetDlgItem(IDC_EDIT)->MoveWindow( &pos );
		infoBottom = pos.bottom;

		((CEdit*)GetDlgItem(IDC_EDIT))->ModifyStyle( ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL, 0 );
#ifndef DESKTOP
		OSVERSIONINFO ver;
		GetVersionEx( &ver );
		if ( ver.dwMajorVersion < 5 )
		{
#endif
		GetDlgItem(IDOK)->GetWindowRect( &pos );
		ScreenToClient( &pos );
		height = pos.bottom-pos.top;
		pos.top   = infoBottom + 4;
		pos.bottom = pos.top + height;
		pos.left  = 4;
		pos.right = cx/2 - 4;
		GetDlgItem(IDOK)->MoveWindow( &pos );

		GetDlgItem(IDCANCEL)->GetWindowRect( &pos );
		ScreenToClient( &pos );
		pos.top   = infoBottom + 4;
		pos.bottom = pos.top + height;
		pos.left = cx/2 + 4;
		pos.right = cx - 8;
		GetDlgItem(IDCANCEL)->MoveWindow( &pos );
#ifndef DESKTOP
		}
		else
		{
			GetDlgItem( IDOK )->ShowWindow( SW_HIDE );
			GetDlgItem( IDCANCEL )->ShowWindow( SW_HIDE );
		}
#endif


		//((CEdit*)GetDlgItem(IDC_EDIT))->ModifyStyleEx( 0, ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL );

#ifdef DESKTOP
		CRect client;
		GetWindowRect( &pos );
		GetClientRect( &client );
		if ( infoBottom + height + 8 != client.Height() )
		{
			pos.bottom = pos.top + pos.Height() - client.Height() + infoBottom + height + 8;
			MoveWindow( &pos );
		}
#endif
	}
	
	((CEdit*)GetDlgItem(IDC_EDIT))->SetSel(0,0,FALSE);	
}
示例#7
0
int RenderFAISector (HDC hdc, const RECT rc , double lat1, double lon1, double lat2, double lon2, int iOpposite , COLORREF fillcolor)
{
float fFAI_Percentage = FAI_NORMAL_PERCENTAGE;

#define N_PLOYGON (3*FAI_SECTOR_STEPS)
double fDist_a, fDist_b, fDist_c, fAngle;
int i;

int iPolyPtr=0;
double lat_d,lon_d;
double alpha, fDistTri, cos_alpha=0;
POINT apSectorPolygon[N_PLOYGON];
POINT Pt1;
DistanceBearing(lat1, lon1, lat2, lon2, &fDist_c, &fAngle);

if(fabs(fDist_c) < 1000.0)  /* distance too short for a FAI sector */
	return -1;

LKASSERT(fFAI_Percentage>0);
double fDistMax = fDist_c/fFAI_Percentage;
LKASSERT(fFAI_Percentage!=0.5);
double fDistMin = fDist_c/(1.0-2.0*fFAI_Percentage);
double fDelta_Dist = 2.0* fDist_c*fFAI_Percentage / (double)(FAI_SECTOR_STEPS);

double dir = -1.0;

  if(fDistMax < FAI_BIG_THRESHOLD)
  {
    fDistMax = fDist_c/FAI_NORMAL_PERCENTAGE;
    fDistMin = fDist_c/(1.0-2.0*FAI_NORMAL_PERCENTAGE);
  }

  if (iOpposite >0)
  {
	dir = 1.0;
  }


  /********************************************************************
   * calc right leg
   ********************************************************************/
  fDelta_Dist =(fDistMax-fDistMin)/ (double)(FAI_SECTOR_STEPS);
  fDistTri = fDistMin;
  if(fDistTri < FAI_BIG_THRESHOLD)
  	fFAI_Percentage = FAI_NORMAL_PERCENTAGE;
  else
	fFAI_Percentage = FAI_NORMAL_PERCENTAGE;
  fDist_a = fDistMin * fFAI_Percentage;
  fDist_b = fDistMin * fFAI_Percentage;
  for(i =0 ;i < FAI_SECTOR_STEPS; i++)
  {
  	LKASSERT(fDist_c*fDist_b!=0);
	cos_alpha = ( fDist_b*fDist_b + fDist_c*fDist_c - fDist_a*fDist_a )/(2.0*fDist_c*fDist_b);
	alpha = acos(cos_alpha)*180/PI * dir;
	FindLatitudeLongitude(lat1, lon1, AngleLimit360( fAngle + alpha ) , fDist_b, &lat_d, &lon_d);


	MapWindow::LatLon2Screen(lon_d, lat_d,  Pt1);
    apSectorPolygon[iPolyPtr++] = Pt1;

    fDistTri += fDelta_Dist;
    if(fDistTri < FAI_BIG_THRESHOLD)
      fFAI_Percentage = FAI_NORMAL_PERCENTAGE;
    else
      fFAI_Percentage = FAI_NORMAL_PERCENTAGE;
    fDist_a = fFAI_Percentage * fDistTri;
	fDist_b = fDistTri - fDist_a - fDist_c;
  }

  /********************************************************************
   * calc top leg
   ********************************************************************/
  if(fDistMax < FAI_BIG_THRESHOLD)
    fFAI_Percentage = FAI_NORMAL_PERCENTAGE;
  else
    fFAI_Percentage = FAI_NORMAL_PERCENTAGE;

  fDelta_Dist =  (fDistMax*(1.0-3.0*fFAI_Percentage)) / (double)(FAI_SECTOR_STEPS);
  fDist_a = fDist_c;
  fDist_b = fDistMax - fDist_a - fDist_c;
  for(i =0 ;i < FAI_SECTOR_STEPS; i++)
  {
	LKASSERT(fDist_c*fDist_b!=0);
	cos_alpha = ( fDist_b*fDist_b + fDist_c*fDist_c - fDist_a*fDist_a )/(2.0*fDist_c*fDist_b);
	alpha = acos(cos_alpha)*180/PI * dir;
	FindLatitudeLongitude(lat1, lon1, AngleLimit360( fAngle + alpha ) , fDist_b, &lat_d, &lon_d);

	MapWindow::LatLon2Screen(lon_d, lat_d,  Pt1);
    apSectorPolygon[iPolyPtr++] = Pt1;

	fDist_a += fDelta_Dist;
	fDist_b = fDistMax - fDist_a - fDist_c;
  }

  /********************************************************************
   * calc left leg
   ********************************************************************/
  fDelta_Dist =(fDistMax-fDistMin)/ (double)(FAI_SECTOR_STEPS);
  fDistTri = fDistMax;

  fDist_b = fDistMax * fFAI_Percentage;
  fDist_a = fDistTri - fDist_b - fDist_c;
  for(i =0 ;i < FAI_SECTOR_STEPS; i++)
  {
    LKASSERT(fDist_c*fDist_b!=0);
	cos_alpha = ( fDist_b*fDist_b + fDist_c*fDist_c - fDist_a*fDist_a )/(2.0*fDist_c*fDist_b);
	alpha = acos(cos_alpha)*180/PI * dir;
	FindLatitudeLongitude(lat1, lon1, AngleLimit360( fAngle + alpha ) , fDist_b, &lat_d, &lon_d);

	MapWindow::LatLon2Screen(lon_d, lat_d,  Pt1);
    apSectorPolygon[iPolyPtr++] = Pt1;

    fDistTri -= fDelta_Dist;
    if(fDistTri < FAI_BIG_THRESHOLD)
      fFAI_Percentage = FAI_NORMAL_PERCENTAGE;
    else
      fFAI_Percentage = FAI_NORMAL_PERCENTAGE;

    fDist_b = fFAI_Percentage * fDistTri;
	fDist_a = fDistTri - fDist_b - fDist_c;
  }

  /********************************************************************
   * draw polygon
   ********************************************************************/
  HPEN   hpSectorPen  = (HPEN)CreatePen(PS_SOLID, IBLSCALE(2),  fillcolor );
  HBRUSH hpSectorFill = NULL;

  HPEN hpOldPen     = (HPEN)  SelectObject(hdc, hpSectorPen);
  HBRUSH hpOldBrush;
/*  if (fillcolor != 0)
  {
	hpSectorFill = (HBRUSH)CreateSolidBrush(fillcolor);
    hpOldBrush = (HBRUSH)SelectObject(hdc, hpSectorFill);
  }
  else */
    hpOldBrush = (HBRUSH)SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));


  /********************************************/
 // Polygon(hdc, apSectorPolygon,iPolyPtr);
  if (ForcedClipping || DeviceNeedClipping)
    ClipPolygon(hdc,apSectorPolygon,iPolyPtr,rc, true);
  else
    Polygon(hdc,apSectorPolygon,iPolyPtr);
  /********************************************/

  SelectObject(hdc, (HPEN)hpOldPen);
  SelectObject(hdc, (HBRUSH)hpOldBrush);
  DeleteObject(hpSectorPen);
  if(hpSectorFill != NULL)
    DeleteObject(hpSectorFill);



  /********************************************************************
   * calc round leg grid
   ********************************************************************/
  hpSectorPen  = (HPEN)CreatePen(PS_SOLID, (2), RGB_DARKGREY );
  SelectObject(hdc, hpSectorPen);

  double fTic= 1/DISTANCEMODIFY;
  if(fDist_c > 5/DISTANCEMODIFY)   fTic = 10/DISTANCEMODIFY;
  if(fDist_c > 50/DISTANCEMODIFY)  fTic = 25/DISTANCEMODIFY;
  if(fDist_c > 100/DISTANCEMODIFY) fTic = 50/DISTANCEMODIFY;
  if(fDist_c > 200/DISTANCEMODIFY) fTic = 100/DISTANCEMODIFY;
  if(fDist_c > 500/DISTANCEMODIFY) fTic = 250/DISTANCEMODIFY;
  POINT line[2];
  fDistTri = ((int)(fDistMin/fTic)+1) * fTic ;
  HFONT hfOld = (HFONT)SelectObject(hdc, LK8PanelUnitFont);
  int iCnt =0;
  SetTextColor(hdc, RGB_DARKGREY);
  while(fDistTri < fDistMax)
  {
    fDelta_Dist =  (fDistTri-fDistMin)*(1.0-2.0*fFAI_Percentage) / (double)(FAI_SECTOR_STEPS-1);
    fDist_a = fDistTri*fFAI_Percentage;
    fDist_b = fDistTri - fDist_a - fDist_c;
    for(i =0 ;i < FAI_SECTOR_STEPS; i++)
    {
      LKASSERT(fDist_c*fDist_b!=0);
      cos_alpha = ( fDist_b*fDist_b + fDist_c*fDist_c - fDist_a*fDist_a )/(2.0*fDist_c*fDist_b);
	  alpha = acos(cos_alpha)*180/PI * dir;
	  FindLatitudeLongitude(lat1, lon1, AngleLimit360( fAngle + alpha ) , fDist_b, &lat_d, &lon_d);

	  MapWindow::LatLon2Screen(lon_d, lat_d,  line[0]);

      if(i> 0)
      {
  		ForcedClipping=true;
  		MapWindow::_DrawLine(hdc, PS_DASH, NIBLSCALE(1), line[0] , line[1] , RGB_BLACK, rc);
  		ForcedClipping=false;
      }
	  //  Polyline(hdc, line, 2);

      line[1] =  line[0];
	  fDist_a += fDelta_Dist;
	  fDist_b = fDistTri - fDist_a - fDist_c;

      TCHAR text[180]; SIZE tsize;
      if(iCnt==0)
        _stprintf(text, TEXT("%i%s"), (int)(fDistTri*DISTANCEMODIFY), Units::GetUnitName(Units::GetUserDistanceUnit()));
      else
        _stprintf(text, TEXT("%i"), (int)(fDistTri*DISTANCEMODIFY));
      GetTextExtentPoint(hdc, text, _tcslen(text), &tsize);
      if(i == 0)
        ExtTextOut(hdc, line[0].x, line[0].y, ETO_OPAQUE, NULL, text, _tcslen(text), NULL);

      if(iCnt > 1)
  	    if(i == FAI_SECTOR_STEPS-1)
  	      ExtTextOut(hdc, line[0].x, line[0].y, ETO_OPAQUE, NULL, text, _tcslen(text), NULL);

      if(iCnt > 2)
  	    if((i== (FAI_SECTOR_STEPS/2)))
  	      ExtTextOut(hdc, line[0].x, line[0].y, ETO_OPAQUE, NULL, text, _tcslen(text), NULL);
    }
    iCnt++;
    fDistTri+=fTic;
  }

SelectObject(hdc, hfOld);
SelectObject(hdc, (HPEN)hpOldPen);
DeleteObject( hpSectorPen);
return 0;
}
示例#8
0
int		LinkTimeControl::PaintFCurves( ParamDimensionBase *dim, HDC hdc, Rect& rcGraph, Rect& rcPaint,
			float tzoom, int tscroll, float vzoom, int vscroll, DWORD flags )
{
	const int n = NumKeys();
	if ( n == 0 )
		return 0;

	Interval valid;
	int h = rcGraph.h()-1;
	HPEN dpen,spen;
	BOOL init=FALSE;		
	Interval range = GetTimeRange(TIMERANGE_ALL);	
	SetBkMode(hdc,TRANSPARENT);	

	dpen = CreatePen(PS_DOT,0,GetColorManager()->GetColor(kFunctionCurveFloat));
	spen = CreatePen(PS_SOLID,0,GetColorManager()->GetColor(kFunctionCurveFloat));

	SIZE size;
	GetTextExtentPoint( hdc, _T("0"), 1, &size );

	float val;
	TimeValue leftTime = ScreenToTime(rcPaint.left,tzoom,tscroll);
	TimeValue rightTime = ScreenToTime(rcPaint.right,tzoom,tscroll);
	int x, y;

	// dotted line to left of keys
	if ( leftTime < range.Start() )
	{
		SelectObject(hdc,dpen);
		GetValue(range.Start(),&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		MoveToEx(hdc,rcPaint.left,y,NULL);
		LineTo(hdc,TimeToScreen(range.Start(),tzoom,tscroll),y);
	}

	SelectObject(hdc,spen);

	// first node text
	{
		TimeValue t = GetKeyTime( 0 );
		if ( t >= leftTime && t <= rightTime )
		{
			GetValue(t,&val,valid);
			y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
			x = TimeToScreen(t,tzoom,tscroll);
			INode* node = fOwner->GetNode( 0 );
			DLTextOut( hdc, x, y-1-size.cy, node ? node->GetName() : _T("World") );
		}
	}

	// solid line between keys
	for ( int i=1; i<n; ++i )
	{
		TimeValue t0 = GetKeyTime( i-1 );
		TimeValue t1 = GetKeyTime( i );
		if ( t1 < leftTime || t0 > rightTime )
			continue;
		GetValue(t0,&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		MoveToEx(hdc,TimeToScreen(t0,tzoom,tscroll),y,NULL);
		x = TimeToScreen(t1,tzoom,tscroll);
		LineTo(hdc,x,y);
		GetValue(t1,&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		LineTo(hdc,x,y);

		INode* node = fOwner->GetNode( i );
		DLTextOut( hdc, x, y-1-size.cy, node ? node->GetName() : _T("World") );
	}

	// dotted line to right of keys
	if ( rightTime > range.End() )
	{
		SelectObject(hdc,dpen);
		GetValue(range.End(),&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		MoveToEx(hdc,TimeToScreen(range.End(),tzoom,tscroll),y,NULL);
		LineTo(hdc,rcPaint.right,y);
	}

	SelectObject( hdc, spen );
	HBRUSH hUnselBrush = CreateSolidBrush(GetColorManager()->GetColor(kTrackbarKeys));
	HBRUSH hSelBrush = CreateSolidBrush(GetColorManager()->GetColor(kTrackbarSelKeys));

	// render keys themselves
	for ( int i=0; i<n; ++i )
	{
		TimeValue t = GetKeyTime( i );
		if ( t < leftTime || t > rightTime )
			continue;
		GetValue(t,&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		x = TimeToScreen(t,tzoom,tscroll);
		SelectObject( hdc, IsKeySelected( i ) ? hSelBrush : hUnselBrush );
		Rectangle(hdc,x-3,y-3,x+3,y+3);
	}

	SetBkMode(hdc,OPAQUE);
	SelectObject(hdc,GetStockObject(BLACK_PEN));	

	DeleteObject(spen);
	DeleteObject(dpen);
	DeleteObject(hUnselBrush);
	DeleteObject(hSelBrush);

	return 0;
}
const int ArbolOpcionesBasicas::CalcularAncho(HWND hWnd) {
	int TamFinal = 0;
	HDC Buffer = GetDC(hWnd);
	
	HFONT Viejo = static_cast<HFONT>(SelectObject(Buffer, DWL::SO::DWLEstilos::Fuentes.Tahoma13()));
	SIZE Tam;
	GetTextExtentPoint(Buffer, IDIOMA__INICIO, DWLStrLen(IDIOMA__INICIO), &Tam);
	TamFinal = Tam.cx + 40;
	GetTextExtentPoint(Buffer, IDIOMA__ABRIR_ARCHIVO, DWLStrLen(IDIOMA__ABRIR_ARCHIVO), &Tam);
	if (TamFinal < Tam.cx + 40) TamFinal = Tam.cx + 40;
	GetTextExtentPoint(Buffer, IDIOMA__BASE_DE_DATOS, DWLStrLen(IDIOMA__BASE_DE_DATOS), &Tam);
	if (TamFinal < Tam.cx + 40) TamFinal = Tam.cx + 40;
	GetTextExtentPoint(Buffer, IDIOMA__BUSCAR_ARCHIVOS, DWLStrLen(IDIOMA__BUSCAR_ARCHIVOS), &Tam);
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
	GetTextExtentPoint(Buffer, IDIOMA__REVISAR_MEDIOS, DWLStrLen(IDIOMA__REVISAR_MEDIOS), &Tam);
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
/*	GetTextExtentPoint(Buffer, IDIOMA__REVISAR_GENEROS, DWLStrLen(IDIOMA__REVISAR_GENEROS), &Tam);
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
	GetTextExtentPoint(Buffer, IDIOMA__REVISAR_GRUPOS, DWLStrLen(IDIOMA__REVISAR_GRUPOS), &Tam);
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
	GetTextExtentPoint(Buffer, IDIOMA__REVISAR_DISCOS, DWLStrLen(IDIOMA__REVISAR_DISCOS), &Tam);*/
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
	GetTextExtentPoint(Buffer, IDIOMA__LISTA_DE_REPRODUCCION, DWLStrLen(IDIOMA__LISTA_DE_REPRODUCCION), &Tam);
	if (TamFinal < Tam.cx + 40) TamFinal = Tam.cx + 40;
	GetTextExtentPoint(Buffer, IDIOMA__ECUALIZADOR, DWLStrLen(IDIOMA__ECUALIZADOR), &Tam);
	if (TamFinal < Tam.cx + 40) TamFinal = Tam.cx + 40;
	GetTextExtentPoint(Buffer, IDIOMA__OPCIONES, DWLStrLen(IDIOMA__OPCIONES), &Tam);
	if (TamFinal < Tam.cx + 40) TamFinal = Tam.cx + 40;
	GetTextExtentPoint(Buffer, IDIOMA__ASPECTO, DWLStrLen(IDIOMA__ASPECTO), &Tam);
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
	GetTextExtentPoint(Buffer, IDIOMA__BASE_DE_DATOS, DWLStrLen(IDIOMA__BASE_DE_DATOS), &Tam);
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
	GetTextExtentPoint(Buffer, IDIOMA__TECLAS_RAPIDAS, DWLStrLen(IDIOMA__TECLAS_RAPIDAS), &Tam);
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
	GetTextExtentPoint(Buffer, IDIOMA__LISTA, DWLStrLen(IDIOMA__LISTA), &Tam);
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
	GetTextExtentPoint(Buffer, IDIOMA__VIDEO, DWLStrLen(IDIOMA__VIDEO), &Tam);
	if (TamFinal < Tam.cx + 58) TamFinal = Tam.cx + 58;
	GetTextExtentPoint(Buffer, IDIOMA__VER_VIDEO, DWLStrLen(IDIOMA__VER_VIDEO), &Tam);
	if (TamFinal < Tam.cx + 40) TamFinal = Tam.cx + 40;
	GetTextExtentPoint(Buffer, IDIOMA__SOBRE_BUBATRONIK, DWLStrLen(IDIOMA__SOBRE_BUBATRONIK), &Tam);
	if (TamFinal < Tam.cx + 40) TamFinal = Tam.cx + 40;

	SelectObject(Buffer, Viejo);
	ReleaseDC(_hWnd, Buffer);
	return TamFinal;
}
/*********************************************************************************************
 *
 * This is the window procedure for the main window.
 *
 *      Message:                Action:
 *      ========                =======
 *      WM_CREATE               save hInst for dialog box calls, and save menu and window colors
 *      WM_DESTROY              indicate that the window proc is complete
 *      WM_PAINT                print output message centered in client area
 *      WM_SIZE                 save new client dimensions
 *      WM_COMMAND              IDM_LOCALTIME: display message box with local time
 *                              IDM_UPTIME: display message box with time system has been up
 *                              IDM_SHOWCOLORS: display message box with text representation of
 *                                         menu text and background colors
 *                              IDM_CHANGECOLORS: change menu text and background colors
 *                              IDM_RESTORECOLORS: restore menu text and background colors to their
 *                                         original values
 *                              IDM_SCRDIM: display message box with screen dimensions
 *                              IDM_BEEP: display beep dialog
 *                              IDM_EXIT: leave the program
 *
 *********************************************************************************************/
LRESULT CALLBACK WndProc(HWND hWnd,
                 UINT messg,
                 WPARAM wParam,
                 LPARAM lParam)
{
    static HINSTANCE hInst;           // used for dialog box
    static BOOL bNeedToRestoreColors; // flag to do cleanup
    HDC hdc;                          // device context for painting
    PAINTSTRUCT ps;                   // paint structure for painting
    DWORD dElapsedTimeSysHasBeenUp;   // time (ms) since system was booted
    DWORD dOtherTime;                 // another variable to hold time
    char lpstrOutString[256];         // string for message boxes
    SIZE mySize, *lpSize=&mySize;     // used to calculate coordinates to center text
    SYSTEMTIME SysTime;               // system time
    SYSTEMTIME *lpSysTime = &SysTime; // pointer to previous
    DWORD dwCheckColorInfo[2];        // holds color information
    DWORD dwNewColorInfo[2] =         // colors to change (red windows, green menus)
        {RGB(255,0,0),RGB(0,255,0)};
    static DWORD dwSavedColorInfo[2]= // saved colors
        {0,0};
    static int iDisplayElements[2] =  // elements to change
        {COLOR_MENUTEXT, COLOR_MENU};
    int i;                            // temp
    int hsize,vsize,hres,vres;        // screen dimensions

    switch (messg) {
        /*
         * WM_CREATE: get instance handle for later use putting up
         *            dialog box.  Get initial colors for windows and menus
         *            so they can be restored upon exit (unless the user
         *            remembers to do it).
         */
        case WM_CREATE:
            hInst = ((LPCREATESTRUCT) lParam) -> hInstance;
            dwSavedColorInfo[0] = GetSysColor(COLOR_MENUTEXT);
            dwSavedColorInfo[1] = GetSysColor(COLOR_MENU);
            bNeedToRestoreColors = FALSE;
            break;
        /*
         * WM_DESTROY: If user forgot to restore colors, do it.  Then
         *                         terminate this window.
         */
        case WM_DESTROY:
            if (bNeedToRestoreColors) {
                SetSysColors(2,iDisplayElements,dwSavedColorInfo);
                bNeedToRestoreColors = FALSE;
            }
            PostQuitMessage(0);
            break;
        /*
         * WM_PAINT: Put the text string into the window, at the center
         *           of the client area.
         */
        case WM_PAINT:
            hdc = BeginPaint(hWnd,&ps);
            GetTextExtentPoint(hdc,lpstrHiWorld,strlen(lpstrHiWorld),lpSize);
            TextOut(hdc,(newX-(lpSize->cx))/2, (newY-(lpSize->cy))/2, lpstrHiWorld,strlen(lpstrHiWorld));
            EndPaint(hWnd,&ps);
            break;
        /*
         * WM_SIZE: save new x and y coordinates to use later in
         *          centering
         */
        case WM_SIZE:
            newX = LOWORD(lParam);
            newY = HIWORD(lParam);
            break;
        /*
         * WM_COMMAND: see individual items
         */
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                /*
                 * IDM_LOCALTIME: Get the local time, put it into a string,
                 *                then output it via a message box
                 */
                case IDM_LOCALTIME:
                    GetLocalTime(lpSysTime);
                    sprintf(lpstrOutString,"Today is \n\t%02d/%02d/%02d\n and the time is \n\t%02d:%02d:%02d",
                            lpSysTime->wMonth,
                            lpSysTime->wDay,
                            lpSysTime->wYear-1900,
                            lpSysTime->wHour,
                            lpSysTime->wMinute,
                            lpSysTime->wSecond);
                    MessageBox(hWnd,lpstrOutString,"Local time",MB_OK);
                    break;
                /*
                 * IDM_UPTIME: Get the current time, put it into a string,
                 *             then output it via a message box
                 */
                case IDM_UPTIME:
                    dElapsedTimeSysHasBeenUp = GetCurrentTime();
                    dOtherTime = timeGetTime();
                    sprintf(lpstrOutString,"System has been up for:\n\t%d milliseconds (GetCurrentTime)\n\t%d milliseconds (timeGetTime)",
                            dElapsedTimeSysHasBeenUp,dOtherTime);
                    MessageBox(hWnd,lpstrOutString,"Time since system was booted",MB_OK);
                    break;
                /*
                 * IDM_SHOWCOLORS: Get the current menu text and menu background
                 *                 colors.  Put them into a text string then
                 *                 output them via a message box.
                 */
                case IDM_SHOWCOLORS:
                    i = 0;
                    dwCheckColorInfo[0] = GetSysColor(COLOR_MENUTEXT);
                    strcpy(lpstrOutString,"Menu text is ");
                    i += strlen(lpstrOutString);
                    RGB2Text(dwCheckColorInfo[0],&lpstrOutString[i]);
                    dwCheckColorInfo[1] = GetSysColor(COLOR_MENU);
                    strcat(lpstrOutString,"Menu background is ");
                    i = strlen(lpstrOutString);
                    RGB2Text(dwCheckColorInfo[1],&lpstrOutString[i]);
                    MessageBox(hWnd,lpstrOutString,"Color Information",MB_OK);
                    break;
                /*
                 * IDM_CHANGECOLORS: Enable the "restore" menu item.  Set flag to
                 *                   ensure that we clean up, then change the
                 *                   menu text and menu background colors.
                 */
                case IDM_CHANGECOLORS:
                    EnableMenuItem(GetMenu(hWnd),IDM_RESTORECOLORS,MF_ENABLED|MF_BYCOMMAND);
                    bNeedToRestoreColors = TRUE;
                    SetSysColors(2,iDisplayElements,dwNewColorInfo);
                    break;
                /*
                 * IDM_RESTORECOLORS: Disable the "restore" menu item.  Clear the
                 *                    cleanup flag, then change the
                 *                    menu text and menu background colors
                 *                    back to their original values.
                 */
                case IDM_RESTORECOLORS:
                    EnableMenuItem(GetMenu(hWnd),IDM_RESTORECOLORS,MF_GRAYED|MF_BYCOMMAND);
                    bNeedToRestoreColors = FALSE;
                    SetSysColors(2,iDisplayElements,dwSavedColorInfo);
                    break;
                /*
                 * IDM_SCRDIM: Get the screen dimensions, put them into a string,
                 *             then output it via a message box
                 */
                case IDM_SCRDIM:
                    hdc = GetDC(hWnd);
                    hsize = GetDeviceCaps(hdc,HORZSIZE);
                    vsize = GetDeviceCaps(hdc,VERTSIZE);
                    hres = GetDeviceCaps(hdc,HORZRES);
                    vres = GetDeviceCaps(hdc,VERTRES);
                    sprintf(lpstrOutString,
                            "Horizontal size:\t\t%d mm\nVertical Size:\t\t%d mm\nHorizontal resolution:\t%d pixels\nVertical Resolution:\t%d pixels",
                            hsize,vsize,hres,vres);
                    ReleaseDC(hWnd,hdc);
                    MessageBox(hWnd,lpstrOutString,"Screen Dimensions",MB_OK);
                    break;
                /*
                 * IDM_BEEP: Display beep dialog box.
                 */
                case IDM_BEEP:
                    DialogBox(hInst,MAKEINTRESOURCE(BEEPDIALOG),hWnd,BeepDiaProc);
                    break;
                /*
                 * WM_DESTROY: If user forgot to restore colors, do it.  Then
                 *                 terminate this window.
                 */
                case IDM_EXIT:
                    if (bNeedToRestoreColors) {
                        SetSysColors(2,iDisplayElements,dwSavedColorInfo);
                        bNeedToRestoreColors = FALSE;
                    }
                    PostQuitMessage(0);
                    break;
                default:
                    return(DefWindowProc(hWnd,messg,wParam,lParam));
                }
                break;
        default:
            return(DefWindowProc(hWnd,messg,wParam,lParam));
        }
        return(0L);
}
示例#11
0
/************************************************************************
*
*   SteCreate - WM_CREATE message handler
*
************************************************************************/
void SteCreate( 
    HWND hWnd )
{
    HDC        hdc;
    TEXTMETRIC tm = {0};
    int        i;
    WORD       patern = 0xA4A4;
    SIZE       size;
    HFONT      hFont;
    LOGFONT    lFont = {0};

    //
    // Note that this window has a class DC
    //

    hdc = GetDC( hWnd );

    //
    // Select fixed pitch system font and get its text metrics
    //

    hfntFixed = GetStockObject( SYSTEM_FIXED_FONT );
    hfntOld = SelectObject( hdc, hfntFixed );
    GetTextMetrics( hdc, &tm );
    ReleaseDC( hWnd, hdc );

    GetTextExtentPoint( hdc, (LPSTR)&patern, sizeof( WORD), (LPSIZE) &size );

//    cxMetrics = tm.tmAveCharWidth;
//    cyMetrics = tm.tmHeight;

    cxMetrics = (UINT) size.cx / 2;
    cyMetrics = (UINT) size.cy;

    //
    // Determine the version of DBCS Windows from system font charset ID.
    // Then hardcode a DBCS character value for the 'Pattern/DBCS' command.
    // The value is the Han character for 'door' or 'gate', which is
    // left-right symmetrical.
    //

    switch( tm.tmCharSet )
    {
    case SHIFTJIS_CHARSET:
        DBCSFillChar = 0x96e5;
        break;

    case HANGEUL_CHARSET:
        DBCSFillChar = 0xdaa6;
        break;

    case CHINESEBIG5_CHARSET:
        DBCSFillChar = 0xaaf9;
        break;

    default:
        DBCSFillChar = 0x7071;  // 'pq'
        break;
    }

    //                   
    // Initialize caret width.  Fat in INSERT mode, skinny in OVERTYPE mode.
    //

    fInsertMode = FALSE;
    CaretWidth = cxOverTypeCaret = GetSystemMetrics( SM_CXBORDER );

    //
    // Sets the logical font to be used to display characters in the 
    // composition window. Especially for at caret or near caret operation, 
    // application should set composition font.
    //
    // If Application provides user to dynamicly change font, each time after
    // user change font, application should set composition font again.
    //

    if ( ( hFont = (HFONT)SendMessage( hWnd, WM_GETFONT, 0, 0L ) ) != NULL )
    {
        if ( GetObject( hFont, sizeof(LOGFONT), (LPVOID)&lFont ) )
        {
            HIMC	hImc;

            if ( (  hImc = ImmGetContext( hWnd ) ) )
            {
                ImmSetCompositionFont( hImc, &lFont );
                ImmReleaseContext( hWnd, hImc );
            }
        }
    }

    //
    // Get the property and apiabilities of current keyboard layout(IME).
    // If the keyboard layout is US, the return value will be zero.
    //

    gImeUIData.fdwProperty = ImmGetProperty( GetKeyboardLayout(0),
                                             IGP_PROPERTY );

    //
    // Initialize candidate list window array.
    //

    for( i = 0; i < MAX_LISTCAND; i++ )
    {
         gImeUIData.hListCand[ i ] = NULL;
         gImeUIData.hListCandMem[ i ] = NULL;
    }


    PostMessage( hWnd, WM_COMMAND, IDC_CLEAR, 0L );


    //
    // Initialise the current keyboard layout.
    //
    
    hCurKL = GetKeyboardLayout(0L);
}
示例#12
0
文件: Dialogs.cpp 项目: braun/LK8000
HWND CreateProgressDialog(TCHAR* text) {

  static int yFontSize, xFontSize;
  HDC	hTempDC = NULL;


  if (doinitprogress) {

	doinitprogress=false;

	DWORD Style=0;
	Style = WS_CHILD | ES_MULTILINE | ES_CENTER | ES_READONLY | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

	hStartupWindow=CreateWindow(TEXT("STATIC"), TEXT("\0"), Style, 0, 0, ScreenSizeX, ScreenSizeY, hWndMainWindow, NULL, hInst, NULL);
	if (hStartupWindow==NULL) {
		StartupStore(_T("***** CRITIC, no startup window!%s"),NEWLINE);
		FailStore(_T("CRITIC, no startup window!"));
		return NULL;
	}
	if (!(hStartupDC = GetDC(hStartupWindow))) {
		StartupStore(_T("------ Cannot state startup window%s"),NEWLINE);
		FailStore(_T("Cannot state startup window"));
		return(NULL);
	}
/*
	SHFullScreen(hProgress, SHFS_HIDETASKBAR |SHFS_HIDESIPBUTTON |SHFS_HIDESTARTICON);
	SetWindowPos(hProgress,HWND_TOP,0,0,0,0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
*/
	//RECT rt;
	//GetClientRect(hStartupWindow,&rt);
	//FillRect(hStartupDC,&rt,(HBRUSH)GetStockObject(BLACK_BRUSH));
	//SetWindowPos(hStartupWindow,HWND_TOP,0,0,0,0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
	//SHFullScreen(hStartupWindow, SHFS_HIDETASKBAR |SHFS_HIDESIPBUTTON |SHFS_HIDESTARTICON); 
	//SetForegroundWindow(hStartupWindow);
	//UpdateWindow(hStartupWindow);

	ShowWindow(hStartupWindow,SW_SHOWNORMAL);
	BringWindowToTop(hStartupWindow);

	// Load welcome screen bitmap
	HBITMAP hWelcomeBitmap=NULL;
	TCHAR sDir[MAX_PATH];
        TCHAR srcfile[MAX_PATH];
        LocalPath(sDir,TEXT(LKD_BITMAPS));

	// first look for lkstart_480x272.bmp for example
	_stprintf(srcfile,_T("%s\\LKSTART_%s.BMP"),sDir, GetSizeSuffix() );

        if (  GetFileAttributes(srcfile) == 0xffffffff ) {
		// no custom file, get a generic one
		switch(ScreenSize) {
			case ss800x480:
			case ss640x480:
			case ss720x408:
			case ss896x672:
				_stprintf(srcfile,_T("%s\\LKSTART_LB.BMP"),sDir);
				break;

			case ss480x272:
			case ss480x234:
			case ss400x240:
			case ss320x240:
				_stprintf(srcfile,_T("%s\\LKSTART_LS.BMP"),sDir);
				break;

			case ss480x640:
			case ss480x800:
				_stprintf(srcfile,_T("%s\\LKSTART_PB.BMP"),sDir);
				break;

			case ss240x320:
			case ss272x480:
				_stprintf(srcfile,_T("%s\\LKSTART_PS.BMP"),sDir);
				break;

			default:
				_stprintf(srcfile,_T("%s\\LKSTART_DEFAULT.BMP"),sDir);
				break;
		}
	}
	#if (WINDOWSPC>0)
	hWelcomeBitmap=(HBITMAP)LoadImage(GetModuleHandle(NULL),srcfile,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
	#else
	hWelcomeBitmap=(HBITMAP)SHLoadDIBitmap(srcfile);
	#endif
	// still nothing? use internal (poor man) resource
	if (hWelcomeBitmap==NULL)
		hWelcomeBitmap=LoadBitmap(hInst, MAKEINTRESOURCE(IDB_SWIFT));

	hTempDC = CreateCompatibleDC(hStartupDC);

	// AA
	HBITMAP oldBitmap = (HBITMAP)SelectObject(hTempDC, hWelcomeBitmap);
        SelectObject(hTempDC, LKSTARTBOTTOMFONT);
	SIZE TextSize;
        GetTextExtentPoint(hTempDC, _T("X"),1, &TextSize);
        yFontSize = TextSize.cy;
        xFontSize = TextSize.cx;

	BITMAP bm;
	GetObject(hWelcomeBitmap,sizeof(bm), &bm);

	StretchBlt(hStartupDC,0,0, 
		ScreenSizeX,ScreenSizeY-1, 
		hTempDC, 0, 0, 
		2,2,
		BLACKNESS);

	if ( (bm.bmWidth >ScreenSizeX)||(bm.bmHeight>ScreenSizeY)) {
		StretchBlt(hStartupDC,0,0, 
			ScreenSizeX,ScreenSizeY-NIBLSCALE(2)-(yFontSize*2)-1, 
			hTempDC, 0, 0, 
			bm.bmWidth,bm.bmHeight,
			SRCCOPY);
	} else {
		BitBlt(hStartupDC,(ScreenSizeX-bm.bmWidth)/2,0,bm.bmWidth,bm.bmHeight,hTempDC, 0, 0, SRCCOPY);
	}


	DeleteObject(hWelcomeBitmap);

	// AA


	SelectObject(hTempDC, oldBitmap);
	if (DeleteDC(hTempDC)==0) StartupStore(_T("**** Cannot delete hTempDC\n"));
  }

  BringWindowToTop(hStartupWindow); // we shall return here also on shutdown and file reloads

  // RECT is left, top, right, bottom
  RECT PrintAreaR; 
  PrintAreaR.left   = NIBLSCALE(2);
  PrintAreaR.bottom = ScreenSizeY-NIBLSCALE(2);
  PrintAreaR.top    = PrintAreaR.bottom - (yFontSize*2);
  PrintAreaR.right  = ScreenSizeX - NIBLSCALE(2);

  HFONT oldFont=(HFONT)SelectObject(hStartupDC,LKSTARTBOTTOMFONT);

  HBRUSH hB=LKBrush_Petrol;
  FillRect(hStartupDC,&PrintAreaR, hB);

  // Create text area

  // we cannot use LKPen here because they are not still initialised for startup menu. no problem
  HPEN hP=(HPEN)  CreatePen(PS_SOLID,NIBLSCALE(1),RGB_GREEN);
  SelectObject(hStartupDC,hP);
  SelectObject(hStartupDC,hB);
  Rectangle(hStartupDC, PrintAreaR.left,PrintAreaR.top,PrintAreaR.right,PrintAreaR.bottom);
  DeleteObject(hP);

  hP=(HPEN)  CreatePen(PS_SOLID,NIBLSCALE(1),RGB_BLACK);
  SelectObject(hStartupDC,hP);
  Rectangle(hStartupDC, PrintAreaR.left+NIBLSCALE(2),PrintAreaR.top+NIBLSCALE(2),PrintAreaR.right-NIBLSCALE(2),PrintAreaR.bottom-NIBLSCALE(2));

  SetTextColor(hStartupDC,RGB_WHITE);
  SetBkMode(hStartupDC,TRANSPARENT);

  unsigned int maxchars= (ScreenSizeX/xFontSize)-1;
  if (_tcslen(text) <maxchars) {
	maxchars=_tcslen(text);
  }
  ExtTextOut(hStartupDC,PrintAreaR.left+(xFontSize/2),PrintAreaR.top + ((PrintAreaR.bottom - PrintAreaR.top)/2)-(yFontSize/2),
	ETO_OPAQUE,NULL,text,maxchars,NULL);

  SelectObject(hStartupDC,oldFont);
  // Sleep(300); // Slow down display of data? No because in case of important things, Sleep is set by calling part

  DeleteObject(hP);


  return hStartupWindow;
}
示例#13
0
VOID TextTest(HDC hdc)
{

    LOGFONT lfnt;                  // dummy logical font description
    HFONT   hfont;                 // handle to dummy font
    HFONT   hfontUnderline,hfontStrikeOut;              // handle of font originally in DC
    HRGN    hrgnTmp;
    int     y;

#ifdef  DOS_PLATFORM
#define MAX_LENGTH  80
    char    aBuffer[MAX_LENGTH];
#endif  //DOS_PLATFORM

// Create a logical font

#ifndef DOS_PLATFORM
    memset(&lfnt, 0, sizeof(lfnt));
#else
    memzero(&lfnt, sizeof(lfnt));
#endif  //DOS_PLATFORM

    lfnt.lfHeight     = 24;
    lfnt.lfEscapement = 0; // mapper respects this filed
    lfnt.lfUnderline  = 0; // no underline
    lfnt.lfStrikeOut  = 0; // no strike out
    lfnt.lfItalic     = 0;
    lfnt.lfWeight     = 400; // normal

    strcpy(lfnt.lfFaceName, DEFAULT_FACENAME);

    if ((hfont = CreateFontIndirect(&lfnt)) == NULL)
    {
        DbgPrint("Logical font creation failed.\n");
        return;
    }

    lfnt.lfUnderline  = 1; // underline

    if ((hfontUnderline = CreateFontIndirect(&lfnt)) == NULL)
    {
        DbgPrint("Logical font creation failed.\n");
        return;
    }

    lfnt.lfUnderline  = 0; // underline
    lfnt.lfStrikeOut  = 1; // no underline

    if ((hfontStrikeOut = CreateFontIndirect(&lfnt)) == NULL)
    {
        DbgPrint("Logical font creation failed.\n");
        return;
    }

// Select font into DC

    SelectObject(hdc, hfont);

// Set text alignment

    SetTextAlign(hdc, TA_LEFT | TA_TOP | TA_NOUPDATECP);

//

// List the character widths

    vListCharWidths(hdc);
    vDoPause(0);

// Clear screen

    BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, BLACKNESS);

    SetTextColor(hdc, RGB(127,127,0));
    SetBkColor(hdc, RGB(0,255,0));

// nonclipped underlined text

// Select font into DC

    SelectObject(hdc, hfontUnderline);

    TextOut(hdc, 0, 0, "This is normal text.", 20);

    SelectObject(hdc, hfont);

// Inverse text

    BitBlt(hdc, 0, 30, MAX_CX, 30, (HDC) 0, 0, 0, WHITENESS);

    SetROP2(hdc, R2_BLACK);

    TextOut(hdc, 0, 30, "This is inverse text.", 21);

    SetROP2(hdc, R2_WHITE);

// Clipped text (simple retangular region)

    hrgnTmp = CreateRectRgn(10, 70, MAX_CX, 90);
    SelectClipRgn(hdc, hrgnTmp);
    DeleteObject(hrgnTmp);

    TextOut(hdc, 0, 60, "This is clipped text.", 21);

// Clipped text (circular region)

    hrgnTmp = hrgnCircle(150, 240, 150);
    SelectClipRgn(hdc, hrgnTmp);
    DeleteObject(hrgnTmp);

    BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

    SetROP2(hdc, R2_BLACK);

    SelectObject(hdc, hfontStrikeOut);
    TextOut(hdc, 0, 120, "There was a young man from Wight,", 33);
    TextOut(hdc, 0, 150, "Who travelled much faster then light.", 37);
    SelectObject(hdc, hfontUnderline);
    TextOut(hdc, 0, 180, "He left home one day", 20);
    TextOut(hdc, 0, 210, "In a relative way,", 18);
    TextOut(hdc, 0, 240, "And arrived home the previous night.", 36);

    hrgnTmp = CreateRectRgn(0, 0, MAX_CX, MAX_CY);
    SelectClipRgn(hdc, hrgnTmp);
    DeleteObject(hrgnTmp);


    SelectObject(hdc, hfont);
    SetTextColor(hdc, RGB(127,127,0));

    {
    // check that update current position mode works properly
        SIZE  size;
        POINT pt;
        PSZ   pszExtent;
        LOGFONT lfntEsc;
        HFONT   hfntOld, hfntEsc;

        vDoPause(0);

        BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

        y = 30;

        TextOut(hdc, 0, y  , "Once upon a time there was a young man from Wight,", strlen("Once upon a time there was a young man from Wight,"));
        y += 30;

        GetCurrentPositionEx(hdc,&pt);
        DbgPOINT(&pt,"before MoveToEx");

        SetTextAlign(hdc, TA_LEFT | TA_TOP | TA_UPDATECP);

        MoveToEx(hdc, 0, y, &pt);

        GetCurrentPositionEx(hdc,&pt);
        DbgPOINT(&pt,"before " );

        TextOut(hdc, 0, 0 , "Once upon a time ", strlen("Once upon a time "));

        GetCurrentPositionEx(hdc,&pt);
        DbgPOINT(&pt,"after " );

        // change bk color to observe another textOut call
        SetBkColor(hdc, RGB(0,0,255));

        TextOut(hdc, 0, 0 , "there was a young man from Wight,", strlen("there was a young man from Wight,"));

        SetTextAlign(hdc, TA_LEFT | TA_TOP | TA_NOUPDATECP);
        SetBkColor(hdc, RGB(0,255,0));

    // get text extent test,

        pszExtent = "iiiiiiiiii";

        TextOut(hdc,200,100, pszExtent, strlen(pszExtent));
        GetTextExtentPoint(hdc, pszExtent, strlen(pszExtent), &size);
        DbgPrint("%s, cx = %ld, cy = %ld\n", pszExtent, size.cx, size.cy);

        pszExtent = "iiiiWWiiii";

        TextOut(hdc,200,150, pszExtent, strlen(pszExtent));
        GetTextExtentPoint(hdc, pszExtent, strlen(pszExtent), &size);
        DbgPrint("%s, cx = %ld, cy = %ld\n", pszExtent, size.cx, size.cy);

    // see whether text extent works with font with escapement

    // Create a logical font

    #ifndef DOS_PLATFORM
        memset(&lfntEsc, 0, sizeof(lfnt));
    #else
        memzero(&lfntEsc, sizeof(lfnt));
    #endif  //DOS_PLATFORM

        lfntEsc.lfHeight     = 18;
        lfntEsc.lfEscapement = 450; // 45 degrees
        lfntEsc.lfUnderline  = 0;   // no underline
        lfntEsc.lfStrikeOut  = 0;   // no strike out
        lfntEsc.lfItalic     = 0;
        lfntEsc.lfWeight     = 400; // normal

        if ((hfntEsc = CreateFontIndirect(&lfntEsc)) == NULL)
        {
            DbgPrint("Logical font creation failed.\n");
            return;
        }

        hfntOld = SelectObject(hdc, hfntEsc);

        pszExtent = "iiiiiiiiii";

        TextOut(hdc,100,200, pszExtent, strlen(pszExtent));
        GetTextExtentPoint(hdc, pszExtent, strlen(pszExtent), &size);
        DbgPrint("%s, cx = %ld, cy = %ld\n", pszExtent, size.cx, size.cy);
        Rectangle(hdc,100,300,100 + size.cx,300 + size.cy);

        pszExtent = "iiiiWWiiii";

        TextOut(hdc,400,200, pszExtent, strlen(pszExtent));
        GetTextExtentPoint(hdc, pszExtent, strlen(pszExtent), &size);
        DbgPrint("%s, cx = %ld, cy = %ld\n", pszExtent, size.cx, size.cy);
        Rectangle(hdc,400,300,400 + size.cx,300 + size.cy);

        SelectObject(hdc, hfntOld);

    }

    {
    // test for emboldening and italicizing

        char ach[] = {0,1,2,4,32,88};

        HFONT  hfontBold, hfontItalic, hfontBoldItalic, hfontOld;
        char * pszString = "string";

        vDoPause(0);
        BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

        lfnt.lfStrikeOut = 0;
        lfnt.lfWeight = 700;        // bold

        if ((hfontBold = CreateFontIndirect(&lfnt)) == NULL)
        {
            DbgPrint("Logical font creation failed.\n");
            return;
        }

        lfnt.lfWeight = 400;        // normal
        lfnt.lfItalic = 1;

        if ((hfontItalic = CreateFontIndirect(&lfnt)) == NULL)
        {
            DbgPrint("Logical font creation failed.\n");
            return;
        }

        lfnt.lfWeight = 700;        // bold

        if ((hfontBoldItalic = CreateFontIndirect(&lfnt)) == NULL)
        {
            DbgPrint("Logical font creation failed.\n");
            return;
        }

        lfnt.lfWeight = 400;        // normal
        lfnt.lfItalic = 0;

    // trying a string of chars with couple of chars out of range of the font


        TextOut
        (
        hdc,
        40,
        40,
        "trying a string of chars with couple of chars out of range of the font",
        strlen("trying a string of chars with couple of chars out of range of the font")
        );

        TextOut(hdc, 80, 80, (LPSTR)ach, sizeof(ach));

        vDoPause(0);

        BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

        y = 40;
        TextOut(hdc, 0, y, "string" , strlen("string"));

        y += 40;
        bTextOut(hdc,hfontBold, 0, y, pszString);


        y += 40;
        bTextOut(hdc,hfontItalic, 0, y, pszString);


        y += 40;
        bTextOut(hdc,hfontBoldItalic, 0, y, pszString);

// couple of more strings, just for the fun of it

        y += 80;
        bTextOut(hdc,hfontItalic, 0, y, "These are funny italic strings:" );
        y += 40;
        bTextOut(hdc,hfontItalic,   0, y, "UuuuU" );
        bTextOut(hdc,hfontItalic, 100, y, "WvvvW" );
        bTextOut(hdc,hfontItalic, 200, y, "VvvvV" );
        bTextOut(hdc,hfontItalic, 300, y, "YyyyY" );
        bTextOut(hdc,hfontItalic, 400, y, " 2 break chars " );

        y += 80;
        bTextOut(hdc,hfontBoldItalic, 0, y, "These are silly bold italic strings:" );
        y += 40;
        bTextOut(hdc,hfontBoldItalic,   0, y, "UuuuU" );
        bTextOut(hdc,hfontBoldItalic, 100, y, "WvvvW" );
        bTextOut(hdc,hfontBoldItalic, 200, y, "VvvvV" );
        bTextOut(hdc,hfontBoldItalic, 300, y, "YyyyY" );
        bTextOut(hdc,hfontBoldItalic, 400, y, " 2 break chars " );

        DeleteObject(hfontBold);
        DeleteObject(hfontItalic);
        DeleteObject(hfontBoldItalic);
    }

    {
    // test fonts that are both emboldened and/or
    // italicized  and striked out and/or outlined

        HFONT  hfontBoldStrikeUnder,
               hfontItalicUnder,
               hfontBoldItalicUnder,
               hfontItalicStrike,
               hfontBoldItalicStrikeUnder;  // wow, what a font !!!

        char * pszString = "string";

        vDoPause(0);
        BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

        lfnt.lfItalic = 0;
        lfnt.lfWeight = 700;        // bold
        lfnt.lfStrikeOut = 1;
        lfnt.lfUnderline = 1;

        if ((hfontBoldStrikeUnder = CreateFontIndirect(&lfnt)) == NULL)
        {
            DbgPrint("Logical font creation failed.\n");
            return;
        }

        lfnt.lfItalic = 1;
        lfnt.lfWeight = 400;
        lfnt.lfStrikeOut = 0;
        lfnt.lfUnderline = 1;

        if ((hfontItalicUnder = CreateFontIndirect(&lfnt)) == NULL)
        {
            DbgPrint("Logical font creation failed.\n");
            return;
        }

        lfnt.lfItalic = 1;
        lfnt.lfWeight = 700;
        lfnt.lfStrikeOut = 0;
        lfnt.lfUnderline = 1;

        if ((hfontBoldItalicUnder = CreateFontIndirect(&lfnt)) == NULL)
        {
            DbgPrint("Logical font creation failed.\n");
            return;
        }

        lfnt.lfItalic = 1;
        lfnt.lfWeight = 400;
        lfnt.lfStrikeOut = 1;
        lfnt.lfUnderline = 0;

        if ((hfontItalicStrike = CreateFontIndirect(&lfnt)) == NULL)
        {
            DbgPrint("Logical font creation failed.\n");
            return;
        }

        lfnt.lfItalic = 1;
        lfnt.lfWeight = 700;
        lfnt.lfStrikeOut = 1;
        lfnt.lfUnderline = 1;

        if ((hfontBoldItalicStrikeUnder = CreateFontIndirect(&lfnt)) == NULL)
        {
            DbgPrint("Logical font creation failed.\n");
            return;
        }

    // "clear" logfont

        lfnt.lfItalic = 0;
        lfnt.lfWeight = 400;
        lfnt.lfStrikeOut = 0;
        lfnt.lfUnderline = 0;


        y = 40;
        bTextOut(hdc,hfont, 20, y, "Normal font : YYYYYY");

        y += 40;
        bTextOut(hdc,hfontBoldStrikeUnder, 20, y, "Bold Striked Out and Underlined font : YYYY");


        y += 40;
        bTextOut(hdc,hfontItalicUnder, 20, y, "Italicized Underlined font: YYYY");


        y += 40;
        bTextOut(hdc,hfontBoldItalicUnder, 20, y, "Underlined Bold Italic font :askpW");

        y += 40;
        bTextOut(hdc,hfontItalicStrike, 20, y, "Striked Out Italic font :askpW");

        y += 40;
        bTextOut(hdc,hfontBoldItalicStrikeUnder, 20, y, "Underlined and Striked Out Bold Italic font :askpW");

        DeleteObject(hfontBoldStrikeUnder);
        DeleteObject(hfontItalicUnder);
        DeleteObject(hfontBoldItalicUnder);
        DeleteObject(hfontItalicStrike);
        DeleteObject(hfontBoldItalicStrikeUnder);
    }



    {
    // check whether mapper can select different sizes from an *.fon file
    // and choose bold, italic and bold_italic fonts

        HFONT  hfontHt;

        short     alfHeight[6] = {13, 16, 19, 23, 27, 35};
        int       iHt;
        int       iName;
        PSZ       pszComment = "Trying to map to the face name: ";

        for (iName = 0; iName < sizeof(apszFaceName)/4; iName++)
        {
            #ifndef DOS_PLATFORM
                memset(&lfnt, 0, sizeof(lfnt));
            #else
                memzero(&lfnt, sizeof(lfnt));
            #endif  //DOS_PLATFORM
            strcpy(lfnt.lfFaceName, apszFaceName[iName]);

            vDoPause(0);
            BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

            lfnt.lfItalic = 0;
            lfnt.lfWeight = 400;
            lfnt.lfStrikeOut = 0;
            lfnt.lfUnderline = 0;

            SetTextAlign(hdc, TA_UPDATECP);
            MoveToEx(hdc,60,40,NULL);
            TextOut(hdc,0,0,pszComment, strlen(pszComment));
            TextOut(hdc, 0, 0,  apszFaceName[iName], strlen(apszFaceName[iName]));
            SetTextAlign(hdc, TA_NOUPDATECP);

            y = 80;

            for (iHt = 0L; iHt < 6L; iHt++)
            {
                lfnt.lfHeight = alfHeight[iHt];

                if ((hfontHt = CreateFontIndirect(&lfnt)) == NULL)
                {
                    DbgPrint("Logical font creation failed.\n");
                    return;
                }

                bTextOut(hdc,hfontHt, 20, y, "Normal: Different font sizes from an *.fon file");
                y += 40;
                DeleteObject(hfontHt);
            }

            vDoPause(0);
            BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

            SetTextAlign(hdc, TA_UPDATECP);
            MoveToEx(hdc,60,40,NULL);
            TextOut(hdc,0,0,pszComment, strlen(pszComment));
            TextOut(hdc, 0, 0,  apszFaceName[iName], strlen(apszFaceName[iName]));
            SetTextAlign(hdc, TA_NOUPDATECP);

            lfnt.lfItalic = 1;
            lfnt.lfWeight = 700;
            lfnt.lfStrikeOut = 0;
            lfnt.lfUnderline = 0;

            y = 80;

            for (iHt = 0L; iHt < 6L; iHt++)
            {
                lfnt.lfHeight = alfHeight[iHt];

                if ((hfontHt = CreateFontIndirect(&lfnt)) == NULL)
                {
                    DbgPrint("Logical font creation failed.\n");
                    return;
                }

                bTextOut(hdc,hfontHt, 20, y, "Bold Italic: Different font sizes from an *.fon file");
                y += 40;
                DeleteObject(hfontHt);
            }
        }
    }


    {
        vDoPause(0);

    // this part of the test tests the SetTextJustification functionality

        BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

        y = 30;

    // first print strings without justification to see how long they are

        TextOut(hdc, 0, y       , "There was a young man from Wight,", 33);      // 120
        TextOut(hdc, 0, y + 30  , "Who travelled much faster then light.", 37);  // 150
        TextOut(hdc, 0, y + 60  , "He left home one day", 20);                   // 180
        TextOut(hdc, 0, y + 90  , "In a relative way,", 18);                     // 210
        TextOut(hdc, 0, y + 120 , "And arrived home the previous night.", 36);   // 240

        y += 190;

    // coerce strings to have total length CX_LEN by addjusting spaces that
    // correspond to break chars

    // add more space to break chars (positive dda) (CX_LEN > text extent)

        vJustify(hdc, 0, y ,       "There was a young man from Wight,",    CX_LEN);      // 120
        vJustify(hdc, 0, y + 30  , "Who travelled much faster then light.",CX_LEN);  // 150
        vJustify(hdc, 0, y + 60  , "He left home one day",                 CX_LEN);                   // 180
        vJustify(hdc, 0, y + 90  , "In a relative way,",                   CX_LEN);                     // 210
        vJustify(hdc, 0, y + 120 , "And arrived home the previous night.", CX_LEN);   // 240
    }

    {
        vDoPause(0);

    // add more space to break chars (positive dda) (CX_LEN > text extent)

        BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

        y = 30;

    // first print strings without justification to see how long they are

        TextOut(hdc, 0, y       , "Once upon a time there was a young man from Wight,", strlen("Once upon a time there was a young man from Wight,"));
        TextOut(hdc, 0, y + 30  , "Who travelled much much much faster then light."   , strlen("Who travelled much much much faster then light."   ));
        TextOut(hdc, 0, y + 60  , "Nobody knows why he left home one day"             , strlen("Nobody knows why he left home one day"             ));                   // 180
        TextOut(hdc, 0, y + 90  , "Nor why he did it in a very relative way,"         , strlen("Nor why he did it in a very relative way,"         ));                     // 210
        TextOut(hdc, 0, y + 120 , "And arrived back home the previous night."         , strlen("And arrived back home the previous night."         ));

        y += 190;

        vJustify(hdc, 0, y ,       "Once upon a time there was a young man from Wight," ,CX_LEN);
        vJustify(hdc, 0, y + 30  , "Who travelled much much much faster then light."    ,CX_LEN);
        vJustify(hdc, 0, y + 60  , "Nobody knows why he left home one day"              ,CX_LEN);
        vJustify(hdc, 0, y + 90  , "Nor why he did it in a very relative way,"          ,CX_LEN);                     // 210
        vJustify(hdc, 0, y + 120 , "And arrived back home the previous night."          ,CX_LEN);

    }

    {

        vDoPause(0);

    // justifying two or more strings with a single set text justification

        BitBlt(hdc, 0, 0, MAX_CX, MAX_CY, (HDC) 0, 0, 0, WHITENESS);

        y = 30;

        TextOut(hdc, 0, y  , "Once upon a time there was a young man from Wight,", strlen("Once upon a time there was a young man from Wight,"));
        y += 30;
        vJustify(hdc, 0, y , "Once upon a time there was a young man from Wight," ,CX_LEN);
        y += 30;
        vJustify2(hdc, 0, y , "Once upon a time there", " was a young man from Wight," ,CX_LEN);
        y += 30;
        vJustify3(hdc, 0, y , "Once upon a ti","me there was a young"," man from Wight," ,CX_LEN);
        y += 30;
        vJustify3(hdc, 0, y , "Once ","upon a time there was a young"," man from Wight," ,CX_LEN);
        y += 90;

    // this string is shorter than CX_LEN

        TextOut(hdc, 0, y , "There was a young man from Wight,", 33);      // 120
        y += 30;
        vJustify(hdc, 0, y , "There was a young man from Wight,",    CX_LEN);      // 120
        y += 30;
        vJustify2(hdc, 0, y , "There was a y","oung man from Wight,",    CX_LEN);      // 120
        y += 30;
        vJustify3(hdc, 0, y , "The","re was a young"," man from Wight,",    CX_LEN);      // 120
        y += 30;
        vJustify3(hdc, 0, y , "There wa","s a young"," man from Wight,",    CX_LEN);      // 120
    }
}
示例#14
0
tlFont::tlFont(LPDIRECT3DDEVICE9 dev_) {
	dev=dev_;
	HDC hdc = GetDC(NULL);
	HDC mdc = CreateCompatibleDC(hdc);
	HBITMAP bm = CreateCompatibleBitmap(hdc,WRITER_WIDTH,WRITER_HEIGHT);     

	int size = 32;
	int track = 5;
	HFONT hf=CreateFont(size, 0, 0, 0, FW_NORMAL, 
	0  , FALSE, FALSE,
	DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, 
	ANTIALIASED_QUALITY, DEFAULT_PITCH,"Verdana");

	unsigned int * buffer = new unsigned int[WRITER_WIDTH*WRITER_HEIGHT];

	RECT r={0,0,WRITER_WIDTH,WRITER_HEIGHT};

	SelectObject(mdc, bm);
	FillRect(mdc, &r, (HBRUSH)GetStockObject(BLACK_BRUSH));

	SelectObject(mdc, hf);      
	SetBkMode(mdc, TRANSPARENT);
	SetTextColor(mdc, 0xFFFFFF);
	int x=0;
	int y=0;
	for (int i=0; i<256; i++) {
		char s[2]={i,0};
		TextOut(mdc, x, y, s, 1);

		SIZE sz;
		GetTextExtentPoint(mdc,s,1,&sz);
		texcoordu1[i]=x/(float)WRITER_WIDTH;	x+=sz.cx;
		texcoordu2[i]=x/(float)WRITER_WIDTH;	x+=track;

		texcoordv1[i]= y       /(float)WRITER_WIDTH;
		texcoordv2[i]=(y+sz.cy)/(float)WRITER_WIDTH;

		if (x>450) {
			x=0;
			y+=size+track;
		}
	}

	BITMAPINFO bmi;    
	bmi.bmiHeader.biSize=sizeof(bmi.bmiHeader);
	bmi.bmiHeader.biWidth=WRITER_WIDTH;
	bmi.bmiHeader.biHeight=WRITER_HEIGHT;
	bmi.bmiHeader.biPlanes=1;
	bmi.bmiHeader.biBitCount=32;
	bmi.bmiHeader.biCompression=BI_RGB;

	GetDIBits(mdc,bm,0,WRITER_HEIGHT,buffer,&bmi,DIB_RGB_COLORS);

#ifdef SAVETGA
  FILE * f =fopen("dump.tga","wb");
  TGAW(WRITER_WIDTH);
  TGAH(WRITER_HEIGHT);
  fwrite(tgahead,0x12,1,f);
  fwrite(buffer,WRITER_WIDTH*WRITER_HEIGHT*4,1,f);
  fclose(f);
#endif

	dev->CreateTexture(WRITER_WIDTH,WRITER_HEIGHT,1,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&tex,NULL);

	D3DLOCKED_RECT rc;
	if (tex->LockRect(0,&rc,NULL,0)) return;

	unsigned char * trow=(unsigned char *)rc.pBits;
	for (int j=0; j<WRITER_HEIGHT; j++) {
		unsigned int* t=(unsigned int*)trow;
		for (int k=0; k<WRITER_WIDTH; k++) {
			*t = ((buffer[j*WRITER_WIDTH+k] & 0xff) << 24) | 0x00FFFFFF;
//	*t = ((buffer[j*WRITER_WIDTH+k] ^ 0xAA) << 24) | 0x00FFFFFF;
			t++;
		}
		trow+=rc.Pitch;
	}
	tex->UnlockRect(0);

}
示例#15
0
static PF_Err
DrawEvent(	
	PF_InData		*in_data,
	PF_OutData		*out_data,
	PF_ParamDef		*params[],
	PF_LayerDef		*output,
	PF_EventExtra	*event_extra)
{
	PF_Err			err		=	PF_Err_NONE;
	
	AEGP_SuiteHandler suites(in_data->pica_basicP);
	

	event_extra->evt_out_flags = 0;
	

	if (!(event_extra->evt_in_flags & PF_EI_DONT_DRAW) && params[EXTRACT_DATA]->u.arb_d.value != NULL)
	{
		if(PF_EA_CONTROL == event_extra->effect_win.area)
		{
			ArbitraryData *arb_data = (ArbitraryData *)PF_LOCK_HANDLE(params[EXTRACT_DATA]->u.arb_d.value);
			ExtractStatus *extract_status = (ExtractStatus *)PF_LOCK_HANDLE(in_data->sequence_data);
		
		#define MAX_MESSAGE_LEN 127
			A_char	red_message[MAX_MESSAGE_LEN],
					green_message[MAX_MESSAGE_LEN],
					blue_message[MAX_MESSAGE_LEN],
					alpha_message[MAX_MESSAGE_LEN];
					
			A_char	*channel_message[4] = {	red_message,
											green_message,
											blue_message,
											alpha_message };
			
			ChannelStatus *channel_status[4] = {	&extract_status->red,
													&extract_status->green,
													&extract_status->blue,
													&extract_status->alpha };
												
			ChannelData *channel_data[4] = {	&arb_data->red,
												&arb_data->green,
												&arb_data->blue,
												&arb_data->alpha };
		
			// set up the messages
			for(int i=0; i<4; i++)
			{
				if(channel_data[i]->action == DO_COPY)
				{
					strcpy(channel_message[i], "(copy)");
				}
				else if(channel_data[i]->action == DO_EXTRACT)
				{
					// start with the name
					strcpy(channel_message[i], channel_data[i]->name);
					
					// process status returned from Render()
					if(channel_status[i]->status == STATUS_NOT_FOUND)
					{
						strcat(channel_message[i], " (not found)");
					}
					else if(channel_status[i]->status == STATUS_NO_CHANNELS)
					{
						strcat(channel_message[i], " (none available)");
					}
					else if(channel_status[i]->status == STATUS_ERROR)
					{
						strcat(channel_message[i], " (error)");
					}
					// can't change params during draw, need a click
					//else if(channel_status[i]->status == STATUS_INDEX_CHANGE)
					//{
					//	channel_data[i]->index = channel_status[i]->index;
					//	params[EXTRACT_DATA]->uu.change_flags = PF_ChangeFlag_CHANGED_VALUE;
					//}
				}
			}
			
			PF_Rect control_rect = event_extra->effect_win.current_frame;
			
			
#if PF_AE_PLUG_IN_VERSION < PF_AE100_PLUG_IN_VERSION

		// old-school Carbon/Win32 drawing code

		#ifdef WIN_ENV
			void*			dp = (*(event_extra->contextH))->cgrafptr;
			HDC				ecw_hdc	=	0;
			PF_GET_CGRAF_DATA(dp, PF_CGrafData_HDC, (void **)&ecw_hdc);
			PF_Point		pen;
		#endif

			PF_App_Color	pf_bg_color;
			suites.AppSuite()->PF_AppGetBgColor(&pf_bg_color);
			
		#ifdef MAC_ENV
			RGBColor titleColor, itemColor;
			RGBColor		bg_color;
	
			bg_color.red	=	pf_bg_color.red;
			bg_color.green	=	pf_bg_color.green;
			bg_color.blue	=	pf_bg_color.blue;
			
			RGBBackColor(&bg_color);
		
			EraseRect(&control_rect);
			
			GetForeColor(&itemColor);
			
			titleColor.red   = TITLE_COMP(itemColor.red);
			titleColor.green = TITLE_COMP(itemColor.green);
			titleColor.blue  = TITLE_COMP(itemColor.blue);
				
			RGBForeColor(&titleColor);
		#endif

		#ifdef MAC_ENV
		#define DRAW_STRING(STRING)	DrawText(STRING, 0, strlen(STRING));
		#define MOVE_TO(H, V)		MoveTo( (H), (V) );
		#else
		#define DRAW_STRING(STRING) \
			do{ \
				WCHAR u_string[100]; \
				UTF8toUTF16(STRING, (utf16_char *)u_string, 99); \
				TextOut(ecw_hdc, pen.h, pen.v, u_string, strlen(STRING)); \
			}while(0);
		#define MOVE_TO(H, V)		MoveToEx(ecw_hdc, (H), (V), NULL); pen.h = (H); pen.v = (V);
		#endif

		
#else // PF_AE_PLUG_IN_VERSION >= PF_AE100_PLUG_IN_VERSION

			// new-school Drawbot drawing code
			
			DRAWBOT_DrawRef			drawbot_ref = NULL;
			suites.PFEffectCustomUISuite()->PF_GetDrawingReference(event_extra->contextH, &drawbot_ref);
			
			DRAWBOT_SupplierRef		supplier_ref = NULL;
			DRAWBOT_SurfaceRef		surface_ref = NULL;

			suites.DBDrawbotSuite()->GetSupplier(drawbot_ref, &supplier_ref);
			suites.DBDrawbotSuite()->GetSurface(drawbot_ref, &surface_ref);
				
			DRAWBOT_ColorRGBA title_color = {0.8f, 0.8f, 0.8f, 1.0f};
			DRAWBOT_ColorRGBA item_color = title_color;
			
			item_color.red *= (1.0 - kUI_TITLE_COLOR_SCALEDOWN);
			item_color.green *= (1.0 - kUI_TITLE_COLOR_SCALEDOWN);
			item_color.blue *= (1.0 - kUI_TITLE_COLOR_SCALEDOWN);
			
			DRAWBOT_BrushP title_brushP(suites.DBSupplierSuite(), supplier_ref, &title_color);
			DRAWBOT_BrushP item_brushP(suites.DBSupplierSuite(), supplier_ref, &item_color);
			
			float default_font_sizeF = 0.0;
			suites.DBSupplierSuite()->GetDefaultFontSize(supplier_ref, &default_font_sizeF);
			
			DRAWBOT_FontP fontP(suites.DBSupplierSuite(), supplier_ref, default_font_sizeF);
			
			DRAWBOT_PointF32 text_origin = {0.f, 0.f};
			
			DRAWBOT_BrushP *current_brush = &title_brushP;
			
		#define MOVE_TO(H, V) \
			text_origin.x = (H) + 0.5f; \
			text_origin.y = (V) + 0.5f;
		
		#define DRAW_STRING(STRING) \
			do{ \
				DRAWBOT_UTF16Char u_str[100]; \
				UTF8toUTF16(STRING, u_str, 99); \
				suites.DBSurfaceSuite()->DrawString(surface_ref, current_brush->Get(), fontP.Get(), u_str, \
						&text_origin, kDRAWBOT_TextAlignment_Default, kDRAWBOT_TextTruncation_None, 0.0f); \
			}while(0);
			
#endif //PF_AE_PLUG_IN_VERSION >= PF_AE100_PLUG_IN_VERSION


			// Property Headings
			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_RED, control_rect.top) );
			DRAW_STRING("Red");
			
			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_GREEN, control_rect.top) );
			DRAW_STRING("Green");

			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_BLUE, control_rect.top) );
			DRAW_STRING("Blue");

			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_ALPHA, control_rect.top) );
			DRAW_STRING("Alpha");
			
			//Property Items
			PF_Point prop_origin;
			prop_origin.v = control_rect.top;
			
	#if PF_AE_PLUG_IN_VERSION < PF_AE100_PLUG_IN_VERSION
		#ifdef MAC_ENV
			RGBForeColor(&itemColor);
			prop_origin.h = control_rect.left + TextWidth("Alpha", 0, strlen("Alpha"));
		#else
			SIZE text_dim = {15, 8};
			GetTextExtentPoint(ecw_hdc, TEXT("Alpha"), strlen("Alpha"), &text_dim);
			prop_origin.h = control_rect.left + text_dim.cx;
		#endif
	#else
			current_brush = &item_brushP;
			prop_origin.h = control_rect.left + 50;
	#endif
			
			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_RED, prop_origin.v) );
			DRAW_STRING(red_message);
			
			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_GREEN, prop_origin.v) );
			DRAW_STRING(green_message);

			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_BLUE, prop_origin.v) );
			DRAW_STRING(blue_message);

			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_ALPHA, prop_origin.v) );
			DRAW_STRING(alpha_message);
			

			event_extra->evt_out_flags = PF_EO_HANDLED_EVENT;

			PF_UNLOCK_HANDLE(params[EXTRACT_DATA]->u.arb_d.value);
			PF_UNLOCK_HANDLE(in_data->sequence_data);
		}
	}

	return err;
}
示例#16
0
void MapWindow::DrawCommon(HDC hdc, RECT rc) {

  SIZE WPTextSize, DSTextSize, BETextSize, RETextSize, AATextSize, HLTextSize, MITextSize;
  TCHAR Buffer[LKSIZEBUFFERLARGE];
  static RECT s_sortBox[6]; 
  static TCHAR Buffer1[MAXCOMMON][MAXCOMMONNUMPAGES][24], Buffer2[MAXCOMMON][MAXCOMMONNUMPAGES][10], Buffer3[MAXCOMMON][MAXCOMMONNUMPAGES][10];
  static TCHAR Buffer4[MAXCOMMON][MAXCOMMONNUMPAGES][12], Buffer5[MAXCOMMON][MAXCOMMONNUMPAGES][12];
  static short maxnlname;
  char text[LKSIZETEXT];
  short i, k, iRaw, wlen, rli=0, curpage, drawn_items_onpage;
  double Value;
  COLORREF rcolor;


  static short Column0, Column1, Column2, Column3, Column4, Column5;
  static POINT p1, p2;
  static short rawspace;
  // Printable area for live nearest values
  static short left,right,bottom;
  // one for each mapspace, no matter if 0 and 1 are unused

  // Vertical and horizontal spaces
  #define INTERRAW	1
  #define HEADRAW	NIBLSCALE(6)	
  RECT invsel;

  short curmapspace=MapSpaceMode;

  static bool doinit=true;
  
  if (doinit) {

  // Set screen borders to avoid writing on extreme pixels
  if ( ScreenSize < (ScreenSize_t)sslandscape ) {
	// Portrait mode has tight horizontal margins...
	left=rc.left+NIBLSCALE(1);
	right=rc.right-NIBLSCALE(1);
  	bottom=rc.bottom-BottomSize-NIBLSCALE(2);
	maxnlname=MAXNLNAME-5; // 7 chars max, 8 sized
  	_stprintf(Buffer,TEXT("MAKSJSMM"));  
  } else {
	left=rc.left+NIBLSCALE(5);
	right=rc.right-NIBLSCALE(5);
  	bottom=rc.bottom-BottomSize;
	maxnlname=MAXNLNAME-3; // 9 chars, sized 10 100213
  	_stprintf(Buffer,TEXT("ABCDEFGHMx")); 
  }

  SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest  was LK8Title
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &WPTextSize);

  // Size distance
  _stprintf(Buffer,TEXT("000.0")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &DSTextSize);

  // Bearing
  _stprintf(Buffer,TEXT("<<123")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &BETextSize);

  // reqE
  _stprintf(Buffer,TEXT("5299")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &RETextSize);

  // Altitude Arrival
  _stprintf(Buffer,TEXT("+9999")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &AATextSize);

  SelectObject(hdc, LK8InfoNormalFont);
  _stprintf(Buffer,TEXT("MMMM")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &HLTextSize);

  SelectObject(hdc, LK8PanelMediumFont);
  _stprintf(Buffer,TEXT("1.1"));
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &MITextSize);

  short afterwpname=left+WPTextSize.cx+NIBLSCALE(5);
  short intercolumn=(right-afterwpname- DSTextSize.cx-BETextSize.cx-RETextSize.cx-AATextSize.cx)/3; 

  Column0=MITextSize.cx+LEFTLIMITER+NIBLSCALE(5);
  Column1=left;							// WP align left
  Column2=afterwpname+DSTextSize.cx;						// DS align right
  Column3=Column2+intercolumn+BETextSize.cx;			// BE align right
  Column4=Column3+intercolumn+RETextSize.cx;			// RE align right
  Column5=Column4+intercolumn+AATextSize.cx;			// AA align right


  if ( ScreenSize < (ScreenSize_t)sslandscape ) {
  	TopSize=rc.top+HEADRAW*2+HLTextSize.cy;
  	p1.x=0; p1.y=TopSize; p2.x=rc.right; p2.y=p1.y;
  	TopSize+=HEADRAW;
  	CommonNumraws=(bottom - TopSize) / (WPTextSize.cy+(INTERRAW*2));
  	if (CommonNumraws>MAXCOMMON) CommonNumraws=MAXCOMMON;
  	rawspace=(WPTextSize.cy+INTERRAW);
  } else {
  	TopSize=rc.top+HEADRAW*2+HLTextSize.cy;
  	p1.x=0; p1.y=TopSize; p2.x=rc.right; p2.y=p1.y;
  	TopSize+=HEADRAW/2;
  	CommonNumraws=(bottom - TopSize) / (WPTextSize.cy+INTERRAW);
  	if (CommonNumraws>MAXCOMMON) CommonNumraws=MAXCOMMON;
  	rawspace=(WPTextSize.cy+INTERRAW);
  }

#define INTERBOX intercolumn/2

  // Wpname
  s_sortBox[0].left=0;
  if ( ScreenSize < (ScreenSize_t)sslandscape ) s_sortBox[0].right=left+WPTextSize.cx-NIBLSCALE(2);
  else s_sortBox[0].right=left+WPTextSize.cx-NIBLSCALE(10);
  s_sortBox[0].top=0;
  s_sortBox[0].bottom=p1.y;
  SortBoxX[MSM_COMMON][0]=s_sortBox[0].right;
  SortBoxX[MSM_RECENT][0]= SortBoxX[MSM_COMMON][0];

  // Distance
  if ( ScreenSize < (ScreenSize_t)sslandscape ) s_sortBox[1].left=Column1+afterwpname-INTERBOX;
  else s_sortBox[1].left=Column1+afterwpname-INTERBOX-NIBLSCALE(2);
  s_sortBox[1].right=Column2+INTERBOX;
  s_sortBox[1].top=0;
  s_sortBox[1].bottom=p1.y;
  SortBoxX[MSM_COMMON][1]=s_sortBox[1].right;
  SortBoxX[MSM_RECENT][1]= SortBoxX[MSM_COMMON][1];

  // Bearing
  s_sortBox[2].left=Column2+INTERBOX;
  s_sortBox[2].right=Column3+INTERBOX;
  s_sortBox[2].top=0;
  s_sortBox[2].bottom=p1.y;
  SortBoxX[MSM_COMMON][2]=s_sortBox[2].right;
  SortBoxX[MSM_RECENT][2]= SortBoxX[MSM_COMMON][2];

  // reqE
  s_sortBox[3].left=Column3+INTERBOX;
  s_sortBox[3].right=Column4+INTERBOX;
  s_sortBox[3].top=0;
  s_sortBox[3].bottom=p1.y;
  SortBoxX[MSM_COMMON][3]=s_sortBox[3].right;
  SortBoxX[MSM_RECENT][3]= SortBoxX[MSM_COMMON][3];

  // AltArr
  s_sortBox[4].left=Column4+INTERBOX;
  s_sortBox[4].right=Column5+INTERBOX;
  s_sortBox[4].top=0;
  s_sortBox[4].bottom=p1.y;
  SortBoxX[MSM_COMMON][4]=s_sortBox[4].right;
  SortBoxX[MSM_RECENT][4]= SortBoxX[MSM_COMMON][4];

  SortBoxY[MSM_COMMON]=p1.y;
  SortBoxY[MSM_RECENT]=SortBoxY[MSM_COMMON];

  // Caution: could be wrong? no..
  //CommonNumpages=(short)ceil( (float)MAXCOMMON / (float)CommonNumraws );
  CommonNumpages=roundupdivision(MAXCOMMON, CommonNumraws);
  if (CommonNumpages>MAXCOMMONNUMPAGES) CommonNumpages=MAXCOMMONNUMPAGES; 
  else if (CommonNumpages<1) CommonNumpages=1;

  // set the initial highlighted item to the first, in each MapSpace
  SelectedRaw[MSM_COMMON]=0; 
  SelectedRaw[MSM_RECENT]=0; 
  SelectedPage[MSM_COMMON]=0;
  SelectedPage[MSM_RECENT]=0;

  doinit=false;
  return;
  } // doinit

  int *pNumber;
  int *pIndex;
  switch(curmapspace) {
	case MSM_COMMON:
			pNumber=&CommonNumber;
			pIndex=CommonIndex;
			break;
	case MSM_RECENT:
	default:
			pNumber=&RecentNumber;
			pIndex=RecentIndex;
			break;
	
  }


  // calculate again real number of pages
  CommonNumpages=roundupdivision(*pNumber, CommonNumraws);
  if (CommonNumpages>MAXCOMMONNUMPAGES) CommonNumpages=MAXCOMMONNUMPAGES;
  else if (CommonNumpages<1) CommonNumpages=1;
  // current page in use by current mapspacemode
  curpage=SelectedPage[curmapspace];
  if (curpage<0||curpage>=MAXCOMMONNUMPAGES) {
	// DoStatusMessage(_T("ERR-092 current page invalid!")); // selection while waiting for data ready
	// immediate action to resolve this problem, take it back to normality
	SelectedPage[curmapspace]=0;
	LKevent=LKEVENT_NONE;
	return;
  }
  // list changed, and we are now over the real new size> resetting
  if (curpage>=CommonNumpages) curpage=0; 

  // synthetic event handler . Remember to always clear events!
  switch (LKevent) {
	case LKEVENT_NONE:
		break;
	case LKEVENT_ENTER:
		// i=CommonIndex[SelectedRaw[curmapspace] + (curpage*CommonNumraws)]; OLD
		i=pIndex[SelectedRaw[curmapspace] + (curpage*CommonNumraws)];

		if ( !ValidWayPoint(i)) {
			#if 0 // selection while waiting for data ready
			// dont say error if empty list and an enter was pressed
			if (*pNumber) 
				DoStatusMessage(_T("ERR-018 Invalid selection"));
			#endif
			break;
		}
		SelectedWaypoint=i;
		LastDoCommon = GPS_INFO.Time+NEARESTONHOLD; //@ 101003
		PopupWaypointDetails();
		LastDoCommon = 0; //@ 101003
		// SetModeType(LKMODE_MAP, MP_MOVING); Experimental OFF 101219
		LKevent=LKEVENT_NONE;
		return;
		break;
	case LKEVENT_DOWN:
		if (++SelectedRaw[curmapspace] >=CommonNumraws) SelectedRaw[curmapspace]=0;
		LastDoCommon=GPS_INFO.Time+PAGINGTIMEOUT-1.0; //@ 101003
		// Event to be cleared at the end
		break;
	case LKEVENT_UP:
		if (--SelectedRaw[curmapspace] <0) SelectedRaw[curmapspace]=CommonNumraws-1;
		LastDoCommon=GPS_INFO.Time+PAGINGTIMEOUT-1.0; //@ 101003
		break;
	case LKEVENT_PAGEUP:
		LKevent=LKEVENT_NONE;
		break;
	case LKEVENT_PAGEDOWN:
		LKevent=LKEVENT_NONE;
		break;
	case LKEVENT_NEWRUN:
		for (i=0; i<MAXCOMMON; i++) {
			for (k=0; k<MAXCOMMONNUMPAGES; k++) {
				_stprintf(Buffer1[i][k],_T("------------")); // 12 chars
				_stprintf(Buffer2[i][k],_T("----"));
				_stprintf(Buffer3[i][k],_T("----"));
				_stprintf(Buffer4[i][k],_T("----"));
				_stprintf(Buffer5[i][k],_T("----"));
			}
		}
		break;
	case LKEVENT_NEWPAGE:
		break;
	default:
		LKevent=LKEVENT_NONE;
		break;
  }

  // Draw Headline

  if (INVERTCOLORS)
	_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p1, p2, RGB_GREEN, rc);
  else
	_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p1, p2, RGB_DARKGREEN, rc);

  SelectObject(hdc, LK8InfoNormalFont); // Heading line

  if ( ScreenSize < (ScreenSize_t)sslandscape ) { // portrait mode
	_stprintf(Buffer,TEXT("%d.%d"),ModeIndex,CURTYPE+1);
	SelectObject(hdc, LK8PanelMediumFont);
	LKWriteText(hdc, Buffer, LEFTLIMITER, rc.top+TOPLIMITER , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);
	SelectObject(hdc, LK8InfoNormalFont);

	if (curmapspace == MSM_COMMON )
		// LKTOKEN _@M1309_ "COMN"
  		_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1309_")), curpage+1, CommonNumpages); 
	else
		// LKTOKEN _@M1310_ "HIST"
  		_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1310_")), curpage+1, CommonNumpages); 
	LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);


	// LKTOKEN _@M1300_ "Dist"
	 _stprintf(Buffer,gettext(TEXT("_@M1300_"))); 
	// always sorted manually here!
	LKWriteText(hdc, Buffer, Column2, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

	// LKTOKEN _@M1301_ "Dir"
	_stprintf(Buffer,gettext(TEXT("_@M1301_"))); 
	LKWriteText(hdc, Buffer, Column3, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

	// LKTOKEN _@M1302_ "rEff"
	_stprintf(Buffer,gettext(TEXT("_@M1302_"))); 
	LKWriteText(hdc, Buffer, Column4, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

	// LKTOKEN _@M1303_ "AltA"
	_stprintf(Buffer,gettext(TEXT("_@M1303_"))); 
	LKWriteText(hdc, Buffer, Column5, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);


  } else {

	_stprintf(Buffer,TEXT("%d.%d"),ModeIndex,CURTYPE+1);
	SelectObject(hdc, LK8PanelMediumFont);
	LKWriteText(hdc, Buffer, LEFTLIMITER, rc.top+TOPLIMITER , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);
	SelectObject(hdc, LK8InfoNormalFont);

	if ( (ScreenSize == (ScreenSize_t)ss640x480) || (ScreenSize == (ScreenSize_t)ss320x240) || ScreenSize == ss896x672 ) {
		if (curmapspace == MSM_COMMON )
			// LKTOKEN _@M1309_ "COMN"
			_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1309_")), curpage+1,CommonNumpages); 
		else
			// LKTOKEN _@M1310_ "HIST"
			_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1310_")), curpage+1,CommonNumpages); 
		LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);

		// LKTOKEN _@M1300_ "Dist"
		_stprintf(Buffer,gettext(TEXT("_@M1300_"))); 
		LKWriteText(hdc, Buffer, Column2, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1301_ "Dir"
		_stprintf(Buffer,gettext(TEXT("_@M1301_"))); 
		LKWriteText(hdc, Buffer, Column3, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1302_ "rEff"
		_stprintf(Buffer,gettext(TEXT("_@M1302_"))); 
		LKWriteText(hdc, Buffer, Column4, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1308_ "Arriv"
		_stprintf(Buffer,gettext(TEXT("_@M1308_"))); 
		LKWriteText(hdc, Buffer, Column5, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);
	} else {
		if (curmapspace==MSM_COMMON)
			// LKTOKEN _@M1309_ "COMN"
			_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1309_")), curpage+1,CommonNumpages); 
		else
			// LKTOKEN _@M1310_ "HIST"
			_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1310_")), curpage+1,CommonNumpages); 
		LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);

		// LKTOKEN _@M1304_ "Distance"
		_stprintf(Buffer,gettext(TEXT("_@M1304_"))); 
		LKWriteText(hdc, Buffer, Column2, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1305_ "Direction"
		_stprintf(Buffer,gettext(TEXT("_@M1305_"))); 
		LKWriteText(hdc, Buffer, Column3, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1306_ "ReqEff"
		_stprintf(Buffer,gettext(TEXT("_@M1306_"))); 
		LKWriteText(hdc, Buffer, Column4, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1307_ "AltArr"
		_stprintf(Buffer,gettext(TEXT("_@M1307_"))); 
		LKWriteText(hdc, Buffer, Column5, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);
	}
	

  } // landscape mode


  SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest

  // try to reduce conflicts, as task thread could change it while we are using it here.
  // so we copy it and clear it here once forever in this run
  bool ndr;
  switch (curmapspace) {
	case MSM_COMMON:
  		ndr=CommonDataReady;
  		CommonDataReady=false;
		break;
	case MSM_RECENT:
  		ndr=RecentDataReady;
  		RecentDataReady=false;
		break;
	default:
		ndr=false;
		break;
   }

  // numraws always <= MAXNEAREST 
  for (i=0, drawn_items_onpage=0; i<CommonNumraws; i++) {
	iRaw=TopSize+(rawspace*i);
	short curraw=(curpage*CommonNumraws)+i;
	if (curraw>=MAXCOMMON) break;
	rli=pIndex[curraw];


	if (!ndr) goto KeepOldValues;
	if ( ValidWayPoint(rli) ) {

		wlen=wcslen(WayPointList[rli].Name);
		if (wlen>maxnlname) {
			_tcsncpy(Buffer, WayPointList[rli].Name, maxnlname); Buffer[maxnlname]='\0';
		}
		else {
			_tcsncpy(Buffer, WayPointList[rli].Name, wlen); Buffer[wlen]='\0';
		}
		ConvToUpper(Buffer); // 100213 FIX UPPERCASE DRAWNEAREST
		_tcscpy(Buffer1[i][curpage],Buffer); 

		// Distance
		Value=WayPointCalc[rli].Distance*DISTANCEMODIFY;
         	_stprintf(Buffer2[i][curpage],TEXT("%0.1lf"),Value);

		// relative bearing

		if (!MapWindow::mode.Is(MapWindow::Mode::MODE_CIRCLING)) {
			Value = WayPointCalc[rli].Bearing -  GPS_INFO.TrackBearing;

			if (Value < -180.0)
				Value += 360.0;
			else
				if (Value > 180.0)
					Value -= 360.0;

#ifndef __MINGW32__
			if (Value > 1)
				_stprintf(Buffer3[i][curpage], TEXT("%2.0f\xB0\xBB"), Value);
			else
				if (Value < -1)
					_stprintf(Buffer3[i][curpage], TEXT("\xAB%2.0f\xB0"), -Value);
				else
					_tcscpy(Buffer3[i][curpage], TEXT("\xAB\xBB"));
#else
			if (Value > 1)
				_stprintf(Buffer3[i][curpage], TEXT("%2.0f°»"), Value);
			else
				if (Value < -1)
					_stprintf(Buffer3[i][curpage], TEXT("«%2.0f°"), -Value);
				else
					_tcscpy(Buffer3[i][curpage], TEXT("«»"));
#endif
		} else
			_stprintf(Buffer3[i][curpage], TEXT("%2.0f°"), WayPointCalc[rli].Bearing);

		// Requested GR
		Value=WayPointCalc[rli].GR;
		if (Value<1 || Value>=MAXEFFICIENCYSHOW) 
			_stprintf(Buffer4[i][curpage],_T("---"));
		else {
			if (Value>99) sprintf(text,"%.0f",Value);
			else sprintf(text,"%.1f",Value);
			_stprintf(Buffer4[i][curpage],_T("%S"),text);
		}

		// arrival altitude
		Value=ALTITUDEMODIFY*WayPointCalc[rli].AltArriv[AltArrivMode];
		if (Value <-9999 ||  Value >9999 )
			strcpy(text,"---");
		else
			sprintf(text,"%+.0f",Value);
		wsprintf(Buffer5[i][curpage], TEXT("%S"),text);

	} else {
		// Invalid waypoint, fill in all empty data and maybe break loop
		_stprintf(Buffer1[i][curpage],_T("------------"));
		_stprintf(Buffer2[i][curpage],_T("---"));
		_stprintf(Buffer3[i][curpage],_T("---"));
		_stprintf(Buffer4[i][curpage],_T("---"));
		_stprintf(Buffer5[i][curpage],_T("---"));
	}


KeepOldValues:

	if ( ValidWayPoint(rli) ) {
  		SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest
		drawn_items_onpage++;
		// Common turnpoints are mixed, so we must be sure that reachable is checked only against a landable
		if ((WayPointCalc[rli].VGR == 3 )|| ( WayPointCalc[rli].IsLandable && !WayPointList[rli].Reachable)) // 091205
			rcolor=RGB_LIGHTRED;
		else
			rcolor=RGB_WHITE;
	} else 
			rcolor=RGB_GREY;
			//TextDisplayMode.AsFlag.Color = TEXTGREY;

	LKWriteText(hdc, Buffer1[i][curpage], Column1, iRaw , 0, WTMODE_NORMAL, WTALIGN_LEFT, rcolor, false);
	
	// set again correct font
  	SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest
	LKWriteText(hdc, Buffer2[i][curpage], Column2, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

	LKWriteText(hdc, Buffer3[i][curpage], Column3, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

	LKWriteText(hdc, Buffer4[i][curpage], Column4, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

	LKWriteText(hdc, Buffer5[i][curpage], Column5, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

  }  // for


  // clear flag, and don't outbox
  if (LKevent==LKEVENT_NEWRUN || LKevent==LKEVENT_NEWPAGE ) {
		LKevent=LKEVENT_NONE;
		return;
  }

  // BOXOUT SELECTED ITEM
    if (drawn_items_onpage>0) { 

	if (SelectedRaw[curmapspace] <0 || SelectedRaw[curmapspace]>(CommonNumraws-1)) {
		LKevent=LKEVENT_NONE;
		return;
	}
	// avoid boxing and selecting nonexistent items
	// selectedraw starts from 0, drawnitems from 1...
	// In this case we set the first one, or last one, assuming we are rotating forward or backward
	if (SelectedRaw[curmapspace] >= drawn_items_onpage) {
		if (LKevent==LKEVENT_DOWN) SelectedRaw[curmapspace]=0;
		else 
		// up from top to bottom, bottom empty, look for the last valid one (ie first going back from bottom)
		if (LKevent==LKEVENT_UP) SelectedRaw[curmapspace]=drawn_items_onpage-1;
		else {
			// DoStatusMessage(_T("Cant find valid raw")); // no more needed
			SelectedRaw[curmapspace]=0;
		}
	}
	invsel.left=left;
	invsel.right=right;
	invsel.top=TopSize+(rawspace*SelectedRaw[curmapspace])+NIBLSCALE(2);
	invsel.bottom=TopSize+(rawspace*(SelectedRaw[curmapspace]+1))-NIBLSCALE(1);
	InvertRect(hdc,&invsel);
  } 

  LKevent=LKEVENT_NONE;
  return;
}
示例#17
0
void DrawHSI(HDC hdc, POINT Orig, RECT rc )
{
	HFONT oldfont;
	HPEN oldpen;

	// short rcHeight = rc.bottom;
	short rcx=rc.left+rc.right/2;
	short rad=(rc.right/2) - (rcx/10);
	short rcy= rad;

	if ( DisplayOrientation == NORTHSMART || 
		DisplayOrientation == NORTHTRACK ||
		DisplayOrientation == NORTHUP ||
#ifndef MAP_ZOOM
		DisplayMode == dmCircling
#else /* MAP_ZOOM */
		MapWindow::mode.Is(MapWindow::Mode::MODE_CIRCLING)
#endif /* MAP_ZOOM */
		)
	{
		return; //Only for Trackup and compatible modes
	}


	//XXXOREN - move to globals
	//HPEN hPenBlack = ::CreatePen(PS_SOLID, (5), RGB(0x00,0x0,0x0));
	//HPEN hPenWhite = (HPEN)CreatePen(PS_SOLID, (2), RGB(0xff,0xff,0xff));
	HPEN hPenBlack = LKPen_Black_N3;
	HPEN hPenWhite = LKPen_White_N2;

	oldfont = (HFONT)SelectObject(hdc, LK8InfoNormalFont);

	//Draw current heading
	///////////////////

	TCHAR brgText[LKSIZEBUFFERLARGE];
	int bearing= (int) (GPS_INFO.TrackBearing+0.5);
	wsprintf(brgText,_T("%03d"),bearing);

	SIZE brgSize;
	GetTextExtentPoint(hdc, brgText, _tcslen(brgText), &brgSize);
	drawOutlineText(hdc,rcx -(brgSize.cx/2), 0 ,brgText,RGB_WHITE);

	//Draw pointer
	POINT pt[7];
	pt[0].x = rcx - (brgSize.cx/2) -5;
	pt[0].y = brgSize.cy - 5;

	pt[1].x = rcx - (brgSize.cx/2) -5;
	pt[1].y = brgSize.cy + 2;

	pt[2].x = rcx - (brgSize.cx/10);
	pt[2].y = brgSize.cy + 2;

	pt[3].x = rcx;
	pt[3].y = brgSize.cy + 7;

	pt[4].x = rcx + (brgSize.cx/10);
	pt[4].y = brgSize.cy + 2;

	pt[5].x = rcx + (brgSize.cx/2) +5;
	pt[5].y = brgSize.cy + 2;

	pt[6].x = rcx + (brgSize.cx/2) +5;
	pt[6].y = brgSize.cy - 5;

	oldpen=(HPEN) SelectObject(hdc, hPenBlack);
	::Polyline(hdc,pt,7);
	SelectObject(hdc, hPenWhite);
	::Polyline(hdc,pt,7);

	//Offset arc below heading
	rcy += brgSize.cy +10;

	DrawCompassArc(hdc,Orig.x,rcy,rad,rc,GPS_INFO.TrackBearing);

	SetTextColor(hdc,RGB_BLACK);
	SelectObject(hdc,(HPEN)oldpen);
	SelectObject(hdc,(HFONT) oldfont);

}
/*********************************************************************************************
 *
 * This is the dialog procedure for the beep dialog.
 *
 *      Message:                Action:
 *      ========                =======
 *      WM_INITDIALOG           initialize beep duration and frequency
 *      WM_CLOSE                end this dialog
 *      WM_PAINT                display text strings under each scroll bar to represent
 *                              the value of the slider
 *      WM_HSCROLL              adjust scroll bars and duration/frequency values
 *      WM_COMMAND              ID_BEEPNOW:  beep with the specified frequency/duration
 *                              ID_DONE: dismiss dialog box
 *
 *********************************************************************************************/
BOOL WINAPI BeepDiaProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam)
{

        char lpstrOutString[256];        // string used to display text in dialog box
    RECT rect;
    HDC hdc;                                         // device context for painting
    PAINTSTRUCT ps;                          // paint structure for painting
    SIZE mySize;                 // used to place text in dialog box
    ULONG ulDlgUnitsToPixels;        // used to place text in dialog box
    static LONG ulBeepDuration; // beep duration - selected by slider
    static LONG ulBeepFreq;     // beep frequency - selected by slider
    LONG *pscrollpos;           // current slider value
    int id;                      // determines which slider
    char *templateStringMS = "Selected Value: %5d ms   ";
    char *templateStringHZ = "Selected Value: %5d hz   ";

    switch (messg) {
        /*
         * WM_INITDIALOG: initialize duration and frequency variables
         */
        case WM_INITDIALOG:
            ulBeepDuration = MINDURATION;
            ulBeepFreq = MINFREQ;
            break;
        /*
         * WM_CLOSE: Dismiss this dialog
         */
        case WM_CLOSE:
            EndDialog(hDlg,FALSE);
            break;
        /*
         * WM_PAINT: Determine position in dialog box for text output and
                 *           put the text strings there
         */
        case WM_PAINT:
            hdc = BeginPaint(hDlg,&ps);
            ulDlgUnitsToPixels = GetDialogBaseUnits();
            sprintf(lpstrOutString,templateStringHZ,ulBeepFreq*FREQSTEP);
            TextOut(hdc,(40*LOWORD(ulDlgUnitsToPixels))/4,(40*HIWORD(ulDlgUnitsToPixels))/8,lpstrOutString,strlen(lpstrOutString));
            sprintf(lpstrOutString,templateStringMS,ulBeepDuration*DURATIONSTEP);
            TextOut(hdc,(40*LOWORD(ulDlgUnitsToPixels))/4,(100*HIWORD(ulDlgUnitsToPixels))/8,lpstrOutString,strlen(lpstrOutString));
            EndPaint(hDlg,&ps);
            break;
        /*
         * WM_HSCROLL: handle horizontal scrolling.  For all scroll
         *             messages, determine which scroll bar this is (via GetDlgCtrlId)
         *             and set a pointer to the scroll value (pscrollpos).
         */
        case WM_HSCROLL:
            ulDlgUnitsToPixels = GetDialogBaseUnits();
            id = GetDlgCtrlID((HWND)lParam);
            hdc = GetDC(hDlg);
            GetTextExtentPoint(hdc,templateStringHZ,strlen(templateStringHZ),&mySize);
            DeleteDC(hdc);
            if (id==ID_FREQBAR) {
                SetScrollRange((HWND)lParam,SB_CTL,MINFREQ,MAXFREQ,TRUE);
                pscrollpos = &ulBeepFreq;
                rect.top = (40*HIWORD(ulDlgUnitsToPixels))/8;
                rect.bottom = rect.top + mySize.cy;
                rect.left = (40*LOWORD(ulDlgUnitsToPixels))/4;
                rect.right = rect.left + mySize.cx;
            } else {
                SetScrollRange((HWND)lParam,SB_CTL,MINDURATION,MAXDURATION,TRUE);
                pscrollpos = &ulBeepDuration;
                rect.top = (100*HIWORD(ulDlgUnitsToPixels))/8;
                rect.bottom = rect.top + mySize.cy;
                rect.left = (40*LOWORD(ulDlgUnitsToPixels))/4;
                rect.right = rect.left + mySize.cx;
            }
            switch(LOWORD(wParam)) {
                /*
                 * SB_LINERIGHT: user incremented by 1.  Update scroll
                 *               position and redraw.
                 */
                case SB_LINERIGHT:
                    (*pscrollpos)++;
                    if ((id==ID_FREQBAR) && (*pscrollpos > MAXFREQ)) {
                       *pscrollpos = MAXFREQ;
                    } else if ((id==ID_DURBAR) && (*pscrollpos > MAXDURATION)){
                       *pscrollpos = MAXDURATION;
                    }
                    SetScrollPos((HWND)lParam,SB_CTL,*pscrollpos,TRUE);
                    break;
                /*
                 * SB_LINELEFT: user decremented by 1.  Update scroll
                 *              position and redraw.
                 */
                case SB_LINELEFT:
                    (*pscrollpos)--;
                    if ((id==ID_FREQBAR) && (*pscrollpos < MINFREQ)) {
                       *pscrollpos = MINFREQ;
                    } else if ((id=ID_DURBAR) && (*pscrollpos < MINDURATION)) {
                       *pscrollpos = MINDURATION;
                    }
                    SetScrollPos((HWND)lParam,SB_CTL,*pscrollpos,TRUE);
                    break;
                /*
                 * SB_LINELEFT: user decremented by 1 "page".  Update scroll
                 *              position and redraw.
                 */
                case SB_PAGELEFT:
                    *pscrollpos -= BEEPSCROLLWIDTH;
                    if ((id==ID_FREQBAR) && (*pscrollpos < MINFREQ)) {
                       *pscrollpos = MINFREQ;
                    } else if ((id=ID_DURBAR) && (*pscrollpos < MINDURATION)) {
                       *pscrollpos = MINDURATION;
                    }
                    SetScrollPos((HWND)lParam,SB_CTL,*pscrollpos,TRUE);
                    break;
                /*
                 * SB_LINERIGHT: user incremented by 1 "page".  Update scroll
                 *               position and redraw.
                 */
                case SB_PAGERIGHT:
                    *pscrollpos += BEEPSCROLLWIDTH;
                    if ((id==ID_FREQBAR) && (*pscrollpos > MAXFREQ)) {
                       *pscrollpos = MAXFREQ;
                    } else if ((id==ID_DURBAR) && (*pscrollpos > MAXDURATION)){
                       *pscrollpos = MAXDURATION;
                    }
                    SetScrollPos((HWND)lParam,SB_CTL,*pscrollpos,TRUE);
                    break;
                /*
                 * SB_THUMBPOSITION: user moved to a specified position.  Update scroll
                 *                   position and redraw.
                 * SB_THUMBTRACK: same as SB_THUMBPOSITION
                 */
                case SB_THUMBPOSITION:
                case SB_THUMBTRACK:
                    *pscrollpos = HIWORD(wParam);
                    SetScrollPos((HWND)lParam,SB_CTL,*pscrollpos,TRUE);
                    break;
            }
            InvalidateRect(hDlg,&rect,FALSE);
            break;
        /*
         * WM_COMMAND: see individual actions
         */
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                /*
                 * ID_BEEPNOW: use Beep API to make the sound!
                 */
                case ID_BEEPNOW:
                    Beep(ulBeepFreq*FREQSTEP,ulBeepDuration*DURATIONSTEP);
                    break;
                /*
                 * ID_DONE: dismiss this dialog
                 */
                case ID_DONE:
                    EndDialog(hDlg,TRUE);
                    break;
                default:
                    return FALSE;
            }
            default:
                return FALSE;
        }
        return TRUE;
}
示例#19
0
int DrawCompassArc(HDC hdc, long x, long y, int radius, RECT rc,
	    double bearing)

{
		const int indicatorStep = 10;

		// For Oren: remember to always DeleteObject you create with Create, or in 1 hour any
		// device will run out of GDI space, including your PC...
		// Meanwhile, I have created LKObjects, so anytime we should use them . No need to delete them.
		//HPEN hPenBlack = ::CreatePen(PS_SOLID, (5), RGB(0x00,0x0,0x0));  
		//HPEN hPenWhite = (HPEN)CreatePen(PS_SOLID, (2), RGB(0xff,0xff,0xff));
		HPEN hPenBlack = LKPen_Black_N5;
		HPEN hPenWhite = LKPen_White_N2;
		HFONT oldfont;
		HPEN oldpen;

		oldpen=(HPEN) SelectObject(hdc, hPenBlack);
		DrawArc(hdc, x, y,radius, rc, 300, 60);

		int heading = (int)(bearing +0.5);

		// -----------Draw the detents around the circle-----------------------------

		double angleDiff = heading % indicatorStep;

		int screenAngle = (int)(300 - angleDiff);
		int curHeading = (int)(heading - 60 - angleDiff);
		TCHAR textBuffer[32];

		POINT pt[2];
		int i;

		oldfont=(HFONT)SelectObject(hdc, LK8MediumFont); // always remember to save object or we miss font 

		for(i = - 60; i<= 60;
				i+=indicatorStep,screenAngle += indicatorStep,curHeading += indicatorStep)
		{

			if ( (screenAngle < 300) && (screenAngle > 60) )
 			{
				continue;
			}

			screenAngle  = (int)AngleLimit360(screenAngle);

			pt[0].x = x + (long) (radius * fastsine(screenAngle) );
			pt[0].y = y - (long) (radius * fastcosine(screenAngle) );

			// The length of the tickmarks on the compass rose
			double tickLength;

			// Make sure the display heading is between 0 and 360
			int displayHeading = (int)AngleLimit360(curHeading);

			// If the heading is a multiple of ten, it gets a long tick
			if(displayHeading%30==0)
			{
				tickLength = 15;

				if(displayHeading%30==0)
				{

					int drawHdg = displayHeading/10;
					switch ( drawHdg )
					{
					case 0:
						wsprintf( textBuffer, _T("N"));
						break;
					case 9:
						wsprintf( textBuffer, _T("E"));
						break;
					case 18:
						wsprintf( textBuffer, _T("S"));
						break;
					case 27:
						wsprintf( textBuffer, _T("W"));
						break;
					default:
						wsprintf( textBuffer, _T("%d"), displayHeading/10 );
					}

					SIZE textSize;
					GetTextExtentPoint(hdc, textBuffer, _tcslen(textBuffer), &textSize);

					int textX = x + (long) ((radius - (textSize.cy/2)-2) * fastsine(screenAngle) ) - textSize.cx/2;
					int textY = y - (long) ((radius - (textSize.cy/2)-2) * fastcosine(screenAngle) );
					drawOutlineText(hdc,textX,textY ,textBuffer,RGB_WHITE);
				}
			}
			else // Otherwise it gets a short tick
				tickLength = 10;

			pt[1].x = x + (long) ((radius -tickLength) * fastsine(screenAngle) );
			pt[1].y = y - (long) ((radius -tickLength) * fastcosine(screenAngle) );
			SelectObject(hdc, hPenBlack);
			::Polyline(hdc,pt,2);
			SelectObject(hdc, hPenWhite);
			::Polyline(hdc,pt,2);
		}

		SelectObject(hdc, hPenWhite);
		DrawArc(hdc, x, y,radius, rc, 300, 60);
		SelectObject(hdc, oldfont);
		SelectObject(hdc, oldpen);
		return 0;
}
示例#20
0
void MapWindow::DrawTraffic(HDC hdc, RECT rc) {

  SIZE WPTextSize, DSTextSize, BETextSize, RETextSize, AATextSize, HLTextSize, MITextSize;
  TCHAR Buffer[LKSIZEBUFFERLARGE];
  static RECT s_sortBox[6]; 
  static TCHAR Buffer1[MAXTRAFFIC][MAXTRAFFICNUMPAGES][24], Buffer2[MAXTRAFFIC][MAXTRAFFICNUMPAGES][10];
  static TCHAR Buffer3[MAXTRAFFIC][MAXTRAFFICNUMPAGES][10];
  static TCHAR Buffer4[MAXTRAFFIC][MAXTRAFFICNUMPAGES][12], Buffer5[MAXTRAFFIC][MAXTRAFFICNUMPAGES][12];
  static short s_maxnlname;
  char text[30];
  short i, k, iRaw, wlen, rli=0, curpage, drawn_items_onpage;
  double value;
  COLORREF rcolor;

  // column0 starts after writing 1:2 (ModeIndex:CURTYPE+1) with a different font..
  static short Column0;
  static short Column1, Column2, Column3, Column4, Column5;
  static POINT p1, p2;
  static short s_rawspace;
  // Printable area for live nearest values
  static short left,right,bottom;
  // one for each mapspace, no matter if 0 and 1 are unused

  short curmapspace=MapSpaceMode;
  static int TrafficNumraws=0;
  //static int TrafficNumpages=0; global..
  // Vertical and horizontal spaces
  #define INTERRAW	1
  #define HEADRAW	NIBLSCALE(6)	
  HBRUSH sortbrush;
  RECT invsel;

  if (INVERTCOLORS) {
  	sortbrush=LKBrush_LightGreen;
  } else {
  	sortbrush=LKBrush_DarkGreen;
  }

  if (DoInit[MDI_DRAWTRAFFIC]) {

  if ( ScreenSize < (ScreenSize_t)sslandscape ) {
	left=rc.left+NIBLSCALE(1);
	right=rc.right-NIBLSCALE(1);
  	bottom=rc.bottom-BottomSize-NIBLSCALE(2);
	s_maxnlname=MAXNLNAME-5; // 7 chars max, 8 sized
  	_stprintf(Buffer,TEXT("MAKSJSMM"));  
  } else {
	left=rc.left+NIBLSCALE(5);
	right=rc.right-NIBLSCALE(5);
  	bottom=rc.bottom-BottomSize;
	s_maxnlname=MAXNLNAME-3; // 9 chars, sized 10
  	_stprintf(Buffer,TEXT("ABCDEFGHMx")); 
  }


  SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest  was LK8Title
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &WPTextSize);

  _stprintf(Buffer,TEXT("000.0")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &DSTextSize);

  _stprintf(Buffer,TEXT("<<123")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &BETextSize);

  _stprintf(Buffer,TEXT("5299")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &RETextSize);

  _stprintf(Buffer,TEXT("+9999")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &AATextSize);

  SelectObject(hdc, LK8InfoNormalFont); // Heading line  was MapWindow QUI
  _stprintf(Buffer,TEXT("MMMM")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &HLTextSize);

  SelectObject(hdc, LK8PanelMediumFont);  
  _stprintf(Buffer,TEXT("1.1")); 
  GetTextExtentPoint(hdc, Buffer, _tcslen(Buffer), &MITextSize);

  short afterwpname=left+WPTextSize.cx+NIBLSCALE(5);
  short intercolumn=(right-afterwpname- DSTextSize.cx-BETextSize.cx-RETextSize.cx-AATextSize.cx)/3; 

  Column0=MITextSize.cx+LEFTLIMITER+NIBLSCALE(5);
  Column1=left;							// WP align left
  Column2=afterwpname+DSTextSize.cx;						// DS align right
  Column3=Column2+intercolumn+BETextSize.cx;			// BE align right
  Column4=Column3+intercolumn+RETextSize.cx;			// RE align right
  Column5=Column4+intercolumn+AATextSize.cx;			// AA align right


  if ( ScreenSize < (ScreenSize_t)sslandscape ) {
  	TopSize=rc.top+HEADRAW*2+HLTextSize.cy;
  	p1.x=0; p1.y=TopSize; p2.x=rc.right; p2.y=p1.y;
  	TopSize+=HEADRAW;
  	TrafficNumraws=(bottom - TopSize) / (WPTextSize.cy+(INTERRAW*2));
  	if (TrafficNumraws>MAXTRAFFIC) TrafficNumraws=MAXTRAFFIC;
  	s_rawspace=(WPTextSize.cy+INTERRAW);
  } else {
  	TopSize=rc.top+HEADRAW*2+HLTextSize.cy;
  	p1.x=0; p1.y=TopSize; p2.x=rc.right; p2.y=p1.y;
  	TopSize+=HEADRAW/2;
  	TrafficNumraws=(bottom - TopSize) / (WPTextSize.cy+INTERRAW);
  	if (TrafficNumraws>MAXTRAFFIC) TrafficNumraws=MAXTRAFFIC;
  	s_rawspace=(WPTextSize.cy+INTERRAW);
  }

#define INTERBOX intercolumn/2

  // Traffic name
  s_sortBox[0].left=Column0; // FIX 090925 era solo 0
  if ( ScreenSize < (ScreenSize_t)sslandscape ) s_sortBox[0].right=left+WPTextSize.cx-NIBLSCALE(2);
  else s_sortBox[0].right=left+WPTextSize.cx-NIBLSCALE(10);
  s_sortBox[0].top=2;
  s_sortBox[0].bottom=p1.y;
  SortBoxX[MSM_TRAFFIC][0]=s_sortBox[0].right;

  // Distance
  if ( ScreenSize < (ScreenSize_t)sslandscape ) s_sortBox[1].left=Column1+afterwpname-INTERBOX;
  else s_sortBox[1].left=Column1+afterwpname-INTERBOX-NIBLSCALE(2);
  s_sortBox[1].right=Column2+INTERBOX;
  s_sortBox[1].top=2;
  s_sortBox[1].bottom=p1.y;
  SortBoxX[MSM_TRAFFIC][1]=s_sortBox[1].right;

  // Bearing
  s_sortBox[2].left=Column2+INTERBOX;
  s_sortBox[2].right=Column3+INTERBOX;
  s_sortBox[2].top=2;
  s_sortBox[2].bottom=p1.y;
  SortBoxX[MSM_TRAFFIC][2]=s_sortBox[2].right;

  // Vario
  s_sortBox[3].left=Column3+INTERBOX;
  s_sortBox[3].right=Column4+INTERBOX;
  s_sortBox[3].top=2;
  s_sortBox[3].bottom=p1.y;
  SortBoxX[MSM_TRAFFIC][3]=s_sortBox[3].right;

  // Altitude
  s_sortBox[4].left=Column4+INTERBOX;
  //s_sortBox[4].right=Column5+INTERBOX;
  s_sortBox[4].right=rc.right-1;
  s_sortBox[4].top=2;
  s_sortBox[4].bottom=p1.y;
  SortBoxX[MSM_TRAFFIC][4]=s_sortBox[4].right;

  SortBoxY[MSM_TRAFFIC]=p1.y;

  TrafficNumpages=roundupdivision(MAXTRAFFIC, TrafficNumraws);
  if (TrafficNumpages>MAXTRAFFICNUMPAGES) TrafficNumpages=MAXTRAFFICNUMPAGES;
  else if (TrafficNumpages<1) TrafficNumpages=1;

  SelectedRaw[MSM_TRAFFIC]=0;
  SelectedPage[MSM_TRAFFIC]=0;

  DoInit[MDI_DRAWTRAFFIC]=false;
  return;
  } // doinit

  DoTraffic(&DrawInfo,  &DerivedDrawInfo);

  TrafficNumpages=roundupdivision(LKNumTraffic, TrafficNumraws);
  if (TrafficNumpages>MAXTRAFFICNUMPAGES) TrafficNumpages=MAXTRAFFICNUMPAGES;
  else if (TrafficNumpages<1) TrafficNumpages=1;

  curpage=SelectedPage[curmapspace];
  if (curpage<0||curpage>=MAXTRAFFICNUMPAGES) {
	// DoStatusMessage(_T("ERR-041 traffic curpage invalid!"));  // selection while waiting for data ready
	SelectedPage[curmapspace]=0;
	LKevent=LKEVENT_NONE;
	return;
  }

  switch (LKevent) {
	case LKEVENT_NONE:
		break;
	case LKEVENT_ENTER:
		LKevent=LKEVENT_NONE;
		i=LKSortedTraffic[SelectedRaw[curmapspace]+(curpage*TrafficNumraws)];

		if ( (i<0) || (i>=MAXTRAFFIC) || (LKTraffic[i].ID<=0) ) {
			#if 0 // selection while waiting for data ready
			if (LKNumTraffic>0)
				DoStatusMessage(_T("ERR-045 Invalid selection")); 
			#endif
			break;
		}
		LKevent=LKEVENT_NONE; 
		// Do not update Traffic while in details mode, max 10m
		LastDoTraffic=DrawInfo.Time+600;
		dlgLKTrafficDetails(i);
		LastDoTraffic=0;
		break;
	case LKEVENT_DOWN:
		if (++SelectedRaw[curmapspace] >=TrafficNumraws) SelectedRaw[curmapspace]=0;
		// Reset LastDoTraffic so that it wont be updated while selecting an item
		LastDoTraffic=DrawInfo.Time+PAGINGTIMEOUT-1.0;
		break;
	case LKEVENT_UP:
		if (--SelectedRaw[curmapspace] <0) SelectedRaw[curmapspace]=TrafficNumraws-1;
		LastDoTraffic=DrawInfo.Time+PAGINGTIMEOUT-1.0;
		break;
	case LKEVENT_PAGEUP:
		LKevent=LKEVENT_NONE;
		break;
	case LKEVENT_PAGEDOWN:
		LKevent=LKEVENT_NONE;
		break;
	case LKEVENT_NEWRUN:
		for (i=0; i<MAXTRAFFIC; i++) {
			for (k=0; k<MAXTRAFFICNUMPAGES; k++) {
				_stprintf(Buffer1[i][k],_T("------------")); // 12 chars
				_stprintf(Buffer2[i][k],_T("----"));
				_stprintf(Buffer3[i][k],_T("----"));
				_stprintf(Buffer4[i][k],_T("----"));
				_stprintf(Buffer5[i][k],_T("----"));
			}
		}
		break;
	case LKEVENT_NEWPAGE:
		break;
	default:
		LKevent=LKEVENT_NONE;
		break;
  }


  if (INVERTCOLORS)
	  _DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p1, p2, RGB_GREEN, rc);
  else
	  _DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p1, p2, RGB_DARKGREEN, rc);

  SelectObject(hdc, LK8InfoNormalFont); // Heading line

  short cursortbox=SortedMode[curmapspace];

  if ( ScreenSize < (ScreenSize_t)sslandscape ) { // portrait mode
	FillRect(hdc,&s_sortBox[cursortbox], sortbrush); 
	_stprintf(Buffer,TEXT("%d.%d"),ModeIndex,CURTYPE+1);
  	SelectObject(hdc, LK8PanelMediumFont); 
	LKWriteText(hdc, Buffer, LEFTLIMITER, rc.top+TOPLIMITER , 0,  WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);
  	SelectObject(hdc, LK8InfoNormalFont); 

 		// LKTOKEN _@M1331_ "TRF"
		_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1331_")), curpage+1,TrafficNumpages); 
	if (cursortbox==0)
 		LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_BLACK, false);
	else
 		LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);

	// LKTOKEN _@M1300_ "Dist"
	 _stprintf(Buffer, gettext(TEXT("_@M1300_"))); 
	if (cursortbox==1)
		LKWriteText(hdc, Buffer, Column2, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
	else
		LKWriteText(hdc, Buffer, Column2, HEADRAW , 0, WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

	// LKTOKEN _@M1301_ "Dir"
	_stprintf(Buffer, gettext(TEXT("_@M1301_"))); 
	if (cursortbox==2)
		LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
	else
		LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

	// LKTOKEN _@M1332_ "Var"
	_stprintf(Buffer, gettext(TEXT("_@M1332_"))); 
	if (cursortbox==3)
		LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
	else
		LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

	// LKTOKEN _@M1334_ "Alt"
	_stprintf(Buffer, gettext(TEXT("_@M1334_"))); 
	if (cursortbox==4)
		LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
	else
		LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);


  } else {
	FillRect(hdc,&s_sortBox[cursortbox], sortbrush); 

	if ( (ScreenSize == (ScreenSize_t)ss640x480) || (ScreenSize == (ScreenSize_t)ss320x240)|| ScreenSize==ss896x672 ) {

		_stprintf(Buffer,TEXT("%d.%d"),ModeIndex,CURTYPE+1);
  		SelectObject(hdc, LK8PanelMediumFont); 
		LKWriteText(hdc, Buffer, LEFTLIMITER, rc.top+TOPLIMITER , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);
  		SelectObject(hdc, LK8InfoNormalFont); 

 		// LKTOKEN _@M1331_ "TRF"
		_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1331_")), curpage+1,TrafficNumpages); 
		if (cursortbox==0)
			LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0,WTMODE_NORMAL, WTALIGN_LEFT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0,WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);

		// LKTOKEN _@M1300_ "Dist"
		 _stprintf(Buffer, gettext(TEXT("_@M1300_"))); 
		if (cursortbox==1)
			LKWriteText(hdc, Buffer, Column2, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column2, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1301_ "Dir"
		_stprintf(Buffer, gettext(TEXT("_@M1301_"))); 
		if (cursortbox==2)
			LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1332_ "Var"
		_stprintf(Buffer, gettext(TEXT("_@M1332_"))); 
		if (cursortbox==3)
			LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1334_ "Alt"
		_stprintf(Buffer, gettext(TEXT("_@M1334_"))); 
		if (cursortbox==4)
			LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);
	} else {
		_stprintf(Buffer,TEXT("%d.%d"),ModeIndex,CURTYPE+1);
  		SelectObject(hdc, LK8PanelMediumFont); 
		LKWriteText(hdc, Buffer, LEFTLIMITER, rc.top+TOPLIMITER , 0, WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);
  		SelectObject(hdc, LK8InfoNormalFont); 

 		// LKTOKEN _@M1331_ "TRF"
		_stprintf(Buffer,TEXT("%s %d/%d"), gettext(TEXT("_@M1331_")), curpage+1,TrafficNumpages); 
		if (cursortbox==0)
			LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0,WTMODE_NORMAL, WTALIGN_LEFT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column0, HEADRAW-NIBLSCALE(1) , 0,WTMODE_NORMAL, WTALIGN_LEFT, RGB_LIGHTGREEN, false);

		// LKTOKEN _@M1304_ "Distance"
		_stprintf(Buffer, gettext(TEXT("_@M1304_"))); 
		if (cursortbox==1)
			LKWriteText(hdc, Buffer, Column2, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column2, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1305_ "Direction"
		_stprintf(Buffer, gettext(TEXT("_@M1305_"))); 
		if (cursortbox==2)
			LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column3, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1333_ "Vario"
		_stprintf(Buffer, gettext(TEXT("_@M1333_"))); 
		if (cursortbox==3)
			LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column4, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);

		// LKTOKEN _@M1334_ "Alt"
		_stprintf(Buffer, gettext(TEXT("_@M1334_"))); 
		if (cursortbox==4)
			LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_BLACK, false);
		else
			LKWriteText(hdc, Buffer, Column5, HEADRAW , 0,WTMODE_NORMAL, WTALIGN_RIGHT, RGB_WHITE, false);
	}
	

  } // landscape mode


  SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest

  #ifdef DEBUG_LKT_DRAWTRAFFIC
  TCHAR v2buf[100]; 
  wsprintf(v2buf,_T("MAXTRAFFIC=%d LKNumTraff=%d / TrafficNumraws=%d TrafficNumpages=%d calc=%d\n"),MAXTRAFFIC, LKNumTraffic,TrafficNumraws, TrafficNumpages, (short)(ceil(MAXTRAFFIC/TrafficNumraws)));
  StartupStore(v2buf);
  #endif

  for (i=0, drawn_items_onpage=0; i<TrafficNumraws; i++) {
	iRaw=TopSize+(s_rawspace*i);
	short curraw=(curpage*TrafficNumraws)+i;
	if (curraw>=MAXTRAFFIC) break;
	rli=LKSortedTraffic[curraw];

	#ifdef DEBUG_LKT_DRAWTRAFFIC
	StartupStore(_T("..LKDrawTraff page=%d curraw=%d rli=%d \n"),
		curpage,curraw,rli);
	#endif

	if ( (rli>=0) && (LKTraffic[rli].ID>0) ) {

		// Traffic name
		wlen=wcslen(LKTraffic[rli].Name);

		// if name is unknown then it is a '?'
		if (wlen==1) { 
			_stprintf(Buffer,_T("%06x"),LKTraffic[rli].ID);
			Buffer[s_maxnlname]='\0';
		} else {
			// if XY I-ABCD  doesnt fit..
			if ( (wlen+3)>s_maxnlname) {
				LK_tcsncpy(Buffer, LKTraffic[rli].Name, s_maxnlname);
			}
			else {
				unsigned short cnlen=_tcslen(LKTraffic[rli].Cn);
				// if cn is XY create XY I-ABCD
				if (cnlen==1 || cnlen==2) {
					_tcscpy(Buffer,LKTraffic[rli].Cn);
					_tcscat(Buffer,_T(" "));
					_tcscat(Buffer,LKTraffic[rli].Name);
					// for safety
					Buffer[s_maxnlname]='\0';
				} else {
					// else use only long name
					LK_tcsncpy(Buffer, LKTraffic[rli].Name, wlen);
				}
			}
			ConvToUpper(Buffer);
		}
		if (LKTraffic[rli].Locked) {
			TCHAR buf2[LKSIZEBUFFERLARGE];
			_stprintf(buf2,_T("*%s"),Buffer);
			buf2[s_maxnlname]='\0';
			_tcscpy(Buffer,buf2);
		}
		#ifdef DEBUG_LKT_DRAWTRAFFIC
		StartupStore(_T(".. Traffic[%d] Name=<%s> Id=<%0x> Status=%d Named:<%s>\n"),rli,LKTraffic[rli].Name,
			LKTraffic[rli].ID, LKTraffic[rli].Status,Buffer);
		#endif
		_tcscpy(Buffer1[i][curpage],Buffer); 

		// Distance
		value=LKTraffic[rli].Distance*DISTANCEMODIFY;
         	_stprintf(Buffer2[i][curpage],TEXT("%0.1lf"),value);

		// relative bearing

		if (!MapWindow::mode.Is(MapWindow::Mode::MODE_CIRCLING)) {
			value = LKTraffic[rli].Bearing -  DrawInfo.TrackBearing;

			if (value < -180.0)
				value += 360.0;
			else
				if (value > 180.0)
					value -= 360.0;

#ifndef __MINGW32__
			if (value > 1)
				_stprintf(Buffer3[i][curpage], TEXT("%2.0f\xB0\xBB"), value);
			else
				if (value < -1)
					_stprintf(Buffer3[i][curpage], TEXT("\xAB%2.0f\xB0"), -value);
				else
					_tcscpy(Buffer3[i][curpage], TEXT("\xAB\xBB"));
#else
			if (value > 1)
				_stprintf(Buffer3[i][curpage], TEXT("%2.0f°»"), value);
			else
				if (value < -1)
					_stprintf(Buffer3[i][curpage], TEXT("«%2.0f°"), -value);
				else
					_tcscpy(Buffer3[i][curpage], TEXT("«»"));
#endif
		} else {
			_stprintf(Buffer3[i][curpage], _T("%2.0f°"), LKTraffic[rli].Bearing);
		}
			

		// Vario
		value=LIFTMODIFY*LKTraffic[rli].Average30s;
		if (value<-6 || value>6) 
			_stprintf(Buffer4[i][curpage],_T("---"));
		else {
			sprintf(text,"%+.1f",value);
			_stprintf(Buffer4[i][curpage],_T("%S"),text);
		}

		// Altitude
		value=ALTITUDEMODIFY*LKTraffic[rli].Altitude;
		if (value<-1000 || value >45000 )
			strcpy(text,"---");
		else
			sprintf(text,"%.0f",value);
		wsprintf(Buffer5[i][curpage], TEXT("%S"),text);

	} else {
		// Empty traffic, fill in all empty data and maybe break loop
		_stprintf(Buffer1[i][curpage],_T("------------"));
		_stprintf(Buffer2[i][curpage],_T("---"));
		_stprintf(Buffer3[i][curpage],_T("---"));
		_stprintf(Buffer4[i][curpage],_T("---"));
		_stprintf(Buffer5[i][curpage],_T("---"));
	}


	if ((rli>=0) && (LKTraffic[rli].ID>0)) {
		drawn_items_onpage++;
		if (LKTraffic[rli].Status == LKT_REAL) {
			rcolor=RGB_WHITE;
  			SelectObject(hdc, LK8InfoBigFont);
		} else {
			if (LKTraffic[rli].Status == LKT_GHOST) {
				rcolor=RGB_LIGHTYELLOW;
			} else {
				rcolor=RGB_LIGHTRED;
			}
  			SelectObject(hdc, LK8InfoBigItalicFont);
		}
	} else 
		rcolor=RGB_GREY;

	LKWriteText(hdc, Buffer1[i][curpage], Column1, iRaw , 0, WTMODE_NORMAL, WTALIGN_LEFT, rcolor, false);
	
  	SelectObject(hdc, LK8InfoBigFont); // Text font for Nearest
	LKWriteText(hdc, Buffer2[i][curpage], Column2, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

	LKWriteText(hdc, Buffer3[i][curpage], Column3, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

	LKWriteText(hdc, Buffer4[i][curpage], Column4, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

	LKWriteText(hdc, Buffer5[i][curpage], Column5, iRaw , 0, WTMODE_NORMAL, WTALIGN_RIGHT, rcolor, false);

  }  // for


  if (LKevent==LKEVENT_NEWRUN || LKevent==LKEVENT_NEWPAGE ) {
		LKevent=LKEVENT_NONE;
		return;
  }

  if (drawn_items_onpage>0) {

	if (SelectedRaw[curmapspace] <0 || SelectedRaw[curmapspace]>(TrafficNumraws-1)) {
  		LKevent=LKEVENT_NONE; // 100328
		return;
	}
	if (SelectedRaw[curmapspace] >= drawn_items_onpage) {
		if (LKevent==LKEVENT_DOWN) SelectedRaw[curmapspace]=0;
		else 
		if (LKevent==LKEVENT_UP) SelectedRaw[curmapspace]=drawn_items_onpage-1;
		else {
			SelectedRaw[curmapspace]=0;
		}
	}
	invsel.left=left;
	invsel.right=right;
	invsel.top=TopSize+(s_rawspace*SelectedRaw[curmapspace])+NIBLSCALE(2);
	invsel.bottom=TopSize+(s_rawspace*(SelectedRaw[curmapspace]+1))-NIBLSCALE(1);
	InvertRect(hdc,&invsel);

  } 

  LKevent=LKEVENT_NONE;
  return;
}
示例#21
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageViewCenter,enMode_Spread);
	DrawViewImage(pDC,m_ImageViewBack,enMode_Centent);

	//绘画用户
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

#ifdef _DEBUG
		////测试代码
		//tagUserData Obj;
		//Obj.cbUserStatus = US_READY;
		//Obj.lScore = 999999999;
		//_sntprintf( Obj.szName,sizeof(Obj.szName),TEXT("用户的名字"));
		//wUserTimer = i+1;
		//pUserData = &Obj;
		////庄家标志
		//CImageHandle ImageHandleBanker(&m_ImageBanker);
		//m_ImageBanker.AlphaDrawImage(pDC,m_PointBanker[i].x,m_PointBanker[i].y,m_ImageBanker.GetWidth(),m_ImageBanker.GetHeight(),0,0,RGB(255,0,255));

#endif
	
		//绘画用户
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextAlign((i==1)?TA_RIGHT:TA_LEFT);
			pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));

			//用户金币
			TCHAR szBuffer[64]=TEXT("");
			LONGLONG lLeaveScore=pUserData->lScore-m_lTableScore[i];
			_snprintf(szBuffer,sizeof(szBuffer),TEXT(" [%s]"/*"[¥%I64d]"*/),/*lLeaveScore*/NumToString(lLeaveScore));
			int TempX=0;
			int TempY=0;
			if(i%2==1)
			{
				TempX=35;
				if(i==3)TempX*=-1;
				TempY=30;
			}

			//获取用户名长度
			CSize szStr;
			int iLen=lstrlen(pUserData->szName);
			GetTextExtentPoint(pDC->GetSafeHdc(), pUserData->szName, iLen, &szStr);

			//用户名字
			DrawTextString(pDC,pUserData->szName,RGB(255,255,255),RGB(0,0,0),m_ptName[i].x-60,m_ptName[i].y+TempY);
			//用户金币
			DrawTextString(pDC,szBuffer,RGB(230,215,90),RGB(0,0,0),m_ptName[i].x-60+szStr.cx,m_ptName[i].y+TempY);

			//其他信息
			if (wUserTimer!=0)
			{
				//if(m_bCallUser!=0xff)DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
				//else if (pUserData->cbUserStatus==US_PLAY)
				//if(pUserData->cbUserStatus<=US_SIT/*GS_FREE*/)
				if (wUserTimer<60)
					DrawUserTimer(pDC,nWidth/2,nHeight/2-25,wUserTimer);
				else
				{
					DrawUserTimer(pDC,nWidth/2,nHeight/2-25,0);
				}
				//else DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			}
			if (pUserData->cbUserStatus==US_READY) 
			{
				//DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
				m_pngNiuNum.DrawImage(pDC, m_ptReady[i].x,m_ptReady[i].y, m_pngNiuNum.GetWidth()/13, m_pngNiuNum.GetHeight(), (m_pngNiuNum.GetWidth()/13)*11, 0);
			}
			//DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE,32,32);
		}
	}

	//等待下注
	if (m_bInvest==true)
	{
		//创建资源
// 		CFont InfoFont;
// 		InfoFont.CreateFont(-24,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("楷体_GB2312"));
// 
// 		//设置 DC
// 		pDC->SetTextAlign(TA_CENTER|TA_TOP);
// 		CFont * pOldFont=pDC->SelectObject(&InfoFont);
// 
// 		//绘画信息
// 		TCHAR zsInfo[128]=TEXT("");
// 		_sntprintf(zsInfo,sizeof(zsInfo),TEXT("等待闲家下注"));
// 		DrawTextString(pDC,zsInfo,RGB(250,200,40),RGB(0,0,0),nWidth/2,nHeight/2);
// 
// 		//清理资源
// 		pDC->SelectObject(pOldFont);
// 		InfoFont.DeleteObject();
		int x = (nWidth-m_pngWaitBet.GetWidth())/2;
		m_pngWaitBet.DrawImage(pDC, x, nHeight/2);
	}

	//特殊牌型
	if (m_bUserAction==true)
	{
		//创建资源
		CFont InfoFont;
		InfoFont.CreateFont(-16,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("楷体_GB2312"));

		//设置 DC
		pDC->SetTextColor(RGB(250,200,40));
		pDC->SetTextAlign(TA_CENTER|TA_TOP);
		CFont * pOldFont=pDC->SelectObject(&InfoFont);

		//绘画信息
		pDC->TextOut(nWidth/2,nHeight/2+150,"特殊牌型,系统自动为你配牌 ^-^");

		//清理资源
		pDC->SelectObject(pOldFont);
		InfoFont.DeleteObject();
	}

	//等待摊牌
	if (m_bOpenCard==true)
	{
// 		//创建资源
// 		CFont InfoFont;
// 		InfoFont.CreateFont(-24,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("楷体_GB2312"));
// 
// 		//设置 DC
// 		pDC->SetTextColor(RGB(250,200,40));
// 		pDC->SetTextAlign(TA_CENTER|TA_TOP);
// 		CFont * pOldFont=pDC->SelectObject(&InfoFont);
// 
// 		//绘画信息
// 		TCHAR zsInfo[128]=TEXT("");
// 		_sntprintf(zsInfo,sizeof(zsInfo),TEXT("等待玩家摊牌"));
// 		DrawTextString(pDC,zsInfo,RGB(250,200,40),RGB(0,0,0),nWidth/2,nHeight/2);
// 
// 		//清理资源
// 		pDC->SelectObject(pOldFont);
// 		InfoFont.DeleteObject();
	}

	//等待叫庄
	if(m_bCallUser!=0xff && (m_bCallUser!=2 || m_bLookOnUser))
	{
		CImageHandle HandleOx(&m_ImageWaitCall);
		int y=m_SendEndingPos[m_bCallUser].y+10;
		int x=nWidth/2 - m_ImageWaitCall.GetWidth()/2;
		if(m_bCallUser==1)x=nWidth/2+273-120;
		else if(m_bCallUser==3)x=nWidth/2-273-30;
		else if(m_bCallUser==0)y+=30;
// 		m_ImageWaitCall.AlphaDrawImage(pDC,x,y,m_ImageWaitCall.GetWidth(),
// 			m_ImageWaitCall.GetHeight(),0,0,RGB(255,0,255));

		m_pngWaitCall.DrawImage(pDC, x,y);
	}

	//庄家信息
	if (m_wBankerUser!=INVALID_CHAIR)
	{
		const tagUserData * pUserData=GetUserInfo(m_wBankerUser);
		if (pUserData!=NULL)
		{
			//庄家标志
			//CImageHandle ImageHandleBanker(&m_ImageBanker);
			//m_ImageBanker.AlphaDrawImage(pDC,m_PointBanker[m_wBankerUser].x,m_PointBanker[m_wBankerUser].y,m_ImageBanker.GetWidth(),m_ImageBanker.GetHeight(),0,0,RGB(255,0,255));
			m_pngBanker.DrawImage(pDC, m_PointBanker[m_wBankerUser].x,m_PointBanker[m_wBankerUser].y);
		}
	}

	//绘画积分
	for (BYTE i=0;i<GAME_PLAYER;i++)
	{
		const tagUserData * pUserData=GetUserInfo(i);
		if (pUserData!=NULL &&(m_lTableScore[i]!=0L || m_bShowSocre[i]))
		{
			int iPos=1;
			if(m_bShowSocre[i])
			{
				if(m_lTableScore[i]>0L)iPos=0;
				else if(m_lTableScore[i]<=0L)iPos=2;
			}
			CImageHandle HandleScore(&m_ImageScore);
			m_ImageScore.AlphaDrawImage(pDC,m_ptJeton[i].x,m_ptJeton[i].y,m_ImageScore.GetWidth()/3,
				m_ImageScore.GetHeight(),m_ImageScore.GetWidth()/3*iPos,0,RGB(255,0,255));

			//创建字体
			CFont ViewFont;
			ViewFont.CreateFont(-16,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("宋体"));

			//设置 DC
			//pDC->SetTextAlign(TA_CENTER);
			pDC->SetTextAlign(TA_LEFT);
			CFont * pOldFont=pDC->SelectObject(&ViewFont);

			//绘画信息
			TCHAR tc[NAME_LEN]=TEXT("");
			_sntprintf(tc,sizeof(tc),TEXT("%I64d"),m_lTableScore[i]);
			//nWidth/2,nHeight/2
			//DrawTextString(pDC,tc,RGB(247,231,8),RGB(255,255,255),nWidth/2+10,m_ptJeton[i].y+15);
			CRect rcScore;
			rcScore.left = m_ptJeton[i].x-50;
			rcScore.top = m_ptJeton[i].y;
			rcScore.bottom = rcScore.top+m_ImageScore.GetHeight();
			rcScore.right = rcScore.left + m_ImageScore.GetWidth()/3+100;

			//DrawTextString(pDC, tc, RGB(247,231,8),RGB(255,255,255), rcScore);
			pDC->SetTextColor(RGB(247,231,8));
			pDC->DrawText(tc,lstrlen(tc),&rcScore,DT_VCENTER|DT_CENTER|DT_SINGLELINE|DT_END_ELLIPSIS);
			//pDC->Draw3dRect(rcScore, RGB(255,255,255),RGB(255,255,255));

			//清理资源
			pDC->SelectObject(pOldFont);
			ViewFont.DeleteObject();
		}
	}

	//显示摊牌标志
	for (BYTE i=0;i<GAME_PLAYER;i++)
	{
		if (m_bOpenCardUser[i]==TRUE)
		{
			//创建字体
			CFont ViewFont;
			ViewFont.CreateFont(-20,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("华文彩云"));

			//设置 DC
			pDC->SetTextAlign(TA_LEFT);
			CFont * pOldFont=pDC->SelectObject(&ViewFont);

			//绘画信息
// 			TCHAR tc[NAME_LEN]=TEXT("");
// 			_snprintf(tc,sizeof(tc),"摊");
			INT x,y;
			if(i==0)
			{
				x = m_ptJeton[i].x+20;
				y = m_ptJeton[i].y+40;
			}
			else if(i==1)
			{
				x = m_ptJeton[i].x+97;
				y = m_ptJeton[i].y-55;
			}
			else if(i==2)
			{
				x =m_ptJeton[i].x+20;
				y = m_ptJeton[i].y-60;
			}
			else 
			{
				x = m_ptJeton[i].x-37;
				y = m_ptJeton[i].y-55;
			}
			//DrawTextString(pDC,tc,RGB(250,128,56),RGB(0,0,0),x,y);
			m_pngNiuNum.DrawImage(pDC, x, y, m_pngNiuNum.GetWidth()/13, m_pngNiuNum.GetHeight(), (m_pngNiuNum.GetWidth()/13)*12, 0);


			//清理资源
			pDC->SelectObject(pOldFont);
			ViewFont.DeleteObject();
		}
	}

	//绘画扑克
	if (m_SendCardItemArray.GetCount()>0)
	{
		//变量定义
		CImageHandle HandleCard(&m_ImageCard);
		tagSendCardItem * pSendCardItem=&m_SendCardItemArray[0];

		//获取大小
		int nItemWidth=m_ImageCard.GetWidth()/13;
		int nItemHeight=m_ImageCard.GetHeight()/5;

		//绘画扑克
		int nXPos=m_SendCardPos.x-nItemWidth/2;
		int nYPos=m_SendCardPos.y-nItemHeight/2+10;
		m_ImageCard.AlphaDrawImage(pDC,nXPos,nYPos,nItemWidth,nItemHeight,nItemWidth*2,nItemHeight*4,RGB(255,0,255));
	}

	//显示点数
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		if(m_bOxValue[i]!=0xff)
		//if((m_bOxValue[i]=OX_THREE_SAME) || true)
		{
			if(m_bShow || i==2)
			{
				INT nxSp = m_pngNiuNum.GetWidth()/13;
				if(m_bOxValue[i]!=0)
				{
					CImageHandle HandleOxValue(&m_ImageOxValue);
					INT nXpt = (i%2!=0)?(m_ptValue[i].x-80):(m_CardControl[i].GetCardPos().x-2-m_pngNiuNum.GetWidth()/13);
					INT nypt = m_ptValue[i].y;
// 					m_ImageOxValue.AlphaDrawImage(pDC,nXpt,nypt,
// 						m_ImageOxValue.GetWidth(),m_ImageOxValue.GetHeight(),0,0,RGB(255,0,255));

					if(m_bOxValue[i]>=OX_THREE_SAME)
					{
						pDC->SetTextColor(RGB(0,0,0));
						pDC->SetTextAlign(TA_LEFT);
						TCHAR tCh[64]= {0};
						_snprintf(tCh, 64, TEXT("花牛"));
						if(m_bOxValue[i]==OX_THREE_SAME)_sntprintf(tCh,64,TEXT("葫芦"));
						else if(m_bOxValue[i]==OX_FOUR_SAME)_sntprintf(tCh,64,TEXT("炸弹"));
						pDC->TextOut(nXpt+33,nypt+10,tCh,lstrlen(tCh));
					}	
					else if(m_bOxValue[i]==10)
					{
// 						CImageHandle HandleDoulbeOx(&m_ImageDoulbeOx);
// 						m_ImageDoulbeOx.AlphaDrawImage(pDC,nXpt+33,nypt+6,
// 							m_ImageDoulbeOx.GetWidth(),m_ImageDoulbeOx.GetHeight(),0,0,RGB(255,0,255));
						INT nXpt = m_ptValue[i].x;
						INT nypt = m_ptValue[i].y;
						m_pngNiuNum.DrawImage(pDC, nXpt-((i!=1)?30:5), nypt+1, nxSp, m_pngNiuNum.GetHeight(), nxSp*10, 0);
					}	
					else if(m_bOxValue[i]<10)
					{
// 						CImageHandle HandleNumber(&m_ImageNumber);
// 						m_ImageNumber.AlphaDrawImage(pDC,nXpt+35,nypt+7,
// 							m_ImageNumber.GetWidth()/9,m_ImageNumber.GetHeight(),
// 							m_ImageNumber.GetWidth()/9*((int)m_bOxValue[i]-1),0,RGB(255,0,255));
						m_pngNiuNum.DrawImage(pDC, nXpt, nypt+6, nxSp, m_pngNiuNum.GetHeight(), nxSp*((int)m_bOxValue[i]), 0);
					}
				}
				else if(m_bOxValue[i]==0)
				{				
 					INT nXpt = m_ptValue[i].x;
 					INT nypt = m_ptValue[i].y;
// 					CImageHandle HandleOxValueZero(&m_ImageOxValueZero);
// 					m_ImageOxValueZero.AlphaDrawImage(pDC,nXpt+((i!=1)?31:5),nypt+1,
// 						m_ImageOxValueZero.GetWidth(),m_ImageOxValueZero.GetHeight(),0,0,RGB(255,0,255));
					m_pngNiuNum.DrawImage(pDC ,nXpt-((i!=1)?30:5), nypt+1, nxSp, m_pngNiuNum.GetHeight(), 0, 0);
				}
			}
		}
	}
	return;
}
示例#22
0
文件: dskbench.c 项目: mingpen/OpenNT
VOID
DrawMeterBar(
    HWND   hwnd,
    DWORD  ctlId,
    DWORD  wPartsComplete,
    DWORD  wPartsInJob,
    BOOL   fRedraw
    )
{
    RECT    rcPrcnt;
    DWORD   dwColor;
    SIZE    size;
    DWORD   pct;
    CHAR    szPercentage[255];
    HPEN    hpen;
    HPEN    oldhpen;
    HDC     hDC;
    RECT    rcItem;
    POINT   pt;


    wPartsComplete == 0;

    hDC = GetDC( hwnd );

    GetWindowRect( GetDlgItem(hwnd,ctlId), &rcItem );

    pt.x = rcItem.left;
    pt.y = rcItem.top;
    ScreenToClient( hwnd, &pt );
    rcItem.left = pt.x;
    rcItem.top  = pt.y;

    pt.x = rcItem.right;
    pt.y = rcItem.bottom;
    ScreenToClient( hwnd, &pt );
    rcItem.right  = pt.x;
    rcItem.bottom = pt.y;

    hpen = CreatePen( PS_SOLID, 1, RGB(0,0,0) );
    oldhpen = SelectObject( hDC, hpen );
    if (fRedraw) {
        Rectangle( hDC, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom );
    }
    SelectObject( hDC, oldhpen );
    DeleteObject( hpen );
    rcItem.left   += 2;
    rcItem.top    += 2;
    rcItem.right  -= 2;
    rcItem.bottom -= 2;

    //
    // Set-up default foreground and background text colors.
    //
    SetBkColor( hDC, RGB(125,125,125) );
    SetTextColor( hDC, RGB(125,58,125) );

    SetTextAlign(hDC, TA_CENTER | TA_TOP);

    //
    // Invert the foreground and background colors.
    //
    dwColor = GetBkColor(hDC);
    SetBkColor(hDC, SetTextColor(hDC, dwColor));

    //
    // calculate the percentage done
    //
    try {
        pct = (DWORD)((float)wPartsComplete / (float)wPartsInJob * 100.0);
    } except(EXCEPTION_EXECUTE_HANDLER) {
        pct = 0;
    }

    //
    // Set rectangle coordinates to include only left part of the window
    //
    rcPrcnt.top    = rcItem.top;
    rcPrcnt.bottom = rcItem.bottom;
    rcPrcnt.left   = rcItem.left;
    rcPrcnt.right  = rcItem.left +
                     (DWORD)((float)(rcItem.right - rcItem.left) * ((float)pct / 100));

    //
    // Output the percentage value in the window.
    // Function also paints left part of window.
    //
    wsprintf(szPercentage, "%d%%", pct);
    GetTextExtentPoint(hDC, "X", 1, &size);
    ExtTextOut( hDC,
                (rcItem.right - rcItem.left) / 2,
                rcItem.top + ((rcItem.bottom - rcItem.top - size.cy) / 2),
                ETO_OPAQUE | ETO_CLIPPED,
                &rcPrcnt,
                szPercentage,
                strlen(szPercentage),
                NULL
              );

    //
    // Adjust rectangle so that it includes the remaining
    // percentage of the window.
    //
    rcPrcnt.left = rcPrcnt.right;
    rcPrcnt.right = rcItem.right;

    //
    // Invert the foreground and background colors.
    //
    dwColor = GetBkColor(hDC);
    SetBkColor(hDC, SetTextColor(hDC, dwColor));

    //
    // Output the percentage value a second time in the window.
    // Function also paints right part of window.
    //
    ExtTextOut( hDC,
                (rcItem.right - rcItem.left) / 2,
                rcItem.top + ((rcItem.bottom - rcItem.top - size.cy) / 2),
                ETO_OPAQUE | ETO_CLIPPED,
                &rcPrcnt,
                szPercentage,
                strlen(szPercentage),
                NULL
              );
    ReleaseDC( hwnd, hDC );
    return;
}
示例#23
0
LRESULT CALLBACK _export BalloonProc(HWND hwnd, UINT message, WPARAM wParam,
                                     LPARAM lParam)
{
static DWORD lasttime;  // ??? should be a property
static POINT ttpos;
  RECT rect;
  POINT point;
  int x, y, width, height;
  SIZE size;
  LPSTR ptr;
  char text[256];

  switch (message) {
  case WM_CREATE: {
    HFONT hfont = CreateFont(-11, 0, 0, 0, FW_NORMAL, FALSE, 0, 0, DEFAULT_CHARSET,
                             OUT_DEFAULT_PRECIS, CLIP_CHARACTER_PRECIS,
                             PROOF_QUALITY, FF_DONTCARE, "MS Sans Serif");
    SetProp(hwnd,MAKEINTRESOURCE(atomFont),hfont);
    break;
  } /* case */

  case WM_DESTROY: {
    HFONT hfont = (HFONT)GetProp(hwnd,MAKEINTRESOURCE(atomFont));
    if (hfont)
      DeleteObject(hfont);
    RemoveProp(hwnd,MAKEINTRESOURCE(atomAlignStyle));
    RemoveProp(hwnd,MAKEINTRESOURCE(atomTailSize));
    RemoveProp(hwnd,MAKEINTRESOURCE(atomTimeout));
    RemoveProp(hwnd,MAKEINTRESOURCE(atomFont));
    break;
  } /* case */

  case WM_ERASEBKGND:
    return 0L;

  case WM_LBUTTONDOWN:
  case WM_RBUTTONDOWN:
  case WM_LBUTTONUP:
  case WM_RBUTTONUP:
    ShowWindow(hwnd, SW_HIDE);
    if (IsWindow(GetParent(hwnd)))
      PostMessage(GetParent(hwnd), BAN_VISIBLE, (WPARAM)hwnd, 0L);
    break;

  case WM_WINDOWPOSCHANGING:
  case WM_WINDOWPOSCHANGED:
    return 0L;

  case WM_PAINT: {
    PAINTSTRUCT ps;
    COLORREF clrBackgr;
    HBRUSH hbrBackgr;
    HRGN hrgn;
    int AlignStyle=(int)GetProp(hwnd,MAKEINTRESOURCE(atomAlignStyle));
    HFONT hfont = (HFONT)GetProp(hwnd,MAKEINTRESOURCE(atomFont));

    HDC hdc = BeginPaint(hwnd, &ps);
    GetClientRect(hwnd, &rect);

    clrBackgr=GetNearestColor(hdc, RGB(255,255,192));
    hbrBackgr = CreateSolidBrush(clrBackgr);
    #if defined __WIN32__
      hrgn=CreateRectRgn(0,0,1,1);
      GetWindowRgn(hwnd,hrgn);      /* Win32-only */
    #else
      #if BM_RADIUS==0
        hrgn=CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom);
      #else
        hrgn=CreateRoundRectRgn(rect.left, rect.top, rect.right, rect.bottom, BM_RADIUS, BM_RADIUS);
      #endif
    #endif
    FillRgn(hdc,hrgn,hbrBackgr);
    FrameRgn(hdc,hrgn,GetStockObject(BLACK_BRUSH),1,1);
    DeleteObject(hbrBackgr);

    hfont = SelectObject(hdc, hfont);
    GetWindowText(hwnd, text, sizeof text);
    GetTextExtentPoint(hdc, text, lstrlen(text), &size);
    SetBkMode(hdc, TRANSPARENT);
    y=BM_MARGINTOP;
    if (AlignStyle==BAA_TOP) {
      int TailSize=(int)GetProp(hwnd,MAKEINTRESOURCE(atomTailSize));
      y+=TailSize;
    } /* if */
    for (ptr=strtok(text,"\n"); ptr!=NULL; ptr=strtok(NULL,"\n"), y+=size.cy) {
      GetTextExtentPoint(hdc, ptr, lstrlen(ptr), &size);
      x = ((rect.right-rect.left) - size.cx) / 2;
      TextOut(hdc, x, y, ptr, lstrlen(ptr));
    } /* for */
    SelectObject(hdc, hfont);

    EndPaint(hwnd, &ps);
    break;
  } /* case */

  case WM_TIMER: {
    DWORD timeout=(DWORD)GetProp(hwnd,MAKEINTRESOURCE(atomTimeout));
    DWORD curtime=GetTickCount();
    GetCursorPos(&point);
    if (timeout==0)
      break;
    if (curtime >= lasttime+timeout)
      SendMessage(hwnd, BAM_SHOW, 0, 0L);
    break;
  } /* if */

  case BAM_SETPOS:
    ttpos=*(LPPOINT)lParam;
    break;

  case BAM_SHOW:
    if (wParam) {
      HDC hdc;
      HRGN hrgn;
      int AlignStyle=(int)GetProp(hwnd,MAKEINTRESOURCE(atomAlignStyle));
      int TailSize=(int)GetProp(hwnd,MAKEINTRESOURCE(atomTailSize));
      HFONT hfont=(HFONT)GetProp(hwnd,MAKEINTRESOURCE(atomFont));
      ASSERT(lParam!=0);
      lstrcpy(text, (LPSTR)lParam);
      SetWindowText(hwnd, text);
      InvalidateRect(hwnd, NULL, FALSE);
      hdc = GetDC(hwnd);
      hfont = SelectObject(hdc, hfont);
      for (ptr=strtok(text,"\n"), width=height=0; ptr!=NULL; ptr=strtok(NULL,"\n")) {
        GetTextExtentPoint(hdc, ptr, lstrlen(ptr), &size);
        width = max(width, size.cx);
        height += size.cy;
      } /* for */
      SelectObject(hdc, hfont);
      ReleaseDC(hwnd, hdc);
      width += 2*BM_MARGINX;
      height += BM_MARGINTOP + BM_MARGINBOTTOM;
      #if 0
        // round width up to multiple of 16 pixels and height up to a multiple
        // of 8 pixels
        width+=16-1;
        width=width - (width%16);
        height+=8-1;
        height=height - (height%8);
      #endif
      // also add the tail size to the height
      height+=TailSize;
      // check alignment
      switch (AlignStyle) {
      case BAA_TOP:
        x = ttpos.x - width/4;
        y = ttpos.y;
        break;
      case BAA_BOTTOM:
        x = ttpos.x - width/4;
        y = ttpos.y - height;
        break;
      } /* switch */
      // check screen position against the screen size (width)
      if (x < 0)
        x = 0;
      else if (x+width >= GetSystemMetrics(SM_CXSCREEN)-1)
        x = GetSystemMetrics(SM_CXSCREEN) - width - 1;
      if (y < 0)
        y = 0;
      else if (y+height >= GetSystemMetrics(SM_CYSCREEN)-1)
        y = GetSystemMetrics(SM_CYSCREEN) - height - 1;
      GetWindowRect(hwnd,&rect);  // get first, check later (for new region)
      SetWindowPos(hwnd, HWND_TOPMOST, x, y, width, height, SWP_SHOWWINDOW|SWP_NOACTIVATE);
      hrgn=MakeBalloonRegion(width+1,height+1,BM_RADIUS,AlignStyle,TailSize,ttpos.x-x,ttpos.y-y);
      ASSERT(hrgn!=NULL);
      SetWindowRgn(hwnd, hrgn, TRUE);
      UpdateWindow(hwnd);
      lasttime=GetTickCount();
    } else {
      ShowWindow(hwnd, SW_HIDE);
      lasttime=GetTickCount();
    } /* if */
    break;

  default:
    return DefWindowProc(hwnd, message, wParam, lParam);
  } /* switch */
  return 0L;
}
示例#24
0
BOOL StringToBitmap::TTFAddString(String_256 *text, UINT32 Xsize, UINT32 Ysize, UINT32 DPI, PLOGFONT pLogFont,
                                  INT32 IntLeading, KernelBitmap **BM, UINT32 ForeColour)
{
    KernelBitmap *Bitmap = *BM;

    /*	HDC ScreenDC = CreateCompatibleDC(NULL);
    	if (ScreenDC == NULL)
    	{
    		ERROR3("StringToBitmap::AddString: Unable to create screen DC");
    		return FALSE;
    	}*/

    CDC SysDisplay;
    BOOL ok=SysDisplay.CreateCompatibleDC(NULL);
    if(!ok)
    {
        //DeleteDC(ScreenDC);
        ERROR3("StringToBitmap::TTF AddString: Unable to create CDC");
        return FALSE;
    }

    HDC ScreenDC = SysDisplay.m_hDC;

    // bodge to get things working with GetBezierFromChar
    INT32 OldlfHeight = pLogFont->lfHeight;
    pLogFont->lfHeight = -(pLogFont->lfHeight - IntLeading);

    UINT32 CurrentPathSizeAlloc = 0;
    Trans2DMatrix *pTransform = NULL;
    DocCoord *pPathCoords = NULL;

    Path *pPath = NULL;
    //pPath = new Path();

    DocCoord *pPolyCordBuffer = NULL;
    PathVerb *pPolyVerbBuffer = NULL;
    UINT32 TextLength = (UINT32)text->Length();
    SIZE StringSize= {0,0};

    // Get handle of font

//	HFONT hNewFont = CreateFontIndirect(pLogFont);
//	HGDIOBJ hOldFont = SelectObject(ScreenDC, hNewFont);

    CFont UnHintedCFont;
    if(!UnHintedCFont.CreateFontIndirect(pLogFont))
    {
        SysDisplay.DeleteDC();
        pLogFont->lfHeight = OldlfHeight;
        return FALSE;
    }

    CFont* pOldCFont=SysDisplay.SelectObject(&UnHintedCFont);

    // Get the default character to use if a charater is not present in the font.
    WCHAR FontDefaultCharacter = (unsigned char)'?';
    TEXTMETRIC FontTextData;
#ifdef _UNCCODE
    if (SysDisplay.GetTextMetrics(&FontTextData))
        FontDefaultCharacter = FontTextData.tmDefaultChar;
#else
    if (SysDisplay.GetTextMetrics(&FontTextData))
        FontDefaultCharacter = (unsigned char)FontTextData.tmDefaultChar;
#endif

    // Work out a nice scaling factor so the font fits in the bitmap ok...

    // Not 32 ?
    GetTextExtentPoint(ScreenDC, *text, TextLength, &StringSize);

    if(StringSize.cy == 0)
    {
        SysDisplay.SelectObject(pOldCFont);
        SysDisplay.DeleteDC();
        pLogFont->lfHeight = OldlfHeight;
        return FALSE;
    }

    //ERROR3IF(!ok, "Initial GetTextExtentPoint32() failed");
    double YScale = ((double)Ysize / (double)StringSize.cy) / (double)2;
    double XScale = YScale;

    // Shift thumbnail upwards, and scale down a bit - to get the g's looking right
    // One or two fonts require this reducing (their tops are clipped), 72000/100 is
    // about right for most of them though...
    // Note the external previews were done with 72000/220 for Matrix and 72000/140 for
    // the capital only fonts.
    double YShift = 72000/100;//72000/80;

    YScale = (YScale * 78) / 100;
    XScale = (XScale * 78) / 100;

    if(!text->IsEmpty())
    {
        const TCHAR* pCurrentChar = (const TCHAR*)(*text);

        while (ok && *pCurrentChar!=0)
        {
            // Get the current character as Unicode.
#ifdef _UNICODE
            WCHAR wchr = *pCurrentChar;		// pCurrentChar is a pointer to WCHAR in _UNICODE builds
#else
            UINT32 CharToConvert = 0;
            if (UnicodeManager::IsDBCSLeadByte(*pCurrentChar))
                CharToConvert = UnicodeManager::ComposeMultiBytes(*pCurrentChar, *(pCurrentChar+1));
            else
                CharToConvert = (unsigned char)(*pCurrentChar);
            WCHAR wchr = UnicodeManager::MultiByteToUnicode(CharToConvert);
#endif

            // Get positioning information for this character
            ok = GetTextExtentPoint(ScreenDC, *text, (pCurrentChar-(TCHAR*)(*text)), &StringSize);
            ERROR3IF(!ok, "GetTextExtentPoint32() failed");
            if (!ok) break;

            // Get the characters path
            DWORD PathSize = 0;
            ok = TextManager::GetBezierFromChar(&SysDisplay, wchr, pLogFont, &PathSize, (POINT *)NULL, (BYTE *)NULL);
            if (!ok)
            {
                wchr = FontDefaultCharacter;
                ok = TextManager::GetBezierFromChar(&SysDisplay, wchr, pLogFont, &PathSize, (POINT *)NULL, (BYTE *)NULL);
            }
            ERROR3IF(!ok, "GetBezierFromChar returned false");
            if (!ok) break;

            // Pointer to an array of path coordinates
            if(pPolyCordBuffer == NULL)
            {
                TRY
                {
                    pPolyCordBuffer = new DocCoord[PathSize];
                }
                CATCH (CMemoryException, e)
                {
                    pPolyCordBuffer = NULL;
                    /*ERROR(_R(IDS_OUT_OF_MEMORY), FALSE);*/
                }
                END_CATCH
            }

            // Pointer to an array of path verbs
            if(pPolyVerbBuffer == NULL)
            {
                TRY
                {
                    pPolyVerbBuffer = new PathVerb[PathSize];
                }
                CATCH (CMemoryException, e)
                {
                    pPolyVerbBuffer = NULL;
                    /*ERROR(_R(IDS_OUT_OF_MEMORY), FALSE);*/
                }
                END_CATCH
            }

            if (pPolyCordBuffer == NULL || pPolyVerbBuffer == NULL)
            {
                ok = FALSE;
                break;
            }

            CurrentPathSizeAlloc = PathSize;

            // Fill up the buffers until they're bursting with fontyness
            ok = TextManager::GetBezierFromChar(&SysDisplay, wchr, pLogFont, &PathSize, (POINT *)pPolyCordBuffer,
                                                (BYTE *)pPolyVerbBuffer);
            if(!ok) TRACEUSER( "Richard", _T("GetBezierFromChar returned false in second phase...\n"));
            if(!ok)	break;

            // Spaces set PathSize to zero
            if((PathSize > 0)/* && (pPath != NULL)*/)
            {
                pPath = new Path();
                pPath->Initialise(PathSize, 12);
                pPath->CopyPathDataFrom(pPolyCordBuffer, pPolyVerbBuffer, PathSize, TRUE);

                // Major bodge at present with the x spacing...
                Matrix scale(XScale, 0, 0, YScale, (INT32)((XScale*StringSize.cx*72000)/(double)DPI), (INT32)YShift);

                pTransform = new Trans2DMatrix(scale);
                pPathCoords = pPath->GetCoordArray();
                pTransform->Transform( pPathCoords, pPath->GetNumCoords() );
                delete pTransform;

                pPath->InitialiseFlags();

                ok = ALU->GradFillPath(pPath, ForeColour, ForeColour, 0, 0, 0,/*Xsize/2,*/ Ysize, S2BMP_ANTIALIAS);
                ERROR3IF(!ok, "Gradfillpath returned false");
                if(!ok)	break;

                delete pPath;
            }

            // S2BMP_MAGIC is the worderfully fabby constant that mark's getbezierfromchar returns
            // Theory goes that he's going to sort this out sometime...
            if(CurrentPathSizeAlloc != S2BMP_MAGIC)
            {
                delete []pPolyCordBuffer;
                delete []pPolyVerbBuffer;

                pPolyCordBuffer = NULL;
                pPolyVerbBuffer = NULL;
                CurrentPathSizeAlloc = 0;
            }

            pPath = NULL;
            pTransform = NULL;

            pCurrentChar = camStrinc(pCurrentChar);
        }
示例#25
0
void Elapsed_OnCreate (ElapsedInfo *pei)
{
   Subclass_AddHook (GetParent(pei->hElapsed), ElapsedDlgProc);

   TCHAR szTimeSep[ cchRESOURCE ];
   if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STIME, szTimeSep, cchRESOURCE))
      lstrcpy (szTimeSep, TEXT(":"));

   RECT rElapsed;
   GetClientRect (pei->hElapsed, &rElapsed);

   POINT ptElapsed = {0,0};
   ClientToScreen (pei->hElapsed, &ptElapsed);
   ScreenToClient (GetParent (pei->hElapsed), &ptElapsed);

   SIZE s88; // size of widest likely double-digit number
   SIZE s888; // maximum width to which we'll go for second- and minute- fields
   SIZE sTimeSep; // size of ":"

   HDC hdc = GetDC (GetParent (pei->hElapsed));
   GetTextExtentPoint (hdc, TEXT("88"), lstrlen(TEXT("88")), &s88);
   GetTextExtentPoint (hdc, szTimeSep, lstrlen(szTimeSep), &sTimeSep);
   ReleaseDC (GetParent (pei->hElapsed), hdc);

   s888 = s88;
   s888.cx = (LONG)( (double)(s88.cx) * 1.2 );

   LONG cxNumbers = cxRECT(rElapsed) - (2 * sTimeSep.cx) - GetSystemMetrics (SM_CXVSCROLL);
   LONG cxSeconds = min( max( cxNumbers/3, s88.cx ), s888.cx );
   LONG cxMinutes = min( max( cxNumbers/3, s88.cx ), s888.cx );
   LONG cxHours   = cxNumbers - cxSeconds - cxMinutes;
   LONG yy = ptElapsed.y;
   LONG cy = cyRECT(rElapsed);

   pei->idHours = 100+NextControlID (GetParent (pei->hElapsed));
   pei->hHours = CreateWindow (
                TEXT("EDIT"),
                TEXT(""),
                WS_CHILD | WS_TABSTOP | ES_RIGHT | ES_NUMBER,
                ptElapsed.x, yy, cxHours, cy,
                GetParent(pei->hElapsed),
                (HMENU)pei->idHours,
                THIS_HINST,
                0);

   pei->hSep1 = CreateWindow (
                TEXT("STATIC"),
                szTimeSep,
                WS_CHILD,
                ptElapsed.x + cxHours, yy, sTimeSep.cx, cy,
                GetParent(pei->hElapsed),
                (HMENU)-1,
                THIS_HINST,
                0);

   pei->idMinutes = 100+NextControlID (GetParent (pei->hElapsed));
   pei->hMinutes = CreateWindow (
                TEXT("EDIT"),
                TEXT(""),
                WS_CHILD | WS_TABSTOP | ES_RIGHT | ES_NUMBER,
                ptElapsed.x + cxHours + sTimeSep.cx, yy, cxMinutes, cy,
                GetParent(pei->hElapsed),
                (HMENU)pei->idMinutes,
                THIS_HINST,
                0);

   pei->hSep2 = CreateWindow (
                TEXT("STATIC"),
                szTimeSep,
                WS_CHILD,
                ptElapsed.x + cxHours + cxMinutes + sTimeSep.cx, yy, sTimeSep.cx, cy,
                GetParent(pei->hElapsed),
                (HMENU)-1,
                THIS_HINST,
                0);

   pei->idSeconds = 100+NextControlID (GetParent (pei->hElapsed));
   pei->hSeconds = CreateWindow (
                TEXT("EDIT"),
                TEXT(""),
                WS_CHILD | WS_TABSTOP | ES_RIGHT | ES_NUMBER,
                ptElapsed.x + cxHours + cxMinutes + 2 * sTimeSep.cx, yy, cxSeconds, cy,
                GetParent(pei->hElapsed),
                (HMENU)pei->idSeconds,
                THIS_HINST,
                0);

   Subclass_AddHook (pei->hHours,   ElapsedEditProc);
   Subclass_AddHook (pei->hMinutes, ElapsedEditProc);
   Subclass_AddHook (pei->hSeconds, ElapsedEditProc);

   HFONT hf = (HFONT)SendMessage (GetParent (pei->hElapsed), WM_GETFONT, 0, 0);
   SendMessage (pei->hHours,   WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));
   SendMessage (pei->hSep1,    WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));
   SendMessage (pei->hMinutes, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));
   SendMessage (pei->hSep2,    WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));
   SendMessage (pei->hSeconds, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));

   EnableWindow (pei->hHours,   IsWindowEnabled (pei->hElapsed));
   EnableWindow (pei->hSep1,    IsWindowEnabled (pei->hElapsed));
   EnableWindow (pei->hMinutes, IsWindowEnabled (pei->hElapsed));
   EnableWindow (pei->hSep2,    IsWindowEnabled (pei->hElapsed));
   EnableWindow (pei->hSeconds, IsWindowEnabled (pei->hElapsed));

   ShowWindow (pei->hHours,   TRUE);
   ShowWindow (pei->hSep1,    TRUE);
   ShowWindow (pei->hMinutes, TRUE);
   ShowWindow (pei->hSep2,    TRUE);
   ShowWindow (pei->hSeconds, TRUE);

   RECT rWindow;
   GetWindowRect (pei->hElapsed, &rWindow);
   rWindow.right += (cxHours + cxMinutes + cxSeconds + 2 * sTimeSep.cx) - cxRECT(rElapsed);

   SetWindowPos (pei->hElapsed, NULL, 0, 0, cxRECT(rWindow), cyRECT(rWindow),
                 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);

   SET_ELAPSED_TIME(&pei->timeMin,  0, 0, 0);
   SET_ELAPSED_TIME(&pei->timeMax, 24, 0, 0);

   Elapsed_Edit_OnEnforceRange (pei, pei->hHours);
   Elapsed_Edit_OnEnforceRange (pei, pei->hMinutes);
   Elapsed_Edit_OnEnforceRange (pei, pei->hSeconds);

   Elapsed_Edit_OnSetFocus (pei, pei->hHours);

   pei->fCanCallBack = TRUE;
}
示例#26
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static CHOOSEFONT cf ;
     static int        iPage ;
     static LOGFONT    lf ;
     HDC               hdc ;
     int               cxChar, cyChar, x, y, i, cxLabels ;
     PAINTSTRUCT       ps ;
     SIZE              size ;
     TCHAR             szBuffer [8] ;
     TEXTMETRIC        tm ;
     WCHAR             ch ;

     switch (message)
     {
     case WM_CREATE:
          hdc = GetDC (hwnd) ;
          lf.lfHeight = - GetDeviceCaps (hdc, LOGPIXELSY) / 6 ;  // 12 points
          lstrcpy (lf.lfFaceName, TEXT ("Lucida Sans Unicode")) ;
          ReleaseDC (hwnd, hdc) ;

          cf.lStructSize = sizeof (CHOOSEFONT) ;
          cf.hwndOwner   = hwnd ;
          cf.lpLogFont   = &lf ;
          cf.Flags       = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS ;

          SetScrollRange (hwnd, SB_VERT, 0, 255, FALSE) ;
          SetScrollPos   (hwnd, SB_VERT, iPage,  TRUE ) ;
          return 0 ;

     case WM_COMMAND:
          switch (LOWORD (wParam))
          {
          case IDM_FONT:
               if (ChooseFont (&cf))
                    InvalidateRect (hwnd, NULL, TRUE) ;
               return 0 ;
          }
          return 0 ;

     case WM_VSCROLL:
          switch (LOWORD (wParam))
               {
               case SB_LINEUP:         iPage -=  1 ;  break ;
               case SB_LINEDOWN:       iPage +=  1 ;  break ;
               case SB_PAGEUP:         iPage -= 16 ;  break ;
               case SB_PAGEDOWN:       iPage += 16 ;  break ;
               case SB_THUMBPOSITION:  iPage = HIWORD (wParam) ;  break ;

               default:
                    return 0 ;
               }

          iPage = max (0, min (iPage, 255)) ;

          SetScrollPos (hwnd, SB_VERT, iPage, TRUE) ;
          InvalidateRect (hwnd, NULL, TRUE) ;
          return 0 ;

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;

          SelectObject (hdc, CreateFontIndirect (&lf)) ;

          GetTextMetrics (hdc, &tm) ;
          cxChar = tm.tmMaxCharWidth ;
          cyChar = tm.tmHeight + tm.tmExternalLeading ;

          cxLabels = 0 ;

          for (i = 0 ; i < 16 ; i++)
          {
               wsprintf (szBuffer, TEXT (" 000%1X: "), i) ;
               GetTextExtentPoint (hdc, szBuffer, 7, &size) ;

               cxLabels = max (cxLabels, size.cx) ;
          }

          for (y = 0 ; y < 16 ; y++)
          {
               wsprintf (szBuffer, TEXT (" %03X_: "), 16 * iPage + y) ;
               TextOut (hdc, 0, y * cyChar, szBuffer, 7) ;

               for (x = 0 ; x < 16 ; x++)
               {
                    ch = (WCHAR) (256 * iPage + 16 * y + x) ;
                    TextOutW (hdc, x * cxChar + cxLabels,
                                   y * cyChar, &ch, 1);
               }
          }

          DeleteObject (SelectObject (hdc, GetStockObject (SYSTEM_FONT)));
          EndPaint (hwnd, &ps) ;
          return 0 ;

     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
示例#27
0
int CALLBACK GenericContainerCellDraw( HWND hCntWnd, LPFIELDINFO lpFld, LPRECORDCORE lpRec, LPVOID lpData, HDC hDC, int nXstart, int nYstart, UINT fuOptions, LPRECT lpRect, LPSTR lpszOut, UINT uLenOut)
{
  COLORREF  crOldText = 0;
  COLORREF  crOldBk   = 0;
  BOOL      bChgedTxtColor = FALSE;
  BOOL      bChgedBkColor  = FALSE;

  // Custom management
  GENCNTR_COLUMN  cont_col;
  char            buf[BUFSIZE];

  // combo downarrow bitmap paint
  HDC     hMemDC;
  HBITMAP hBitmap, hOldBitmap;
  RECT    rcClient;
  int     x, y;
  HBRUSH  hBrush;

  // text alignment
  SIZE  size;
  int   remainder;
  int   availwidth;
  int   margin;

  // Decorations for title type cell
  HPEN  hOldPen, hWhitePen, hDkGrayPen;

  // Combo selection paint
  int   cpt;
  char *pItem;

  CntFldDataGet(lpRec, lpFld, 0, &cont_col);

  // Clear whole rectangle (old decorations cleanup) for combo type cell
  if (cont_col.type == CONT_COLTYPE_COMBO) {
    rcClient.left   = lpRect->left;
    rcClient.top    = lpRect->top;
    rcClient.right  = lpRect->right;
    rcClient.bottom = lpRect->bottom;
    hBrush = GetStockObject(WHITE_BRUSH);
    FillRect(hDC, &rcClient, hBrush);
  }

  switch (cont_col.type) {
    case CONT_COLTYPE_TITLE:
      fuOptions |= ETO_OPAQUE;
      crOldBk = SetBkColor(hDC, RGB(192,192,192));  // Light gray background
      bChgedBkColor = TRUE;
      crOldText = SetTextColor(hDC, RGB(255, 0, 0) ); // Red text
      bChgedTxtColor = TRUE;
      x_strcpy(buf, cont_col.ucol.s);
      //wsprintf(buf, "Title : %s", cont_col.ucol.s);
      break;
    case CONT_COLTYPE_TEXT:
      x_strcpy(buf, cont_col.ucol.s);
      //wsprintf(buf, "Text : %s", cont_col.ucol.s);
      break;
    case CONT_COLTYPE_COMBO:
      pItem = cont_col.ucol.sCombo.pItems;  // first item
      for (cpt=0; cpt<cont_col.ucol.sCombo.selection; cpt++)
        pItem += x_strlen(pItem) + 1;
      x_strcpy(buf, pItem);           // Show the 'nth' item
      //wsprintf(buf, "Combo : %s", cont_col.ucol.s);
      break;
    case CONT_COLTYPE_INT:
      wsprintf(buf, "%ld", cont_col.ucol.i);
      //wsprintf(buf, "Int : %ld", cont_col.ucol.i);
      break;
    case CONT_COLTYPE_FLOAT:
      // NOTE : wsprintf is not aware of the floating format...
      sprintf(buf, "%.*f", cont_col.precision, cont_col.ucol.f);
      //sprintf(buf, "Float : %.2f", cont_col.ucol.f);
      break;
    case CONT_COLTYPE_EMPTY:
      buf[0] = '\0';    // empty cell
      break;
    default:
      x_strcpy(buf, "Unknown type!");
      break;
  }

  // manage the horizontal positioning of the text
  if (cont_col.align != CONT_ALIGN_LEFT) {
    availwidth = lpRect->right - lpRect->left;
    margin = nXstart - lpRect->left;
#ifdef WIN32
    GetTextExtentPoint32(hDC, buf, x_strlen(buf), &size);
#else
    GetTextExtentPoint(hDC, buf, x_strlen(buf), &size);
#endif

    remainder = availwidth - 2*margin - size.cx;

    if (remainder > 0)
      switch (cont_col.align) {
        case CONT_ALIGN_CENTER:
          nXstart += remainder/2;
          break;
        case CONT_ALIGN_RIGHT:
          nXstart += remainder;
          break;
      }
  }

  // Draw the field data.
  ExtTextOut( hDC, nXstart, nYstart, fuOptions, lpRect,
              buf, x_strlen(buf), (LPINT)NULL);

  // Restore colors
  if (bChgedTxtColor)
    SetTextColor(hDC, crOldText);
  if (bChgedBkColor)
    SetBkColor(hDC, crOldBk);

  // Draw decorations for title type cell
  if (cont_col.type == CONT_COLTYPE_TITLE) {
    hWhitePen  = GetStockObject(WHITE_PEN);
    hDkGrayPen = CreatePen(PS_SOLID, 2, RGB(128, 128, 128));  // Dark gray

    hOldPen = SelectObject(hDC, hWhitePen);
    MoveToEx(hDC, lpRect->left,     lpRect->bottom, NULL);
    LineTo(hDC, lpRect->left,     lpRect->top);
    LineTo(hDC, lpRect->right-1,  lpRect->top);

    SelectObject(hDC, hDkGrayPen);
    MoveToEx(hDC, lpRect->left+2,  lpRect->bottom-2, NULL);
    LineTo(hDC, lpRect->right-2, lpRect->bottom-2);
    LineTo(hDC, lpRect->right-2, lpRect->top+1);

    SelectObject(hDC, hOldPen);
    DeleteObject(hDkGrayPen);
  }

  // Draw decorations for combo type cell
  if (cont_col.type == CONT_COLTYPE_COMBO) {
    hMemDC = CreateCompatibleDC(hDC);
    if (hMemDC) {
      hBitmap = LoadBitmap(0, (LPCSTR)OBM_DNARROW);
      if (hBitmap) {
        hOldBitmap = (HBITMAP)SelectObject(hMemDC,hBitmap);

        y = lpRect->top + 1;
        // 1 parent needed when in the CellDraw function!
        if (IsLastColumn(GetParent(hCntWnd), cont_col.colnum)) {
          GetClientRect(hCntWnd, &rcClient);
          x = rcClient.right;
          //x -= GetSystemMetrics(SM_CXVSCROLL);
          x -= 1;
        }
        else
          x = lpRect->right - 1;
        x -= GetSystemMetrics(SM_CXVSCROLL);
        BitBlt(hDC, x, y, BITMAPS_WIDTH, BITMAPS_HEIGHT,
               hMemDC, 0, 0, SRCCOPY);
        SelectObject(hMemDC,hOldBitmap);
        DeleteObject(hBitmap);
      }
      DeleteDC(hMemDC);
    }
  }

  // Finished
  return 0;

}
示例#28
0
//************************************************************************
// updates the cutoff index
//************************************************************************
void CLCDLabel::UpdateCutOffIndex()
{
	int iLen = m_strText.length();
	
	m_vLines.clear();

	if(iLen <= 0)
	{
		m_strCutOff = _T("");
		m_iCutOffIndex = 0;
		return;
	}
	// variables
	
	HDC hDC = CreateCompatibleDC(NULL);
	SelectObject(hDC, m_hFont);   
    
	if(NULL == hDC)
		return;

	int iWidth = GetWidth();
	SIZE sizeChar = {0, 0};
	SIZE sizeLine =  {0, 0};
	SIZE sizeWord = {0,0};
	SIZE sizeCutOff = {0, 0};

	int iAvailableLines = GetHeight()/m_iFontHeight;
	// unitialized or too small labels need to be handled
	if(iAvailableLines <= 0)
		iAvailableLines = 1;

	// process wordwrapping
	int i = 0;
	if(m_bWordWrap && GetWidth() > 0)
	{
		int *piExtents = new int[m_strText.length()];
		TCHAR *szString = (TCHAR*)m_strText.c_str();
		int iMaxChars = 0;
		tstring::size_type pos = 0;

		while(i<iLen && m_vLines.size() < iAvailableLines)
		{
			GetTextExtentExPoint(hDC,szString+i,m_strText.length()-i,GetWidth(),&iMaxChars,piExtents,&sizeLine);
			
			// filter out spaces or line breaks at the beginning of a new line
			if(m_strText[i] == '\n' || m_strText[i] == ' ')
				i++;

			pos = m_strText.find(_T("\n"),i);
			// check for linebreaks
			if(pos != tstring::npos && pos != i && pos >= i && pos != i+iMaxChars)
				iMaxChars = 1 + pos - i;
			// if the string doesnt fit, try to wrap the last word to the next line
			else if(iMaxChars < iLen - i || sizeLine.cx >= GetWidth())
			{
				// find the last space in the line ( substract -1 from offset to ignore spaces as last chars )
				pos = m_strText.rfind(_T(" "),i + iMaxChars -1 );
				if(pos != tstring::npos && pos != i && pos >= i & pos != i+iMaxChars)
					iMaxChars = 1 + pos - i;
			}

			if(m_vLines.size() == iAvailableLines-1)
				iMaxChars = iLen - i;

			m_vLines.push_back(m_strText.substr(i,iMaxChars));
			i += iMaxChars;
		}
		free(piExtents);
	}
	else
		m_vLines.push_back(m_strText);

	// calculate the cutoff position

	GetTextExtentPoint(hDC,_T("..."),3,&sizeCutOff);

	int *piWidths = new int[(*--m_vLines.end()).length()];
	int iMaxChars = 0;

	GetTextExtentExPoint(hDC,(*--m_vLines.end()).c_str(),(*--m_vLines.end()).length(),iWidth,&iMaxChars,piWidths,&sizeLine);
	
	if(iMaxChars < (*--m_vLines.end()).length())
	{
		for(iMaxChars--;iMaxChars>0;iMaxChars--)
		{	
			if(piWidths[iMaxChars] + sizeCutOff.cx <= iWidth)
				break;
		}
		(*--m_vLines.end()) = (*--m_vLines.end()).substr(0,iMaxChars) + _T("...");
	}
	free(piWidths);

	DeleteObject(hDC);

	//if(GetWidth() == 0)
		m_iLineCount = 1;
	//else
	//	m_iLineCount = ceil((double)(sizeLine.cx + sizeCutOff.cx)/GetWidth());

	//if(m_iLineCount > GetHeight()/m_iFontHeight)
	//	m_iLineCount = GetHeight()/m_iFontHeight;
}
示例#29
0
void Debugstr::OutString (char *str, BOOL fRecord)
{
   char      *psz, *pch;
   HDC        hdc;
   DWORD      fg, bk;
   RECT       r;
   RECT       r2;
   HFONT      hfOld;
   LOGFONT    lf;
   SIZE       siz;

   Register();	// does nothing unless first time
   Initialize();	// does nothing unless first time

   if (str == NULL)
      str = "(null)";

   OutputDebugString (str);

   if (Debugstr::hwnd == NULL)
      return;

   if ((hdc = GetDC (Debugstr::hwnd)) == NULL)
      return;

   fg = SetTextColor (hdc, GetSysColor( COLOR_BTNTEXT ));
   bk = SetBkColor (hdc, GetSysColor( COLOR_BTNFACE ));

   if (brBack == NULL)
      {
      brBack = CreateSolidBrush (GetBkColor(hdc));
      }

   if (hfNew == NULL)
      {
      memset (&lf, 0, sizeof(lf));

      lf.lfWeight = FW_NORMAL;
      lf.lfHeight = -MulDiv (8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
      strcpy (lf.lfFaceName, "Arial");

      hfNew = CreateFontIndirect(&lf);
      }

   hfOld = (HFONT)SelectObject(hdc, hfNew);
   GetTextMetrics (hdc, &tm);

   GetClientRect (Debugstr::hwnd, &r);

   if (!strcmp (str, "CLS"))
      {
      gx  = 0;
      gy  = minY;
      gcX = 0;
      gcY = 0;
      gdata[gcY][0] = 0;
      gdata[gcY+1][0] = 0;

      FillRect (hdc, &r, brBack);
      }
   else for (psz = str; *psz; )
      {
      if ((pch = strchr(psz, '\n')) == NULL)
         {
         Output (hdc, psz, fRecord);
         break;
         }

      *pch = 0;
      Output (hdc, psz, fRecord);

      gy += (ushort)tm.tmHeight;
      gcY++;
      gx  = minX;
      gcX = 0;

      if (fRecord)
         {
         if ((gy + tm.tmHeight) > (ushort)r.bottom)
            {
            gy = minY;
            gcY = 0;

            GetTextExtentPoint (hdc, gdata[gcY], (int)strlen(gdata[gcY]), &siz);

            r2.top = gy;
            r2.bottom = gy + tm.tmHeight;
            r2.left = gx -1;
            r2.right = siz.cx;
            r2.right += gx;
            FillRect (hdc, &r2, brBack);

            gdata[gcY][0] = 0;
            }
         }

      nRefr = max( nRefr, gcY );

      *pch = '\n';
      psz = 1+pch;

      if (fRecord)
         {
         GetTextExtentPoint (hdc, gdata[gcY+1], (int)strlen(gdata[gcY+1]), &siz);

         r2.top = gy +tm.tmHeight;
         r2.bottom = gy +tm.tmHeight +tm.tmHeight;
         r2.left = gx;
         r2.right = siz.cx;
         r2.right += gx;
         FillRect (hdc, &r2, brBack);

         gdata[gcY+1][0] = 0;
         }
      }

   SelectObject (hdc, hfOld);
   SetTextColor (hdc, fg);
   SetBkColor   (hdc, bk);
   ReleaseDC    (Debugstr::hwnd, hdc);
}
示例#30
0
void npredictMDIChild::Paint ( TDC& dc , BOOL , TRect& )
{
	int i, j, n, b, row, col, rstart, rstop, cstart, cstop, prevcol ;
	int xlab_height, xlab_width, ylab_height, ylab_width, wide ;
	int xlab_lw, xlab_rw, tick_height, font_height, r0, r1, c0 ;
	double xscale, yscale, xtickscale, ytickscale, *sig, val ;
   double x, xfac ;
	char msg[256] ;
	TRect rect ;
	SIZE size ;
	TColor bkgnd, *lines ;
	TBrush *brush ;
	TPen *pen, *second_pen ;
   TFont *font ;

	n = istop - istart + 1 ;
	sig = signal->sig ;
	
	dc.SetMapMode ( MM_TEXT ) ;
	dc.SetROP2 ( R2_COPYPEN ) ;
	dc.SetBkMode ( OPAQUE ) ;
	bkgnd = dc.GetNearestColor ( TColor ( background_color ) ) ;
	dc.SetBkColor ( bkgnd ) ;
	GetClientRect ( rect ) ;
	b = rect.bottom ;   // We use origin at bottom, so b-y adapts to Windows

/*
	Paint the background
*/

	brush = new TBrush ( bkgnd ) ;
	dc.SelectObject ( *brush ) ;
	pen = new TPen ( bkgnd ) ;
	dc.SelectObject ( *pen ) ;
	dc.Rectangle ( rect ) ;
	dc.RestoreBrush () ;
	delete brush ;
	dc.RestorePen () ;
	delete pen ;
		
/*
   Setup main drawing pen and secondary pen for hash lines
*/

   lines = new TColor ( 0 , 0 , 0 ) ;
	pen = new TPen ( *lines , 1 , PS_SOLID ) ;
	second_pen = new TPen ( *lines , 1 , PS_DASH ) ;

/*
	Compute the maximum height and width of the axis tick labels.
	This lets us position the graph optimally.
*/
	
	xlab_height = xlab_width = ylab_height = ylab_width = xlab_lw = xlab_rw = 0 ;
	
	font_height = rect.bottom / 20 ;
	if (rect.right / 24 < font_height)
		font_height = rect.right / 24 ;

	if (font_height < 8)
      font_height = 0 ;

	if (font_height) {
		font = new TFont ( "Helvetica" , font_height ) ;
		dc.SelectObject ( *font ) ;
   	for (i=0 ; i<xnticks ; i++) {
   		sprintf ( msg , "%*.*lf", xndigits, xnfrac, xmin + i * xdif ) ;
   		GetTextExtentPoint ( dc , msg , strlen(msg) , &size ) ;
   		if (! i)
   			xlab_lw = size.cx ;      // Width of leftmost x label
   		if (i == xnticks-1)
   			xlab_rw = size.cx ;      // And rightmost x label
   		if (size.cx > xlab_width)
   			xlab_width = size.cx ;
   		if (size.cy > xlab_height)
   			xlab_height = size.cy ;
   		}

   	for (i=0 ; i<ynticks ; i++) {
   		sprintf ( msg , "%*.*lf", yndigits, ynfrac, ymin + i * ydif ) ;
   		GetTextExtentPoint ( dc , msg , strlen(msg) , &size ) ;
			if (size.cx > ylab_width)
				ylab_width = size.cx ;
			if (size.cy > ylab_height)
				ylab_height = size.cy ;
			}

		tick_height = xlab_height / 2 ;
		}

	else {
		tick_height = rect.bottom / 64  +  2 ;
      font = NULL ;
      }

/*
   Last check on label display.  Are X-axis labels to wide?
*/

   if ((xlab_width * xnticks) > (3 * rect.right / 4)) {
      font_height = 0 ;
	   xlab_height = xlab_width = ylab_height = ylab_width = 0 ;
      xlab_lw = xlab_rw = 0 ;
		tick_height = rect.bottom / 64  +  2 ;
      if (font != NULL) {
	      dc.RestoreFont () ;
      	delete font ;
         font = NULL ;
         }
      }

/*
	Compute the graph extent based on these label metrics
*/

	
	rstart = tick_height + xlab_height + 1  ;  // Ticks, X tick labels
	rstop = rect.bottom - ylab_height/2 - 2 ;  // Top half of topmost label

	if (xlab_lw / 2  >  ylab_width)            // If left half of X label biggest
		cstart = xlab_lw / 2 + 1 ;              // Use it for offset
	else
		cstart = ylab_width + 2 ;               // Otherwise Y labels determine it

	cstop = rect.right - xlab_rw / 2 - 2 ;     // Leave room for rightmost label
	
/*
	Compute scales for data and ticks
*/

   xscale = (double) (cstop - cstart) / (xmax - xmin) ;
   xfac = (rightx - leftx) / (n-1) ;
	yscale = (double) (rstop - rstart) / (ymax - ymin) ;

	xtickscale = (double) (cstop-cstart) / (double) (xnticks-1) ;
	ytickscale = (double) (rstop-rstart) / (double) (ynticks-1) ;

/*
	Outline the graph, draw ticks, and write their labels
*/

	dc.SelectObject ( *pen ) ;
	dc.MoveTo ( cstart , b-rstart ) ;
	dc.LineTo ( cstop , b-rstart ) ;
	dc.LineTo ( cstop , b-rstop ) ;
	dc.LineTo ( cstart , b-rstop ) ;
	dc.LineTo ( cstart , b-rstart ) ;
	dc.RestorePen () ;

	for (i=0 ; i<ynticks ; i++) {                 /* Y ticks */
		row = rstart + i * ytickscale + 0.5 ;
		if (i  &&  (i < ynticks-1)) {  // Horizontal interior lines
         dc.SelectObject ( *second_pen ) ;
			dc.MoveTo ( cstart , b-row ) ;
			dc.LineTo ( cstop , b-row ) ;
         dc.RestorePen () ;
			}
      if (font_height) {
   		sprintf ( msg , "%*.*lf", yndigits, ynfrac, ymin + i * ydif ) ;
   		rect.bottom = b - (row - ylab_height / 2) ;
   		rect.top = rect.bottom - ylab_height - 1 ;
   		rect.right = cstart - 1 ;
   		rect.left = rect.right - ylab_width - 1 ;
         dc.SelectObject ( *pen ) ;
   		dc.DrawText ( msg , -1 , rect , DT_SINGLELINE | DT_BOTTOM | DT_RIGHT );
         dc.RestorePen () ;
         }
		}

   dc.SelectObject ( *pen ) ;
	prevcol = 0 ;
	for (i=0 ; i<xnticks ; i++) {                         /* X ticks */
		col = cstart + i * xtickscale + 0.5 ;
		dc.MoveTo ( col , b-rstart ) ;
		dc.LineTo ( col , b-(rstart - tick_height) ) ;
		if (i) {  /* Make an additional, unlabeled tick between main ones */
			dc.MoveTo ( (col + prevcol) / 2  , b-rstart ) ;
			dc.LineTo ( (col + prevcol) / 2 , b-(rstart - tick_height/2) ) ;
			}
		prevcol = col ;
		if (font_height) {
			sprintf ( msg , "%*.*lf", xndigits, xnfrac, xmin + i * xdif ) ;
         while (*msg == ' ')          // Remove leading blanks
            strcpy ( msg , msg+1 ) ;
			rect.top = b - (rstart - tick_height) ;
			rect.bottom = rect.top + xlab_height - 1 ;
			rect.right = col + xlab_width / 2 ;
			rect.left = rect.right - xlab_width - 1 ;
			dc.DrawText ( msg , -1 , rect , DT_SINGLELINE | DT_BOTTOM | DT_CENTER);
			}
		}
   dc.RestorePen () ;

   if (font_height) {
	   dc.RestoreFont () ;
   	delete font ;
      }

/*
   Draw the graph
*/

   if ((signal->type == DataSignal)  ||  (signal->type == SpectrumSignal)
    || (signal->type == SpectrumDevSignal)) {
      if ((command_id == ID_PRED_DISPLAY_CONFIDENCE) && // Draw confidence first
          (signal->known_n <= istop)) {                 // If visible
         delete second_pen ;    // No longer needed for hash lines, so use for
         second_pen = new TPen ( *lines , 1 , PS_DOT ) ; // Confidence lines
         dc.SelectObject ( *second_pen ) ;
         i = signal->known_n - 1 ;
         if (i >= istart)
            r0 = rstart + (int) ((sig[i] - ymin) * yscale) ;
         else {
            i = istart ;
            j = i - signal->known_n ;
            if (signal->mult_conf)
               val = sig[i] * signal->intervals[2*j] ;
            else 
               val = sig[i] + signal->intervals[2*j] ;
            r0 = rstart + (int) ((val - ymin) * yscale + 0.5) ;
            }
         if (r0 < rstart)
            r0 = rstart ;
         if (r0 > rstop)
            r0 = rstop ;
         r0 = b - r0 ;
         x = (i - istart) * xfac + leftx ;
         c0 = cstart + (int) (xscale * (x-xmin) + 0.5) ;
         dc.MoveTo ( c0 , r0 ) ;
         for (i=i+1 ; i<signal->known_n+signal->npred ; i++) {
            if (i > istop)
               break ;
            j = i - signal->known_n ;
            if (signal->mult_conf)
               val = sig[i] * signal->intervals[2*j] ;
            else 
               val = sig[i] + signal->intervals[2*j] ;
            r0 = rstart + (int) ((val - ymin) * yscale + 0.5) ;
            if (r0 < rstart)
               r0 = rstart ;
            if (r0 > rstop)
               r0 = rstop ;
            r0 = b - r0 ;
            x = (i - istart) * xfac + leftx ;
            c0 = cstart + (int) (xscale * (x-xmin) + 0.5) ;
      		dc.LineTo ( c0 , r0 ) ;
            }

         i = signal->known_n - 1 ;
         if (i >= istart)
            r0 = rstart + (int) ((sig[i] - ymin) * yscale) ;
         else {
            i = istart ;
            j = i - signal->known_n ;
            if (signal->mult_conf)
               val = sig[i] * signal->intervals[2*j] ;
            else 
               val = sig[i] + signal->intervals[2*j] ;
            r0 = rstart + (int) ((val - ymin) * yscale + 0.5) ;
            }
         if (r0 < rstart)
            r0 = rstart ;
         if (r0 > rstop)
            r0 = rstop ;
         r0 = b - r0 ;
         x = (i - istart) * xfac + leftx ;
         c0 = cstart + (int) (xscale * (x-xmin) + 0.5) ;
         dc.MoveTo ( c0 , r0 ) ;
         for (i=signal->known_n ; i<signal->known_n+signal->npred ; i++) {
            if (i > istop)
               break ;
            j = i - signal->known_n ;
            if (signal->mult_conf)
               val = sig[i] * signal->intervals[2*j+1] ;
            else 
               val = sig[i] + signal->intervals[2*j+1] ;
            r0 = rstart + (int) ((val - ymin) * yscale + 0.5) ;
            if (r0 < rstart)
               r0 = rstart ;
            if (r0 > rstop)
               r0 = rstop ;
            r0 = b - r0 ;
            x = (i - istart) * xfac + leftx ;
            c0 = cstart + (int) (xscale * (x-xmin) + 0.5) ;
      		dc.LineTo ( c0 , r0 ) ;
            }
         dc.RestorePen () ;
         }

      if (signal->type == SpectrumDevSignal) {
         delete second_pen ;    // No longer needed for hash lines, so use for
         second_pen = new TPen ( *lines , 1 , PS_DOT ) ; // Confidence lines
         dc.SelectObject ( *second_pen ) ;
         row = rstart + (int) ((corrlim - ymin) * yscale + 0.5) ; // Confidence
         if ((row >= rstart)  &&  (row <= rstop)) {
            dc.MoveTo ( cstart , b-row ) ;
            dc.LineTo ( cstop , b-row ) ;
            }
         row = rstart + (int) ((-corrlim - ymin) * yscale + 0.5) ; // Confidence
         if ((row >= rstart)  &&  (row <= rstop)) {
            dc.MoveTo ( cstart , b-row ) ;
            dc.LineTo ( cstop , b-row ) ;
            }
         dc.RestorePen () ;
         }

      dc.SelectObject ( *pen ) ;
      r0 = rstart + (int) ((sig[istart] - ymin) * yscale) ;
      if (r0 < rstart)
         r0 = rstart ;
      if (r0 > rstop)
         r0 = rstop ;
      r0 = b - r0 ;
      x = leftx ;
      c0 = cstart + (int) (xscale * (x-xmin) + 0.5) ;
      dc.MoveTo ( c0 , r0 ) ;
   	for (i=istart+1 ; i<=istop ; i++) {
         r0 = rstart + (int) ((sig[i] - ymin) * yscale + 0.5) ;
         if (r0 < rstart)
            r0 = rstart ;
         if (r0 > rstop)
            r0 = rstop ;
         r0 = b - r0 ;
         x = (i - istart) * xfac + leftx ;
         c0 = cstart + (int) (xscale * (x-xmin) + 0.5) ;
   		dc.LineTo ( c0 , r0 ) ;
   		}
      dc.RestorePen () ;
      } // If DataSignal or SpectrumSignal

   else if (signal->type == CorrelationSignal) {
      delete second_pen ;    // No longer needed for hash lines, so use for
      second_pen = new TPen ( *lines , 1 , PS_DOT ) ; // Confidence lines
      dc.SelectObject ( *second_pen ) ;
      row = rstart + (int) ((corrlim - ymin) * yscale + 0.5) ; // Confidence
      if ((row >= rstart)  &&  (row <= rstop)) {
         dc.MoveTo ( cstart , b-row ) ;
         dc.LineTo ( cstop , b-row ) ;
         }
      row = rstart + (int) ((-corrlim - ymin) * yscale + 0.5) ; // Confidence
      if ((row >= rstart)  &&  (row <= rstop)) {
         dc.MoveTo ( cstart , b-row ) ;
         dc.LineTo ( cstop , b-row ) ;
         }
      dc.RestorePen () ;
      wide = (cstop - cstart) / n ;
      r0 = rstart + (int) ((0.0 - ymin) * yscale + 0.5) ;
      for (i=0 ; i<ynticks ; i++) {            // Search all horizontal ticks
         row = rstart + i * ytickscale + 0.5 ; // Because rounding error
         if (abs ( r0 - row ) <= 1) {          // Might make 0 off by one
            r0 = row ;                         // Which looks ugly
            break ;
            }
         }
      if (r0 < rstart)
         r0 = rstart ;
      if (r0 > rstop)
         r0 = rstop ;
      r0 = b - r0 ;
      dc.SelectObject ( *pen ) ;
   	for (i=0 ; i<n ; i++) {
         c0 = cstart + (int) (xscale * (i+1) + 0.5) ;
         r1 = rstart + (int) ((sig[i] - ymin) * yscale + 0.5) ;
         if (r1 < rstart)
            r1 = rstart ;
         if (r1 > rstop)
            r1 = rstop ;
         r1 = b - r1 ;
         dc.MoveTo ( c0 , r0 ) ;
   		dc.LineTo ( c0 , r1 ) ;
         if (wide && (c0 > cstart)) {
            dc.MoveTo ( c0-1 , r0 ) ;
            dc.LineTo ( c0-1 , r1 ) ;
            }
         if (wide && (c0 < cstop)) {
            dc.MoveTo ( c0+1 , r0 ) ;
            dc.LineTo ( c0+1 , r1 ) ;
            }
         if ((wide > 9)  &&  (c0 > cstart+1)) {
            dc.MoveTo ( c0-2 , r0 ) ;
            dc.LineTo ( c0-2 , r1 ) ;
            }
         if ((wide > 9)  &&  (c0 < cstop-1)) {
            dc.MoveTo ( c0+2 , r0 ) ;
            dc.LineTo ( c0+2 , r1 ) ;
            }
   		}
      dc.RestorePen () ;
      }

	delete pen ;
	delete second_pen ;
	delete lines ;
}