Reformat BabyGrid.cpp for a good readibility and nothing more

Close #14886
This commit is contained in:
Don Ho 2024-03-20 16:24:32 +01:00
parent 73bc79ee50
commit 0bc28df616
1 changed files with 2640 additions and 2814 deletions

View File

@ -243,9 +243,13 @@ int GetColOfMouse(int SI,int x)
BOOL OutOfRange(_BGCELL* cell) BOOL OutOfRange(_BGCELL* cell)
{ {
if ((cell->row > MAX_ROWS) || (cell->col > MAX_COLS)) if ((cell->row > MAX_ROWS) || (cell->col > MAX_COLS))
{return TRUE;} {
return TRUE;
}
else else
{return FALSE;} {
return FALSE;
}
} }
void SetCell(_BGCELL* cell, int row, int col) void SetCell(_BGCELL* cell, int row, int col)
@ -431,7 +435,8 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe
int high, low; int high, low;
high = ((c - 1) / 26); high = ((c - 1) / 26);
low = c % 26; low = c % 26;
if(high == 0){high = 32;}else{high+=64;} if (high == 0) { high = 32; }
else { high += 64; }
if (low == 0) { low = 26; } if (low == 0) { low = 26; }
low += 64; low += 64;
wsprintf(buffer, TEXT("%c%c"), high, low); wsprintf(buffer, TEXT("%c%c"), high, low);
@ -962,127 +967,6 @@ void NotifyEditEnd(HWND hWnd,int SI)
} }
/*
void NotifyF1(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F1);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF2(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F2);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF3(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F3);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF4(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F4);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF5(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F5);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF6(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F6);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF7(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F7);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF8(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F8);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF9(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F9);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF10(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F10);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF11(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F11);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
void NotifyF12(HWND hWnd,int SI)
{
WPARAM wParam;
LPARAM lParam;
lParam = MAKELPARAM(BGHS[SI].cursorrow,BGHS[SI].cursorcol);
wParam=MAKEWPARAM((UINT)BGHS[SI].gridmenu,BGN_F12);
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
}
*/
void NotifyCellClicked(HWND hWnd, int SI) void NotifyCellClicked(HWND hWnd, int SI)
{ {
WPARAM wParam; WPARAM wParam;
@ -1892,7 +1776,8 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
BGHS[SelfIndex].cols = MAX_COLS; BGHS[SelfIndex].cols = MAX_COLS;
} }
} }
{RECT rect; {
RECT rect;
GetClientRect(hWnd, &rect); GetClientRect(hWnd, &rect);
InvalidateRect(hWnd, &rect, TRUE); InvalidateRect(hWnd, &rect, TRUE);
} }
@ -2406,69 +2291,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
break; break;
} }
/*
if(wParam == VK_F1)
{
NotifyF1(hWnd,SelfIndex);
break;
}
if(wParam == VK_F2)
{
NotifyF2(hWnd,SelfIndex);
break;
}
if(wParam == VK_F3)
{
NotifyF3(hWnd,SelfIndex);
break;
}
if(wParam == VK_F4)
{
NotifyF4(hWnd,SelfIndex);
break;
}
if(wParam == VK_F5)
{
NotifyF5(hWnd,SelfIndex);
break;
}
if(wParam == VK_F6)
{
NotifyF6(hWnd,SelfIndex);
break;
}
if(wParam == VK_F7)
{
NotifyF7(hWnd,SelfIndex);
break;
}
if(wParam == VK_F8)
{
NotifyF8(hWnd,SelfIndex);
break;
}
if(wParam == VK_F9)
{
NotifyF9(hWnd,SelfIndex);
break;
}
if(wParam == VK_F10)
{
NotifyF10(hWnd,SelfIndex);
break;
}
if(wParam == VK_F11)
{
NotifyF11(hWnd,SelfIndex);
break;
}
if(wParam == VK_F12)
{
NotifyF12(hWnd,SelfIndex);
break;
}
*/
if (wParam == VK_DELETE) if (wParam == VK_DELETE)
{ {
NotifyDelete(hWnd, SelfIndex); NotifyDelete(hWnd, SelfIndex);
@ -2937,7 +2760,8 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
case WM_DESTROY: case WM_DESTROY:
{ int k; {
int k;
if (CountGrids() == 0) if (CountGrids() == 0)
{ {
DeleteObject(hfontbody); DeleteObject(hfontbody);
@ -2984,7 +2808,8 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
wParam = MAKEWPARAM(GetMenu(hWnd), BGN_GOTFOCUS); wParam = MAKEWPARAM(GetMenu(hWnd), BGN_GOTFOCUS);
lParam = 0; lParam = 0;
SendMessage(GetParent(hWnd), WM_COMMAND, wParam, lParam); SendMessage(GetParent(hWnd), WM_COMMAND, wParam, lParam);
{TEXTMETRIC tm; {
TEXTMETRIC tm;
HDC hdc; HDC hdc;
hdc = GetDC(hWnd); hdc = GetDC(hWnd);
GetTextMetrics(hdc, &tm); GetTextMetrics(hdc, &tm);
@ -3120,6 +2945,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
DestroyWindow(hWnd); DestroyWindow(hWnd);
} }
break; break;
default: default:
return DefWindowProc(hWnd, message, wParam, lParam); return DefWindowProc(hWnd, message, wParam, lParam);
} }