astyle to the rescue!
authorSam Lantinga <slouken@libsdl.org>
Fri, 07 Dec 2012 20:28:52 -0800
changeset 6725a7a99a9d419a
parent 6724 6c5ed0c4cc6d
child 6726 f2898757eaae
astyle to the rescue!
src/video/x11/SDL_x11messagebox.c
     1.1 --- a/src/video/x11/SDL_x11messagebox.c	Fri Dec 07 23:26:28 2012 -0500
     1.2 +++ b/src/video/x11/SDL_x11messagebox.c	Fri Dec 07 20:28:52 2012 -0800
     1.3 @@ -19,8 +19,6 @@
     1.4    3. This notice may not be removed or altered from any source distribution.
     1.5  */
     1.6  
     1.7 -/* !!! FIXME: clean up differences in coding style in this file. */
     1.8 -
     1.9  #include "SDL_config.h"
    1.10  
    1.11  #if SDL_VIDEO_DRIVER_X11
    1.12 @@ -40,21 +38,19 @@
    1.13  static const char g_MessageBoxFontLatin1[] = "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1";
    1.14  static const char g_MessageBoxFont[] = "-*-*-*-*-*-*-*-*-*-*-*-*-*-*";
    1.15  
    1.16 -static const SDL_MessageBoxColor g_default_colors[ SDL_MESSAGEBOX_COLOR_MAX ] =
    1.17 -{
    1.18 -    { 56,  54,  53  }, // SDL_MESSAGEBOX_COLOR_BACKGROUND,       
    1.19 -    { 209, 207, 205 }, // SDL_MESSAGEBOX_COLOR_TEXT,             
    1.20 -    { 140, 135, 129 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,    
    1.21 +static const SDL_MessageBoxColor g_default_colors[ SDL_MESSAGEBOX_COLOR_MAX ] = {
    1.22 +    { 56,  54,  53  }, // SDL_MESSAGEBOX_COLOR_BACKGROUND,
    1.23 +    { 209, 207, 205 }, // SDL_MESSAGEBOX_COLOR_TEXT,
    1.24 +    { 140, 135, 129 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
    1.25      { 105, 102, 99  }, // SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
    1.26 -    { 205, 202, 53  }, // SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,  
    1.27 +    { 205, 202, 53  }, // SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
    1.28  };
    1.29  
    1.30  #define SDL_MAKE_RGB( _r, _g, _b )  ( ( ( Uint32 )( _r ) << 16 ) | \
    1.31                                        ( ( Uint32 )( _g ) << 8 ) |  \
    1.32                                        ( ( Uint32 )( _b ) ) )
    1.33  
    1.34 -typedef struct SDL_MessageBoxButtonDataX11
    1.35 -{
    1.36 +typedef struct SDL_MessageBoxButtonDataX11 {
    1.37      int x, y;                           /* Text position */
    1.38      int length;                         /* Text length */
    1.39      int text_width;                     /* Text width */
    1.40 @@ -64,15 +60,13 @@
    1.41      const SDL_MessageBoxButtonData *buttondata;   /* Button data from caller */
    1.42  } SDL_MessageBoxButtonDataX11;
    1.43  
    1.44 -typedef struct TextLineData
    1.45 -{
    1.46 +typedef struct TextLineData {
    1.47      int width;                          /* Width of this text line */
    1.48      int length;                         /* String length of this text line */
    1.49      const char *text;                   /* Text for this line */
    1.50  } TextLineData;
    1.51  
    1.52 -typedef struct SDL_MessageBoxDataX11
    1.53 -{
    1.54 +typedef struct SDL_MessageBoxDataX11 {
    1.55      XFontSet font_set;                  /* for UTF-8 systems */
    1.56      XFontStruct *font_struct;            /* Latin1 (ASCII) fallback. */
    1.57      Window window;
    1.58 @@ -138,15 +132,13 @@
    1.59      int numbuttons = data->numbuttons;
    1.60      SDL_MessageBoxButtonDataX11 *buttonpos = data->buttonpos;
    1.61  
    1.62 -    for ( i = 0; i < numbuttons; i++ )
    1.63 -    {
    1.64 +    for ( i = 0; i < numbuttons; i++ ) {
    1.65          SDL_Rect *rect = &buttonpos[ i ].rect;
    1.66  
    1.67          if ( ( x >= rect->x ) &&
    1.68 -            ( x <= ( rect->x + rect->w ) ) &&
    1.69 -            ( y >= rect->y ) &&
    1.70 -            ( y <= ( rect->y + rect->h ) ) )
    1.71 -        {
    1.72 +             ( x <= ( rect->x + rect->w ) ) &&
    1.73 +             ( y >= rect->y ) &&
    1.74 +             ( y <= ( rect->y + rect->h ) ) ) {
    1.75              return i;
    1.76          }
    1.77      }
    1.78 @@ -227,13 +219,11 @@
    1.79      const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
    1.80  
    1.81      /* Go over text and break linefeeds into separate lines. */
    1.82 -    if ( messageboxdata->message && messageboxdata->message[ 0 ] )
    1.83 -    {
    1.84 +    if ( messageboxdata->message && messageboxdata->message[ 0 ] ) {
    1.85          const char *text = messageboxdata->message;
    1.86          TextLineData *plinedata = data->linedata;
    1.87  
    1.88 -        for ( i = 0; i < MAX_TEXT_LINES; i++, plinedata++ )
    1.89 -        {
    1.90 +        for ( i = 0; i < MAX_TEXT_LINES; i++, plinedata++ ) {
    1.91              int height;
    1.92              char *lf = SDL_strchr( ( char * )text, '\n' );
    1.93  
    1.94 @@ -261,8 +251,7 @@
    1.95      }
    1.96  
    1.97      /* Loop through all buttons and calculate the button widths and height. */
    1.98 -    for ( i = 0; i < data->numbuttons; i++ )
    1.99 -    {
   1.100 +    for ( i = 0; i < data->numbuttons; i++ ) {
   1.101          int height;
   1.102  
   1.103          data->buttonpos[ i ].buttondata = &data->buttondata[ i ];
   1.104 @@ -275,8 +264,7 @@
   1.105          button_text_height = IntMax( button_text_height, height );
   1.106      }
   1.107  
   1.108 -    if ( data->numlines )
   1.109 -    {
   1.110 +    if ( data->numlines ) {
   1.111          /* x,y for this line of text. */
   1.112          data->xtext = data->text_height;
   1.113          data->ytext = data->text_height + data->text_height;
   1.114 @@ -287,15 +275,12 @@
   1.115          /* Bump the dialog box width and height up if needed. */
   1.116          data->dialog_width = IntMax( data->dialog_width, 2 * data->xtext + text_width_max );
   1.117          data->dialog_height = IntMax( data->dialog_height, ybuttons );
   1.118 -    }
   1.119 -    else
   1.120 -    {
   1.121 +    } else {
   1.122          /* Button y starts at height of button text. */
   1.123          ybuttons = button_text_height;
   1.124      }
   1.125  
   1.126 -    if ( data->numbuttons )
   1.127 -    {
   1.128 +    if ( data->numbuttons ) {
   1.129          int x, y;
   1.130          int width_of_buttons;
   1.131          int button_spacing = button_text_height;
   1.132 @@ -315,8 +300,7 @@
   1.133          x = ( data->dialog_width - width_of_buttons ) / 2;
   1.134          y = ybuttons + ( data->dialog_height - ybuttons - button_height ) / 2;
   1.135  
   1.136 -        for ( i = 0; i < data->numbuttons; i++ )
   1.137 -        {
   1.138 +        for ( i = 0; i < data->numbuttons; i++ ) {
   1.139              /* Button coordinates. */
   1.140              data->buttonpos[ i ].rect.x = x;
   1.141              data->buttonpos[ i ].rect.y = y;
   1.142 @@ -339,22 +323,18 @@
   1.143  static void
   1.144  X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data )
   1.145  {
   1.146 -    if ( data->font_set != NULL )
   1.147 -    {
   1.148 +    if ( data->font_set != NULL ) {
   1.149          XFreeFontSet( data->display, data->font_set );
   1.150          data->font_set = NULL;
   1.151      }
   1.152  
   1.153 -    if ( data->font_struct != NULL )
   1.154 -    {
   1.155 +    if ( data->font_struct != NULL ) {
   1.156          XFreeFont( data->display, data->font_struct );
   1.157          data->font_struct = NULL;
   1.158      }
   1.159  
   1.160 -    if ( data->display )
   1.161 -    {
   1.162 -        if ( data->window != None )
   1.163 -        {
   1.164 +    if ( data->display ) {
   1.165 +        if ( data->window != None ) {
   1.166              XUnmapWindow( data->display, data->window );
   1.167              XDestroyWindow( data->display, data->window );
   1.168              data->window = None;
   1.169 @@ -381,16 +361,16 @@
   1.170      }
   1.171  
   1.172      data->event_mask = ExposureMask |
   1.173 -        ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
   1.174 -        StructureNotifyMask | FocusChangeMask | PointerMotionMask;
   1.175 +                       ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
   1.176 +                       StructureNotifyMask | FocusChangeMask | PointerMotionMask;
   1.177      wnd_attr.event_mask = data->event_mask;
   1.178  
   1.179      data->window = XCreateWindow(
   1.180 -                            display, DefaultRootWindow( display ),
   1.181 -                            0, 0,
   1.182 -                            data->dialog_width, data->dialog_height,
   1.183 -                            0, CopyFromParent, InputOutput, CopyFromParent,
   1.184 -                            CWEventMask, &wnd_attr );
   1.185 +                       display, DefaultRootWindow( display ),
   1.186 +                       0, 0,
   1.187 +                       data->dialog_width, data->dialog_height,
   1.188 +                       0, CopyFromParent, InputOutput, CopyFromParent,
   1.189 +                       CWEventMask, &wnd_attr );
   1.190      if ( data->window == None ) {
   1.191          SDL_SetError("Couldn't create X window");
   1.192          return -1;
   1.193 @@ -455,8 +435,7 @@
   1.194      XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
   1.195  
   1.196      XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
   1.197 -    for ( i = 0; i < data->numlines; i++ )
   1.198 -    {
   1.199 +    for ( i = 0; i < data->numlines; i++ ) {
   1.200          TextLineData *plinedata = &data->linedata[ i ];
   1.201  
   1.202          if (SDL_X11_HAVE_UTF8) {
   1.203 @@ -470,8 +449,7 @@
   1.204          }
   1.205      }
   1.206  
   1.207 -    for ( i = 0; i < data->numbuttons; i++ )
   1.208 -    {
   1.209 +    for ( i = 0; i < data->numbuttons; i++ ) {
   1.210          SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ i ];
   1.211          const SDL_MessageBoxButtonData *buttondata = buttondatax11->buttondata;
   1.212          int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0;
   1.213 @@ -583,8 +561,7 @@
   1.214              last_key_pressed = XLookupKeysym( &e.xkey, 0 );
   1.215              break;
   1.216  
   1.217 -        case KeyRelease:
   1.218 -        {
   1.219 +        case KeyRelease: {
   1.220              Uint32 mask = 0;
   1.221              KeySym key = XLookupKeysym( &e.xkey, 0 );
   1.222