|
@@ -432,97 +432,97 @@ draw_default:;
|
|
|
if (cur_disabled & 1) {
|
|
|
GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _color_list[wi->color&0xF].unk2 | PALETTE_MODIFIER_GREYOUT);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} while (cur_click>>=1, cur_disabled>>=1, cur_hidden >>= 1, (++wi)->type != WWT_LAST);
|
|
|
|
|
|
|
|
|
if (w->flags4 & WF_WHITE_BORDER_MASK) {
|
|
|
//DrawFrameRect(w->left, w->top, w->left + w->width-1, w->top+w->height-1, 0xF, 0x10);
|
|
|
DrawFrameRect(0, 0, w->width-1, w->height-1, 0xF, FR_BORDERONLY);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
static const Widget _dropdown_menu_widgets[] = {
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL},
|
|
|
{ WIDGETS_END},
|
|
|
};
|
|
|
|
|
|
static int GetDropdownItem(const Window *w)
|
|
|
{
|
|
|
byte item, counter;
|
|
|
int y;
|
|
|
|
|
|
if (GetWidgetFromPos(w, _cursor.pos.x - w->left, _cursor.pos.y - w->top) < 0)
|
|
|
return -1;
|
|
|
|
|
|
y = _cursor.pos.y - w->top - 2;
|
|
|
|
|
|
if (y < 0)
|
|
|
return - 1;
|
|
|
|
|
|
item = y / 10;
|
|
|
if (item >= WP(w,dropdown_d).num_items || (HASBIT(WP(w,dropdown_d).disabled_state, item) && !HASBIT(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0)
|
|
|
return - 1;
|
|
|
|
|
|
// Skip hidden items -- +1 for each hidden item before the clicked item.
|
|
|
for (counter = 0; item >= counter; ++counter)
|
|
|
if (HASBIT(WP(w,dropdown_d).hidden_state, counter)) item++;
|
|
|
|
|
|
return item;
|
|
|
}
|
|
|
|
|
|
static void DropdownMenuWndProc(Window *w, WindowEvent *e)
|
|
|
{
|
|
|
int item;
|
|
|
|
|
|
switch(e->event) {
|
|
|
switch (e->event) {
|
|
|
case WE_PAINT: {
|
|
|
int x,y,i,sel;
|
|
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
|
x = 1;
|
|
|
y = 2;
|
|
|
sel = WP(w,dropdown_d).selected_index;
|
|
|
|
|
|
for (i = 0; WP(w,dropdown_d).items[i] != INVALID_STRING_ID; i++) {
|
|
|
if (HASBIT(WP(w,dropdown_d).hidden_state, i)) {
|
|
|
sel--;
|
|
|
continue;
|
|
|
}
|
|
|
if (WP(w,dropdown_d).items[i] != 0) {
|
|
|
if (sel == 0) GfxFillRect(x + 1, y, x + w->width - 4, y + 9, 0);
|
|
|
DrawString(x + 2, y, WP(w,dropdown_d).items[i], sel == 0 ? 12 : 16);
|
|
|
|
|
|
if (HASBIT(WP(w,dropdown_d).disabled_state, i)) {
|
|
|
GfxFillRect(x, y, x + w->width - 3, y + 9,
|
|
|
PALETTE_MODIFIER_GREYOUT | _color_list[_dropdown_menu_widgets[0].color].window_color_bga
|
|
|
);
|
|
|
}
|
|
|
} else {
|
|
|
int c1 = _color_list[_dropdown_menu_widgets[0].color].window_color_1a;
|
|
|
int c2 = _color_list[_dropdown_menu_widgets[0].color].window_color_2;
|
|
|
|
|
|
GfxFillRect(x + 1, y + 3, x + w->width - 5, y + 3, c1);
|
|
|
GfxFillRect(x + 1, y + 4, x + w->width - 5, y + 4, c2);
|
|
|
}
|
|
|
y += 10;
|
|
|
sel--;
|
|
|
}
|
|
|
} break;
|
|
|
|
|
|
case WE_CLICK: {
|
|
|
item = GetDropdownItem(w);
|
|
|
if (item >= 0) {
|
|
|
WP(w,dropdown_d).click_delay = 4;
|
|
|
WP(w,dropdown_d).selected_index = item;
|
|
|
SetWindowDirty(w);
|
|
|
}
|
|
|
} break;
|
|
|
|
|
|
case WE_MOUSELOOP: {
|
|
|
Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
|
|
|
if (w2 == NULL) {
|
|
|
DeleteWindow(w);
|