Пример #1
0
void WrapWrite_GLCD( unsigned char* message){
	unsigned char i, x, mx;
	x = 0;
	mx = 160-curX-curY*20;
	for( i=0; i<mx; i++ ){
		if ((curX+x) == 10){
			GotoXY(10, curY);
			x = 0;
		} else if ((curX+x) == 20){
			GotoXY(0, curY+1);			
			x = 0;
		}
	if( !message[i] ) break;
	PutChar(message[i]);
	x++;
	}
}
Пример #2
0
//*****************************************************************************
float CScreen::GetVal(int iX, int iY)
{
	float val;
	if (iX != -1 && iY != -1)
		GotoXY(iX, iY);
	scanf_s("%f", &val);
	return val;
}
Пример #3
0
void Lcd_t::Cls() {
#if LCD_DMA_BASED
    for(uint32_t i=0; i < LCD_VIDEOBUF_SIZE; i++) IBuf[i] = 0x0001;
#else
    GotoXY(0, 0);
    for(uint32_t i=0; i < 864; i++) IWriteData(0);
#endif
}
Пример #4
0
void DrawDemo( void ) {
	char xx;
	int i;
	//char carRX = 0;
	/*u8 fontWidth;
	if ( Blink == 0 ) {
		Blink = 30000;
		fontWidth = DrawChar5x5(curX, curY, '_', LCD_PIXEL_INV);
		
		// Blink Debug LED
		GPIO_WriteReverse(GPIOD, GPIO_PIN_0);	
		
	} else {
		Blink--;
	}
	if (UART2_GetFlagStatus(UART2_FLAG_RXNE) != RESET) {
		carRX = UART2_ReceiveData8();
		
	}
	if ( carRX != 0 ) {
		fontWidth = DrawChar5x5(curX, curY, '_', LCD_PIXEL_OFF);
		if ( carRX == 13 ) {			
			curX = 2;
			curY += FONT_HEIGHT + 1;
			if ( curY > DISPLAY_HEIGHT ) {
				DrawScreen();
			}	
			
		} else if ( carRX == 10 ) {
			
		} else {			
			fontWidth = DrawChar5x5(curX, curY, carRX, LCD_PIXEL_ON);
			curX += fontWidth + 1;			
			if ( curX > DISPLAY_WIDTH ) {		
				curX = 2;
				curY += FONT_HEIGHT + 1;				
				if ( curY + FONT_HEIGHT > DISPLAY_HEIGHT ) {
					DrawScreen();
				}
			}
		}

	}*/

	Blink = 0;
	DrawScreen();
	GotoXY(2,10);
	PutText(text,LCD_PIXEL_ON);
	UpdateLCD();
	if (  strlen(text) > 0 ) {
		xx = text[0];
		for(i=1; i < strlen(text)-1; i++) {
			text[i - 1] = text[i];
		}
		text[strlen(text)-2] = xx;
	}

}
Пример #5
0
void CUI::RemShipState(bool who, units shiplen, units s)
{
	units shift = 2;
	switch (who)
	{
	case (PLAYER) :
		switch (shiplen)
		{
		case (4) :						//***  4-Ship count. ***
			GotoXY(s + *l4 + 5, 4);
			PrintCol("\xDB");
			break;
		case (3) :						//***  3-Ship count. ***
			*l3 += 2;
			GotoXY(s + *l3 + 2, 4);
			PrintCol("\xDB");
			break;
		case (2) :						//***  2-Ship count. ***
			*l2 += 2;
			GotoXY(s + *l2 + 1, 4);
			PrintCol("\xDB");
			break;
		case (1) :						//***  1-Ship count. ***
			*l1 += 2;
			GotoXY(s + *l1, 4);
			PrintCol("\xDB");
			break;
		}
		break;
	case (COMP) :
		switch (shiplen)
		{
		case (4) :						//***  4-Ship count. ***
			GotoXY(s + *k4 + 5, 4 + shift);
			PrintCol("\xDB");
			break;
		case (3) :						//***  3-Ship count. ***
			*k3 += 2;
			GotoXY(s + *k3 + 2, 4 + shift);
			PrintCol("\xDB");
			break;
		case (2) :						//***  2-Ship count. ***
			*k2 += 2;
			GotoXY(s + *k2 + 1, 4 + shift);
			PrintCol("\xDB");
			break;
		case (1) :						//***  1-Ship count. ***
			*k1 += 2;
			GotoXY(s + *k1, 4 + shift);
			PrintCol("\xDB");
			break;
		}
		break;
	}
}	
Пример #6
0
bool ScrollBarEx3(UINT X1,UINT Y1,UINT Length, UINT64 Start,UINT64 End,UINT64 Size)
{
	WCHAR StackBuffer[4000/sizeof(WCHAR)], *Buffer = StackBuffer;
	if ( Length <= 2 || End < Start )
		return false;
	if ( Length >= ARRAYSIZE(StackBuffer) )
		Buffer = new WCHAR[Length + 1];

	Buffer[0] = Oem2Unicode[0x1E];
	Buffer[Length--] = L'\0';
	Buffer[Length--] = Oem2Unicode[0x1F];
	WCHAR b0 = BoxSymbols[BS_X_B0], b2 = BoxSymbols[BS_X_B2];
	UINT i, i1, i2;

	if ( End > Size )
		End = Size;

	if ( !Size || Start >= End )
	{
		i1 = Length+1;
		i2 = 0;
	}
	else
	{
		UINT thickness = static_cast<UINT>(((End - Start) * Length) / Size);
		if ( !thickness )
			++thickness;

		if ( thickness >= Length )
			i2 = (i1 = 1) + Length;
		else if ( End >= Size )
			i1 = (i2 = 1 + Length) - thickness;
		else
		{
			i1 = 1 + static_cast<UINT>((Start*Length + Size/2)/ Size);
			if ( i1 == 1 && Start > 0 )
				++i1;
			i2 = i1 + thickness;
			if ( i2 >= Length+1 )
			{
				i2 = Length + 1;
			   if ( i1 < i2-1 )
					--i2;
			}
		}
	}

	for (i = 1; i <= Length; i++)
		Buffer[i] = (i >= i1 && i < i2 ? b2 : b0);

	GotoXY(X1, Y1);
	VText(Buffer);
	if ( Buffer != StackBuffer )
		delete[] Buffer;

	return true;
}
Пример #7
0
void CUI::PrintField(Field* f)
{
	int xx;
	if (f->owner == PLAYER) xx = 1 + x;
	else xx = 2 + _w + x;
	units fx = 0, fy = 0;
	for (int h = y + 1; h != _h + y + 1; h++) for (int w = xx; w != _w + xx; w++)
	{
		GotoXY(w, h);
		fx = w - xx;
		fy = h - y - 1;
		f->SetPos(fx, fy);
		SetColor(clship, clback);
		printf("%c", (char)f->GetPosVal());
	}
	GotoXY(x, y + _h + 3);
	SetColor(cldef, clbdef);
}
Пример #8
0
void Panel::DrawSeparator(int Y) const
{
	if (Y<m_Y2)
	{
		SetColor(COL_PANELBOX);
		GotoXY(m_X1,Y);
		ShowSeparator(m_X2-m_X1+1,1);
	}
}
Пример #9
0
/*
   Отрисовка прямоугольника.
*/
void Box(int x1,int y1,int x2,int y2,const FarColor& Color,int Type)
{
    if (x1>=x2 || y1>=y2)
        return;

    SetColor(Color);
    Type=(Type==DOUBLE_BOX || Type==SHORT_DOUBLE_BOX);

    WCHAR StackBuffer[StackBufferSize/sizeof(WCHAR)];
    wchar_t_ptr HeapBuffer;
    LPWSTR BufPtr=StackBuffer;

    const size_t height=y2-y1;
    if(height>StackBufferSize/sizeof(WCHAR))
    {
        HeapBuffer.reset(height);
        BufPtr=HeapBuffer.get();
    }
    wmemset(BufPtr, BoxSymbols[Type?BS_V2:BS_V1], height-1);
    BufPtr[height-1]=0;
    GotoXY(x1,y1+1);
    VText(BufPtr);
    GotoXY(x2,y1+1);
    VText(BufPtr);
    const size_t width=x2-x1+2;
    if(width>StackBufferSize/sizeof(WCHAR))
    {
        if(width>height)
        {
            HeapBuffer.reset(width);
            BufPtr=HeapBuffer.get();
        }
    }
    BufPtr[0]=BoxSymbols[Type?BS_LT_H2V2:BS_LT_H1V1];
    wmemset(BufPtr+1, BoxSymbols[Type?BS_H2:BS_H1], width-3);
    BufPtr[width-2]=BoxSymbols[Type?BS_RT_H2V2:BS_RT_H1V1];
    BufPtr[width-1]=0;
    GotoXY(x1,y1);
    Text(BufPtr);
    BufPtr[0]=BoxSymbols[Type?BS_LB_H2V2:BS_LB_H1V1];
    BufPtr[width-2]=BoxSymbols[Type?BS_RB_H2V2:BS_RB_H1V1];
    GotoXY(x1,y2);
    Text(BufPtr);
}
Пример #10
0
size_t CommandLine::DrawPrompt()
{
	const auto PromptList = GetPrompt();
	const size_t MaxLength = PromptSize*ObjWidth() / 100;

	std::vector<size_t> Sizes;
	Sizes.reserve(PromptList.size());

	size_t PromptLength = 0;
	size_t FixedLength = 0;
	size_t CollapsibleCount = 0;
	for (const auto& i: PromptList)
	{
		Sizes.emplace_back(i.Text.size());
		PromptLength += i.Text.size();
		if (i.Collapsible)
			++CollapsibleCount;
		else
			FixedLength += i.Text.size();
	}

	size_t CollapsibleItemLength = 0;
	bool TryCollapse = false;
	if (PromptLength > MaxLength)
	{
		if (CollapsibleCount)
		{
			if (FixedLength < MaxLength)
				CollapsibleItemLength = (MaxLength - FixedLength) / CollapsibleCount;
			TryCollapse = true;
		}
	}

	size_t CurLength = 0;
	GotoXY(m_X1, m_Y1);

	for (const auto& i: PromptList)
	{
		auto str = i.Text;

		if (TryCollapse && i.Collapsible)
		{
			TruncPathStr(str, static_cast<int>(CollapsibleItemLength));
		}

		if (CurLength + str.size() > MaxLength)
			TruncPathStr(str, std::max(0, static_cast<int>(MaxLength - CurLength)));
		SetColor(i.Colour);
		Text(str);
		CurLength += str.size();

		if (CurLength >= MaxLength)
			break;
	}
	return CurLength;
}
Пример #11
0
void MenuBar::DisplayObject()
{
	string strSpace=L"    ";
	string strMsg=strSpace+MSG(MMenuLeftTitle)+strSpace+MSG(MMenuFilesTitle)+strSpace+MSG(MMenuCommandsTitle)+strSpace+MSG(MMenuOptionsTitle)+strSpace+MSG(MMenuRightTitle);
	RemoveHighlights(strMsg);
	int Length=X2-X1+1;
	GotoXY(X1,Y1);
	SetColor(COL_HMENUTEXT);
	FS << fmt::LeftAlign() << fmt::Width(Length) << fmt::Precision(Length) << strMsg;
}
Пример #12
0
void BigButtonPressed(int x, int y, char *str)
{
  stdwindow(x,y,x+50,y+10);
  HLine(x+1, y+1, 48, darkw);
  VLine(x+1, y+1, 8, darkw);
  HLine(x+2, y+8, 47, winbg);
  VLine(x+48, y+2, 7, winbg);
  GotoXY(x+1+(25-(pixels(str)/2)), y+3);
  printstring(str);
}
Пример #13
0
	void forceInit()
	{
		GotoXY(1, 19);
		printf("                                  ");
		GotoXY(1, 19);
		printf("正在进行第二步处理...");
		int x = 0;
		isok = false;
		for (int i = 1; i < 10; i++)
		{
			for (int j = 1; j < 10; j++)
			{
				sz[x++] = SUDOK[i][j].result;
			}
		}
		SetColor(6);
		force(0);
		SetColor(10);
	}
