mirror of
https://github.com/quantum5/Zalgo.git
synced 2025-04-24 21:52:03 -04:00
Added X-SAMPA table.
Also: 1. Cleaned up text handling by storing them in resource. 2. Added useful methods to make code look better. 3. Allowed PreviewWindow to be used for general text displaying. Signed-off-by: Xiaomao Chen <xiaomao5@live.com>
This commit is contained in:
parent
738ed0f7ea
commit
7da74dbbf1
4
Makefile
4
Makefile
|
@ -52,8 +52,8 @@ $(SRCDIR)\Window.cpp: $(INCDIR)\Window.hpp
|
||||||
$(SRCDIR)\NLSWrap.cpp: $(INCDIR)\NLSWrap.hpp
|
$(SRCDIR)\NLSWrap.cpp: $(INCDIR)\NLSWrap.hpp
|
||||||
$(SRCDIR)\MainLogic.cpp: $(INCDIR)\MainWindow.hpp $(INCDIR)\NLSWrap.hpp $(INCDIR)\ConversionData.inc
|
$(SRCDIR)\MainLogic.cpp: $(INCDIR)\MainWindow.hpp $(INCDIR)\NLSWrap.hpp $(INCDIR)\ConversionData.inc
|
||||||
|
|
||||||
$(OUTDIR)\Zalgo.res: Zalgo.rc
|
$(OUTDIR)\Zalgo.res: Zalgo.rc res\x-sampa.txt res\init.txt
|
||||||
$(RC) $(RCFLAGS) /fo$@ $**
|
$(RC) $(RCFLAGS) /fo$@ Zalgo.rc
|
||||||
|
|
||||||
{$(SRCDIR)}.cpp{$(OUTDIR)}.obj::
|
{$(SRCDIR)}.cpp{$(OUTDIR)}.obj::
|
||||||
$(CXX) $(CXXFLAGS) /Fo$(OUTDIR)\ /Fd$(OUTDIR)\ $<
|
$(CXX) $(CXXFLAGS) /Fo$(OUTDIR)\ /Fd$(OUTDIR)\ $<
|
||||||
|
|
3
Zalgo.rc
3
Zalgo.rc
|
@ -1,3 +1,6 @@
|
||||||
#include <resource.h>
|
#include <resource.h>
|
||||||
|
|
||||||
RID_ICON ICON Zalgo.ico
|
RID_ICON ICON Zalgo.ico
|
||||||
|
RID_XSAMPA ZALGO_TEXT "res\\x-sampa.txt"
|
||||||
|
RID_INIT ZALGO_TEXT "res\\init.txt"
|
||||||
|
RID_LOOSE ZALGO_TEXT "res\\loose.txt"
|
||||||
|
|
|
@ -27,10 +27,11 @@
|
||||||
#define ZALGO_CYRILLIC 0xA555
|
#define ZALGO_CYRILLIC 0xA555
|
||||||
#define ZALGO_GREEK 0xA556
|
#define ZALGO_GREEK 0xA556
|
||||||
#define ZALGO_XSAMPA 0xA557
|
#define ZALGO_XSAMPA 0xA557
|
||||||
|
#define ZALGO_XSAMPA_TABLE 0xA558
|
||||||
|
|
||||||
class MainWindow : public Window {
|
class MainWindow : public Window {
|
||||||
public:
|
public:
|
||||||
virtual LPCTSTR ClassName() { return TEXT("Zalgo_Main"); }
|
virtual LPCTSTR ClassName() { return L"Zalgo_Main"; }
|
||||||
static MainWindow *Create(LPCTSTR szTitle);
|
static MainWindow *Create(LPCTSTR szTitle);
|
||||||
protected:
|
protected:
|
||||||
LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
@ -55,11 +56,11 @@ protected:
|
||||||
HWND m_messLevel, m_messUpDown;
|
HWND m_messLevel, m_messUpDown;
|
||||||
HWND m_mess, m_unmess, m_previewShow;
|
HWND m_mess, m_unmess, m_previewShow;
|
||||||
HWND m_nfc, m_nfd;
|
HWND m_nfc, m_nfd;
|
||||||
HWND m_latin, m_cyrillic, m_greek, m_xsampa;
|
HWND m_latin, m_cyrillic, m_greek, m_xsampa, m_xsampa_table;
|
||||||
MyDropTarget m_dropTarget;
|
MyDropTarget m_dropTarget;
|
||||||
PreviewWindow *m_preview;
|
PreviewWindow *m_preview, *m_data_display;
|
||||||
private:
|
private:
|
||||||
HFONT hFont, hFontMono;
|
HFONT hFont;
|
||||||
HBRUSH hBrush;
|
HBRUSH hBrush;
|
||||||
UDACCEL *udaSecondAccel;
|
UDACCEL *udaSecondAccel;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,9 +12,13 @@
|
||||||
|
|
||||||
class PreviewWindow : public Window {
|
class PreviewWindow : public Window {
|
||||||
public:
|
public:
|
||||||
virtual LPCTSTR ClassName() { return TEXT("Zalgo_Preview"); }
|
virtual LPCTSTR ClassName() { return L"Zalgo_Preview"; }
|
||||||
static PreviewWindow *Create(LPCTSTR szTitle);
|
static PreviewWindow *Create(LPCTSTR szTitle);
|
||||||
void Destroy() { DestroyWindow(m_hwnd); }
|
void Destroy() { DestroyWindow(m_hwnd); }
|
||||||
|
|
||||||
|
void ChangeText(LPWSTR text, bool padding = true);
|
||||||
|
void SetFont(HFONT hFont);
|
||||||
|
void SetFont(const LOGFONT &lf);
|
||||||
protected:
|
protected:
|
||||||
LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
LRESULT OnCreate();
|
LRESULT OnCreate();
|
||||||
|
@ -24,6 +28,7 @@ protected:
|
||||||
virtual HICON GetIcon();
|
virtual HICON GetIcon();
|
||||||
private:
|
private:
|
||||||
HFONT hFont;
|
HFONT hFont;
|
||||||
|
bool used_logfont;
|
||||||
HBRUSH hBrush;
|
HBRUSH hBrush;
|
||||||
int xChar, yChar, xUpper, xClient, yClient, xClientMax, xPos, yPos;
|
int xChar, yChar, xUpper, xClient, yClient, xClientMax, xPos, yPos;
|
||||||
LPTSTR *lpLines;
|
LPTSTR *lpLines;
|
||||||
|
|
|
@ -32,8 +32,10 @@ inline void MakeRectBottomRight(RECT &rect, int x, int y, int cx, int cy)
|
||||||
|
|
||||||
class Window {
|
class Window {
|
||||||
public:
|
public:
|
||||||
HWND GetHWND() { return m_hwnd; }
|
HWND GetHWND() const { return m_hwnd; }
|
||||||
|
bool ShowWindow(int nCmdShow) { return ::ShowWindow(m_hwnd, nCmdShow) != 0; }
|
||||||
static HINSTANCE GetInstance() { return (HINSTANCE) GetModuleHandle(NULL); }
|
static HINSTANCE GetInstance() { return (HINSTANCE) GetModuleHandle(NULL); }
|
||||||
|
operator HWND() const { return m_hwnd; }
|
||||||
protected:
|
protected:
|
||||||
virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
virtual void PaintContent(PAINTSTRUCT *pps) {}
|
virtual void PaintContent(PAINTSTRUCT *pps) {}
|
||||||
|
@ -52,8 +54,7 @@ private:
|
||||||
void OnPaint();
|
void OnPaint();
|
||||||
void OnPrintClient(HDC hdc);
|
void OnPrintClient(HDC hdc);
|
||||||
|
|
||||||
static LRESULT CALLBACK
|
static LRESULT CALLBACK s_WndProc(HWND hwnd, UINT uMsg,
|
||||||
s_WndProc(HWND hwnd, UINT uMsg,
|
|
||||||
WPARAM wParam, LPARAM lParam);
|
WPARAM wParam, LPARAM lParam);
|
||||||
protected:
|
protected:
|
||||||
HWND m_hwnd;
|
HWND m_hwnd;
|
||||||
|
|
|
@ -1 +1,10 @@
|
||||||
#define RID_ICON 1
|
#define RID_ICON 1
|
||||||
|
#define RID_XSAMPA 2
|
||||||
|
#define RID_INIT 3
|
||||||
|
#define RID_LOOSE 4
|
||||||
|
|
||||||
|
inline void GetMessageFont(LOGFONT &lf) {
|
||||||
|
NONCLIENTMETRICS ncmMetrics = { sizeof(NONCLIENTMETRICS) };
|
||||||
|
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncmMetrics, 0);
|
||||||
|
memcpy(&lf, &ncmMetrics.lfMessageFont, sizeof lf);
|
||||||
|
}
|
||||||
|
|
BIN
res/init.txt
Normal file
BIN
res/init.txt
Normal file
Binary file not shown.
BIN
res/loose.txt
Normal file
BIN
res/loose.txt
Normal file
Binary file not shown.
BIN
res/x-sampa.txt
Normal file
BIN
res/x-sampa.txt
Normal file
Binary file not shown.
|
@ -14,24 +14,6 @@
|
||||||
#define BOTTOM(x, y, cx, cy) x, (y - cy), cx, cy
|
#define BOTTOM(x, y, cx, cy) x, (y - cy), cx, cy
|
||||||
#define BOTTOMRIGHT(x, y, cx, cy) (x - cx), (y - cy), cx, cy
|
#define BOTTOMRIGHT(x, y, cx, cy) (x - cx), (y - cy), cx, cy
|
||||||
|
|
||||||
#define ZALGO_INITIAL (L"To invoke the hive-mind representing chaos.\r\n"\
|
|
||||||
L"Invoking the feeling of chaos.\r\n"\
|
|
||||||
L"With out order.\r\n"\
|
|
||||||
L"The Nezperdian hive-mind of chaos. Zalgo.\r\n"\
|
|
||||||
L"He who Waits Behind The Wall.\r\n"\
|
|
||||||
L"ZALGO!\r\n\r\n"\
|
|
||||||
L"WARNING: Resulting text size is roughly original "\
|
|
||||||
L"* (1 + fuck up level). Thou hast been warned.\r\n"\
|
|
||||||
L"\r\n"\
|
|
||||||
L"NOTE: If this program crashes on thee, blame "\
|
|
||||||
L"thyself for fucking up a piece of text that is too "\
|
|
||||||
L"big with a very high fuck up level.\r\n\r\n"\
|
|
||||||
L"Do blame Windows for not able to show proper text "\
|
|
||||||
L"in the edit control, for now, use the preview "\
|
|
||||||
L"button.\r\n\r\n"\
|
|
||||||
L"Bonus Geek Info: NFD text will lose all "\
|
|
||||||
L"diacritics. Thou hast been warned.\r\n")
|
|
||||||
|
|
||||||
UINT ZALGO_MESS_LEVEL_[3] = {6, 10, 14};
|
UINT ZALGO_MESS_LEVEL_[3] = {6, 10, 14};
|
||||||
#define ZALGO_MESS_LEVEL_OF(type) (ZALGO_MESS_LEVEL_[type-0xDEAD])
|
#define ZALGO_MESS_LEVEL_OF(type) (ZALGO_MESS_LEVEL_[type-0xDEAD])
|
||||||
|
|
||||||
|
@ -47,6 +29,23 @@ UINT ZALGO_MESS_LEVEL_[3] = {6, 10, 14};
|
||||||
WNDPROC wpOrigEditProc;
|
WNDPROC wpOrigEditProc;
|
||||||
DWORD rgbWindowBackground;
|
DWORD rgbWindowBackground;
|
||||||
|
|
||||||
|
wchar_t *GetResourceString(int id, HMODULE module = NULL) {
|
||||||
|
HRSRC hRC;
|
||||||
|
DWORD size;
|
||||||
|
HGLOBAL hRes;
|
||||||
|
wchar_t *data;
|
||||||
|
|
||||||
|
hRC = FindResource(module, MAKEINTRESOURCE(id), L"ZALGO_TEXT");
|
||||||
|
if (!hRC)
|
||||||
|
return NULL;
|
||||||
|
size = SizeofResource(module, hRC);
|
||||||
|
hRes = LoadResource(module, hRC);
|
||||||
|
data = new wchar_t[size / sizeof(wchar_t) + 1];
|
||||||
|
memcpy(data, LockResource(hRes), size);
|
||||||
|
data[size / sizeof(wchar_t)] = 0;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT APIENTRY EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT APIENTRY EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (uMsg == WM_KEYDOWN) {
|
if (uMsg == WM_KEYDOWN) {
|
||||||
|
@ -67,24 +66,26 @@ BOOL MainWindow::WinRegisterClass(WNDCLASS *pwc)
|
||||||
|
|
||||||
LRESULT MainWindow::OnCreate()
|
LRESULT MainWindow::OnCreate()
|
||||||
{
|
{
|
||||||
NONCLIENTMETRICS ncmMetrics = { sizeof(NONCLIENTMETRICS) };
|
LOGFONT lf;
|
||||||
RECT client;
|
RECT client;
|
||||||
|
LPWSTR initial = NULL;
|
||||||
|
|
||||||
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncmMetrics, 0);
|
|
||||||
GetClientRect(m_hwnd, &client);
|
GetClientRect(m_hwnd, &client);
|
||||||
|
GetMessageFont(lf);
|
||||||
hFont = CreateFontIndirect(&ncmMetrics.lfMessageFont);
|
hFont = CreateFontIndirect(&lf);
|
||||||
hBrush = GetSysColorBrush(COLOR_WINDOW);
|
hBrush = GetSysColorBrush(COLOR_WINDOW);
|
||||||
rgbWindowBackground = GetSysColor(COLOR_WINDOW);
|
rgbWindowBackground = GetSysColor(COLOR_WINDOW);
|
||||||
hFontMono = CreateFont(0, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET,
|
|
||||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
|
||||||
CLEARTYPE_QUALITY, FF_MODERN, TEXT("Consolas"));
|
|
||||||
|
|
||||||
|
initial = GetResourceString(RID_INIT);
|
||||||
|
if (!initial)
|
||||||
|
MessageBox(m_hwnd, L"Zalgo initial not found", L"Zalgo Error", MB_ICONERROR);
|
||||||
// Children
|
// Children
|
||||||
m_message = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT,
|
m_message = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT,
|
||||||
ZALGO_INITIAL, WS_CHILDWINDOW | WS_VISIBLE | ES_LEFT |
|
initial, WS_CHILDWINDOW | WS_VISIBLE | ES_LEFT |
|
||||||
ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL,
|
ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL,
|
||||||
0, 0, 0, 0, m_hwnd, (HMENU) ZALGO_MESSAGE, GetInstance(), NULL);
|
0, 0, 0, 0, m_hwnd, (HMENU) ZALGO_MESSAGE, GetInstance(), NULL);
|
||||||
|
if (initial)
|
||||||
|
delete [] initial;
|
||||||
|
|
||||||
m_goUp = CreateWindow(WC_BUTTON, L"fuck up going &up",
|
m_goUp = CreateWindow(WC_BUTTON, L"fuck up going &up",
|
||||||
WS_CHILDWINDOW | WS_VISIBLE | BS_CHECKBOX, 0, 0, 0, 0,
|
WS_CHILDWINDOW | WS_VISIBLE | BS_CHECKBOX, 0, 0, 0, 0,
|
||||||
|
@ -146,6 +147,9 @@ LRESULT MainWindow::OnCreate()
|
||||||
m_xsampa = CreateWindow(WC_BUTTON, L"&X-SAMPA to IPA",
|
m_xsampa = CreateWindow(WC_BUTTON, L"&X-SAMPA to IPA",
|
||||||
WS_CHILDWINDOW | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0,
|
WS_CHILDWINDOW | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0,
|
||||||
m_hwnd, (HMENU) ZALGO_XSAMPA, GetInstance(), NULL);
|
m_hwnd, (HMENU) ZALGO_XSAMPA, GetInstance(), NULL);
|
||||||
|
m_xsampa_table = CreateWindow(WC_BUTTON, L"X-&SAMPA Table",
|
||||||
|
WS_CHILDWINDOW | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0,
|
||||||
|
m_hwnd, (HMENU) ZALGO_XSAMPA_TABLE, GetInstance(), NULL);
|
||||||
|
|
||||||
PostMessage(m_messUpDown, UDM_SETRANGE32, 1, ZALGO_MESS_LEVEL_OF(ZALGO_MAX_MESS));
|
PostMessage(m_messUpDown, UDM_SETRANGE32, 1, ZALGO_MESS_LEVEL_OF(ZALGO_MAX_MESS));
|
||||||
PostMessage(m_messUpDown, UDM_SETPOS32, 0, ZALGO_MESS_LEVEL_OF(ZALGO_NORMAL_MESS));
|
PostMessage(m_messUpDown, UDM_SETPOS32, 0, ZALGO_MESS_LEVEL_OF(ZALGO_NORMAL_MESS));
|
||||||
|
@ -168,6 +172,7 @@ LRESULT MainWindow::OnCreate()
|
||||||
SETFONT(m_cyrillic);
|
SETFONT(m_cyrillic);
|
||||||
SETFONT(m_greek);
|
SETFONT(m_greek);
|
||||||
SETFONT(m_xsampa);
|
SETFONT(m_xsampa);
|
||||||
|
SETFONT(m_xsampa_table);
|
||||||
#undef SETFONT
|
#undef SETFONT
|
||||||
|
|
||||||
Button_SetCheck(m_goUp, 1);
|
Button_SetCheck(m_goUp, 1);
|
||||||
|
@ -177,10 +182,14 @@ LRESULT MainWindow::OnCreate()
|
||||||
Edit_Enable(m_messLevel, 0);
|
Edit_Enable(m_messLevel, 0);
|
||||||
|
|
||||||
if (!m_dropTarget.DragDropRegister(m_hwnd))
|
if (!m_dropTarget.DragDropRegister(m_hwnd))
|
||||||
MessageBox(m_hwnd, TEXT("Failed to register Drag and Drop handler"),
|
MessageBox(m_hwnd, L"Failed to register Drag and Drop handler",
|
||||||
TEXT("Zalgo has COME!!!"), MB_ICONERROR);
|
L"Zalgo has COME!!!", MB_ICONERROR);
|
||||||
|
|
||||||
m_preview = PreviewWindow::Create(L"Text Preview");
|
m_preview = PreviewWindow::Create(L"Text Preview");
|
||||||
|
m_data_display = PreviewWindow::Create(L"X-SAMPA Table");
|
||||||
|
lf.lfHeight = (LONG) (lf.lfHeight * 1.3);
|
||||||
|
lf.lfWidth = (LONG) (lf.lfWidth * 1.3);
|
||||||
|
m_data_display->SetFont(lf);
|
||||||
|
|
||||||
// Subclassing
|
// Subclassing
|
||||||
wpOrigEditProc = (WNDPROC) SetWindowLongPtr(m_message,
|
wpOrigEditProc = (WNDPROC) SetWindowLongPtr(m_message,
|
||||||
|
@ -212,7 +221,9 @@ LRESULT MainWindow::OnDestroy()
|
||||||
DestroyWindow(m_cyrillic);
|
DestroyWindow(m_cyrillic);
|
||||||
DestroyWindow(m_greek);
|
DestroyWindow(m_greek);
|
||||||
DestroyWindow(m_xsampa);
|
DestroyWindow(m_xsampa);
|
||||||
|
DestroyWindow(m_xsampa_table);
|
||||||
delete m_preview;
|
delete m_preview;
|
||||||
|
delete m_data_display;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,6 +278,7 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
REPOS(m_cyrillic, BOTTOM(117, client.bottom - 84, 100, 25));
|
REPOS(m_cyrillic, BOTTOM(117, client.bottom - 84, 100, 25));
|
||||||
REPOS(m_greek, BOTTOM(222, client.bottom - 84, 100, 25));
|
REPOS(m_greek, BOTTOM(222, client.bottom - 84, 100, 25));
|
||||||
REPOS(m_xsampa, BOTTOM(327, client.bottom - 84, 100, 25));
|
REPOS(m_xsampa, BOTTOM(327, client.bottom - 84, 100, 25));
|
||||||
|
REPOS(m_xsampa_table, BOTTOM(432, client.bottom - 84, 100, 25));
|
||||||
EndDeferWindowPos(hdwp);
|
EndDeferWindowPos(hdwp);
|
||||||
#undef REPOS
|
#undef REPOS
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -288,8 +300,9 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
text = new wchar_t[textlen];
|
text = new wchar_t[textlen];
|
||||||
Edit_GetText(m_message, text, textlen);
|
Edit_GetText(m_message, text, textlen);
|
||||||
|
|
||||||
SendMessage(m_preview->GetHWND(), WM_CHANGETEXT, 0, (LPARAM) text);
|
m_preview->ChangeText(text);
|
||||||
ShowWindow(m_preview->GetHWND(), SW_SHOW);
|
m_preview->ShowWindow(SW_SHOW);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TEXT_TO_NFC:
|
case TEXT_TO_NFC:
|
||||||
OnTextNFC();
|
OnTextNFC();
|
||||||
|
@ -314,6 +327,21 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
case ZALGO_GO_DOWN:
|
case ZALGO_GO_DOWN:
|
||||||
Button_SetCheck((HWND) lParam, !IsDlgButtonChecked(m_hwnd, LOWORD(wParam)));
|
Button_SetCheck((HWND) lParam, !IsDlgButtonChecked(m_hwnd, LOWORD(wParam)));
|
||||||
break;
|
break;
|
||||||
|
case ZALGO_XSAMPA_TABLE: {
|
||||||
|
wchar_t *text;
|
||||||
|
|
||||||
|
SetWindowText(m_data_display->GetHWND(), L"X-SAMPA Table");
|
||||||
|
text = GetResourceString(RID_XSAMPA);
|
||||||
|
if (!text) {
|
||||||
|
MessageBox(m_hwnd, L"X-SAMPA table not found", L"X-SAMPA Error", MB_ICONERROR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_data_display->ChangeText(text, false);
|
||||||
|
m_data_display->ShowWindow(SW_SHOW);
|
||||||
|
SetForegroundWindow(*m_data_display);
|
||||||
|
delete [] text;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
Button_SetCheck(GetDlgItem(m_hwnd, ZALGO_MINI_MESS), 0);
|
Button_SetCheck(GetDlgItem(m_hwnd, ZALGO_MINI_MESS), 0);
|
||||||
Button_SetCheck(GetDlgItem(m_hwnd, ZALGO_NORMAL_MESS), 0);
|
Button_SetCheck(GetDlgItem(m_hwnd, ZALGO_NORMAL_MESS), 0);
|
||||||
|
@ -348,19 +376,16 @@ LRESULT MainWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
if (wParam == 'K' && GetKeyState(VK_CONTROL) < 0 &&
|
if (wParam == 'K' && GetKeyState(VK_CONTROL) < 0 &&
|
||||||
GetKeyState(VK_SHIFT) < 0 && GetKeyState(VK_MENU) < 0) {
|
GetKeyState(VK_SHIFT) < 0 && GetKeyState(VK_MENU) < 0) {
|
||||||
static bool unlocked = false;
|
static bool unlocked = false;
|
||||||
// A user has tried to go beyond max, let is work
|
LPWSTR text = GetResourceString(RID_LOOSE);
|
||||||
if (!unlocked && MessageBox(m_hwnd, L"\
|
// A user has tried to go beyond max, let it work
|
||||||
Thou hast tried to loosen my limits, dost thou promise that:\r\n\
|
if (!unlocked && MessageBox(m_hwnd, text,L"About to Unlock Secret",
|
||||||
1. thou will be responsible to use the string generated\r\n\
|
MB_YESNO | MB_ICONQUESTION) == IDYES) {
|
||||||
2. thou will be careful to not enter a number too large that will crash me\r\n\
|
|
||||||
3. if thou dost crash me, blame thyself for entering a number too large\r\n\
|
|
||||||
\r\n\
|
|
||||||
Dost thou agree?", L"About to Unlock Secret", MB_YESNO | MB_ICONQUESTION) == IDYES) {
|
|
||||||
PostMessage(m_messUpDown, UDM_SETRANGE32, 1, LONG_MAX);
|
PostMessage(m_messUpDown, UDM_SETRANGE32, 1, LONG_MAX);
|
||||||
PostMessage(m_messLevel, EM_SETREADONLY, 0, 0);
|
PostMessage(m_messLevel, EM_SETREADONLY, 0, 0);
|
||||||
|
|
||||||
unlocked = true;
|
unlocked = true;
|
||||||
}
|
}
|
||||||
|
delete [] text;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -5,28 +5,13 @@
|
||||||
|
|
||||||
LRESULT PreviewWindow::OnCreate()
|
LRESULT PreviewWindow::OnCreate()
|
||||||
{
|
{
|
||||||
NONCLIENTMETRICS ncmMetrics = { sizeof(NONCLIENTMETRICS) };
|
LOGFONT lf;
|
||||||
RECT client;
|
RECT client;
|
||||||
|
|
||||||
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncmMetrics, 0);
|
|
||||||
GetClientRect(m_hwnd, &client);
|
GetClientRect(m_hwnd, &client);
|
||||||
|
|
||||||
hFont = CreateFontIndirect(&ncmMetrics.lfMessageFont);
|
GetMessageFont(lf);
|
||||||
|
hFont = CreateFontIndirect(&lf);
|
||||||
// Get the handle to the client area's device context.
|
SendMessage(m_hwnd, WM_SETFONT, (WPARAM) hFont, FALSE);
|
||||||
HDC hdc = GetDC(m_hwnd);
|
|
||||||
TEXTMETRIC tm;
|
|
||||||
// Extract font dimensions from the text metrics.
|
|
||||||
GetTextMetrics(hdc, &tm);
|
|
||||||
xChar = tm.tmAveCharWidth;
|
|
||||||
xUpper =(tm.tmPitchAndFamily & 1 ? 3 : 2) * xChar/2;
|
|
||||||
yChar = tm.tmHeight + tm.tmExternalLeading;
|
|
||||||
// Free the device context.
|
|
||||||
ReleaseDC(m_hwnd, hdc);
|
|
||||||
// Set an arbitrary maximum width for client area.
|
|
||||||
//(xClientMax is the sum of the widths of 48 average
|
|
||||||
// lowercase letters and 12 uppercase letters.)
|
|
||||||
xClientMax = 48 * xChar + 12 * xUpper;
|
|
||||||
|
|
||||||
lpLines = NULL;
|
lpLines = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -60,7 +45,7 @@ void PreviewWindow::OnPaint()
|
||||||
yPos = si.nPos;
|
yPos = si.nPos;
|
||||||
|
|
||||||
SelectObject(ps.hdc, hFont);
|
SelectObject(ps.hdc, hFont);
|
||||||
SetBkColor(ps.hdc, RGB(0xF0, 0xF0, 0xF0));
|
SetBkMode(ps.hdc, TRANSPARENT);
|
||||||
// Find painting limits.
|
// Find painting limits.
|
||||||
int FirstLine = max(0, yPos + ps.rcPaint.top / yChar);
|
int FirstLine = max(0, yPos + ps.rcPaint.top / yChar);
|
||||||
int LastLine = min(lines - 1, yPos + ps.rcPaint.bottom / yChar);
|
int LastLine = min(lines - 1, yPos + ps.rcPaint.bottom / yChar);
|
||||||
|
@ -73,12 +58,97 @@ void PreviewWindow::OnPaint()
|
||||||
int y = yChar * (i - yPos);
|
int y = yChar * (i - yPos);
|
||||||
rect.top = y;
|
rect.top = y;
|
||||||
rect.left = x;
|
rect.left = x;
|
||||||
DrawText(ps.hdc, lpLines[i], -1, &rect, DT_NOCLIP);
|
DrawText(ps.hdc, lpLines[i], -1, &rect, DT_EXPANDTABS | DT_NOCLIP | DT_NOPREFIX);
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
EndPaint(m_hwnd, &ps);
|
EndPaint(m_hwnd, &ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewWindow::ChangeText(LPWSTR text, bool padding)
|
||||||
|
{
|
||||||
|
if (lpLines) {
|
||||||
|
for (int i = 0; i < lines; ++i)
|
||||||
|
delete [] lpLines[i];
|
||||||
|
delete [] lpLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
int l = 0, longest = 0, maxlen = 0;
|
||||||
|
LPWSTR str = text;
|
||||||
|
|
||||||
|
if (*str == L'\0') {
|
||||||
|
empty = true;
|
||||||
|
lpLines = NULL;
|
||||||
|
} else empty = false;
|
||||||
|
|
||||||
|
while (*str++)
|
||||||
|
if (*str == L'\n')
|
||||||
|
++l;
|
||||||
|
|
||||||
|
if (*(str-1) != L'\n')
|
||||||
|
++l;
|
||||||
|
|
||||||
|
lines = l;
|
||||||
|
if (padding)
|
||||||
|
lines += 8;
|
||||||
|
lpLines = new LPTSTR[lines];
|
||||||
|
if (padding) {
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
lpLines[i] = new TCHAR[1];
|
||||||
|
lpLines[i][0] = L'\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < l; ++i) {
|
||||||
|
LPTSTR start = text, end, buf;
|
||||||
|
int len;
|
||||||
|
while (*text++ != L'\n' && *(text-1) != L'\0');
|
||||||
|
end = text - 1;
|
||||||
|
len = end - start;
|
||||||
|
if (len > maxlen) {
|
||||||
|
longest = i + (padding ? 4 : 0);
|
||||||
|
maxlen = len;
|
||||||
|
}
|
||||||
|
buf = new TCHAR[len + 1];
|
||||||
|
memcpy(buf, start, len*sizeof(TCHAR));
|
||||||
|
buf[len] = L'\0';
|
||||||
|
lpLines[i + (padding ? 4 : 0)] = buf;
|
||||||
|
}
|
||||||
|
if (padding) {
|
||||||
|
for (int i = l + 4; i < lines; ++i) {
|
||||||
|
lpLines[i] = new TCHAR[1];
|
||||||
|
lpLines[i][0] = L'\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int upper = 0, lower = 0;
|
||||||
|
for (LPTSTR i = lpLines[longest]; *i; ++i) {
|
||||||
|
if (isupper(*i))
|
||||||
|
++upper;
|
||||||
|
else if (!(*i >= 0x0300 && *i < 0x0370 || *i == 0x489))
|
||||||
|
++lower;
|
||||||
|
}
|
||||||
|
xClientMax = lower * xChar + upper * xUpper;
|
||||||
|
|
||||||
|
PostMessage(m_hwnd, WM_SIZE, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewWindow::SetFont(HFONT hFont)
|
||||||
|
{
|
||||||
|
if (used_logfont)
|
||||||
|
DeleteFont(this->hFont);
|
||||||
|
used_logfont = false;
|
||||||
|
SendMessage(m_hwnd, WM_SETFONT, (WPARAM) hFont, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewWindow::SetFont(const LOGFONT &lf)
|
||||||
|
{
|
||||||
|
if (used_logfont)
|
||||||
|
DeleteFont(this->hFont);
|
||||||
|
used_logfont = true;
|
||||||
|
hFont = CreateFontIndirect(&lf);
|
||||||
|
SendMessage(m_hwnd, WM_SETFONT, (WPARAM) hFont, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT PreviewWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT PreviewWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(uMsg) {
|
switch(uMsg) {
|
||||||
|
@ -230,69 +300,31 @@ LRESULT PreviewWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_CHANGETEXT: {
|
case WM_CHANGETEXT:
|
||||||
if (lpLines) {
|
ChangeText((LPTSTR) lParam, (wParam & 1) == 0);
|
||||||
for (int i = 0; i < lines; ++i)
|
|
||||||
delete [] lpLines[i];
|
|
||||||
delete [] lpLines;
|
|
||||||
}
|
|
||||||
|
|
||||||
LPTSTR str = (LPTSTR) lParam;
|
|
||||||
int l = 0, longest = 0, maxlen = 0;
|
|
||||||
|
|
||||||
if (*str == L'\0') {
|
|
||||||
empty = true;
|
|
||||||
lpLines = NULL;
|
|
||||||
} else empty = false;
|
|
||||||
|
|
||||||
while (*str++)
|
|
||||||
if (*str == L'\n')
|
|
||||||
++l;
|
|
||||||
|
|
||||||
if (*(str-1) != L'\n')
|
|
||||||
++l;
|
|
||||||
|
|
||||||
lines = l + 8;
|
|
||||||
lpLines = new LPTSTR[lines];
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
|
||||||
lpLines[i] = new TCHAR[1];
|
|
||||||
lpLines[i][0] = L'\0';
|
|
||||||
}
|
|
||||||
str = (LPTSTR) lParam;
|
|
||||||
for (int i = 0; i < l; ++i) {
|
|
||||||
LPTSTR start = str, end, buf;
|
|
||||||
int len;
|
|
||||||
while (*str++ != L'\n' && *(str-1) != L'\0');
|
|
||||||
end = str - 1;
|
|
||||||
len = end - start;
|
|
||||||
if (len > maxlen) {
|
|
||||||
longest = i+4;
|
|
||||||
maxlen = len;
|
|
||||||
}
|
|
||||||
buf = new TCHAR[len + 1];
|
|
||||||
memcpy(buf, start, len*sizeof(TCHAR));
|
|
||||||
buf[len] = L'\0';
|
|
||||||
lpLines[i+4] = buf;
|
|
||||||
}
|
|
||||||
for (int i = l + 4; i < lines; ++i) {
|
|
||||||
lpLines[i] = new TCHAR[1];
|
|
||||||
lpLines[i][0] = L'\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
int upper = 0, lower = 0;
|
|
||||||
for (LPTSTR i = lpLines[longest]; *i; ++i) {
|
|
||||||
if (isupper(*i))
|
|
||||||
++upper;
|
|
||||||
else if (!(*i >= 0x0300 && *i < 0x0370 || *i == 0x489))
|
|
||||||
++lower;
|
|
||||||
}
|
|
||||||
xClientMax = lower * xChar + upper * xUpper;
|
|
||||||
|
|
||||||
PostMessage(m_hwnd, WM_SIZE, 0, 0);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_SETFONT: {
|
||||||
|
HDC hdc = GetDC(m_hwnd);
|
||||||
|
hFont = (HFONT) wParam;
|
||||||
|
HFONT hOldFont = SelectFont(hdc, hFont);
|
||||||
|
|
||||||
|
TEXTMETRIC tm;
|
||||||
|
// Extract font dimensions from the text metrics.
|
||||||
|
GetTextMetrics(hdc, &tm);
|
||||||
|
xChar = tm.tmAveCharWidth;
|
||||||
|
xUpper =(tm.tmPitchAndFamily & 1 ? 3 : 2) * xChar/2;
|
||||||
|
yChar = tm.tmHeight + tm.tmExternalLeading;
|
||||||
|
// Set an arbitrary maximum width for client area.
|
||||||
|
//(xClientMax is the sum of the widths of 48 average
|
||||||
|
// lowercase letters and 12 uppercase letters.)
|
||||||
|
xClientMax = 48 * xChar + 12 * xUpper;
|
||||||
|
|
||||||
|
SelectFont(hdc, hOldFont);
|
||||||
|
ReleaseDC(m_hwnd, hdc);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
ShowWindow(m_hwnd, SW_HIDE);
|
ShowWindow(SW_HIDE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
||||||
|
|
||||||
MainWindow *win = MainWindow::Create(L"U̬̩͔̐̿ṅ̨̤̬̽i̛̘̳̹ͤ̍c̠̳̬͛o̘̳͗̿̈́d̗̅̓͗͠ḛ͍͛ ̬̠̹̉ͭ͛D̨̤̰̀̂ͦì̛͇͂a͍͇͛ͨͤc̡̟͖͗̔ͤͅr͔͇ͮ̓̍͢i̴͇͇̇͋̽t̛̟̟͋i̲̘̿̊c̺͎ͬ͗-̴̤́̔P̋̍҉͎̹ö̲̯͈̋͞l͎͂l̻̖ͩ̂͜u̵͔̳̇̋t̳̪͐̎e͈̓͢ḓ̗̭̓ ̹̫͛Ṭͫe̙̝̦̊̊̑͢x̶͉ͦ̚t̞̔̈́̀ ̡̪̪̙͒͗G̘̜̋e͍̯̻͋ͬͦn̹̩̫̑̈́ẽ͔̳r̠͙͒̀̅ͅa̭ͫ̓́t̘̺̋̏̚o̰̙̦ͪṛͦͣ́ͅ");
|
MainWindow *win = MainWindow::Create(L"U̬̩͔̐̿ṅ̨̤̬̽i̛̘̳̹ͤ̍c̠̳̬͛o̘̳͗̿̈́d̗̅̓͗͠ḛ͍͛ ̬̠̹̉ͭ͛D̨̤̰̀̂ͦì̛͇͂a͍͇͛ͨͤc̡̟͖͗̔ͤͅr͔͇ͮ̓̍͢i̴͇͇̇͋̽t̛̟̟͋i̲̘̿̊c̺͎ͬ͗-̴̤́̔P̋̍҉͎̹ö̲̯͈̋͞l͎͂l̻̖ͩ̂͜u̵͔̳̇̋t̳̪͐̎e͈̓͢ḓ̗̭̓ ̹̫͛Ṭͫe̙̝̦̊̊̑͢x̶͉ͦ̚t̞̔̈́̀ ̡̪̪̙͒͗G̘̜̋e͍̯̻͋ͬͦn̹̩̫̑̈́ẽ͔̳r̠͙͒̀̅ͅa̭ͫ̓́t̘̺̋̏̚o̰̙̦ͪṛͦͣ́ͅ");
|
||||||
if (win) {
|
if (win) {
|
||||||
ShowWindow(win->GetHWND(), nCmdShow);
|
win->ShowWindow(nCmdShow);
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while (GetMessage(&msg, NULL, 0, 0) > 0) {
|
while (GetMessage(&msg, NULL, 0, 0) > 0) {
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
|
|
Loading…
Reference in a new issue