21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_WINDOWS 25 #include "../../core/windows/SDL_windows.h" 31 #ifndef SS_EDITCONTROL 32 #define SS_EDITCONTROL 0x2000 69 DLGTEMPLATEEX* lpDialog;
76 static INT_PTR MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
81 EndDialog(hDlg, LOWORD(wParam));
90 static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog,
size_t space)
92 size_t size = dialog->size;
97 while ((dialog->used + space) > size) {
101 if (size > dialog->size) {
109 dialog->lpDialog = (DLGTEMPLATEEX*)dialog->data;
114 static SDL_bool AlignDialogData(WIN_DialogData *dialog,
size_t size)
116 size_t padding = (dialog->used %
size);
118 if (!ExpandDialogSpace(dialog, padding)) {
122 dialog->used += padding;
127 static SDL_bool AddDialogData(WIN_DialogData *dialog,
const void *
data,
size_t size)
129 if (!ExpandDialogSpace(dialog, size)) {
133 SDL_memcpy(dialog->data+dialog->used, data, size);
134 dialog->used +=
size;
139 static SDL_bool AddDialogString(WIN_DialogData *dialog,
const char *
string)
157 for (p = wstring; *
p; ++
p) {
162 status = AddDialogData(dialog, wstring, count*
sizeof(WCHAR));
167 static int s_BaseUnitsX;
168 static int s_BaseUnitsY;
169 static void Vec2ToDLU(
short *
x,
short *
y)
173 *x = MulDiv(*x, 4, s_BaseUnitsX);
174 *y = MulDiv(*y, 8, s_BaseUnitsY);
178 static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD
type, DWORD style, DWORD exStyle,
int x,
int y,
int w,
int h,
int id,
const char *caption)
180 DLGITEMTEMPLATEEX item;
186 item.exStyle = exStyle;
193 Vec2ToDLU(&item.x, &item.y);
194 Vec2ToDLU(&item.cx, &item.cy);
196 if (!AlignDialogData(dialog,
sizeof(DWORD))) {
199 if (!AddDialogData(dialog, &item,
sizeof(item))) {
202 if (!AddDialogData(dialog, &marker,
sizeof(marker))) {
205 if (!AddDialogData(dialog, &type,
sizeof(type))) {
208 if (!AddDialogString(dialog, caption)) {
211 if (!AddDialogData(dialog, &extraData,
sizeof(extraData))) {
214 ++dialog->lpDialog->cDlgItems;
219 static SDL_bool AddDialogStatic(WIN_DialogData *dialog,
int x,
int y,
int w,
int h,
const char *
text)
221 DWORD style = WS_VISIBLE | WS_CHILD | SS_LEFT | SS_NOPREFIX | SS_EDITCONTROL;
222 return AddDialogControl(dialog, 0x0082, style, 0, x, y, w, h, -1, text);
225 static SDL_bool AddDialogButton(WIN_DialogData *dialog,
int x,
int y,
int w,
int h,
const char *
text,
int id,
SDL_bool isDefault)
227 DWORD style = WS_VISIBLE | WS_CHILD;
229 style |= BS_DEFPUSHBUTTON;
231 style |= BS_PUSHBUTTON;
233 return AddDialogControl(dialog, 0x0080, style, 0, x, y, w, h,
id, text);
236 static void FreeDialogData(WIN_DialogData *dialog)
242 static WIN_DialogData *CreateDialogData(
int w,
int h,
const char *caption)
244 WIN_DialogData *dialog;
245 DLGTEMPLATEEX dialogTemplate;
249 dialogTemplate.dlgVer = 1;
250 dialogTemplate.signature = 0xffff;
251 dialogTemplate.style = (WS_CAPTION | DS_CENTER | DS_SHELLFONT);
252 dialogTemplate.x = 0;
253 dialogTemplate.y = 0;
254 dialogTemplate.cx =
w;
255 dialogTemplate.cy =
h;
256 Vec2ToDLU(&dialogTemplate.cx, &dialogTemplate.cy);
258 dialog = (WIN_DialogData *)
SDL_calloc(1,
sizeof(*dialog));
263 if (!AddDialogData(dialog, &dialogTemplate,
sizeof(dialogTemplate))) {
264 FreeDialogData(dialog);
270 if (!AddDialogData(dialog, &WordToPass, 2)) {
271 FreeDialogData(dialog);
276 if (!AddDialogData(dialog, &WordToPass, 2)) {
277 FreeDialogData(dialog);
282 if (!AddDialogString(dialog, caption)) {
283 FreeDialogData(dialog);
294 NONCLIENTMETRICSA NCM;
295 NCM.cbSize =
sizeof(NCM);
296 SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0);
300 HDC ScreenDC = GetDC(
NULL);
301 int LogicalPixelsY = GetDeviceCaps(ScreenDC, LOGPIXELSY);
304 WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / LogicalPixelsY);
305 ReleaseDC(
NULL, ScreenDC);
308 if (!AddDialogData(dialog, &WordToPass, 2)) {
309 FreeDialogData(dialog);
314 WordToPass = (WORD)NCM.lfMessageFont.lfWeight;
315 if (!AddDialogData(dialog, &WordToPass, 2)) {
316 FreeDialogData(dialog);
321 ToPass = NCM.lfMessageFont.lfItalic;
322 if (!AddDialogData(dialog, &ToPass, 1)) {
323 FreeDialogData(dialog);
328 ToPass = NCM.lfMessageFont.lfCharSet;
329 if (!AddDialogData(dialog, &ToPass, 1)) {
330 FreeDialogData(dialog);
335 if (!AddDialogString(dialog, NCM.lfMessageFont.lfFaceName)) {
336 FreeDialogData(dialog);
347 WIN_DialogData *dialog;
358 const int ButtonWidth = 88;
359 const int ButtonHeight = 26;
360 const int TextMargin = 16;
361 const int ButtonMargin = 12;
396 HDC FontDC = CreateCompatibleDC(0);
401 NONCLIENTMETRICS NCM;
402 NCM.cbSize =
sizeof(NCM);
403 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0);
404 lf = NCM.lfMessageFont;
405 DialogFont = CreateFontIndirect(&lf);
409 SelectObject(FontDC, DialogFont);
413 GetTextMetrics(FontDC, &TM);
414 s_BaseUnitsX = TM.tmAveCharWidth + 1;
415 s_BaseUnitsY = TM.tmHeight;
421 Size.cx = DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT);
425 TextSize.bottom += 2;
432 Size.cx = TextSize.right - TextSize.left;
433 Size.cy = TextSize.bottom - TextSize.top;
434 Size.cx += TextMargin * 2;
435 Size.cy += TextMargin * 2;
438 if (Size.cx < messageboxdata->
numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin)
439 Size.cx = messageboxdata->
numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin;
442 Size.cy += ButtonHeight + TextMargin;
444 dialog = CreateDialogData(Size.cx, Size.cy, messageboxdata->
title);
449 if (!AddDialogStatic(dialog, TextMargin, TextMargin, TextSize.right - TextSize.left, TextSize.bottom - TextSize.top, messageboxdata->
message)) {
450 FreeDialogData(dialog);
455 x = Size.cx - (ButtonWidth + ButtonMargin) * messageboxdata->
numbuttons;
456 y = Size.cy - ButtonHeight - ButtonMargin;
457 for (i = messageboxdata->
numbuttons - 1; i >= 0; --i) {
465 if (!AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttons[i].text, i, isDefault)) {
466 FreeDialogData(dialog);
469 x += ButtonWidth + ButtonMargin;
473 which = DialogBoxIndirect(
NULL, (DLGTEMPLATE*)dialog->lpDialog,
NULL, (DLGPROC)MessageBoxDialogProc);
474 *buttonid = buttons[which].
buttonid;
476 FreeDialogData(dialog);
#define WIN_UTF8ToString(S)
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
GLuint GLuint GLsizei GLenum type
void * SDL_calloc(size_t nmemb, size_t size)
GLint GLint GLint GLint GLint GLint y
uint8_t Uint8
An unsigned 8-bit integer type.
const SDL_MessageBoxButtonData * buttons
MessageBox structure containing title, text, window, etc.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_assert(condition)
#define SDL_OutOfMemory()
static char text[MAX_TEXT_LENGTH]
GLubyte GLubyte GLubyte GLubyte w
GLfloat GLfloat GLfloat GLfloat h