shcore: Use CRT allocation functions.
[wine.git] / dlls / uxtheme / window.c
blobd059a85b297ded3a5dfa241796214b310f7c03bf
1 /*
2 * Window theming support
4 * Copyright 2022 Zhiyi Zhang for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "winuser.h"
27 #include "uxthemedll.h"
28 #include "vssym32.h"
30 static void uxtheme_draw_menu_button(HTHEME theme, HWND hwnd, HDC hdc, enum NONCLIENT_BUTTON_TYPE type,
31 RECT rect, BOOL down, BOOL grayed)
33 int part, state;
35 switch (type)
37 case MENU_CLOSE_BUTTON:
38 part = WP_MDICLOSEBUTTON;
39 break;
40 case MENU_MIN_BUTTON:
41 part = WP_MDIMINBUTTON;
42 break;
43 case MENU_RESTORE_BUTTON:
44 part = WP_MDIRESTOREBUTTON;
45 break;
46 case MENU_HELP_BUTTON:
47 part = WP_MDIHELPBUTTON;
48 break;
49 /* There is no WP_MDIMAXBUTTON */
50 default:
51 user_api.pNonClientButtonDraw(hwnd, hdc, type, rect, down, grayed);
52 return;
55 if (grayed)
56 state = MINBS_DISABLED;
57 else if (down)
58 state = MINBS_PUSHED;
59 else
60 state = MINBS_NORMAL;
62 if (IsThemeBackgroundPartiallyTransparent(theme, part, state))
63 DrawThemeParentBackground(hwnd, hdc, &rect);
64 DrawThemeBackground(theme, hdc, part, state, &rect, NULL);
67 void WINAPI UXTHEME_NonClientButtonDraw(HWND hwnd, HDC hdc, enum NONCLIENT_BUTTON_TYPE type,
68 RECT rect, BOOL down, BOOL grayed)
70 HTHEME theme;
72 theme = OpenThemeDataForDpi(NULL, L"Window", GetDpiForWindow(hwnd));
73 if (!theme)
75 user_api.pNonClientButtonDraw(hwnd, hdc, type, rect, down, grayed);
76 return;
79 switch (type)
81 case MENU_CLOSE_BUTTON:
82 case MENU_MIN_BUTTON:
83 case MENU_MAX_BUTTON:
84 case MENU_RESTORE_BUTTON:
85 case MENU_HELP_BUTTON:
86 uxtheme_draw_menu_button(theme, hwnd, hdc, type, rect, down, grayed);
87 break;
90 CloseThemeData(theme);