comparison template/dw.c @ 2740:9be24001d288

Style update. Add DW_SIZE_AUTO (-1) for passing automatic sizing to packing. Also convert SIZEEXPAND/STATIC and TYPEBOX/ITEM to the new format based on our new style guidelines. as _DW_SIZE_EXPAND/STATIC and _DW_TYPE_BOX/ITEM.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 19 Dec 2021 15:39:43 +0000
parents 2acc7ba5dea0
children ee1cfa7d645e
comparison
equal deleted inserted replaced
2739:02c53dd5e21d 2740:9be24001d288
73 /* Count up all the space for all items in the box */ 73 /* Count up all the space for all items in the box */
74 for(z=0;z<thisbox->count;z++) 74 for(z=0;z<thisbox->count;z++)
75 { 75 {
76 int itempad, itemwidth, itemheight; 76 int itempad, itemwidth, itemheight;
77 77
78 if(thisbox->items[z].type == TYPEBOX) 78 if(thisbox->items[z].type == _DW_TYPE_BOX)
79 { 79 {
80 Box *tmp = (Box *)_dw_window_pointer_get(thisbox->items[z].hwnd); 80 Box *tmp = (Box *)_dw_window_pointer_get(thisbox->items[z].hwnd);
81 81
82 if(tmp) 82 if(tmp)
83 { 83 {
109 if(thisbox->type == DW_VERT) 109 if(thisbox->type == DW_VERT)
110 { 110 {
111 if(itemwidth > uxmax) 111 if(itemwidth > uxmax)
112 uxmax = itemwidth; 112 uxmax = itemwidth;
113 113
114 if(thisbox->items[z].hsize != SIZEEXPAND) 114 if(thisbox->items[z].hsize != _DW_SIZE_EXPAND)
115 { 115 {
116 if(itemwidth > upxmax) 116 if(itemwidth > upxmax)
117 upxmax = itemwidth; 117 upxmax = itemwidth;
118 } 118 }
119 else 119 else
120 { 120 {
121 if(itempad > upxmax) 121 if(itempad > upxmax)
122 upxmax = itempad; 122 upxmax = itempad;
123 } 123 }
124 thisbox->minheight += itemheight; 124 thisbox->minheight += itemheight;
125 if(thisbox->items[z].vsize != SIZEEXPAND) 125 if(thisbox->items[z].vsize != _DW_SIZE_EXPAND)
126 thisbox->usedpady += itemheight; 126 thisbox->usedpady += itemheight;
127 else 127 else
128 thisbox->usedpady += itempad; 128 thisbox->usedpady += itempad;
129 } 129 }
130 else 130 else
131 { 131 {
132 if(itemheight > uymax) 132 if(itemheight > uymax)
133 uymax = itemheight; 133 uymax = itemheight;
134 if(thisbox->items[z].vsize != SIZEEXPAND) 134 if(thisbox->items[z].vsize != _DW_SIZE_EXPAND)
135 { 135 {
136 if(itemheight > upymax) 136 if(itemheight > upymax)
137 upymax = itemheight; 137 upymax = itemheight;
138 } 138 }
139 else 139 else
140 { 140 {
141 if(itempad > upymax) 141 if(itempad > upymax)
142 upymax = itempad; 142 upymax = itempad;
143 } 143 }
144 thisbox->minwidth += itemwidth; 144 thisbox->minwidth += itemwidth;
145 if(thisbox->items[z].hsize != SIZEEXPAND) 145 if(thisbox->items[z].hsize != _DW_SIZE_EXPAND)
146 thisbox->usedpadx += itemwidth; 146 thisbox->usedpadx += itemwidth;
147 else 147 else
148 thisbox->usedpadx += itempad; 148 thisbox->usedpadx += itempad;
149 } 149 }
150 } 150 }
171 int width = thisbox->items[z].width; 171 int width = thisbox->items[z].width;
172 int itempad = thisbox->items[z].pad * 2; 172 int itempad = thisbox->items[z].pad * 2;
173 int thispad = thisbox->pad * 2; 173 int thispad = thisbox->pad * 2;
174 174
175 /* Calculate the new sizes */ 175 /* Calculate the new sizes */
176 if(thisbox->items[z].hsize == SIZEEXPAND) 176 if(thisbox->items[z].hsize == _DW_SIZE_EXPAND)
177 { 177 {
178 if(thisbox->type == DW_HORZ) 178 if(thisbox->type == DW_HORZ)
179 { 179 {
180 int expandablex = thisbox->minwidth - thisbox->usedpadx; 180 int expandablex = thisbox->minwidth - thisbox->usedpadx;
181 181
183 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx)); 183 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx));
184 } 184 }
185 else 185 else
186 width = x - (itempad + thispad + thisbox->grouppadx); 186 width = x - (itempad + thispad + thisbox->grouppadx);
187 } 187 }
188 if(thisbox->items[z].vsize == SIZEEXPAND) 188 if(thisbox->items[z].vsize == _DW_SIZE_EXPAND)
189 { 189 {
190 if(thisbox->type == DW_VERT) 190 if(thisbox->type == DW_VERT)
191 { 191 {
192 int expandabley = thisbox->minheight - thisbox->usedpady; 192 int expandabley = thisbox->minheight - thisbox->usedpady;
193 193
600 if(hsize && !width) 600 if(hsize && !width)
601 width = 1; 601 width = 1;
602 602
603 /* Fill in the item data appropriately */ 603 /* Fill in the item data appropriately */
604 if(0 /* Test to see if "item" is a box */) 604 if(0 /* Test to see if "item" is a box */)
605 tmpitem[index].type = TYPEBOX; 605 tmpitem[index].type = _DW_TYPE_BOX;
606 else 606 else
607 tmpitem[index].type = TYPEITEM; 607 tmpitem[index].type = _DW_TYPE_ITEM;
608 608
609 tmpitem[index].hwnd = item; 609 tmpitem[index].hwnd = item;
610 tmpitem[index].origwidth = tmpitem[index].width = width; 610 tmpitem[index].origwidth = tmpitem[index].width = width;
611 tmpitem[index].origheight = tmpitem[index].height = height; 611 tmpitem[index].origheight = tmpitem[index].height = height;
612 tmpitem[index].pad = pad; 612 tmpitem[index].pad = pad;
613 if(hsize) 613 if(hsize)
614 tmpitem[index].hsize = SIZEEXPAND; 614 tmpitem[index].hsize = _DW_SIZE_EXPAND;
615 else 615 else
616 tmpitem[index].hsize = SIZESTATIC; 616 tmpitem[index].hsize = _DW_SIZE_STATIC;
617 617
618 if(vsize) 618 if(vsize)
619 tmpitem[index].vsize = SIZEEXPAND; 619 tmpitem[index].vsize = _DW_SIZE_EXPAND;
620 else 620 else
621 tmpitem[index].vsize = SIZESTATIC; 621 tmpitem[index].vsize = _DW_SIZE_STATIC;
622 622
623 thisbox->items = tmpitem; 623 thisbox->items = tmpitem;
624 624
625 /* Update the item count */ 625 /* Update the item count */
626 thisbox->count++; 626 thisbox->count++;