}
static VOID
-GuiConsoleAppendMenuItems(HMENU hMenu,
- const GUICONSOLE_MENUITEM *Items)
+AppendMenuItems(HMENU hMenu,
+ const GUICONSOLE_MENUITEM *Items)
{
UINT i = 0;
WCHAR szMenuString[255];
hSubMenu = CreatePopupMenu();
if (hSubMenu != NULL)
{
- GuiConsoleAppendMenuItems(hSubMenu,
- Items[i].SubMenu);
+ AppendMenuItems(hSubMenu, Items[i].SubMenu);
if (!AppendMenuW(hMenu,
MF_STRING | MF_POPUP,
}
static VOID
-GuiConsoleCreateSysMenu(HWND hWnd)
+CreateSysMenu(HWND hWnd)
{
HMENU hMenu = GetSystemMenu(hWnd, FALSE);
if (hMenu != NULL)
{
- GuiConsoleAppendMenuItems(hMenu, GuiConsoleMainMenuItems);
+ AppendMenuItems(hMenu, GuiConsoleMainMenuItems);
DrawMenuBar(hWnd);
}
}
static VOID
-GuiSendMenuEvent(PCONSOLE Console, UINT CmdId)
+SendMenuEvent(PCONSOLE Console, UINT CmdId)
{
INPUT_RECORD er;
}
static VOID
-GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData);
+Copy(PGUI_CONSOLE_DATA GuiData);
static VOID
-GuiConsolePaste(PGUI_CONSOLE_DATA GuiData);
+Paste(PGUI_CONSOLE_DATA GuiData);
static VOID
-GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord);
+UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD coord);
+
+static VOID
+Mark(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
+ PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
+
+ /* Clear the old selection */
+ // UpdateSelection(GuiData, NULL);
+ Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
+
+ /* Restart a new selection */
+ Console->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X;
+ Console->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y;
+ Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
+ UpdateSelection(GuiData, &Console->Selection.dwSelectionAnchor);
+}
+
static VOID
-GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit);
+SelectAll(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
+ PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
+
+ /* Clear the old selection */
+ // UpdateSelection(GuiData, NULL);
+ Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
+
+ /*
+ * The selection area extends to the whole screen buffer's width.
+ */
+ Console->Selection.dwSelectionAnchor.X = 0;
+ Console->Selection.dwSelectionAnchor.Y = 0;
+ Console->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
+
+ /*
+ * Determine whether the selection must extend to just some part
+ * (for text-mode screen buffers) or to all of the screen buffer's
+ * height (for graphics ones).
+ */
+ if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
+ {
+ /*
+ * We select all the characters from the first line
+ * to the line where the cursor is positioned.
+ */
+ Console->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y;
+ }
+ else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
+ {
+ /*
+ * We select all the screen buffer area.
+ */
+ Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
+ }
+
+ /* Restart a new selection */
+ Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION;
+ UpdateSelection(GuiData, &Console->dwSelectionCursor);
+}
static LRESULT
-GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
+OnCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
{
LRESULT Ret = TRUE;
PCONSOLE Console = GuiData->Console;
- PCONSOLE_SCREEN_BUFFER ActiveBuffer;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{
Ret = FALSE;
goto Quit;
}
- ActiveBuffer = GuiData->ActiveBuffer;
/*
* In case the selected menu item belongs to the user-reserved menu id range,
*/
if (GuiData->CmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->CmdIdHigh)
{
- GuiSendMenuEvent(Console, (UINT)wParam);
+ SendMenuEvent(Console, (UINT)wParam);
goto Unlock_Quit;
}
switch (wParam)
{
case ID_SYSTEM_EDIT_MARK:
- {
- /* Clear the old selection */
- // GuiConsoleUpdateSelection(Console, NULL);
- Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
-
- /* Restart a new selection */
- Console->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X;
- Console->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y;
- Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
- GuiConsoleUpdateSelection(Console, &Console->Selection.dwSelectionAnchor);
-
+ Mark(GuiData);
break;
- }
case ID_SYSTEM_EDIT_COPY:
- GuiConsoleCopy(GuiData);
+ Copy(GuiData);
break;
case ID_SYSTEM_EDIT_PASTE:
- GuiConsolePaste(GuiData);
+ Paste(GuiData);
break;
case ID_SYSTEM_EDIT_SELECTALL:
- {
- /* Clear the old selection */
- // GuiConsoleUpdateSelection(Console, NULL);
- Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
-
- /*
- * The selection area extends to the whole screen buffer's width.
- */
- Console->Selection.dwSelectionAnchor.X = 0;
- Console->Selection.dwSelectionAnchor.Y = 0;
- Console->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
-
- /*
- * Determine whether the selection must extend to just some part
- * (for text-mode screen buffers) or to all of the screen buffer's
- * height (for graphics ones).
- */
- if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
- {
- /*
- * We select all the characters from the first line
- * to the line where the cursor is positioned.
- */
- Console->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y;
- }
- else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
- {
- /*
- * We select all the screen buffer area.
- */
- Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
- }
-
- /* Restart a new selection */
- Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION;
- GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
-
+ SelectAll(GuiData);
break;
- }
case ID_SYSTEM_EDIT_SCROLL:
DPRINT1("Scrolling is not handled yet\n");
}
static VOID
-GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
+ResizeConWnd(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
{
PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
SCROLLINFO sInfo;
}
static BOOL
-GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
+OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
{
PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
PCONSOLE Console;
TEXTMETRICW Metrics;
SIZE CharSize;
- DPRINT("GuiConsoleHandleNcCreate\n");
-
if (NULL == GuiData)
{
DPRINT1("GuiConsoleNcCreate: No GUI data\n");
GuiData->hBitmap = NULL;
GuiData->hSysPalette = NULL; /* Original system palette */
+ /* Update the icons of the window */
+ if (GuiData->hIcon != ghDefaultIcon)
+ {
+ DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_BIG , (LPARAM)GuiData->hIcon );
+ DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
+ }
+
// FIXME: Keep these instructions here ? ///////////////////////////////////
Console->ActiveBuffer->CursorBlinkOn = TRUE;
Console->ActiveBuffer->ForceCursorOff = FALSE;
SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
- GuiConsoleCreateSysMenu(GuiData->hWindow);
+ CreateSysMenu(GuiData->hWindow);
- DPRINT("GuiConsoleHandleNcCreate - setting start event\n");
+ DPRINT("OnNcCreate - setting start event\n");
SetEvent(GuiData->hGuiInitEvent);
return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
}
+
+BOOL
+EnterFullScreen(PGUI_CONSOLE_DATA GuiData);
+VOID
+LeaveFullScreen(PGUI_CONSOLE_DATA GuiData);
+VOID
+SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen);
+VOID
+GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData);
+
+static VOID
+OnActivate(PGUI_CONSOLE_DATA GuiData, WPARAM wParam)
+{
+ PCONSOLE Console = GuiData->Console;
+ WORD ActivationState = LOWORD(wParam);
+
+ DPRINT1("WM_ACTIVATE - ActivationState = %d\n");
+
+ if ( ActivationState == WA_ACTIVE ||
+ ActivationState == WA_CLICKACTIVE )
+ {
+ if (GuiData->GuiInfo.FullScreen)
+ {
+ EnterFullScreen(GuiData);
+ // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
+ // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
+ }
+ }
+ else // if (ActivationState == WA_INACTIVE)
+ {
+ if (GuiData->GuiInfo.FullScreen)
+ {
+ SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+ LeaveFullScreen(GuiData);
+ // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+ // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+ }
+ }
+
+ /*
+ * When we are in QuickEdit mode, ignore the next mouse signal
+ * when we are going to be enabled again via the mouse, in order
+ * to prevent e.g. an erroneous right-click from the user which
+ * would have as an effect to paste some unwanted text...
+ */
+ if (Console->QuickEdit && (ActivationState == WA_CLICKACTIVE))
+ GuiData->IgnoreNextMouseSignal = TRUE;
+}
+
+static VOID
+OnFocus(PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
+{
+ PCONSOLE Console = GuiData->Console;
+ INPUT_RECORD er;
+
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+
+ er.EventType = FOCUS_EVENT;
+ er.Event.FocusEvent.bSetFocus = SetFocus;
+ ConioProcessInputEvent(Console, &er);
+
+ if (SetFocus)
+ DPRINT1("TODO: Create console caret\n");
+ else
+ DPRINT1("TODO: Destroy console caret\n");
+
+ LeaveCriticalSection(&Console->Lock);
+}
+
static VOID
SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
{
}
static VOID
-GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord)
+UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD coord)
{
- PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
+ PCONSOLE Console = GuiData->Console;
RECT oldRect;
SmallRectToRect(GuiData, &oldRect, &Console->Selection.srSelection);
PRECT rcFramebuffer);
static VOID
-GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData)
+OnPaint(PGUI_CONSOLE_DATA GuiData)
{
BOOL Success = TRUE;
PCONSOLE Console = GuiData->Console;
return;
}
+static VOID
+OnPaletteChanged(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
+
+ // See WM_PALETTECHANGED message
+ // if ((HWND)wParam == hWnd) break;
+
+ // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
+ if (ActiveBuffer->PaletteHandle)
+ {
+ DPRINT("WM_PALETTECHANGED changing palette\n");
+
+ /* Specify the use of the system palette for the framebuffer */
+ SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
+
+ /* Realize the (logical) palette */
+ RealizePalette(GuiData->hMemDC);
+ }
+}
+
static BOOL
IsSystemKey(WORD VirtualKeyCode)
{
}
static VOID
-GuiConsoleHandleKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
+OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
{
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
if (VirtualKeyCode == VK_RETURN)
{
/* Copy (and clear) selection if ENTER is pressed */
- GuiConsoleCopy(GuiData);
+ Copy(GuiData);
goto Quit;
}
else if ( VirtualKeyCode == VK_ESCAPE ||
(VirtualKeyCode == 'C' && GetKeyState(VK_CONTROL) & 0x8000) )
{
/* Cancel selection if ESC or Ctrl-C are pressed */
- GuiConsoleUpdateSelection(Console, NULL);
+ UpdateSelection(GuiData, NULL);
goto Quit;
}
if (!MajPressed)
Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
- GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
+ UpdateSelection(GuiData, &Console->dwSelectionCursor);
}
else if (!IsSystemKey(VirtualKeyCode))
{
if (!IsSystemKey(VirtualKeyCode))
{
/* Clear the selection and send the key into the input buffer */
- GuiConsoleUpdateSelection(Console, NULL);
+ UpdateSelection(GuiData, NULL);
}
else
{
}
-// FIXME: Remove after fixing GuiConsoleHandleTimer
+// FIXME: Remove after fixing OnTimer
VOID
-GuiInvalidateCell(IN OUT PFRONTEND This, SHORT x, SHORT y);
+InvalidateCell(PGUI_CONSOLE_DATA GuiData,
+ SHORT x, SHORT y);
static VOID
-GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
+OnTimer(PGUI_CONSOLE_DATA GuiData)
{
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
if (GetType(Buff) == TEXTMODE_BUFFER)
{
- GuiInvalidateCell(&Console->TermIFace, Buff->CursorPosition.X, Buff->CursorPosition.Y);
+ InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
Buff->CursorBlinkOn = !Buff->CursorBlinkOn;
if ((GuiData->OldCursor.x != Buff->CursorPosition.X) ||
}
static BOOL
-GuiConsoleHandleClose(PGUI_CONSOLE_DATA GuiData)
+OnClose(PGUI_CONSOLE_DATA GuiData)
{
PCONSOLE Console = GuiData->Console;
}
static LRESULT
-GuiConsoleHandleNcDestroy(HWND hWnd)
+OnNcDestroy(HWND hWnd)
{
PGUI_CONSOLE_DATA GuiData = GuiGetGuiData(hWnd);
}
static LRESULT
-GuiConsoleHandleMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
+OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
{
BOOL Err = FALSE;
PCONSOLE Console = GuiData->Console;
case WM_LBUTTONDOWN:
{
/* Clear the old selection */
- // GuiConsoleUpdateSelection(Console, NULL);
+ // UpdateSelection(GuiData, NULL);
Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
/* Restart a new selection */
Console->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam);
SetCapture(GuiData->hWindow);
Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION | CONSOLE_MOUSE_DOWN;
- GuiConsoleUpdateSelection(Console, &Console->Selection.dwSelectionAnchor);
+ UpdateSelection(GuiData, &Console->Selection.dwSelectionAnchor);
break;
}
// c = PointToCoord(GuiData, lParam);
Console->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
- // GuiConsoleUpdateSelection(Console, &c);
+ // UpdateSelection(GuiData, &c);
ReleaseCapture();
break;
Console->dwSelectionCursor = cR;
Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION | CONSOLE_MOUSE_DOWN;
- GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
+ UpdateSelection(GuiData, &Console->dwSelectionCursor);
/* Ignore the next mouse move signal */
GuiData->IgnoreNextMouseSignal = TRUE;
{
if (!(Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
{
- GuiConsolePaste(GuiData);
+ Paste(GuiData);
}
else
{
- GuiConsoleCopy(GuiData);
+ Copy(GuiData);
}
/* Ignore the next mouse move signal */
if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
c = PointToCoord(GuiData, lParam); /* TODO: Scroll buffer to bring c into view */
- GuiConsoleUpdateSelection(Console, &c);
+ UpdateSelection(GuiData, &c);
break;
}
PGUI_CONSOLE_DATA GuiData);
static VOID
-GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData)
+Copy(PGUI_CONSOLE_DATA GuiData)
{
- PCONSOLE Console = GuiData->Console;
-
if (OpenClipboard(GuiData->hWindow) == TRUE)
{
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
}
/* Clear the selection */
- GuiConsoleUpdateSelection(Console, NULL);
+ UpdateSelection(GuiData, NULL);
}
VOID
PGUI_CONSOLE_DATA GuiData);
static VOID
-GuiConsolePaste(PGUI_CONSOLE_DATA GuiData)
+Paste(PGUI_CONSOLE_DATA GuiData)
{
if (OpenClipboard(GuiData->hWindow) == TRUE)
{
}
static VOID
-GuiConsoleGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
+OnGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
{
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
}
static VOID
-GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
+OnSize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
{
PCONSOLE Console = GuiData->Console;
Buff->ViewSize.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
}
- GuiConsoleResizeWindow(GuiData, WidthUnit, HeightUnit);
+ ResizeConWnd(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;
LeaveCriticalSection(&Console->Lock);
}
+static VOID
+OnMove(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
+ RECT rcWnd;
+
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+
+ // TODO: Simplify the code.
+ // See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE.
+
+ /* Retrieve our real position */
+ GetWindowRect(GuiData->hWindow, &rcWnd);
+ GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
+ GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
+
+ LeaveCriticalSection(&Console->Lock);
+}
+
/*
// HACK: This functionality is standard for general scrollbars. Don't add it by hand.
*/
static LRESULT
-GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
+OnScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
{
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
}
-BOOL
-EnterFullScreen(PGUI_CONSOLE_DATA GuiData);
-VOID
-LeaveFullScreen(PGUI_CONSOLE_DATA GuiData);
-VOID
-SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen);
-VOID
-GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData);
-
static LRESULT CALLBACK
ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
*/
if (msg == WM_NCCREATE)
{
- return (LRESULT)GuiConsoleHandleNcCreate(hWnd, (LPCREATESTRUCTW)lParam);
+ return (LRESULT)OnNcCreate(hWnd, (LPCREATESTRUCTW)lParam);
}
else if (msg == WM_NCDESTROY)
{
- return GuiConsoleHandleNcDestroy(hWnd);
+ return OnNcDestroy(hWnd);
}
/*
switch (msg)
{
case WM_ACTIVATE:
- {
- WORD ActivationState = LOWORD(wParam);
-
- DPRINT1("WM_ACTIVATE - ActivationState = %d\n");
-
- if ( ActivationState == WA_ACTIVE ||
- ActivationState == WA_CLICKACTIVE )
- {
- if (GuiData->GuiInfo.FullScreen)
- {
- EnterFullScreen(GuiData);
- // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
- // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
- }
- }
- else // if (ActivationState == WA_INACTIVE)
- {
- if (GuiData->GuiInfo.FullScreen)
- {
- SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
- LeaveFullScreen(GuiData);
- // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
- // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
- }
- }
-
- /*
- * When we are in QuickEdit mode, ignore the next mouse signal
- * when we are going to be enabled again via the mouse, in order
- * to prevent e.g. an erroneous right-click from the user which
- * would have as an effect to paste some unwanted text...
- */
- if (Console->QuickEdit && (ActivationState == WA_CLICKACTIVE))
- GuiData->IgnoreNextMouseSignal = TRUE;
-
+ OnActivate(GuiData, wParam);
break;
- }
case WM_CLOSE:
- if (GuiConsoleHandleClose(GuiData)) goto Default;
+ if (OnClose(GuiData)) goto Default;
break;
case WM_PAINT:
- GuiConsoleHandlePaint(GuiData);
+ OnPaint(GuiData);
break;
case WM_TIMER:
- GuiConsoleHandleTimer(GuiData);
+ OnTimer(GuiData);
break;
case WM_PALETTECHANGED:
{
- PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
-
DPRINT("WM_PALETTECHANGED called\n");
/*
if ((HWND)wParam == hWnd) break;
DPRINT("WM_PALETTECHANGED ok\n");
-
- // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
- if (ActiveBuffer->PaletteHandle)
- {
- DPRINT("WM_PALETTECHANGED changing palette\n");
-
- /* Specify the use of the system palette for the framebuffer */
- SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
-
- /* Realize the (logical) palette */
- RealizePalette(GuiData->hMemDC);
- }
-
+ OnPaletteChanged(GuiData);
DPRINT("WM_PALETTECHANGED quit\n");
-
break;
}
break;
}
- GuiConsoleHandleKey(GuiData, msg, wParam, lParam);
+ OnKey(GuiData, msg, wParam, lParam);
break;
}
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
{
- Result = GuiConsoleHandleMouse(GuiData, msg, wParam, lParam);
+ Result = OnMouse(GuiData, msg, wParam, lParam);
break;
}
case WM_HSCROLL:
case WM_VSCROLL:
{
- Result = GuiConsoleHandleScroll(GuiData, msg, wParam);
+ Result = OnScroll(GuiData, msg, wParam);
break;
}
- case WM_NCRBUTTONDOWN:
- {
- DPRINT1("WM_NCRBUTTONDOWN\n");
- /*
- * HACK: !! Because, when we deal with WM_RBUTTON* and we do not
- * call after that DefWindowProc, on ReactOS, right-clicks on the
- * (non-client) application title-bar does not display the system
- * menu and does not trigger a WM_NCRBUTTONUP message too.
- * See: http://git.reactos.org/?p=reactos.git;a=blob;f=reactos/win32ss/user/user32/windows/defwnd.c;hb=332bc8f482f40fd05ab510f78276576719fbfba8#l1103
- * and line 1135 too.
- */
-#if 0
- if (DefWindowProcW(hWnd, WM_NCHITTEST, 0, lParam) == HTCAPTION)
- {
- /* Call DefWindowProcW with the WM_CONTEXTMENU message */
- msg = WM_CONTEXTMENU;
- }
-#endif
- goto Default;
- }
- // case WM_NCRBUTTONUP:
- // DPRINT1("WM_NCRBUTTONUP\n");
- // goto Default;
-
case WM_CONTEXTMENU:
{
if (DefWindowProcW(hWnd /*GuiData->hWindow*/, WM_NCHITTEST, 0, lParam) == HTCLIENT)
HMENU hMenu = CreatePopupMenu();
if (hMenu != NULL)
{
- GuiConsoleAppendMenuItems(hMenu, GuiConsoleEditMenuItems);
+ AppendMenuItems(hMenu, GuiConsoleEditMenuItems);
TrackPopupMenuEx(hMenu,
TPM_RIGHTBUTTON,
GET_X_LPARAM(lParam),
if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{
- GuiSendMenuEvent(Console, WM_INITMENU);
+ SendMenuEvent(Console, WM_INITMENU);
LeaveCriticalSection(&Console->Lock);
}
break;
{
if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{
- GuiSendMenuEvent(Console, WM_MENUSELECT);
+ SendMenuEvent(Console, WM_MENUSELECT);
LeaveCriticalSection(&Console->Lock);
}
}
case WM_COMMAND:
case WM_SYSCOMMAND:
{
- Result = GuiConsoleHandleSysMenuCommand(GuiData, wParam, lParam);
+ Result = OnCommand(GuiData, wParam, lParam);
break;
}
case WM_SETFOCUS:
case WM_KILLFOCUS:
- {
- if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
- {
- BOOL SetFocus = (msg == WM_SETFOCUS);
- INPUT_RECORD er;
-
- er.EventType = FOCUS_EVENT;
- er.Event.FocusEvent.bSetFocus = SetFocus;
- ConioProcessInputEvent(Console, &er);
-
- if (SetFocus)
- DPRINT1("TODO: Create console caret\n");
- else
- DPRINT1("TODO: Destroy console caret\n");
-
- LeaveCriticalSection(&Console->Lock);
- }
+ OnFocus(GuiData, (msg == WM_SETFOCUS));
break;
- }
case WM_GETMINMAXINFO:
- GuiConsoleGetMinMaxInfo(GuiData, (PMINMAXINFO)lParam);
+ OnGetMinMaxInfo(GuiData, (PMINMAXINFO)lParam);
break;
case WM_MOVE:
+ OnMove(GuiData);
+ break;
+
+#if 0 // This code is here to prepare & control dynamic console SB resizing.
+ case WM_SIZING:
{
- if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
+ PRECT dragRect = (PRECT)lParam;
+ switch (wParam)
{
- // TODO: Simplify the code.
- // See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE.
-
- RECT rcWnd;
-
- /* Retrieve our real position */
- GetWindowRect(GuiData->hWindow, &rcWnd);
- GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
- GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
-
- LeaveCriticalSection(&Console->Lock);
+ case WMSZ_LEFT:
+ DPRINT1("WMSZ_LEFT\n");
+ break;
+ case WMSZ_RIGHT:
+ DPRINT1("WMSZ_RIGHT\n");
+ break;
+ case WMSZ_TOP:
+ DPRINT1("WMSZ_TOP\n");
+ break;
+ case WMSZ_TOPLEFT:
+ DPRINT1("WMSZ_TOPLEFT\n");
+ break;
+ case WMSZ_TOPRIGHT:
+ DPRINT1("WMSZ_TOPRIGHT\n");
+ break;
+ case WMSZ_BOTTOM:
+ DPRINT1("WMSZ_BOTTOM\n");
+ break;
+ case WMSZ_BOTTOMLEFT:
+ DPRINT1("WMSZ_BOTTOMLEFT\n");
+ break;
+ case WMSZ_BOTTOMRIGHT:
+ DPRINT1("WMSZ_BOTTOMRIGHT\n");
+ break;
+ default:
+ DPRINT1("wParam = %d\n", wParam);
+ break;
}
+ DPRINT1("dragRect = {.left = %d ; .top = %d ; .right = %d ; .bottom = %d}\n",
+ dragRect->left, dragRect->top, dragRect->right, dragRect->bottom);
break;
}
+#endif
case WM_SIZE:
- GuiConsoleResize(GuiData, wParam, lParam);
+ OnSize(GuiData, wParam, lParam);
break;
case PM_RESIZE_TERMINAL:
/* Resize the window to the user's values */
GuiData->WindowSizeLock = TRUE;
- GuiConsoleResizeWindow(GuiData, WidthUnit, HeightUnit);
+ ResizeConWnd(GuiData, WidthUnit, HeightUnit);
GuiData->WindowSizeLock = FALSE;
break;
}
Rect->bottom = (SmallRect->Bottom + 1 - Buffer->ViewOrigin.Y) * HeightUnit;
}
-static VOID NTAPI
-GuiDrawRegion(IN OUT PFRONTEND This,
- SMALL_RECT* Region);
+static VOID
+DrawRegion(PGUI_CONSOLE_DATA GuiData,
+ SMALL_RECT* Region)
+{
+ RECT RegionRect;
+
+ SmallRectToRect(GuiData, &RegionRect, Region);
+ /* Do not erase the background: it speeds up redrawing and reduce flickering */
+ InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
+ /**UpdateWindow(GuiData->hWindow);**/
+}
+
VOID
-GuiInvalidateCell(IN OUT PFRONTEND This, SHORT x, SHORT y)
+InvalidateCell(PGUI_CONSOLE_DATA GuiData,
+ SHORT x, SHORT y)
{
SMALL_RECT CellRect = { x, y, x, y };
- GuiDrawRegion(This, &CellRect);
+ DrawRegion(GuiData, &CellRect);
}
PCONSOLE Console = GuiData->Console;
RECT rcWnd;
+ DPRINT("PM_CREATE_CONSOLE -- creating window\n");
+
NewWindow = CreateWindowExW(WS_EX_CLIENTEDGE,
GUI_CONWND_CLASS,
Console->Title.Buffer,
WindowCount++;
SetWindowLongW(hWnd, GWL_USERDATA, WindowCount);
- DPRINT("Set icons via PM_CREATE_CONSOLE\n");
- if (GuiData->hIcon == NULL)
- {
- DPRINT("Not really /o\\...\n");
- GuiData->hIcon = ghDefaultIcon;
- GuiData->hIconSm = ghDefaultIconSm;
- }
- else if (GuiData->hIcon != ghDefaultIcon)
- {
- DPRINT("Yes \\o/\n");
- SendMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG, (LPARAM)GuiData->hIcon);
- SendMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
- }
+ //
+ // FIXME: TODO: Move everything there into conwnd.c!OnNcCreate()
+ //
/* Retrieve our real position */
+ // See conwnd.c!OnMove()
GetWindowRect(GuiData->hWindow, &rcWnd);
GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
/* Move and resize the window to the user's values */
/* CAN WE DEADLOCK ?? */
- GuiConsoleMoveWindow(GuiData);
+ GuiConsoleMoveWindow(GuiData); // FIXME: This MUST be done via the CreateWindowExW call.
SendMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
/* Switch to full-screen mode if necessary */
+ // FIXME: Move elsewhere, it cause misdrawings of the window.
if (GuiData->GuiInfo.FullScreen) SwitchFullScreen(GuiData, TRUE);
+ DPRINT("PM_CREATE_CONSOLE -- showing window\n");
// ShowWindow(NewWindow, (int)wParam);
ShowWindowAsync(NewWindow, (int)wParam);
DPRINT("Window showed\n");
DPRINT1("CONSRV: Failed to create GUI_CONSOLE_DATA\n");
return STATUS_UNSUCCESSFUL;
}
- /* HACK */ Console->TermIFace.Data = (PVOID)GuiData; /* HACK */
+ ///// /* HACK */ Console->TermIFace.Data = (PVOID)GuiData; /* HACK */
GuiData->Console = Console;
GuiData->ActiveBuffer = Console->ActiveBuffer;
GuiData->hWindow = NULL;
&hIconSm,
1);
DPRINT("hIcon = 0x%p ; hIconSm = 0x%p\n", hIcon, hIconSm);
- if (hIcon != NULL)
- {
- DPRINT("Effectively set the icons\n");
- GuiData->hIcon = hIcon;
- GuiData->hIconSm = hIconSm;
- }
+ if (hIcon != NULL) GuiData->hIcon = hIcon;
+ if (hIconSm != NULL) GuiData->hIconSm = hIconSm;
}
+ ASSERT(GuiData->hIcon && GuiData->hIconSm);
/* Mouse is shown by default with its default cursor shape */
GuiData->hCursor = ghDefaultCursor;
SMALL_RECT* Region)
{
PGUI_CONSOLE_DATA GuiData = This->Data;
- RECT RegionRect;
-
- SmallRectToRect(GuiData, &RegionRect, Region);
- /* Do not erase the background: it speeds up redrawing and reduce flickering */
- InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
- /**UpdateWindow(GuiData->hWindow);**/
+ DrawRegion(GuiData, Region);
}
static VOID NTAPI
SW_INVALIDATE);
}
- GuiDrawRegion(This, Region);
+ DrawRegion(GuiData, Region);
if (CursorStartX < Region->Left || Region->Right < CursorStartX
|| CursorStartY < Region->Top || Region->Bottom < CursorStartY)
{
- GuiInvalidateCell(This, CursorStartX, CursorStartY);
+ InvalidateCell(GuiData, CursorStartX, CursorStartY);
}
CursorEndX = Buff->CursorPosition.X;
|| CursorEndY < Region->Top || Region->Bottom < CursorEndY)
&& (CursorEndX != CursorStartX || CursorEndY != CursorStartY))
{
- GuiInvalidateCell(This, CursorEndX, CursorEndY);
+ InvalidateCell(GuiData, CursorEndX, CursorEndY);
}
// HACK!!
if (GuiData->ActiveBuffer == Buff)
{
- GuiInvalidateCell(This, Buff->CursorPosition.X, Buff->CursorPosition.Y);
+ InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
}
return TRUE;
if (GuiData->ActiveBuffer == Buff)
{
/* Redraw char at old position (remove cursor) */
- GuiInvalidateCell(This, OldCursorX, OldCursorY);
+ InvalidateCell(GuiData, OldCursorX, OldCursorY);
/* Redraw char at new position (show cursor) */
- GuiInvalidateCell(This, Buff->CursorPosition.X, Buff->CursorPosition.Y);
+ InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
}
return TRUE;
GuiData->hIconSm = hIconSm;
DPRINT("Set icons in GuiChangeIcon\n");
- PostMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG, (LPARAM)GuiData->hIcon);
+ PostMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG , (LPARAM)GuiData->hIcon );
PostMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
}