diff --git a/rosapps/applications/screensavers/cylfrac/CMakeLists.txt b/rosapps/applications/screensavers/cylfrac/CMakeLists.txt index 6527cef3c4d..039df445d0f 100644 --- a/rosapps/applications/screensavers/cylfrac/CMakeLists.txt +++ b/rosapps/applications/screensavers/cylfrac/CMakeLists.txt @@ -2,5 +2,6 @@ add_executable(cylfrac cylfrac.c cylfrac.rc) set_module_type(cylfrac win32gui UNICODE) set_target_properties(cylfrac PROPERTIES SUFFIX ".scr") +target_link_libraries(cylfrac scrnsave) add_importlibs(cylfrac user32 gdi32 opengl32 glu32 winmm msvcrt kernel32) add_cd_file(TARGET cylfrac DESTINATION reactos/system32 FOR all) diff --git a/rosapps/applications/screensavers/cylfrac/cylfrac.c b/rosapps/applications/screensavers/cylfrac/cylfrac.c index 03ed11485ea..d72f6385f35 100644 --- a/rosapps/applications/screensavers/cylfrac/cylfrac.c +++ b/rosapps/applications/screensavers/cylfrac/cylfrac.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "resource.h" #define APPNAME _T("Cylfrac") @@ -50,284 +51,183 @@ BOOL fullscreen = FALSE; float _RGB(float H, float M1, float M2) { - if(H < 0.0) H += 360.0; - else if(H > 360.0) H -= 360.0; - if(H < 60) return M1 + (M2 - M1) * H / 60.0; - if((H >= 60 )&&(H < 180)) return M2; - if((H >= 180)&&(H < 240)) return M1 + (M2 - M1)*(240 - H) / 60.0; - return M1; + if(H < 0.0) H += 360.0; + else if(H > 360.0) H -= 360.0; + if(H < 60) return M1 + (M2 - M1) * H / 60.0; + if((H >= 60 )&&(H < 180)) return M2; + if((H >= 180)&&(H < 240)) return M1 + (M2 - M1)*(240 - H) / 60.0; + return M1; } void HLStoRGB(float H, float L, float S, float* R, float* G, float* B) { float M1, M2; - if(S <= 0.5) M2 = S * (1 + L); - else M2 = S * (1 - L) + L; - M1 = 2 * S - M2; - if (L == 0.0) - { - *R = S; - *G = S; - *B = S; - } else { - *R = _RGB(H + 120.0, M1, M2); - *G = _RGB(H , M1, M2); - *B = _RGB(H - 120.0, M1, M2); - } + if(S <= 0.5) M2 = S * (1 + L); + else M2 = S * (1 - L) + L; + M1 = 2 * S - M2; + if (L == 0.0) + { + *R = S; + *G = S; + *B = S; + } else { + *R = _RGB(H + 120.0, M1, M2); + *G = _RGB(H , M1, M2); + *B = _RGB(H - 120.0, M1, M2); + } } void DrawCylinder(int n, float rota, float width) { - glPushMatrix(); - glColor3f(rval/n, gval/n, bval/n); - glRotatef(rota, 0.0, 1.0, 0.0); - gluCylinder(cylinder, width, width * wfactor, n * 0.5, cylquality, 1); - glTranslatef(0.0, 0.0, -n * 0.5); - gluCylinder(cylinder, width * wfactor, width, n * 0.5, cylquality, 1); - if(n > 1) - { - float r = rota * rotfactor; - glRotatef(90.0, 1.0, 0.0, 0.0); - DrawCylinder(n - 1, r, width * wfactor); - glTranslatef(0.0, n, 0.0); - DrawCylinder(n - 1, -r, width * wfactor); - } - glPopMatrix(); + glPushMatrix(); + glColor3f(rval/n, gval/n, bval/n); + glRotatef(rota, 0.0, 1.0, 0.0); + gluCylinder(cylinder, width, width * wfactor, n * 0.5, cylquality, 1); + glTranslatef(0.0, 0.0, -n * 0.5); + gluCylinder(cylinder, width * wfactor, width, n * 0.5, cylquality, 1); + if(n > 1) + { + float r = rota * rotfactor; + glRotatef(90.0, 1.0, 0.0, 0.0); + DrawCylinder(n - 1, r, width * wfactor); + glTranslatef(0.0, n, 0.0); + DrawCylinder(n - 1, -r, width * wfactor); + } + glPopMatrix(); } void DrawScene(HWND hwnd, HDC dc, int ticks) { - PAINTSTRUCT ps; - dc = BeginPaint(hwnd, &ps); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glRotatef(ticks * 0.01, 0.0, 1.0, -0.5); - angle += ticks * 0.01; - colorh += ticks * 0.003; - if (colorh > 360.0) colorh -= 360.0; - HLStoRGB(colorh, 1.0, 0.7, &rval, &gval, &bval); - DrawCylinder(lvls, angle, 0.2); - SwapBuffers(dc); - EndPaint(hwnd, &ps); + PAINTSTRUCT ps; + dc = BeginPaint(hwnd, &ps); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glRotatef(ticks * 0.01, 0.0, 1.0, -0.5); + angle += ticks * 0.01; + colorh += ticks * 0.003; + if (colorh > 360.0) colorh -= 360.0; + HLStoRGB(colorh, 1.0, 0.7, &rval, &gval, &bval); + DrawCylinder(lvls, angle, 0.2); + SwapBuffers(dc); + EndPaint(hwnd, &ps); } void CALLBACK TimeProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) { - InvalidateRect((HWND)dwUser, NULL, 0); + InvalidateRect((HWND)dwUser, NULL, 0); } void MyPixelFormat(HDC dc) { - int npf; - PIXELFORMATDESCRIPTOR pfd; + int npf; + PIXELFORMATDESCRIPTOR pfd; - ZeroMemory(&pfd, sizeof(pfd)); - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW; + ZeroMemory(&pfd, sizeof(pfd)); + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW; - npf = ChoosePixelFormat(dc, &pfd); - if(npf != 0) - SetPixelFormat(dc, npf, &pfd); + npf = ChoosePixelFormat(dc, &pfd); + if(npf != 0) + SetPixelFormat(dc, npf, &pfd); } void InitGL(HWND hwnd) { - GLfloat lightpos[4] = {2.0, 2.0, -2.0, 0.7}; - GLfloat ca = 1.0; - dc = GetDC(hwnd); - MyPixelFormat(dc); - hrc = wglCreateContext(dc); - wglMakeCurrent(dc, hrc); - cylinder = gluNewQuadric(); - glEnable(GL_DEPTH_TEST); - glEnable(GL_LIGHT0); - glLightfv(GL_LIGHT0, GL_POSITION, (GLfloat *)&lightpos); - glLightfv(GL_LIGHT0, GL_LINEAR_ATTENUATION, &ca); - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); + GLfloat lightpos[4] = {2.0, 2.0, -2.0, 0.7}; + GLfloat ca = 1.0; + dc = GetDC(hwnd); + MyPixelFormat(dc); + hrc = wglCreateContext(dc); + wglMakeCurrent(dc, hrc); + cylinder = gluNewQuadric(); + glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHT0); + glLightfv(GL_LIGHT0, GL_POSITION, (GLfloat *)&lightpos); + glLightfv(GL_LIGHT0, GL_LINEAR_ATTENUATION, &ca); + glEnable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); } -LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +LRESULT WINAPI ScreenSaverProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { - case WM_CREATE: - GetCursorPos(&initpoint); - InitGL(hwnd); - oldticks = GetTickCount(); - TimerID = timeSetEvent (timerdelay, 0, TimeProc, (DWORD)hwnd, TIME_PERIODIC); - break; - case WM_PAINT: - { - DWORD ticks = oldticks; - POINT currpoint; - oldticks = GetTickCount(); - DrawScene(hwnd, dc, oldticks - ticks); - if(fullscreen) - { - GetCursorPos(&currpoint); - if(abs(currpoint.x - initpoint.x) + (abs(currpoint.y - initpoint.y)) > 10) - PostMessage(hwnd, WM_CLOSE, 0, 0); - } - break; - } - case WM_DESTROY: - timeKillEvent(TimerID); - gluDeleteQuadric(cylinder); - wglMakeCurrent(0, 0); - wglDeleteContext(hrc); - ReleaseDC(hwnd, dc); - DeleteDC(dc); - if (fullscreen) - ShowCursor(TRUE); - PostQuitMessage(0); - break; - case WM_NOTIFY: - case WM_SYSKEYDOWN: - PostMessage(hwnd, WM_CLOSE, 0, 0); - break; - case WM_SIZE: - { - int width = LOWORD(lParam); - int height = HIWORD(lParam); - float fscale; - glViewport(0, 0, width, height); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - fscale = 0.8/(float)lvls; - glScalef(fscale, fscale, fscale); - break; - } - - } - return DefWindowProc(hwnd, msg, wParam, lParam); + switch(msg) { + case WM_CREATE: + { + GetCursorPos(&initpoint); + InitGL(hwnd); + oldticks = GetTickCount(); + TimerID = timeSetEvent (timerdelay, 0, TimeProc, (DWORD)hwnd, TIME_PERIODIC); + } + break; + case WM_PAINT: + { + DWORD ticks = oldticks; + POINT currpoint; + oldticks = GetTickCount(); + DrawScene(hwnd, dc, oldticks - ticks); + if(fullscreen) + { + GetCursorPos(&currpoint); + if(abs(currpoint.x - initpoint.x) + (abs(currpoint.y - initpoint.y)) > 10) + PostMessage(hwnd, WM_CLOSE, 0, 0); + } + } + break; + case WM_DESTROY: + { + timeKillEvent(TimerID); + gluDeleteQuadric(cylinder); + wglMakeCurrent(0, 0); + wglDeleteContext(hrc); + ReleaseDC(hwnd, dc); + DeleteDC(dc); + if (fullscreen) + ShowCursor(TRUE); + PostQuitMessage(0); + } + break; + case WM_SIZE: + { + int width = LOWORD(lParam); + int height = HIWORD(lParam); + float fscale; + glViewport(0, 0, width, height); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + fscale = 0.8/(float)lvls; + glScalef(fscale, fscale, fscale); + } + break; + default: + return DefScreenSaverProc(hwnd, msg, wParam, lParam); + } + return 0; } -void InitSaver(HWND hwndParent) +BOOL WINAPI ScreenSaverConfigureDialog(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) { - WNDCLASS wc; - ZeroMemory(&wc, sizeof(wc)); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = WndProc; - wc.lpszClassName = APPNAME; - RegisterClass(&wc); - - if (hwndParent != 0) - { - RECT rect; - GetClientRect(hwndParent, &rect); - CreateWindow(APPNAME, APPNAME, - WS_VISIBLE | WS_CHILD, - 0, 0, - rect.right, - rect.bottom, - hwndParent, 0, - hInstance, NULL); - fullscreen = FALSE; - } else { - HWND hwnd; - hwnd = CreateWindow(APPNAME, APPNAME, - WS_VISIBLE | WS_POPUP | WS_EX_TOPMOST, - 0, 0, - GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), - HWND_DESKTOP, 0, - hInstance, NULL); - ShowWindow(hwnd, SW_SHOWMAXIMIZED); - ShowCursor(FALSE); - fullscreen = TRUE; - } + return FALSE; } -// -// Look for any options Windows has passed to us: -// -// -a (set password) -// -s (screensave) -// -p (preview) -// -c (configure) -// -VOID ParseCommandLine(LPWSTR szCmdLine, UCHAR *chOption, HWND *hwndParent) +BOOL WINAPI RegisterDialogClasses(HANDLE hmodule) { - UCHAR ch = *szCmdLine++; + TCHAR szTitle[256]; + TCHAR szText[256]; - if(ch == '-' || ch == '/') - ch = *szCmdLine++; + LoadString(hmodule, + IDS_TITLE, + szTitle, + 256); - if(ch >= 'A' && ch <= 'Z') - ch += 'a' - 'A'; //convert to lower case + LoadString(hmodule, + IDS_TEXT, + szText, + 256); - *chOption = ch; - ch = *szCmdLine++; - - if(ch == ':') - ch = *szCmdLine++; - - while(ch == ' ' || ch == '\t') - ch = *szCmdLine++; - - if(isdigit(ch)) - { - unsigned int i = _wtoi(szCmdLine - 1); - *hwndParent = (HWND)i; - } - else - *hwndParent = NULL; + MessageBox(0, + szText, + szTitle, + MB_OK | MB_ICONWARNING); + return FALSE; } - -void Configure(void) -{ - TCHAR szTitle[256]; - TCHAR szText[256]; - - LoadString(hInstance, - IDS_TITLE, - szTitle, - 256); - - LoadString(hInstance, - IDS_TEXT, - szText, - 256); - - MessageBox(0, - szText, - szTitle, - MB_OK | MB_ICONWARNING); -} - -int CALLBACK wWinMain (HINSTANCE hInst, - HINSTANCE hPrev, - LPWSTR lpCmdLine, - int iCmdShow) -{ - HWND hwndParent = 0; - UCHAR chOption; - MSG Message; - - hInstance = hInst; - - ParseCommandLine(lpCmdLine, &chOption, &hwndParent); - - switch(chOption) - { - case 's': - InitSaver(0); - break; - - case 'p': - InitSaver(hwndParent); - break; - - case 'c': - default: - Configure(); - return 0; - } - - while (GetMessage(&Message, 0, 0, 0)) - DispatchMessage(&Message); - - return Message.wParam; -} - - diff --git a/rosapps/applications/screensavers/cylfrac/cylfrac.rc b/rosapps/applications/screensavers/cylfrac/cylfrac.rc index 89ea88b1597..dcaf14f56f4 100644 --- a/rosapps/applications/screensavers/cylfrac/cylfrac.rc +++ b/rosapps/applications/screensavers/cylfrac/cylfrac.rc @@ -1,4 +1,5 @@ #include +#include #include "resource.h" LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL @@ -10,18 +11,44 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #include +#include + /* UTF-8 */ #pragma code_page(65001) -#include "lang/bg-BG.rc" -#include "lang/de-DE.rc" -#include "lang/en-US.rc" -#include "lang/es-ES.rc" -#include "lang/fr-FR.rc" -#include "lang/lt-LT.rc" -#include "lang/nl-NL.rc" -#include "lang/no-NO.rc" -#include "lang/pl-PL.rc" -#include "lang/ro-RO.rc" -#include "lang/sk-SK.rc" -#include "lang/uk-UA.rc" +#ifdef LANGUAGE_BG_BG + #include "lang/bg-BG.rc" +#endif +#ifdef LANGUAGE_DE_DE + #include "lang/de-DE.rc" +#endif +#ifdef LANGUAGE_EN_US + #include "lang/en-US.rc" +#endif +#ifdef LANGUAGE_ES_ES + #include "lang/es-ES.rc" +#endif +#ifdef LANGUAGE_ES_ES + #include "lang/fr-FR.rc" +#endif +#ifdef LANGUAGE_LT_LT + #include "lang/lt-LT.rc" +#endif +#ifdef LANGUAGE_NL_NL + #include "lang/nl-NL.rc" +#endif +#ifdef LANGUAGE_NO_NO + #include "lang/no-NO.rc" +#endif +#ifdef LANGUAGE_PL_PL + #include "lang/pl-PL.rc" +#endif +#ifdef LANGUAGE_RO_RO + #include "lang/ro-RO.rc" +#endif +#ifdef LANGUAGE_SK_SK + #include "lang/sk-SK.rc" +#endif +#ifdef LANGUAGE_UK_UA + #include "lang/uk-UA.rc" +#endif diff --git a/rosapps/applications/screensavers/cylfrac/resource.h b/rosapps/applications/screensavers/cylfrac/resource.h index d19735775c6..cea70e403a0 100644 --- a/rosapps/applications/screensavers/cylfrac/resource.h +++ b/rosapps/applications/screensavers/cylfrac/resource.h @@ -1,3 +1,4 @@ +#pragma once #define IDS_DESCRIPTION 1 #define IDS_TITLE 2