Пример #14
0
void Printer::Print(const char* str)
{
	int i;
	for (;*str;str++)
	{
		switch (*str) {
			case '\n':
				for (i=xpos;i<COLUMNS;i++)
				{
					Putchar(i,ypos,' ');
				}
				xpos = 0;
				ypos++;
				break;
			case '\b':
				if (xpos==0&&ypos==0) ;
				else if (xpos==0) {
					xpos = COLUMNS-1;
					ypos--;
				} else {
					xpos--;
				}
				Putchar(xpos,ypos,' ');
				break;
			default:
				Putchar(xpos,ypos,*str);
				if (xpos==COLUMNS-1) {
					xpos = 0;
					ypos++;
				} else {
					xpos++;
				}
				break;
		}
	}
	if (ypos<=(LINES-1)) {
		GotoXY(xpos,ypos);
	} else {
		Scrollup(ypos-(LINES-1));
		GotoXY(xpos,(LINES-1));
	}
}
Пример #15
0
	void comp(int Row, int Col, int x)
	{
		if (x == 0) return ;
		SUDOK[Row][Col].isok = true;
		SUDOK[Row][Col].result = x;
		GotoXY(Col*4 - 2, Row*2 - 1);
		char s[] = "0";
		s[1] += x;
		printf(s);
		Sleep(50);
	}
