Example #1
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)];
	LPWSTR HeapBuffer=nullptr;
	LPWSTR BufPtr=StackBuffer;

	const size_t height=y2-y1;
	if(height>StackBufferSize/sizeof(WCHAR))
	{
		HeapBuffer=new WCHAR[height];
		BufPtr=HeapBuffer;
	}
	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)
		{
			if(HeapBuffer)
			{
				delete[] HeapBuffer;
			}
			HeapBuffer=new WCHAR[width];
		}
		BufPtr=HeapBuffer;
	}
	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);

	if(HeapBuffer)
	{
		delete[] HeapBuffer;
	}
}
Example #2
0
void BoxText(const wchar_t *Str,int IsVert)
{
	if (IsVert)
		VText(Str);
	else
		Text(Str);
}
Example #3
0
void BoxText(const wchar_t* Str, size_t Size, bool IsVert)
{
	if (IsVert)
		VText(Str, Size);
	else
		Text(Str, Size);
}
Example #4
0
void ScrollBar(int X1,int Y1,int Length,unsigned long Current,unsigned long Total)
{
    int ThumbPos;

    if ((Length-=2)<1)
        return;

    if (Total>0)
        ThumbPos=Length*Current/Total;
    else
        ThumbPos=0;

    if (ThumbPos>=Length)
        ThumbPos=Length-1;

    GotoXY(X1,Y1);
    {
        WCHAR StackBuffer[StackBufferSize/sizeof(WCHAR)];
        wchar_t_ptr HeapBuffer;
        LPWSTR BufPtr=StackBuffer;
        if(static_cast<size_t>(Length+3)>=StackBufferSize/sizeof(WCHAR))
        {
            HeapBuffer.reset(Length + 3);
            BufPtr=HeapBuffer.get();
        }
        wmemset(BufPtr+1,BoxSymbols[BS_X_B0],Length);
        BufPtr[ThumbPos+1]=BoxSymbols[BS_X_B2];
        BufPtr[0]=Oem2Unicode[0x1E];
        BufPtr[Length+1]=Oem2Unicode[0x1F];
        BufPtr[Length+2]=0;
        VText(BufPtr);
    }
}
Example #5
0
void BoxText(const string& Str,int IsVert)
{
    if (IsVert)
        VText(Str);
    else
        Text(Str);
}
Example #6
0
bool ScrollBarEx3(UINT X1,UINT Y1,UINT Length, UINT64 Start,UINT64 End,UINT64 Size)
{
    WCHAR StackBuffer[4000/sizeof(WCHAR)], *Buffer = StackBuffer;
    wchar_t_ptr HeapBuffer;
    if ( Length <= 2 || End < Start )
        return false;
    if ( Length >= ARRAYSIZE(StackBuffer) )
    {
        HeapBuffer.reset(Length + 1);
        Buffer = HeapBuffer.get();
    }
    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);
            if (i1 > Length)
                i1 = Length;

            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);

    return true;
}
Example #7
0
void vmprintf(const WCHAR *fmt,...)
{
	va_list argptr;
	va_start(argptr,fmt);
	WCHAR OutStr[2048];
	_vsnwprintf(OutStr,ARRAYSIZE(OutStr)-1,fmt,argptr);
	VText(OutStr);
	va_end(argptr);
}
Example #8
0
void DrawLine(int Length,int Type, const wchar_t* UserSep)
{
	if (Length>1)
	{
		string Buffer = MakeSeparator(Length, Type, UserSep);
		// 12 - UserSep horiz
		// 13 - UserSep vert
		(Type >= 4 && Type <= 7) || (Type >= 10 && Type <= 11) || Type == 13? VText(Buffer) : Text(Buffer);
	}
}
Example #9
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());
}
Example #10
0
bool ScrollBarEx3(UINT X1, UINT Y1, UINT Length, UINT64 Start, UINT64 End, UINT64 Size)
{
	if ( Length < 2)
		return false;

	std::vector<wchar_t> Buffer(Length, BoxSymbols[BS_X_B0]);
	Buffer.front() = Oem2Unicode[0x1E];
	Buffer.back() = Oem2Unicode[0x1F];

	const auto FieldBegin = Buffer.begin() + 1;
	const auto FieldEnd = Buffer.end() - 1;
	const size_t FieldSize = FieldEnd - FieldBegin;

	End = std::min(End, Size);

	auto SliderBegin = FieldBegin, SliderEnd = SliderBegin;

	if (Size && Start < End)
	{
		auto SliderSize = std::max(1u, static_cast<UINT>(((End - Start) * FieldSize) / Size));

		if (SliderSize >= FieldSize)
		{
			SliderBegin = FieldBegin;
			SliderEnd = FieldEnd;
		}
		else if (End >= Size)
		{
			SliderBegin = FieldEnd - SliderSize;
			SliderEnd = FieldEnd;
		}
		else
		{
			SliderBegin = std::min(FieldBegin + static_cast<UINT>((Start*FieldSize) / Size), FieldEnd);
			SliderEnd = std::min(SliderBegin + SliderSize, FieldEnd);
		}
	}

	std::fill(SliderBegin, SliderEnd, BoxSymbols[BS_X_B2]);

	GotoXY(X1, Y1);
	VText(Buffer.data(), Buffer.size());

	return true;
}
Example #11
0
void DrawLine(int Length,int Type, const wchar_t* UserSep)
{
	if (Length>1)
	{
		WCHAR StackBuffer[StackBufferSize/sizeof(WCHAR)];
		LPWSTR HeapBuffer=nullptr;
		LPWSTR BufPtr=StackBuffer;
		if(static_cast<size_t>(Length)>=StackBufferSize/sizeof(WCHAR))
		{
			HeapBuffer=new WCHAR[Length+1];
			BufPtr=HeapBuffer;
		}
		MakeSeparator(Length,BufPtr,Type,UserSep);

		(Type >= 4 && Type <= 7) || (Type >= 10 && Type <= 11)? VText(BufPtr) : Text(BufPtr);
		if(HeapBuffer)
		{
			delete[] HeapBuffer;
		}
	}
}
Example #12
0
void HiText(const wchar_t *Str,const FarColor& HiColor,int isVertText)
{
	string strTextStr;
	FarColor SaveColor;
	size_t pos;
	strTextStr = Str;

	if (!strTextStr.Pos(pos,L'&'))
	{
		if (isVertText)
			VText(strTextStr);
		else
			Text(strTextStr);
	}
	else
	{
		/*
		   &&      = '&'
		   &&&     = '&'
		              ^H
		   &&&&    = '&&'
		   &&&&&   = '&&'
		              ^H
		   &&&&&&  = '&&&'
		*/
		wchar_t *ChPtr = strTextStr.GetBuffer() + pos;
		int I=0;
		wchar_t *ChPtr2=ChPtr;

		while (*ChPtr2++ == L'&')
			++I;

		if (I&1) // нечет?
		{
			*ChPtr=0;

			if (isVertText)
				VText(strTextStr);
			else
				Text(strTextStr); //BUGBUG BAD!!!

			if (ChPtr[1])
			{
				wchar_t Chr[]={ChPtr[1],0};
				SaveColor=CurColor;
				SetColor(HiColor);

				if (isVertText)
					VText(Chr);
				else
					Text(Chr);

				SetColor(SaveColor);
				string strText = (ChPtr+1);
				strTextStr.ReleaseBuffer();
				ReplaceStrings(strText,L"&&",L"&",-1);

				if (isVertText)
					VText(strText.CPtr()+1);
				else
					Text(strText.CPtr()+1);
			}
		}
		else
		{
			strTextStr.ReleaseBuffer();
			ReplaceStrings(strTextStr,L"&&",L"&",-1);

			if (isVertText)
				VText(strTextStr);
			else
				Text(strTextStr); //BUGBUG BAD!!!
		}
	}
}
Example #13
0
void HiText(const string& Str,const FarColor& HiColor,int isVertText)
{
    string strTextStr;
    FarColor SaveColor;
    strTextStr = Str;
    size_t pos = strTextStr.find(L'&');

    if (pos == string::npos)
    {
        if (isVertText)
            VText(strTextStr);
        else
            Text(strTextStr);
    }
    else
    {
        /*
           &&      = '&'
           &&&     = '&'
                      ^H
           &&&&    = '&&'
           &&&&&   = '&&'
                      ^H
           &&&&&&  = '&&&'
        */
        const wchar_t *ChPtr = strTextStr.data() + pos;
        int I=0;
        const wchar_t *ChPtr2=ChPtr;

        while (*ChPtr2++ == L'&')
            ++I;

        if (I&1) // нечет?
        {
            string LeftPart(strTextStr.data(), pos);

            if (isVertText)
                VText(LeftPart);
            else
                Text(LeftPart); //BUGBUG BAD!!!

            if (ChPtr[1])
            {
                wchar_t Chr[]= {ChPtr[1],0};
                SaveColor=CurColor;
                SetColor(HiColor);

                if (isVertText)
                    VText(Chr);
                else
                    Text(Chr);

                SetColor(SaveColor);
                string strText = (ChPtr+1);
                ReplaceStrings(strText,L"&&",L"&",-1);

                if (isVertText)
                    VText(strText.data()+1);
                else
                    Text(strText.data()+1);
            }
        }
        else
        {
            ReplaceStrings(strTextStr,L"&&",L"&",-1);

            if (isVertText)
                VText(strTextStr);
            else
                Text(strTextStr); //BUGBUG BAD!!!
        }
    }
}