- Allow the dialog to be resized, which in turn will grow / shrink the grid view and the fonts inside it. This means users can make the grid larger if they don't have their glasses on or want to see all the fonts in more detail. We no longer need a large font window popping out from the grid when you click on a cell (which I was never a fan of).
- Don't allow scrolling previous to row 0 or after the last row
svn path=/trunk/; revision=70101
CGridView::CGridView() :
m_xNumCells(20),
m_yNumCells(10),
CGridView::CGridView() :
m_xNumCells(20),
m_yNumCells(10),
+ m_ScrollPosition(0),
+ m_NumRows(0)
{
m_szMapWndClass = L"CharGridWClass";
}
{
m_szMapWndClass = L"CharGridWClass";
}
if (hdc == NULL) return false;
// Setup the logfont structure
if (hdc == NULL) return false;
// Setup the logfont structure
- NewFont.Font.lfHeight = GetDeviceCaps(hdc, LOGPIXELSY) / 5;
+ NewFont.Font.lfHeight = 0; // This is set in WM_SIZE
NewFont.Font.lfCharSet = DEFAULT_CHARSET;
StringCchCopyW(NewFont.Font.lfFaceName, LF_FACESIZE, FontName);
NewFont.Font.lfCharSet = DEFAULT_CHARSET;
StringCchCopyW(NewFont.Font.lfFaceName, LF_FACESIZE, FontName);
NewFont.NumValidGlyphs = j;
// Calculate the number of rows required to hold all glyphs
NewFont.NumValidGlyphs = j;
// Calculate the number of rows required to hold all glyphs
- int Rows = NewFont.NumValidGlyphs / m_xNumCells;
+ m_NumRows = NewFont.NumValidGlyphs / m_xNumCells;
if (NewFont.NumValidGlyphs % m_xNumCells)
if (NewFont.NumValidGlyphs % m_xNumCells)
// Set the scrollbar in relation to the rows
// Set the scrollbar in relation to the rows
- SetScrollRange(m_hwnd, SB_VERT, 0, Rows, FALSE);
+ SetScrollRange(m_hwnd, SB_VERT, 0, m_NumRows - m_yNumCells, FALSE);
// We're done, update the current font
m_CurrentFont = NewFont;
// We're done, update the current font
m_CurrentFont = NewFont;
// Get the client area we can draw on. The position we set above includes
// a scrollbar which we obvioulsy can't draw on. GetClientRect gives us
// Get the client area we can draw on. The position we set above includes
// a scrollbar which we obvioulsy can't draw on. GetClientRect gives us
- // the size without the scroll, and it more efficient than getting the
+ // the size without the scroll, and it's more efficient than getting the
// scroll metrics and calculating the size from that
RECT ClientRect;
GetClientRect(m_hwnd, &ClientRect);
// scroll metrics and calculating the size from that
RECT ClientRect;
GetClientRect(m_hwnd, &ClientRect);
// Let all the cells know about their new coords
UpdateCellCoordinates();
// Let all the cells know about their new coords
UpdateCellCoordinates();
+ // We scale the font size up or down depending on the cell size
+ if (m_CurrentFont.hFont)
+ {
+ // Delete the existing font
+ DeleteObject(m_CurrentFont.hFont);
+
+ HDC hdc;
+ hdc = GetDC(m_hwnd);
+ if (hdc)
+ {
+ // Update the font size with respect to the cell size
+ m_CurrentFont.Font.lfHeight = (m_CellSize.cy - 5);
+ m_CurrentFont.hFont = CreateFontIndirectW(&m_CurrentFont.Font);
+ ReleaseDC(m_hwnd, hdc);
+ }
+ }
+
+ // Redraw the whole grid
+ InvalidateRect(m_hwnd, &ClientRect, TRUE);
+
- INT PrevScrollPosition = ScrollPosition;
+ INT PrevScrollPosition = m_ScrollPosition;
switch (Value)
{
case SB_LINEUP:
switch (Value)
{
case SB_LINEUP:
- ScrollPosition -= m_yNumCells;
+ m_ScrollPosition -= m_yNumCells;
- ScrollPosition += m_yNumCells;
+ m_ScrollPosition += m_yNumCells;
break;
case SB_THUMBTRACK:
break;
case SB_THUMBTRACK:
+ m_ScrollPosition = Pos;
+ // Make sure we don't scroll past row 0 or max rows
+ m_ScrollPosition = max(0, m_ScrollPosition);
+ m_ScrollPosition = min(m_ScrollPosition, m_NumRows);
+
+ // Check if there's a difference from the previous position
- ScrollDiff = PrevScrollPosition - ScrollPosition;
+ ScrollDiff = PrevScrollPosition - m_ScrollPosition;
if (ScrollDiff)
{
// Set the new scrollbar position in the scroll box
SetScrollPos(m_hwnd,
SB_VERT,
if (ScrollDiff)
{
// Set the new scrollbar position in the scroll box
SetScrollPos(m_hwnd,
SB_VERT,
TRUE);
// Check if the scrollbar has moved more than the
TRUE);
// Check if the scrollbar has moved more than the
GetClientRect(m_hwnd, &rect);
// Scroll the visible cells which remain within the grid
GetClientRect(m_hwnd, &rect);
// Scroll the visible cells which remain within the grid
- // and invalid any new ones which appear from the top / bottom
+ // and invalidate any new ones which appear from the top / bottom
ScrollWindowEx(m_hwnd,
0,
ScrollDiff * m_CellSize.cy,
ScrollWindowEx(m_hwnd,
0,
ScrollDiff * m_CellSize.cy,
{
// Calculate which glyph to start at based on scroll position
int i;
{
// Calculate which glyph to start at based on scroll position
int i;
- i = m_xNumCells * ScrollPosition;
+ i = m_xNumCells * m_ScrollPosition;
// Make sure we have the correct font on the DC
HFONT hOldFont;
hOldFont = (HFONT)SelectFont(PaintStruct->hdc,
m_CurrentFont.hFont);
// Make sure we have the correct font on the DC
HFONT hOldFont;
hOldFont = (HFONT)SelectFont(PaintStruct->hdc,
m_CurrentFont.hFont);
- // Traverse all the cells and tell them to paint themselves
+ // Traverse all the cells
for (int y = 0; y < m_yNumCells; y++)
for (int x = 0; x < m_xNumCells; x++)
{
for (int y = 0; y < m_yNumCells; y++)
for (int x = 0; x < m_xNumCells; x++)
{
+ // Update the glyph for this cell
WCHAR ch = (WCHAR)m_CurrentFont.ValidGlyphs[i];
m_Cells[y][x]->SetChar(ch);
WCHAR ch = (WCHAR)m_CurrentFont.ValidGlyphs[i];
m_Cells[y][x]->SetChar(ch);
+ // Tell it to paint itself
m_Cells[y][x]->OnPaint(*PaintStruct);
m_Cells[y][x]->OnPaint(*PaintStruct);
{
// Remove focus from any existing cell
m_ActiveCell->SetFocus(false);
{
// Remove focus from any existing cell
m_ActiveCell->SetFocus(false);
+ InvalidateRect(m_hwnd, m_ActiveCell->GetCellCoordinates(), TRUE);
}
// Set the new active cell and give it focus
}
// Set the new active cell and give it focus
CCell*** m_Cells; // *m_Cells[][];
CCell *m_ActiveCell;
CCell*** m_Cells; // *m_Cells[][];
CCell *m_ActiveCell;
- HFONT hFont;
- INT ScrollPosition;
+ INT m_ScrollPosition;
+ int m_NumRows;
CurrentFont m_CurrentFont;
CurrentFont m_CurrentFont;
_In_ CAtlString& FontName
);
_In_ CAtlString& FontName
);
+ HWND GetHwnd() { return m_hwnd; }
+
private:
static LRESULT
CALLBACK
private:
static LRESULT
CALLBACK
-CCharMapWindow::OnSize(void)
+CCharMapWindow::OnSize(
+ _In_ WPARAM wParam
+ )
{
RECT rcClient, rcStatus;
INT lvHeight, iStatusHeight;
{
RECT rcClient, rcStatus;
INT lvHeight, iStatusHeight;
// Get the full client rect
GetClientRect(m_hMainWnd, &rcClient);
// Get the full client rect
GetClientRect(m_hMainWnd, &rcClient);
- // Calculate the remaining height for the treeview
+ // Calculate the remaining height for the gridview
lvHeight = rcClient.bottom - iStatusHeight;
lvHeight = rcClient.bottom - iStatusHeight;
- // Resize the device view
- //m_GridView->OnSize(0,
- // iToolHeight,
- // rcClient.right,
- // lvHeight);
+ // Resize the grid view
+ SendMessageW(m_GridView->GetHwnd(), WM_SIZE, wParam, 0);
+ return This->OnSize(wParam);
Length = GetWindowTextLengthW(hCombo);
if (!Length) return false;
Length = GetWindowTextLengthW(hCombo);
if (!Length) return false;
- CAtlStringW FontName;// = L"hahaha";
FontName.Preallocate(Length);
SendMessageW(hCombo,
FontName.Preallocate(Length);
SendMessageW(hCombo,
IDD_CHARMAP DIALOGEX 6, 6, 290, 224
FONT 8, "MS Shell Dlg", 0, 0
IDD_CHARMAP DIALOGEX 6, 6, 290, 224
FONT 8, "MS Shell Dlg", 0, 0
-STYLE WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
+STYLE WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX
CAPTION "ReactOS Character Map"
BEGIN
LTEXT "Font:", IDC_STATIC, 6, 7, 24, 9
CAPTION "ReactOS Character Map"
BEGIN
LTEXT "Font:", IDC_STATIC, 6, 7, 24, 9
- COMBOBOX IDC_FONTCOMBO, 36, 5, 210, 210, WS_CHILD | WS_VISIBLE |
+ COMBOBOX IDC_FONTCOMBO, 28, 5, 150, 210, WS_CHILD | WS_VISIBLE |
WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT | CBS_HASSTRINGS
LTEXT "Characters to copy:", IDC_STATIC, 6, 188, 66, 9
CONTROL "", IDC_TEXTBOX, RICHEDIT_CLASS, ES_AUTOHSCROLL | WS_BORDER |
WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT | CBS_HASSTRINGS
LTEXT "Characters to copy:", IDC_STATIC, 6, 188, 66, 9
CONTROL "", IDC_TEXTBOX, RICHEDIT_CLASS, ES_AUTOHSCROLL | WS_BORDER |