Пример #16
0
void TestChars(void){
	unsigned char i,j,x;
	x = 0;
	for (i=0x21;i<0xC1;i++){

		if ((curX+x) == 10){
			GotoXY(10, curY);
			x = 0;
		} else if ((curX+x) == 20){
			GotoXY(0, curY+1);			
			x = 0;
		}

		for (j=0;j<5;j++){
			WriteData(tableGLCDChars[i-32][j]);
		}
		//PutChar(i);
		x++;
	}
}
Пример #17
0
void TextField(int x, int y, int width, char *str, int blink)
{
  FilledBox(x, y, width, 9, 0);
  HLine(x, y, width+1, darkw);
  VLine(x, y, 9, darkw);
  HLine(x+1, y+8, width-1, brightw);
  VLine(x+width, y+1, 8, brightw);
  GotoXY(x+2, y+2);
  printstring(str);
  if (blink) printstring("_");
}
Пример #18
0
void CUI::PaintHM(bool mh, bool who, Field* fuf)
{
	switch (mh)				//*** 1 ~ hit, 0 ~ miss. ***
	{
	case (1) :
		if (who == PLAYER) GotoXY(fuf->posx + x + 1, fuf->posy + y + 1);
		else GotoXY(fuf->posx + x + fuf->Width() + 2, fuf->posy + y + 1);
		SetColor(Yellow, LightBlue);
		printf("%c", fuf->hit);
		SetColor(White, Black);
		break;
	case (0) :
		if (who == PLAYER) GotoXY(fuf->posx + x + 1, fuf->posy + y + 1);
		else GotoXY(fuf->posx + x + fuf->Width() + 2, fuf->posy + y + 1);
		SetColor(LightCyan, LightBlue);
		printf("%c", fuf->miss);
		SetColor(White, Black);
		break;
	}
}
Пример #19
0
void Write_GLCD( unsigned char* message){
	unsigned char i, mx;
	mx = 20-curX;
	for( i=0; i<mx; i++ ){
		if ((curX+i) == 10){
				GotoXY(10, curY);
		} 
		if( !message[i] ) break;
		PutChar(message[i]);
	}
}
Пример #20
0
void Boarder()
{
   system("cls");
   int i;
   GotoXY(food.x,food.y);   /*displaying food*/
       printf("F");
   for(i=10;i<71;i++)
   {
       GotoXY(i,10);
           printf("!");
       GotoXY(i,30);
           printf("!");
   }
   for(i=10;i<31;i++)
   {
       GotoXY(10,i);
           printf("!");
       GotoXY(70,i);
       printf("!");
   }
}
Пример #21
0
	void showAll()
	{
		for (int k = 0; k < 81; k++)
		{
			int Row = k/9+1;
			int Col = k%9+1;
			if (!SUDOK[Row][Col].isok)
			{
				GotoXY(Col*4 - 2, Row*2 - 1);
				char s[] = "0";
				s[1] += sz[k];
				printf(sz[k] ? s : " ");
				Sleep(50);
			}
			
		}
		isok = true;
		GotoXY(1, 19);
		printf("                                  ");
		GotoXY(1, 19);
	}
