From d185324a264e89b0ee6b69fb8b5885c205e3494c Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 17 Jan 2015 18:31:39 +0000 Subject: [PATCH] Use range_for in menubar --- common/ui/menubar.cpp | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/common/ui/menubar.cpp b/common/ui/menubar.cpp index 611c78128..be52fa599 100644 --- a/common/ui/menubar.cpp +++ b/common/ui/menubar.cpp @@ -34,6 +34,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "func.h" #include "dxxerror.h" +#include "compiler-exchange.h" +#include "compiler-range_for.h" +#include "partial_range.h" #define MAXMENUS 30 #define MAXITEMS 32 @@ -50,7 +53,7 @@ struct MENU : embed_window_pointer_t { short x, y, w, h; short ShowBar; short CurrentItem; - short NumItems; + uint16_t NumItems; short Displayed; short Active; ITEM Item[MAXITEMS]; @@ -58,7 +61,7 @@ struct MENU : embed_window_pointer_t { MENU Menu[MAXMENUS]; -static int num_menus = 0; +static unsigned num_menus; static int state; #define CMENU (Menu[0].CurrentItem+1) @@ -253,10 +256,8 @@ static int menu_check_mouse_item( MENU * menu ) static void menu_hide_all() { - int i; - - for (i=1; i Menu[menu].w ) { Menu[menu].w = w; - for (i=0; i< Menu[menu].NumItems; i++ ) - Menu[menu].Item[i].w = Menu[menu].w; + range_for (auto &i, partial_range(Menu[menu].Item, Menu[menu].NumItems)) + i.w = Menu[menu].w; } Menu[menu].Item[item].w = Menu[menu].w; Menu[menu].Item[item].x = Menu[menu].x;