static VOID NTAPI
GuiDrawRegion(IN OUT PFRONTEND This, SMALL_RECT* Region);
static VOID
-GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData);
+GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit);
static LRESULT
Ret = FALSE;
goto Quit;
}
- // ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
ActiveBuffer = GuiData->ActiveBuffer;
/*
}
static VOID
-GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData)
+GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
{
- // PCONSOLE Console = GuiData->Console;
- PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
+ PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
SCROLLINFO sInfo;
DWORD Width, Height;
- UINT WidthUnit, HeightUnit;
-
- GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
Width = Buff->ViewSize.X * WidthUnit +
2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
ReleaseDC(GuiData->hWindow, hDC);
+ /* Initialize the terminal framebuffer */
+ GuiData->hMemDC = CreateCompatibleDC(NULL);
+ GuiData->hBitmap = NULL;
+ GuiData->hSysPalette = NULL; /* Original system palette */
+
// FIXME: Keep these instructions here ? ///////////////////////////////////
Console->ActiveBuffer->CursorBlinkOn = TRUE;
Console->ActiveBuffer->ForceCursorOff = FALSE;
static VOID
SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
{
- // PCONSOLE Console = GuiData->Console;
- PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
+ PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
UINT WidthUnit, HeightUnit;
GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
VOID
GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
PGUI_CONSOLE_DATA GuiData,
- HDC hDC,
- PRECT rc);
+ PRECT rcView,
+ PRECT rcFramebuffer);
VOID
GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
PGUI_CONSOLE_DATA GuiData,
- HDC hDC,
- PRECT rc);
+ PRECT rcView,
+ PRECT rcFramebuffer);
static VOID
GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData)
BOOL Success = TRUE;
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
- HDC hDC;
PAINTSTRUCT ps;
+ RECT rcPaint;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{
Success = FALSE;
goto Quit;
}
- // ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
ActiveBuffer = GuiData->ActiveBuffer;
- hDC = BeginPaint(GuiData->hWindow, &ps);
- if (hDC != NULL &&
+ BeginPaint(GuiData->hWindow, &ps);
+ if (ps.hdc != NULL &&
ps.rcPaint.left < ps.rcPaint.right &&
ps.rcPaint.top < ps.rcPaint.bottom)
{
EnterCriticalSection(&GuiData->Lock);
+ /* Compose the current screen-buffer on-memory */
if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
{
GuiPaintTextModeBuffer((PTEXTMODE_SCREEN_BUFFER)ActiveBuffer,
- GuiData, hDC, &ps.rcPaint);
+ GuiData, &ps.rcPaint, &rcPaint);
}
else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
{
GuiPaintGraphicsBuffer((PGRAPHICS_SCREEN_BUFFER)ActiveBuffer,
- GuiData, hDC, &ps.rcPaint);
+ GuiData, &ps.rcPaint, &rcPaint);
}
+ /* Send it to screen */
+ BitBlt(ps.hdc,
+ ps.rcPaint.left,
+ ps.rcPaint.top,
+ rcPaint.right - rcPaint.left,
+ rcPaint.bottom - rcPaint.top,
+ GuiData->hMemDC,
+ rcPaint.left,
+ rcPaint.top,
+ SRCCOPY);
+
if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{
- RECT rc;
- SmallRectToRect(GuiData, &rc, &Console->Selection.srSelection);
+ SmallRectToRect(GuiData, &rcPaint, &Console->Selection.srSelection);
- /* invert the selection */
- if (IntersectRect(&rc, &ps.rcPaint, &rc))
+ /* Invert the selection */
+ if (IntersectRect(&rcPaint, &ps.rcPaint, &rcPaint))
{
- PatBlt(hDC,
- rc.left,
- rc.top,
- rc.right - rc.left,
- rc.bottom - rc.top,
- DSTINVERT);
+ InvertRect(ps.hdc, &rcPaint);
}
}
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
- // ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
ActiveBuffer = GuiData->ActiveBuffer;
if (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS)
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
- Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
+ Buff = GuiData->ActiveBuffer;
if (GetType(Buff) == TEXTMODE_BUFFER)
{
GuiInvalidateCell(&Console->TermIFace, Buff->CursorPosition.X, Buff->CursorPosition.Y);
Buff->CursorBlinkOn = !Buff->CursorBlinkOn;
- if ((GuiData->OldCursor.x != Buff->CursorPosition.X) || (GuiData->OldCursor.y != Buff->CursorPosition.Y))
+ if ((GuiData->OldCursor.x != Buff->CursorPosition.X) ||
+ (GuiData->OldCursor.y != Buff->CursorPosition.Y))
{
SCROLLINFO xScroll;
int OldScrollX = -1, OldScrollY = -1;
// If we successfully got the info for the horizontal scrollbar
if (OldScrollX >= 0)
{
- if ((Buff->CursorPosition.X < Buff->ViewOrigin.X) || (Buff->CursorPosition.X >= (Buff->ViewOrigin.X + Buff->ViewSize.X)))
+ if ((Buff->CursorPosition.X < Buff->ViewOrigin.X) ||
+ (Buff->CursorPosition.X >= (Buff->ViewOrigin.X + Buff->ViewSize.X)))
{
// Handle the horizontal scroll bar
- if (Buff->CursorPosition.X >= Buff->ViewSize.X) NewScrollX = Buff->CursorPosition.X - Buff->ViewSize.X + 1;
- else NewScrollX = 0;
+ if (Buff->CursorPosition.X >= Buff->ViewSize.X)
+ NewScrollX = Buff->CursorPosition.X - Buff->ViewSize.X + 1;
+ else
+ NewScrollX = 0;
}
else
{
// If we successfully got the info for the vertical scrollbar
if (OldScrollY >= 0)
{
- if ((Buff->CursorPosition.Y < Buff->ViewOrigin.Y) || (Buff->CursorPosition.Y >= (Buff->ViewOrigin.Y + Buff->ViewSize.Y)))
+ if ((Buff->CursorPosition.Y < Buff->ViewOrigin.Y) ||
+ (Buff->CursorPosition.Y >= (Buff->ViewOrigin.Y + Buff->ViewSize.Y)))
{
// Handle the vertical scroll bar
- if (Buff->CursorPosition.Y >= Buff->ViewSize.Y) NewScrollY = Buff->CursorPosition.Y - Buff->ViewSize.Y + 1;
- else NewScrollY = 0;
+ if (Buff->CursorPosition.Y >= Buff->ViewSize.Y)
+ NewScrollY = Buff->CursorPosition.Y - Buff->ViewSize.Y + 1;
+ else
+ NewScrollY = 0;
}
else
{
SetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll, TRUE);
}
UpdateWindow(GuiData->hWindow);
+ // InvalidateRect(GuiData->hWindow, NULL, FALSE);
GuiData->OldCursor.x = Buff->CursorPosition.X;
GuiData->OldCursor.y = Buff->CursorPosition.Y;
}
static LRESULT
GuiConsoleHandleNcDestroy(HWND hWnd)
{
+ PGUI_CONSOLE_DATA GuiData = GuiGetGuiData(hWnd);
+
KillTimer(hWnd, CONGUI_UPDATE_TIMER);
GetSystemMenu(hWnd, TRUE);
+ if (GuiData)
+ {
+ /* Free the terminal framebuffer */
+ if (GuiData->hMemDC ) DeleteDC(GuiData->hMemDC);
+ if (GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
+ // if (GuiData->hSysPalette) DeleteObject(GuiData->hSysPalette);
+ if (GuiData->Font) DeleteObject(GuiData->Font);
+ }
+
/* Free the GuiData registration */
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)NULL);
static COORD
PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
{
- // PCONSOLE Console = GuiData->Console;
- PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
+ PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
COORD Coord;
UINT WidthUnit, HeightUnit;
if (OpenClipboard(GuiData->hWindow) == TRUE)
{
PCONSOLE Console = GuiData->Console;
- PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
+ PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
if (GetType(Buffer) == TEXTMODE_BUFFER)
{
{
if (OpenClipboard(GuiData->hWindow) == TRUE)
{
- // PCONSOLE Console = GuiData->Console;
- PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
+ PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
if (GetType(Buffer) == TEXTMODE_BUFFER)
{
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
- // ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
ActiveBuffer = GuiData->ActiveBuffer;
GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
if ((GuiData->WindowSizeLock == FALSE) &&
(wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED))
{
- PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
+ PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
DWORD windx, windy, charx, chary;
UINT WidthUnit, HeightUnit;
Buff->ViewSize.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
}
- GuiConsoleResizeWindow(GuiData);
+ GuiConsoleResizeWindow(GuiData, WidthUnit, HeightUnit);
// Adjust the start of the visible area if we are attempting to show nonexistent areas
if ((Buff->ScreenBufferSize.X - Buff->ViewOrigin.X) < Buff->ViewSize.X) Buff->ViewOrigin.X = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return 0;
- Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
+ Buff = GuiData->ActiveBuffer;
if (uMsg == WM_HSCROLL)
{
SetScrollInfo(GuiData->hWindow, fnBar, &sInfo, TRUE);
UpdateWindow(GuiData->hWindow);
+ // InvalidateRect(GuiData->hWindow, NULL, FALSE);
}
Quit:
case WM_PALETTECHANGED:
{
- PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console);
+ PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
DPRINT1("WM_PALETTECHANGED called\n");
// if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
if (ActiveBuffer->PaletteHandle)
{
- /* Get the Device Context of the console window */
- HDC hDC = GetDC(GuiData->hWindow);
-
DPRINT1("WM_PALETTECHANGED changing palette\n");
- /* Specify the use of the system palette */
- SetSystemPaletteUse(hDC, ActiveBuffer->PaletteUsage);
+ /* Specify the use of the system palette for the framebuffer */
+ SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
/* Realize the (logical) palette */
- RealizePalette(hDC);
-
- /* Release the Device Context and return */
- ReleaseDC(GuiData->hWindow, hDC);
+ RealizePalette(GuiData->hMemDC);
}
DPRINT1("WM_PALETTECHANGED quit\n");
case PM_RESIZE_TERMINAL:
{
+ PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
+ HDC hDC;
+ HBITMAP hnew, hold;
+
+ DWORD Width, Height;
+ UINT WidthUnit, HeightUnit;
+
+ GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
+
+ Width = Buff->ScreenBufferSize.X * WidthUnit ;
+ Height = Buff->ScreenBufferSize.Y * HeightUnit;
+
+ /* Recreate the framebuffer */
+ hDC = GetDC(GuiData->hWindow);
+ hnew = CreateCompatibleBitmap(hDC, Width, Height);
+ ReleaseDC(GuiData->hWindow, hDC);
+ hold = SelectObject(GuiData->hMemDC, hnew);
+ if (GuiData->hBitmap)
+ {
+ if (hold == GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
+ }
+ GuiData->hBitmap = hnew;
+
/* Resize the window to the user's values */
GuiData->WindowSizeLock = TRUE;
- GuiConsoleResizeWindow(GuiData);
+ GuiConsoleResizeWindow(GuiData, WidthUnit, HeightUnit);
GuiData->WindowSizeLock = FALSE;
break;
}
/* Move and resize the window to the user's values */
/* CAN WE DEADLOCK ?? */
GuiConsoleMoveWindow(GuiData);
- GuiData->WindowSizeLock = TRUE;
- GuiConsoleResizeWindow(GuiData);
- GuiData->WindowSizeLock = FALSE;
+ SendMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
/* Switch to full-screen mode if necessary */
if (GuiData->GuiInfo.FullScreen) SwitchFullScreen(GuiData, TRUE);
}
}
- /* Original system palette */
- GuiData->hSysPalette = NULL;
-
/* Mouse is shown by default with its default cursor shape */
GuiData->hCursor = ghDefaultCursor;
GuiData->MouseCursorRefCount = 0;
SmallRectToRect(GuiData, &RegionRect, Region);
/* Do not erase the background: it speeds up redrawing and reduce flickering */
InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
+ /**UpdateWindow(GuiData->hWindow);**/
}
static VOID NTAPI
if (NULL == GuiData || NULL == GuiData->hWindow) return;
- Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console);
+ Buff = GuiData->ActiveBuffer;
if (GetType(Buff) != TEXTMODE_BUFFER) return;
if (0 != ScrolledLines)
{
PGUI_CONSOLE_DATA GuiData = This->Data;
- if (/*ConDrvGetActiveScreenBuffer(GuiData->Console)*/GuiData->ActiveBuffer == Buff)
+ if (GuiData->ActiveBuffer == Buff)
{
GuiInvalidateCell(This, Buff->CursorPosition.X, Buff->CursorPosition.Y);
}
{
PGUI_CONSOLE_DATA GuiData = This->Data;
- if (/*ConDrvGetActiveScreenBuffer(GuiData->Console)*/GuiData->ActiveBuffer == Buff)
+ if (GuiData->ActiveBuffer == Buff)
{
/* Redraw char at old position (remove cursor) */
GuiInvalidateCell(This, OldCursorX, OldCursorY);
PGUI_CONSOLE_DATA GuiData = This->Data;
/* Resize the window to the user's values */
- // GuiData->WindowSizeLock = TRUE;
- // GuiConsoleResizeWindow(GuiData);
- // GuiData->WindowSizeLock = FALSE;
- // NOTE: This code ^^ causes deadlocks...
-
PostMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
}
GuiSetActiveScreenBuffer(IN OUT PFRONTEND This)
{
PGUI_CONSOLE_DATA GuiData = This->Data;
- PCONSOLE_SCREEN_BUFFER ActiveBuffer; // = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console);
- HDC hDC;
+ PCONSOLE_SCREEN_BUFFER ActiveBuffer;
HPALETTE hPalette;
EnterCriticalSection(&GuiData->Lock);
GuiData->WindowSizeLock = TRUE;
InterlockedExchangePointer(&GuiData->ActiveBuffer,
- GuiData->Console->ActiveBuffer);
+ ConDrvGetActiveScreenBuffer(GuiData->Console));
GuiData->WindowSizeLock = FALSE;
LeaveCriticalSection(&GuiData->Lock);
DPRINT1("GuiSetActiveScreenBuffer using palette 0x%p\n", hPalette);
- /* Get the Device Context of the console window */
- hDC = GetDC(GuiData->hWindow);
-
- /* Set the new palette */
- SelectPalette(hDC, hPalette, FALSE);
+ /* Set the new palette for the framebuffer */
+ SelectPalette(GuiData->hMemDC, hPalette, FALSE);
- /* Specify the use of the system palette */
- SetSystemPaletteUse(hDC, ActiveBuffer->PaletteUsage);
+ /* Specify the use of the system palette for the framebuffer */
+ SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
/* Realize the (logical) palette */
- RealizePalette(hDC);
-
- /* Release the Device Context */
- ReleaseDC(GuiData->hWindow, hDC);
+ RealizePalette(GuiData->hMemDC);
GuiResizeTerminal(This);
// ConioDrawConsole(Console);
IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
{
PGUI_CONSOLE_DATA GuiData = This->Data;
- HDC hDC;
/*
* If we were notified to release a screen buffer that is not actually
* it ONLY.
*/
- /* Get the Device Context of the console window */
- hDC = GetDC(GuiData->hWindow);
-
/* Release the old active palette and set the default one */
- if (GetCurrentObject(hDC, OBJ_PAL) == ScreenBuffer->PaletteHandle)
+ if (GetCurrentObject(GuiData->hMemDC, OBJ_PAL) == ScreenBuffer->PaletteHandle)
{
/* Set the new palette */
- SelectPalette(hDC, GuiData->hSysPalette, FALSE);
+ SelectPalette(GuiData->hMemDC, GuiData->hSysPalette, FALSE);
}
- /* Release the Device Context */
- ReleaseDC(GuiData->hWindow, hDC);
-
/* Set the adequate active screen buffer */
if (ScreenBuffer != GuiData->Console->ActiveBuffer)
{
return;
}
- // ActiveBuffer = ConDrvGetActiveScreenBuffer(GuiData->Console);
ActiveBuffer = GuiData->ActiveBuffer;
if (ActiveBuffer)
{
HPALETTE PaletteHandle,
UINT PaletteUsage)
{
- BOOL Success = TRUE;
PGUI_CONSOLE_DATA GuiData = This->Data;
- // PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console);
- HDC hDC;
HPALETTE OldPalette;
- DPRINT1("GuiSetPalette checkpt 0\n");
-
- // if (GetType(ActiveBuffer) != GRAPHICS_BUFFER) return FALSE;
+ // if (GetType(GuiData->ActiveBuffer) != GRAPHICS_BUFFER) return FALSE;
if (PaletteHandle == NULL) return FALSE;
- DPRINT1("GuiSetPalette checkpt 1\n");
-
- /* Get the Device Context of the console window */
- hDC = GetDC(GuiData->hWindow);
-
- DPRINT1("GuiSetPalette calling SelectPalette(0x%p, 0x%p, FALSE)\n", hDC, PaletteHandle);
-
- /* Set the new palette */
- OldPalette = SelectPalette(hDC, PaletteHandle, FALSE);
- DPRINT1("OldPalette = 0x%p\n", OldPalette);
- if (OldPalette == NULL)
- {
- DPRINT1("SelectPalette failed\n");
- Success = FALSE;
- goto Quit;
- }
-
- DPRINT1("GuiSetPalette checkpt 2\n");
+ /* Set the new palette for the framebuffer */
+ OldPalette = SelectPalette(GuiData->hMemDC, PaletteHandle, FALSE);
+ if (OldPalette == NULL) return FALSE;
- /* Specify the use of the system palette */
- SetSystemPaletteUse(hDC, PaletteUsage);
+ /* Specify the use of the system palette for the framebuffer */
+ SetSystemPaletteUse(GuiData->hMemDC, PaletteUsage);
/* Realize the (logical) palette */
- RealizePalette(hDC);
-
- DPRINT1("GuiData->hSysPalette before == 0x%p\n", GuiData->hSysPalette);
+ RealizePalette(GuiData->hMemDC);
/* Save the original system palette handle */
if (GuiData->hSysPalette == NULL) GuiData->hSysPalette = OldPalette;
- DPRINT1("GuiData->hSysPalette after == 0x%p\n", GuiData->hSysPalette);
-
-Quit:
- DPRINT1("GuiSetPalette Quit\n");
- /* Release the Device Context and return */
- ReleaseDC(GuiData->hWindow, hDC);
- return Success;
+ return TRUE;
}
static ULONG NTAPI
VOID
GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
PGUI_CONSOLE_DATA GuiData,
- HDC hDC,
- PRECT rc)
+ PRECT rcView,
+ PRECT rcFramebuffer)
{
PCONSOLE Console = Buffer->Header.Console;
// ASSERT(Console == GuiData->Console);
if (Buffer->Buffer == NULL) return;
- TopLine = rc->top / GuiData->CharHeight + Buffer->ViewOrigin.Y;
- BottomLine = (rc->bottom + (GuiData->CharHeight - 1)) / GuiData->CharHeight - 1 + Buffer->ViewOrigin.Y;
- LeftChar = rc->left / GuiData->CharWidth + Buffer->ViewOrigin.X;
- RightChar = (rc->right + (GuiData->CharWidth - 1)) / GuiData->CharWidth - 1 + Buffer->ViewOrigin.X;
+ rcFramebuffer->left = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->left;
+ rcFramebuffer->top = Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->top;
+ rcFramebuffer->right = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->right;
+ rcFramebuffer->bottom = Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->bottom;
- LastAttribute = ConioCoordToPointer(Buffer, LeftChar, TopLine)->Attributes;
-
- SetTextColor(hDC, RGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute)));
- SetBkColor(hDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute)));
+ LeftChar = rcFramebuffer->left / GuiData->CharWidth;
+ TopLine = rcFramebuffer->top / GuiData->CharHeight;
+ RightChar = rcFramebuffer->right / GuiData->CharWidth;
+ BottomLine = rcFramebuffer->bottom / GuiData->CharHeight;
- if (BottomLine >= Buffer->ScreenBufferSize.Y) BottomLine = Buffer->ScreenBufferSize.Y - 1;
if (RightChar >= Buffer->ScreenBufferSize.X) RightChar = Buffer->ScreenBufferSize.X - 1;
+ if (BottomLine >= Buffer->ScreenBufferSize.Y) BottomLine = Buffer->ScreenBufferSize.Y - 1;
+
+ LastAttribute = ConioCoordToPointer(Buffer, LeftChar, TopLine)->Attributes;
- OldFont = SelectObject(hDC, GuiData->Font);
+ SetTextColor(GuiData->hMemDC, RGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute)));
+ SetBkColor(GuiData->hMemDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute)));
+
+ OldFont = SelectObject(GuiData->hMemDC, GuiData->Font);
for (Line = TopLine; Line <= BottomLine; Line++)
{
*/
if (From->Attributes != LastAttribute || (Char - Start == sizeof(LineBuffer) / sizeof(WCHAR)))
{
- TextOutW(hDC,
- (Start - Buffer->ViewOrigin.X) * GuiData->CharWidth ,
- (Line - Buffer->ViewOrigin.Y) * GuiData->CharHeight,
+ TextOutW(GuiData->hMemDC,
+ Start * GuiData->CharWidth,
+ Line * GuiData->CharHeight,
LineBuffer,
Char - Start);
Start = Char;
Attribute = From->Attributes;
if (Attribute != LastAttribute)
{
- SetTextColor(hDC, RGBFromAttrib(Console, TextAttribFromAttrib(Attribute)));
- SetBkColor(hDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(Attribute)));
+ SetTextColor(GuiData->hMemDC, RGBFromAttrib(Console, TextAttribFromAttrib(Attribute)));
+ SetBkColor(GuiData->hMemDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(Attribute)));
LastAttribute = Attribute;
}
}
*(To++) = (From++)->Char.UnicodeChar;
}
- TextOutW(hDC,
- (Start - Buffer->ViewOrigin.X) * GuiData->CharWidth ,
- (Line - Buffer->ViewOrigin.Y) * GuiData->CharHeight,
+ TextOutW(GuiData->hMemDC,
+ Start * GuiData->CharWidth,
+ Line * GuiData->CharHeight,
LineBuffer,
RightChar - Start + 1);
}
TopLine <= CursorY && CursorY <= BottomLine)
{
CursorHeight = ConioEffectiveCursorSize(Console, GuiData->CharHeight);
+
Attribute = ConioCoordToPointer(Buffer, Buffer->CursorPosition.X, Buffer->CursorPosition.Y)->Attributes;
+ if (Attribute == DEFAULT_SCREEN_ATTRIB) Attribute = Buffer->ScreenDefaultAttrib;
- if (Attribute != DEFAULT_SCREEN_ATTRIB)
- {
- CursorBrush = CreateSolidBrush(RGBFromAttrib(Console, Attribute));
- }
- else
- {
- CursorBrush = CreateSolidBrush(RGBFromAttrib(Console, Buffer->ScreenDefaultAttrib));
- }
+ CursorBrush = CreateSolidBrush(RGBFromAttrib(Console, Attribute));
+ OldBrush = SelectObject(GuiData->hMemDC, CursorBrush);
- OldBrush = SelectObject(hDC, CursorBrush);
- PatBlt(hDC,
- (CursorX - Buffer->ViewOrigin.X) * GuiData->CharWidth,
- (CursorY - Buffer->ViewOrigin.Y) * GuiData->CharHeight + (GuiData->CharHeight - CursorHeight),
+ PatBlt(GuiData->hMemDC,
+ CursorX * GuiData->CharWidth,
+ CursorY * GuiData->CharHeight + (GuiData->CharHeight - CursorHeight),
GuiData->CharWidth,
CursorHeight,
PATCOPY);
- SelectObject(hDC, OldBrush);
+ SelectObject(GuiData->hMemDC, OldBrush);
DeleteObject(CursorBrush);
}
}
- SelectObject(hDC, OldFont);
+ SelectObject(GuiData->hMemDC, OldFont);
}
/* EOF */