Пример #22
0
void ButtonPressed(int x, int y, char *str)
/* -- ric: 13/Jun/98 --     */
/* Draws a depressed button */
{
  stdwindow(x,y,x+30,y+10);
  HLine(x+1, y+1, 28, darkw);
  VLine(x+1, y+1, 8, darkw);
  HLine(x+2, y+8, 27, winbg);
  VLine(x+28, y+2, 7, winbg);
  GotoXY(x+1+(15-(pixels(str)/2)), y+3);
  printstring(str);
}
Пример #23
0
void TestScroll(void){
	unsigned char i,j;

	unsigned char zz[20]={' ',' ',' ',' ','*',' ',' ',' ',' ','*',' ',' ',' ',' ','*',' ',' ',' ',' ','*'};
	
	GotoXY(0, 0);
	for (j=0;j<10;j++){
		for (i=0;i<10;i++){
			PutChar(zz[i+j]);
		}
	}
}
Пример #24
0
void MenuBar::DisplayObject()
{
	FARString strSpace=L"    ";
	FARString strMsg=strSpace+MSG(MMenuLeftTitle)+strSpace+MSG(MMenuFilesTitle)+strSpace+MSG(MMenuCommandsTitle)+strSpace+MSG(MMenuOptionsTitle)+strSpace+MSG(MMenuRightTitle);
	RemoveHighlights(strMsg);
	int Length=X2-X1+1;
	FARString strFullMsg;
    strFullMsg.Format(L"%-*.*ls", Length,Length, strMsg.CPtr());
	GotoXY(X1,Y1);
	SetColor(COL_HMENUTEXT);
	Text(strFullMsg);
}
Пример #25
0
/*
   Отрисовка прямоугольника.
*/
void Box(int x1,int y1,int x2,int y2,const FarColor& Color,int Type)
{
	if (x1>=x2 || y1>=y2)
		return;

	enum line { LineV, LineH, LineLT, LineRT, LineLB, LineRB, LineCount };

	static const BOX_DEF_SYMBOLS BoxInit[2][LineCount] =
	{
		{ BS_V1, BS_H1, BS_LT_H1V1, BS_RT_H1V1, BS_LB_H1V1, BS_RB_H1V1, },
		{ BS_V2, BS_H2, BS_LT_H2V2, BS_RT_H2V2, BS_LB_H2V2, BS_RB_H2V2, },
	};

	const auto Box = BoxInit[(Type == DOUBLE_BOX || Type == SHORT_DOUBLE_BOX)];
	const auto Symbol = [Box](line Line) { return BoxSymbols[Box[Line]]; };

	SetColor(Color);

	std::vector<wchar_t> Buffer;

	Buffer.assign(y2 - y1 - 1, Symbol(LineV));

	GotoXY(x1,y1+1);
	VText(Buffer.data(), Buffer.size());

	GotoXY(x2,y1+1);
	VText(Buffer.data(), Buffer.size());

	Buffer.assign(x2 - x1 + 1, Symbol(LineH));

	Buffer.front() = Symbol(LineLT);
	Buffer.back() = Symbol(LineRT);
	GotoXY(x1,y1);
	Text(Buffer.data(), Buffer.size());

	Buffer.front() = Symbol(LineLB);
	Buffer.back() = Symbol(LineRB);
	GotoXY(x1,y2);
	Text(Buffer.data(), Buffer.size());
}
Пример #26
0
void CheckBox(int x, int y, int checked)
{
  FilledBox(x, y, 7, 6, 0);
  HLine(x, y, 8, darkw);
  VLine(x, y, 7, darkw);
  HLine(x+1, y+6, 7, brightw);
  VLine(x+7, y+1, 5, brightw);
  if (checked)
  {
    GotoXY(x+2, y+2);
    printstring("*");
  }
}
Пример #27
0
	void show()
	{
		system("CLS");
		consolehwnd = GetStdHandle(STD_OUTPUT_HANDLE);
		SetColor(15);
		GotoXY(0, 0);
		printf("┏━┯━┯━┳━┯━┯━┳━┯━┯━┓\n");
		printf("┃ │ │ ┃ │ │ ┃ │ │ ┃\n");
		printf("┠─┼─┼─╂─┼─┼─╂─┼─┼─┨\n");
		printf("┃ │ │ ┃ │ │ ┃ │ │ ┃\n");
		printf("┠─┼─┼─╂─┼─┼─╂─┼─┼─┨\n");
		printf("┃ │ │ ┃ │ │ ┃ │ │ ┃\n");
		printf("┣━┿━┿━╋━┿━┿━╋━┿━┿━┫\n");
		printf("┃ │ │ ┃ │ │ ┃ │ │ ┃\n");
		printf("┠─┼─┼─╂─┼─┼─╂─┼─┼─┨\n");
		printf("┃ │ │ ┃ │ │ ┃ │ │ ┃\n");
		printf("┠─┼─┼─╂─┼─┼─╂─┼─┼─┨\n");
		printf("┃ │ │ ┃ │ │ ┃ │ │ ┃\n");
		printf("┣━┿━┿━╋━┿━┿━╋━┿━┿━┫\n");
		printf("┃ │ │ ┃ │ │ ┃ │ │ ┃\n");
		printf("┠─┼─┼─╂─┼─┼─╂─┼─┼─┨\n");
		printf("┃ │ │ ┃ │ │ ┃ │ │ ┃\n");
		printf("┠─┼─┼─╂─┼─┼─╂─┼─┼─┨\n");
		printf("┃ │ │ ┃ │ │ ┃ │ │ ┃\n");
		printf("┗━┷━┻━┻━┷━┷━┻━┷━┷━┛\n");
		SetColor(6);
		for (int j = 1; j < 10; j++)
			for (int i = 1; i < 9; i++)
			{
				GotoXY(4*j - 2, 2*i);
				if (i % 3 != 0)printf("─");
				GotoXY(4*i, 2*j - 1);
				if (i % 3 != 0)printf("│");
				GotoXY(4*i, 2*j);
				if (i % 3 != 0 && j % 3 != 0)printf("┼");
			}
		GotoXY(1, 19);
	}
