$OpenBSD: patch-widgets_cpp,v 1.1 2018/04/11 12:21:47 sthen Exp $

Index: widgets.cpp
--- widgets.cpp.orig
+++ widgets.cpp
@@ -38,8 +38,8 @@ Button::Button(int x, int y, int w, int h, Font *font,
 
     SDL_Surface *s = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
             24, 0x00FF0000, 0x0000FF00, 0x000000FF, 0/*0xFF000000*/);
-    SDL_Rect src = { x, y, width, height };
-    SDL_Rect dst = { 0, 0, width, height };
+    SDL_Rect src = { static_cast<Sint16>(x), static_cast<Sint16>(y), static_cast<Uint16>(width), static_cast<Uint16>(height) };
+    SDL_Rect dst = { 0, 0, static_cast<Uint16>(width), static_cast<Uint16>(height) };
     SDL_BlitSurface(screen.getSurface(), &src, s, &dst);
     
     int tW, tH;
@@ -71,8 +71,8 @@ Button::Button(int x, int y, int w, int h, Font *font,
             s->format->Bmask, s->format->Amask);
 
     SDL_Surface *tile = loadImage(bg, true);
-    SDL_Rect src = { 0, 0, tile->w, tile->h };
-    SDL_Rect dst = { 0, 0, tile->w, tile->h };
+    SDL_Rect src = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
+    SDL_Rect dst = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
     for (int j = 0; j < height; j += tile->h)
         for (int i = 0; i < width; i += tile->w) {
             dst.x = i;
@@ -117,8 +117,8 @@ Button::Button(int x, int y, int w, int h, Font *font,
             s->format->Bmask, s->format->Amask);
 
     SDL_Surface *tile = loadImage(bg);
-    SDL_Rect src = { 0, 0, tile->w, tile->h };
-    SDL_Rect dst = { 0, 0, tile->w, tile->h };
+    SDL_Rect src = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
+    SDL_Rect dst = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
     for (int j = 0; j < height; j += tile->h)
         for (int i = 0; i < width; i += tile->w) {
             dst.x = i;
@@ -436,8 +436,8 @@ Window::Window(int x, int y, int w, int h, const std::
             s->format->Bmask, s->format->Amask);
 
     SDL_Surface *tile = loadImage(bg);
-    SDL_Rect src = { 0, 0, tile->w, tile->h };
-    SDL_Rect dst = { 0, 0, tile->w, tile->h };
+    SDL_Rect src = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
+    SDL_Rect dst = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
     for (int j = 0; j < height; j += tile->h)
         for (int i = 0; i < width; i += tile->w) {
             dst.x = i;
@@ -582,7 +582,7 @@ void InputField::draw()
 {
     Window::draw();
 
-    SDL_Rect rect = { left+1, top+1, width-2, height-2 };
+    SDL_Rect rect = { static_cast<Sint16>(left+1), static_cast<Sint16>(top+1), static_cast<Uint16>(width-2), static_cast<Uint16>(height-2) };
     SDL_SetClipRect(screen.getSurface(), &rect);
     
     font->draw(left+1, top+1, red,green,blue, true, text);
@@ -721,8 +721,8 @@ Checkbox::Checkbox(int x, int y, int w, int h, Font *f
             s->format->Bmask, s->format->Amask);
 
     SDL_Surface *tile = loadImage(bg);
-    SDL_Rect src = { 0, 0, tile->w, tile->h };
-    SDL_Rect dst = { 0, 0, tile->w, tile->h };
+    SDL_Rect src = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
+    SDL_Rect dst = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
     for (int j = 0; j < height; j += tile->h)
         for (int i = 0; i < width; i += tile->w) {
             dst.x = i;
@@ -917,8 +917,8 @@ void Slider::createSlider(int size)
             s->format->Bmask, s->format->Amask);
 
     SDL_Surface *tile = loadImage(L"blue.bmp");
-    SDL_Rect src = { 0, 0, tile->w, tile->h };
-    SDL_Rect dst = { 0, 0, tile->w, tile->h };
+    SDL_Rect src = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
+    SDL_Rect dst = { 0, 0, static_cast<Uint16>(tile->w), static_cast<Uint16>(tile->h) };
     for (int j = 0; j < size; j += tile->h)
         for (int i = 0; i < size; i += tile->w) {
             dst.x = i;
