@@ -82,7 +82,7 @@ typedef struct SDL_MessageBoxButtonDataX11
82
82
int text_a ;
83
83
int text_d ;
84
84
85
- SDL_Rect text_rct ;
85
+ SDL_Rect text_rect ;
86
86
SDL_Rect rect ; // Rectangle for entire button
87
87
88
88
const SDL_MessageBoxButtonData * buttondata ; // Button data from caller
@@ -92,7 +92,7 @@ typedef struct TextLineData
92
92
{
93
93
int length ; // String length of this text line
94
94
const char * text ; // Text for this line
95
- SDL_Rect rct ;
95
+ SDL_Rect rect ;
96
96
} TextLineData ;
97
97
98
98
typedef struct SDL_MessageBoxDataX11
@@ -224,7 +224,6 @@ static bool X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBox
224
224
data -> buttondata = buttondata ;
225
225
data -> numbuttons = numbuttons ;
226
226
data -> pbuttonid = pbuttonid ;
227
-
228
227
229
228
// Convert flags to icon character
230
229
switch (data -> messageboxdata -> flags & (SDL_MESSAGEBOX_ERROR | SDL_MESSAGEBOX_WARNING | SDL_MESSAGEBOX_INFORMATION )) {
@@ -283,7 +282,7 @@ static bool X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBox
283
282
if (!data -> icon_char_font ) {
284
283
data -> icon_char_font = X11_XLoadQueryFont (data -> display , g_MessageBoxFontLatin1 );
285
284
if (!data -> icon_char_font ) {
286
- return SDL_SetError ( "Couldn't load icon font %s" , g_MessageBoxFontLatin1 ) ;
285
+ data -> icon_char = '\0' ;
287
286
}
288
287
}
289
288
}
@@ -350,14 +349,18 @@ static bool X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data)
350
349
int icon_char_w ;
351
350
int icon_char_h ;
352
351
int icon_char_a ;
353
-
352
+ int icon_char_max ;
353
+
354
354
GetTextWidthHeightForFont (data , data -> icon_char_font , & data -> icon_char , 1 , & icon_char_w , & icon_char_h , & icon_char_a );
355
355
data -> icon_box_rect .w = icon_char_w + paddingx2 ;
356
356
data -> icon_box_rect .h = icon_char_h + paddingx2 ;
357
+ icon_char_max = IntMax (data -> icon_box_rect .w , data -> icon_box_rect .h );
358
+ data -> icon_box_rect .w = icon_char_max ;
359
+ data -> icon_box_rect .h = icon_char_max ;
357
360
data -> icon_box_rect .y = 0 ;
358
361
data -> icon_box_rect .x = 0 ;
359
- data -> icon_char_y = icon_char_a + data -> icon_box_rect .y + SDL_DIALOG_ELEMENT_PADDING ;
360
- data -> icon_char_x = data -> icon_box_rect .x + SDL_DIALOG_ELEMENT_PADDING ;
362
+ data -> icon_char_y = icon_char_a + data -> icon_box_rect .y + ( data -> icon_box_rect . h - icon_char_h )/ 2 + 1 ;
363
+ data -> icon_char_x = data -> icon_box_rect .x + ( data -> icon_box_rect . w - icon_char_w )/ 2 + 1 ;
361
364
}
362
365
363
366
// Go over text and break linefeeds into separate lines.
@@ -383,23 +386,23 @@ static bool X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data)
383
386
384
387
plinedata [i ].text = text ;
385
388
386
- GetTextWidthHeight (data , text , length , & plinedata [i ].rct .w , & plinedata [i ].rct .h , & ascent , & descent );
389
+ GetTextWidthHeight (data , text , length , & plinedata [i ].rect .w , & plinedata [i ].rect .h , & ascent , & descent );
387
390
388
391
// Text widths are the largest we've ever seen.
389
- text_width_max = IntMax (text_width_max , plinedata [i ].rct .w );
392
+ text_width_max = IntMax (text_width_max , plinedata [i ].rect .w );
390
393
391
394
plinedata [i ].length = length ;
392
395
if (lf && (lf > text ) && (lf [-1 ] == '\r' )) {
393
396
plinedata [i ].length -- ;
394
397
}
395
398
396
399
if (i > 0 ) {
397
- plinedata [i ].rct .y = ascent + descent + plinedata [i - 1 ].rct .y ;
400
+ plinedata [i ].rect .y = ascent + descent + plinedata [i - 1 ].rect .y ;
398
401
} else {
399
- plinedata [i ].rct .y = data -> icon_box_rect .y + SDL_DIALOG_ELEMENT_PADDING + ascent ;
402
+ plinedata [i ].rect .y = data -> icon_box_rect .y + SDL_DIALOG_ELEMENT_PADDING + ascent ;
400
403
iascent = ascent ;
401
404
}
402
- plinedata [i ].rct .x = text_ix = data -> icon_box_rect .x + data -> icon_box_rect .w + SDL_DIALOG_ELEMENT_PADDING_2 ;
405
+ plinedata [i ].rect .x = text_ix = data -> icon_box_rect .x + data -> icon_box_rect .w + SDL_DIALOG_ELEMENT_PADDING_2 ;
403
406
text += length + 1 ;
404
407
405
408
// Break if there are no more linefeeds.
@@ -408,18 +411,18 @@ static bool X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data)
408
411
}
409
412
}
410
413
411
- text_height_total = plinedata [linecount - 1 ].rct .y + plinedata [linecount - 1 ].rct .h - iascent - data -> icon_box_rect .y - SDL_DIALOG_ELEMENT_PADDING ;
414
+ text_height_total = plinedata [linecount - 1 ].rect .y + plinedata [linecount - 1 ].rect .h - iascent - data -> icon_box_rect .y - SDL_DIALOG_ELEMENT_PADDING ;
412
415
}
413
416
414
417
// Loop through all buttons and calculate the button widths and height.
415
418
for (i = 0 ; i < data -> numbuttons ; i ++ ) {
416
419
data -> buttonpos [i ].buttondata = & data -> buttondata [i ];
417
420
data -> buttonpos [i ].length = SDL_strlen (data -> buttondata [i ].text );
418
421
419
- GetTextWidthHeight (data , data -> buttondata [i ].text , SDL_strlen (data -> buttondata [i ].text ), & data -> buttonpos [i ].text_rct .w , & data -> buttonpos [i ].text_rct .h , & data -> buttonpos [i ].text_a , & data -> buttonpos [i ].text_d );
422
+ GetTextWidthHeight (data , data -> buttondata [i ].text , SDL_strlen (data -> buttondata [i ].text ), & data -> buttonpos [i ].text_rect .w , & data -> buttonpos [i ].text_rect .h , & data -> buttonpos [i ].text_a , & data -> buttonpos [i ].text_d );
420
423
421
- button_height_max = IntMax (button_height_max , (data -> buttonpos [i ].text_rct .h + SDL_DIALOG_ELEMENT_PADDING_3 * 2 ));
422
- button_width_max = IntMax (button_width_max , (data -> buttonpos [i ].text_rct .w + padding2x2 ));
424
+ button_height_max = IntMax (button_height_max , (data -> buttonpos [i ].text_rect .h + SDL_DIALOG_ELEMENT_PADDING_3 * 2 ));
425
+ button_width_max = IntMax (button_width_max , (data -> buttonpos [i ].text_rect .w + padding2x2 ));
423
426
424
427
}
425
428
button_width_total = button_width_max * data -> numbuttons + SDL_DIALOG_ELEMENT_PADDING * (data -> numbuttons - 1 );
@@ -450,55 +453,55 @@ static bool X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data)
450
453
}
451
454
}
452
455
for (i = 0 ; i < data -> numlines ; i ++ ) {
453
- data -> linedata [i ].rct .x += t ;
456
+ data -> linedata [i ].rect .x += t ;
454
457
}
455
458
456
459
/* Button poistioning */
457
460
for (i = 0 ; i < data -> numbuttons ; i ++ ) {
458
461
data -> buttonpos [i ].rect .w = button_width_max ;
459
- data -> buttonpos [i ].text_rct .x = (data -> buttonpos [i ].rect .w - data -> buttonpos [i ].text_rct .w )/2 ;
462
+ data -> buttonpos [i ].text_rect .x = (data -> buttonpos [i ].rect .w - data -> buttonpos [i ].text_rect .w )/2 ;
460
463
data -> buttonpos [i ].rect .h = button_height_max ;
461
- data -> buttonpos [i ].text_rct .y = data -> buttonpos [i ].text_a + (data -> buttonpos [i ].rect .h - data -> buttonpos [i ].text_rct .h )/2 ;
464
+ data -> buttonpos [i ].text_rect .y = data -> buttonpos [i ].text_a + (data -> buttonpos [i ].rect .h - data -> buttonpos [i ].text_rect .h )/2 ;
462
465
if (i > 0 ) {
463
466
data -> buttonpos [i ].rect .x += data -> buttonpos [i - 1 ].rect .x + data -> buttonpos [i - 1 ].rect .w + SDL_DIALOG_ELEMENT_PADDING_3 ;
464
- data -> buttonpos [i ].text_rct .x += data -> buttonpos [i ].rect .x ;
467
+ data -> buttonpos [i ].text_rect .x += data -> buttonpos [i ].rect .x ;
465
468
}
466
469
}
467
470
button_width_total = data -> buttonpos [data -> numbuttons - 1 ].rect .x + data -> buttonpos [data -> numbuttons - 1 ].rect .w ;
468
471
data -> dialog_width = IntMax (data -> dialog_width , (button_width_total + padding2x2 ));
469
472
if (messageboxdata -> flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT ) {
470
473
for (i = 0 ; i < data -> numbuttons ; i ++ ) {
471
474
data -> buttonpos [i ].rect .x += (data -> dialog_width - button_width_total )/2 ;
472
- data -> buttonpos [i ].text_rct .x += (data -> dialog_width - button_width_total )/2 ;
475
+ data -> buttonpos [i ].text_rect .x += (data -> dialog_width - button_width_total )/2 ;
473
476
if (data -> icon_box_rect .h > text_height_total ) {
474
- data -> buttonpos [i ].text_rct .y += data -> icon_box_rect .h + SDL_DIALOG_ELEMENT_PADDING_2 ;
477
+ data -> buttonpos [i ].text_rect .y += data -> icon_box_rect .h + SDL_DIALOG_ELEMENT_PADDING_2 - 2 ;
475
478
data -> buttonpos [i ].rect .y += data -> icon_box_rect .h + SDL_DIALOG_ELEMENT_PADDING_2 ;
476
479
} else {
477
480
int a ;
478
481
479
482
a = 0 ;
480
483
if (data -> numlines ) {
481
- a = data -> linedata [data -> numlines - 1 ].rct .y + data -> linedata [data -> numlines - 1 ].rct .h ;
484
+ a = data -> linedata [data -> numlines - 1 ].rect .y + data -> linedata [data -> numlines - 1 ].rect .h ;
482
485
}
483
- data -> buttonpos [i ].text_rct .y += a + SDL_DIALOG_ELEMENT_PADDING_2 ;
486
+ data -> buttonpos [i ].text_rect .y += a + SDL_DIALOG_ELEMENT_PADDING_2 - 2 ;
484
487
data -> buttonpos [i ].rect .y += a + SDL_DIALOG_ELEMENT_PADDING_2 ;
485
488
}
486
489
}
487
490
} else {
488
491
for (i = data -> numbuttons ; i != -1 ; i -- ) {
489
492
data -> buttonpos [i ].rect .x += (data -> dialog_width - button_width_total )/2 ;
490
- data -> buttonpos [i ].text_rct .x += (data -> dialog_width - button_width_total )/2 ;
493
+ data -> buttonpos [i ].text_rect .x += (data -> dialog_width - button_width_total )/2 ;
491
494
if (data -> icon_box_rect .h > text_height_total ) {
492
- data -> buttonpos [i ].text_rct .y += data -> icon_box_rect .h + SDL_DIALOG_ELEMENT_PADDING_2 ;
495
+ data -> buttonpos [i ].text_rect .y += data -> icon_box_rect .h + SDL_DIALOG_ELEMENT_PADDING_2 - 2 ;
493
496
data -> buttonpos [i ].rect .y += data -> icon_box_rect .h + SDL_DIALOG_ELEMENT_PADDING_2 ;
494
497
} else {
495
498
int a ;
496
499
497
500
a = 0 ;
498
501
if (data -> numlines ) {
499
- a = data -> linedata [data -> numlines - 1 ].rct .y + data -> linedata [data -> numlines - 1 ].rct .h ;
502
+ a = data -> linedata [data -> numlines - 1 ].rect .y + data -> linedata [data -> numlines - 1 ].rect .h ;
500
503
}
501
- data -> buttonpos [i ].text_rct .y += a + SDL_DIALOG_ELEMENT_PADDING_2 ;
504
+ data -> buttonpos [i ].text_rect .y += a + SDL_DIALOG_ELEMENT_PADDING_2 - 2 ;
502
505
data -> buttonpos [i ].rect .y += a + SDL_DIALOG_ELEMENT_PADDING_2 ;
503
506
}
504
507
}
@@ -513,11 +516,11 @@ static bool X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data)
513
516
data -> icon_char_y += t ;
514
517
}
515
518
for (i = 0 ; i < data -> numbuttons ; i ++ ) {
516
- data -> buttonpos [i ].text_rct .y += t ;
519
+ data -> buttonpos [i ].text_rect .y += t ;
517
520
data -> buttonpos [i ].rect .y += t ;
518
521
}
519
522
for (i = 0 ; i < data -> numlines ; i ++ ) {
520
- data -> linedata [i ].rct .y += t ;
523
+ data -> linedata [i ].rect .y += t ;
521
524
}
522
525
return true;
523
526
}
@@ -738,7 +741,7 @@ static void X11_MessageBoxDraw(SDL_MessageBoxDataX11 *data, GC ctx, bool utf8)
738
741
739
742
if (data -> icon_char != '\0' ) {
740
743
X11_XSetForeground (display , ctx , data -> xcolor [SDL_MESSAGEBOX_COLOR_TEXT ].pixel );
741
- X11_XFillRectangle (display , window , ctx , data -> icon_box_rect .x , data -> icon_box_rect .y , data -> icon_box_rect .w , data -> icon_box_rect .h );
744
+ X11_XFillArc (display , window , ctx , data -> icon_box_rect .x , data -> icon_box_rect .y , data -> icon_box_rect .w , data -> icon_box_rect .h , 0 , 360 * 64 );
742
745
743
746
X11_XSetFont (display , ctx , data -> icon_char_font -> fid );
744
747
X11_XSetForeground (display , ctx , data -> xcolor [SDL_MESSAGEBOX_COLOR_BACKGROUND ].pixel );
@@ -755,13 +758,13 @@ static void X11_MessageBoxDraw(SDL_MessageBoxDataX11 *data, GC ctx, bool utf8)
755
758
#ifdef X_HAVE_UTF8_STRING
756
759
if (SDL_X11_HAVE_UTF8 ) {
757
760
X11_Xutf8DrawString (display , window , data -> font_set , ctx ,
758
- plinedata -> rct .x , plinedata -> rct .y ,
761
+ plinedata -> rect .x , plinedata -> rect .y ,
759
762
plinedata -> text , plinedata -> length );
760
763
} else
761
764
#endif
762
765
{
763
766
X11_XDrawString (display , window , ctx ,
764
- plinedata -> rct .x , plinedata -> rct .y ,
767
+ plinedata -> rect .x , plinedata -> rect .y ,
765
768
plinedata -> text , plinedata -> length );
766
769
}
767
770
}
@@ -788,14 +791,14 @@ static void X11_MessageBoxDraw(SDL_MessageBoxDataX11 *data, GC ctx, bool utf8)
788
791
#ifdef X_HAVE_UTF8_STRING
789
792
if (SDL_X11_HAVE_UTF8 ) {
790
793
X11_Xutf8DrawString (display , window , data -> font_set , ctx ,
791
- buttondatax11 -> text_rct .x ,
792
- buttondatax11 -> text_rct .y ,
794
+ buttondatax11 -> text_rect .x ,
795
+ buttondatax11 -> text_rect .y ,
793
796
buttondata -> text , buttondatax11 -> length );
794
797
} else
795
798
#endif
796
799
{
797
800
X11_XDrawString (display , window , ctx ,
798
- buttondatax11 -> text_rct .x , buttondatax11 -> text_rct .y ,
801
+ buttondatax11 -> text_rect .x , buttondatax11 -> text_rect .y ,
799
802
buttondata -> text , buttondatax11 -> length );
800
803
}
801
804
}
@@ -1007,20 +1010,20 @@ static bool X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int
1007
1010
1008
1011
// Init and display the message box.
1009
1012
if (!X11_MessageBoxInit (& data , messageboxdata , buttonID )) {
1010
- goto INIT_BAIL ;
1013
+ goto done ;
1011
1014
}
1012
1015
1013
1016
if (!X11_MessageBoxInitPositions (& data )) {
1014
- goto INIT_BAIL ;
1017
+ goto done ;
1015
1018
}
1016
1019
1017
1020
if (!X11_MessageBoxCreateWindow (& data )) {
1018
- goto INIT_BAIL ;
1021
+ goto done ;
1019
1022
}
1020
1023
1021
1024
result = X11_MessageBoxLoop (& data );
1022
1025
1023
- INIT_BAIL :
1026
+ done :
1024
1027
X11_MessageBoxShutdown (& data );
1025
1028
#if SDL_SET_LOCALE
1026
1029
if (origlocale ) {
0 commit comments