Пример #28
0
/***************************************
函数名称:Deal_key
功能描述:按键检测
***************************************/
void Deal_key( void)
{
	if (sine == 0)
	{
		mode = 0;
		GotoXY( 0, 1);
		Print("sine");
	}
	if (tria == 0)
	{
		mode = 1;
		GotoXY( 0, 1);
		Print("tria");
	}
	if (squa == 0)
	{
		mode = 2;
		GotoXY( 0, 1);
		Print("squa");
	}
	if (Freq_de == 0)
	{
		while (Freq_de == 0);
		Frequency -= 1;
		
		IntToStr(Frequency, TempBuffer,3);
		GotoXY( 9, 0);
		Print(&TempBuffer[0]);
	}
	if (Freq_ad == 0)
	{
		while (Freq_ad == 0);
		Frequency += 1;
		IntToStr(Frequency, TempBuffer,3);
		GotoXY( 9, 0);
		Print(&TempBuffer[0]);
	}
}
void ClearSelectAreea(){

    ///\fn void ClearSelectAreea()
    ///\brief Sterge suprafata de sugestii.
    ///
    ///Implementarea stergerii DOAR a suprafetei rezervata sugestiilor pentru cuvintele gresite.


    int i;
    for(i=0;i<8;i++){
        GotoXY(0,i);
        printf("                                                                         ");
    }
}
Пример #30
0
// ================================ Graphics ===================================
void Lcd_t::DrawImage(const uint8_t x, const uint8_t y, const uint8_t* Img) {
    uint8_t *p = (uint8_t*)Img;
    uint16_t w;
    uint8_t Width = *p++, Height = *p++;
    for(uint8_t fy=y; fy < y+Height; fy++) {
        GotoXY(x, fy);
        for(uint8_t fx=x; fx < x+Width; fx++) {
            w = *p++;
            w = (w << 1) | 0x0001;
            IBuf[CurrentPosition++] = w;
            if(CurrentPosition >= LCD_VIDEOBUF_SIZE) continue;
        } // fx
    } // fy
}