Author: janderwald
Date: Mon Sep 3 07:29:18 2007
New Revision: 28796
URL:
http://svn.reactos.org/svn/reactos?rev=28796&view=rev
Log:
- halfplement console scrolling support
Modified:
trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c Mon Sep 3 07:29:18 2007
@@ -634,7 +634,35 @@
}
}
-
+VOID
+FASTCALL
+GuiConsoleInitScrollbar(PCSRSS_CONSOLE Console, HWND hwnd)
+{
+ SCROLLINFO sInfo;
+
+ /* set scrollbar sizes */
+ sInfo.cbSize = sizeof(SCROLLINFO);
+ sInfo.fMask = SIF_RANGE | SIF_POS;
+ sInfo.nMin = 0;
+ sInfo.nMax = Console->ActiveBuffer->MaxY;
+ sInfo.nPos = 0;
+ SetScrollInfo(hwnd, SB_HORZ, &sInfo, TRUE);
+ ShowScrollBar(hwnd, SB_VERT, TRUE);
+
+ if (Console->ActiveBuffer->MaxX > Console->Size.X)
+ {
+ sInfo.cbSize = sizeof(SCROLLINFO);
+ sInfo.fMask = SIF_RANGE | SIF_POS;
+ sInfo.nMin = 0;
+ sInfo.nPos = 0;
+ sInfo.nMax = Console->ActiveBuffer->MaxX;
+ SetScrollInfo(hwnd, SB_HORZ, &sInfo, TRUE);
+ }
+ else
+ {
+ ShowScrollBar(hwnd, SB_HORZ, FALSE);
+ }
+}
static BOOL FASTCALL
GuiConsoleHandleNcCreate(HWND hWnd, CREATESTRUCTW *Create)
@@ -743,6 +771,7 @@
SetTimer(hWnd, 1, CURSOR_BLINK_TIME, NULL);
GuiConsoleCreateSysMenu(Console);
+ GuiConsoleInitScrollbar(Console, hWnd);
SetEvent(GuiData->hGuiInitEvent);
return (BOOL) DefWindowProcW(hWnd, WM_NCCREATE, 0, (LPARAM) Create);
@@ -1532,14 +1561,11 @@
DPRINT1("GuiConsoleResize X %d Y %d\n", LOWORD(lParam), HIWORD(lParam));
}
}
-
-VOID FASTCALL
-GuiConsoleCreateScrollBar(PCSRSS_CONSOLE Console, PGUI_CONSOLE_DATA GuiData, HWND
NewWindow)
+VOID
+FASTCALL
+GuiConsoleHandleScrollbarMenu()
{
HMENU hMenu;
- HWND hVScrollBar;
- HWND hHScrollBar;
- SCROLLINFO sInfo;
hMenu = CreatePopupMenu();
if (hMenu == NULL)
@@ -1547,7 +1573,6 @@
DPRINT("CreatePopupMenu failed\n");
return;
}
-
//InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SCROLLHERE);
//InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
//InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SCROLLTOP);
@@ -1559,54 +1584,6 @@
//InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SCROLLUP);
//InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SCROLLDOWN);
- hVScrollBar = CreateWindowExW(0L,
- L"ScrollBar",
- (LPWSTR)NULL,
- WS_CHILD | WS_VSCROLL,
- 0,
- 0,
- 200,
- 50,
- NewWindow,
- NULL, //hMenu,
- GetModuleHandleW(NULL),
- (LPVOID)GuiData);
-
- if (hVScrollBar)
- {
-
- /* set scrollbar sizes */
- sInfo.cbSize = sizeof(SCROLLINFO);
- sInfo.fMask = SIF_RANGE | SIF_POS;
- sInfo.nMin = 0;
- sInfo.nMax = Console->ActiveBuffer->MaxY;
- sInfo.nPos = 0;
- SetScrollInfo(hVScrollBar, SB_CTL, &sInfo, TRUE);
- ShowScrollBar(NewWindow, SB_CTL, TRUE);
- GuiData->hVScrollBar = hVScrollBar;
- }
-
- if (Console->ActiveBuffer->MaxX > Console->Size.X)
- {
- hHScrollBar = CreateWindowExW(0L,
- L"ScrollBar",
- (LPWSTR)NULL,
- WS_CHILD | WS_HSCROLL,
- 0,
- 0,
- 200,
- CW_USEDEFAULT,
- NewWindow,
- hMenu,
- GetModuleHandleW(NULL),
- (LPVOID)GuiData);
- if (hHScrollBar)
- {
- sInfo.nMax = Console->ActiveBuffer->MaxX;
- SetScrollInfo(hHScrollBar, SB_CTL, &sInfo, TRUE);
- GuiData->hHScrollBar = hHScrollBar;
- }
- }
}
static VOID FASTCALL
@@ -1751,12 +1728,12 @@
if (Console->Size.X < Console->ActiveBuffer->MaxX)
{
/* show scrollbar when window becomes smaller than active screen buffer */
- //ShowScrollBar(GuiData->hHScrollBar, SB_CTL, TRUE);
+ ShowScrollBar(pConInfo->hConsoleWindow, SB_CTL, TRUE);
}
else
{
/* hide scrollbar */
- //ShowScrollBar(GuiData->hHScrollBar, SB_CTL, FALSE);
+ ShowScrollBar(pConInfo->hConsoleWindow, SB_CTL, FALSE);
}
}
if (ProcessData)
@@ -1764,6 +1741,94 @@
ConioUnlockScreenBuffer(ActiveBuffer);
}
InvalidateRect(pConInfo->hConsoleWindow, NULL, TRUE);
+}
+
+static
+LRESULT
+GuiConsoleHandleScroll(HWND hwnd, UINT uMsg, WPARAM wParam)
+{
+ SCROLLINFO sInfo;
+ int old_pos;
+
+ /* set scrollbar sizes */
+ sInfo.cbSize = sizeof(SCROLLINFO);
+ sInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE | SIF_TRACKPOS;
+
+ if (!GetScrollInfo(hwnd,
+ (uMsg == WM_HSCROLL ? SB_HORZ : SB_VERT),
+ &sInfo))
+ {
+ return FALSE;
+ }
+
+ old_pos = sInfo.nPos;
+
+ switch(LOWORD(wParam))
+ {
+ case SB_LINELEFT:
+ sInfo.nPos -= 1;
+ break;
+
+ case SB_LINERIGHT:
+ sInfo.nPos += 1;
+ break;
+
+ case SB_PAGELEFT:
+ sInfo.nPos -= sInfo.nPage;
+ break;
+
+ case SB_PAGERIGHT:
+ sInfo.nPos += sInfo.nPage;
+ break;
+
+ case SB_THUMBTRACK:
+ sInfo.nPage = sInfo.nTrackPos;
+ break;
+
+ case SB_TOP:
+ sInfo.nPos = sInfo.nMin;
+ break;
+
+ case SB_BOTTOM:
+ sInfo.nPos = sInfo.nMax;
+ break;
+
+ break;
+
+
+
+ default:
+ break;
+ }
+
+ sInfo.fMask = SIF_POS;
+ sInfo.cbSize = sizeof(SCROLLINFO);
+
+ SetScrollInfo(hwnd,
+ (uMsg == WM_HSCROLL ? SB_HORZ : SB_VERT),
+ &sInfo,
+ TRUE);
+
+ sInfo.cbSize = sizeof(SCROLLINFO);
+ sInfo.fMask = SIF_POS;
+
+ if (!GetScrollInfo(hwnd,
+ (uMsg == WM_HSCROLL ? SB_HORZ : SB_VERT),
+ &sInfo))
+ {
+ return 0;
+ }
+
+ if (old_pos != sInfo.nPos)
+ {
+ ///
+ /// fixme scroll window
+ ///
+
+ // ScrollWindow
+ //UpdateWindow(hwnd);
+ }
+ return 0;
}
static LRESULT CALLBACK
@@ -1814,6 +1879,10 @@
case WM_SYSCOMMAND:
Result = GuiConsoleHandleSysMenuCommand(hWnd, wParam, lParam, GuiData);
break;
+ case WM_HSCROLL:
+ case WM_VSCROLL:
+ Result = GuiConsoleHandleScroll(hWnd, msg, wParam);
+ break;
case WM_SIZE:
GuiConsoleResize(hWnd, wParam, lParam);
break;
@@ -1863,7 +1932,7 @@
}
NewWindow = CreateWindowW(L"ConsoleWindowClass",
Title,
- WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX, //WS_OVERLAPPEDWINDOW
+ WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX | WS_HSCROLL | WS_VSCROLL, //WS_OVERLAPPEDWINDOW
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
@@ -1878,8 +1947,6 @@
}
if (NULL != NewWindow)
{
- // scrollbar support
- //GuiConsoleCreateScrollBar(Console,
(PGUI_CONSOLE_DATA)Console->PrivateData, NewWindow);
SetWindowLongW(hWnd, GWL_USERDATA, GetWindowLongW(hWnd, GWL_USERDATA) + 1);
ShowWindow(NewWindow, SW_SHOW);
}