Respect BL_FLUSH and BL_RESET indications to mswin_status_update.
This commit is contained in:
@@ -298,169 +298,166 @@ onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
FillRect(hdc, &clear_rect, status_bg_brush);
|
FillRect(hdc, &clear_rect, status_bg_brush);
|
||||||
|
|
||||||
// TODO: Put it around for loop instead -- temporary to get a better diff
|
if (data->status_lines != NULL) {
|
||||||
if (data->status_lines == NULL) {
|
|
||||||
BitBlt(front_buffer_hdc, 0, 0, width, height, hdc, 0, 0, SRCCOPY);
|
data->has_blink_fields = FALSE;
|
||||||
|
|
||||||
EndPaint(hWnd, &ps);
|
for (int line = 0; line < NHSW_LINES; line++) {
|
||||||
return 0;
|
LONG left = rt.left;
|
||||||
}
|
LONG cy = 0;
|
||||||
|
int vlen;
|
||||||
|
|
||||||
data->has_blink_fields = FALSE;
|
mswin_status_line * status_line = &data->status_lines->lines[line];
|
||||||
|
|
||||||
for (int line = 0; line < NHSW_LINES; line++) {
|
for (int i = 0; i < status_line->status_strings.count; i++) {
|
||||||
LONG left = rt.left;
|
mswin_status_string * status_string = status_line->status_strings.status_strings[i];
|
||||||
LONG cy = 0;
|
int clr, atr;
|
||||||
int vlen;
|
int fntatr = ATR_NONE;
|
||||||
|
COLORREF nFg, nBg;
|
||||||
|
|
||||||
mswin_status_line * status_line = &data->status_lines->lines[line];
|
if (status_string->str == NULL || status_string->str[0] == '\0')
|
||||||
|
continue;
|
||||||
|
|
||||||
for (int i = 0; i < status_line->status_strings.count; i++) {
|
clr = status_string->color;
|
||||||
mswin_status_string * status_string = status_line->status_strings.status_strings[i];
|
atr = status_string->attribute;
|
||||||
int clr, atr;
|
|
||||||
int fntatr = ATR_NONE;
|
|
||||||
COLORREF nFg, nBg;
|
|
||||||
|
|
||||||
if (status_string->str == NULL || status_string->str[0] == '\0')
|
const char *str = status_string->str;
|
||||||
continue;
|
|
||||||
|
|
||||||
clr = status_string->color;
|
vlen = strlen(str);
|
||||||
atr = status_string->attribute;
|
|
||||||
|
|
||||||
const char *str = status_string->str;
|
if (atr & HL_BOLD)
|
||||||
|
fntatr = ATR_BOLD;
|
||||||
vlen = strlen(str);
|
else if (atr & HL_INVERSE)
|
||||||
|
|
||||||
if (atr & HL_BOLD)
|
|
||||||
fntatr = ATR_BOLD;
|
|
||||||
else if (atr & HL_INVERSE)
|
|
||||||
fntatr = ATR_INVERSE;
|
|
||||||
else if (atr & HL_ULINE)
|
|
||||||
fntatr = ATR_ULINE;
|
|
||||||
else if (atr & HL_BLINK) {
|
|
||||||
data->has_blink_fields = TRUE;
|
|
||||||
if (data->blink_state) {
|
|
||||||
fntatr = ATR_INVERSE;
|
fntatr = ATR_INVERSE;
|
||||||
atr |= HL_INVERSE;
|
else if (atr & HL_ULINE)
|
||||||
|
fntatr = ATR_ULINE;
|
||||||
|
else if (atr & HL_BLINK) {
|
||||||
|
data->has_blink_fields = TRUE;
|
||||||
|
if (data->blink_state) {
|
||||||
|
fntatr = ATR_INVERSE;
|
||||||
|
atr |= HL_INVERSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (atr & HL_DIM)
|
||||||
else if (atr & HL_DIM)
|
fntatr = ATR_DIM;
|
||||||
fntatr = ATR_DIM;
|
|
||||||
|
|
||||||
cached_font * fnt = mswin_get_font(NHW_STATUS, fntatr, hdc, FALSE);
|
cached_font * fnt = mswin_get_font(NHW_STATUS, fntatr, hdc, FALSE);
|
||||||
|
|
||||||
BOOL useUnicode = fnt->supportsUnicode;
|
BOOL useUnicode = fnt->supportsUnicode;
|
||||||
|
|
||||||
winos_ascii_to_wide_str(str, wbuf, SIZE(wbuf));
|
winos_ascii_to_wide_str(str, wbuf, SIZE(wbuf));
|
||||||
|
|
||||||
nFg = (clr == NO_COLOR ? status_fg_color
|
nFg = (clr == NO_COLOR ? status_fg_color
|
||||||
: ((clr >= 0 && clr < CLR_MAX) ? nhcolor_to_RGB(clr)
|
: ((clr >= 0 && clr < CLR_MAX) ? nhcolor_to_RGB(clr)
|
||||||
: status_fg_color));
|
: status_fg_color));
|
||||||
|
|
||||||
if (atr & HL_DIM) {
|
if (atr & HL_DIM) {
|
||||||
/* make a dim representation - this can produce color shift */
|
/* make a dim representation - this can produce color shift */
|
||||||
float redReduction = 0.5f;
|
float redReduction = 0.5f;
|
||||||
float greenReduction = 0.5f;
|
float greenReduction = 0.5f;
|
||||||
float blueReduction = 0.25f;
|
float blueReduction = 0.25f;
|
||||||
uchar red = (uchar) (GetRValue(nFg) * (1.0f - redReduction));
|
uchar red = (uchar)(GetRValue(nFg) * (1.0f - redReduction));
|
||||||
uchar green = (uchar) (GetGValue(nFg) * (1.0f - greenReduction));
|
uchar green = (uchar)(GetGValue(nFg) * (1.0f - greenReduction));
|
||||||
uchar blue = (uchar) (GetBValue(nFg) * (1.0f - blueReduction));
|
uchar blue = (uchar)(GetBValue(nFg) * (1.0f - blueReduction));
|
||||||
nFg = RGB(red, green, blue);
|
nFg = RGB(red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
nBg = status_bg_color;
|
nBg = status_bg_color;
|
||||||
|
|
||||||
if (status_string->space_in_front)
|
if (status_string->space_in_front)
|
||||||
rt.left += fnt->width;
|
rt.left += fnt->width;
|
||||||
|
|
||||||
sz.cy = -1;
|
sz.cy = -1;
|
||||||
|
|
||||||
if (status_string->draw_bar && iflags.wc2_hitpointbar) {
|
if (status_string->draw_bar && iflags.wc2_hitpointbar) {
|
||||||
/* NOTE: we current don't support bar attributes */
|
/* NOTE: we current don't support bar attributes */
|
||||||
|
|
||||||
/* when we are drawing bar we need to look at the hp status
|
/* when we are drawing bar we need to look at the hp status
|
||||||
* field to get the correct percentage and color */
|
* field to get the correct percentage and color */
|
||||||
COLORREF bar_color = nhcolor_to_RGB(status_string->bar_color);
|
COLORREF bar_color = nhcolor_to_RGB(status_string->bar_color);
|
||||||
HBRUSH back_brush = CreateSolidBrush(bar_color);
|
HBRUSH back_brush = CreateSolidBrush(bar_color);
|
||||||
RECT barrect;
|
RECT barrect;
|
||||||
|
|
||||||
/* prepare for drawing */
|
/* prepare for drawing */
|
||||||
SelectObject(hdc, fnt->hFont);
|
SelectObject(hdc, fnt->hFont);
|
||||||
SetBkMode(hdc, OPAQUE);
|
SetBkMode(hdc, OPAQUE);
|
||||||
SetBkColor(hdc, status_bg_color);
|
SetBkColor(hdc, status_bg_color);
|
||||||
SetTextColor(hdc, status_fg_color);
|
SetTextColor(hdc, status_fg_color);
|
||||||
|
|
||||||
if (useUnicode) {
|
if (useUnicode) {
|
||||||
/* get bounding rectangle */
|
/* get bounding rectangle */
|
||||||
GetTextExtentPoint32W(hdc, wbuf, vlen, &sz);
|
GetTextExtentPoint32W(hdc, wbuf, vlen, &sz);
|
||||||
|
|
||||||
/* first draw title normally */
|
/* first draw title normally */
|
||||||
DrawTextW(hdc, wbuf, vlen, &rt, DT_LEFT);
|
DrawTextW(hdc, wbuf, vlen, &rt, DT_LEFT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* get bounding rectangle */
|
||||||
|
GetTextExtentPoint32A(hdc, str, vlen, &sz);
|
||||||
|
|
||||||
|
/* first draw title normally */
|
||||||
|
DrawTextA(hdc, str, vlen, &rt, DT_LEFT);
|
||||||
|
}
|
||||||
|
int bar_percent = status_string->bar_percent;
|
||||||
|
if (bar_percent > 0) {
|
||||||
|
/* calc bar length */
|
||||||
|
barrect.left = rt.left;
|
||||||
|
barrect.top = rt.top;
|
||||||
|
barrect.bottom = sz.cy;
|
||||||
|
if (bar_percent > 0)
|
||||||
|
barrect.right = (int)((bar_percent * sz.cx) / 100);
|
||||||
|
/* else
|
||||||
|
barrect.right = sz.cx; */
|
||||||
|
|
||||||
|
/* then draw hpbar on top of title */
|
||||||
|
FillRect(hdc, &barrect, back_brush);
|
||||||
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
|
SetTextColor(hdc, nBg);
|
||||||
|
|
||||||
|
if (useUnicode)
|
||||||
|
DrawTextW(hdc, wbuf, vlen, &barrect, DT_LEFT);
|
||||||
|
else
|
||||||
|
DrawTextA(hdc, str, vlen, &barrect, DT_LEFT);
|
||||||
|
}
|
||||||
|
DeleteObject(back_brush);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* get bounding rectangle */
|
if (atr & HL_INVERSE) {
|
||||||
GetTextExtentPoint32A(hdc, str, vlen, &sz);
|
COLORREF tmp = nFg;
|
||||||
|
nFg = nBg;
|
||||||
|
nBg = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
/* first draw title normally */
|
/* prepare for drawing */
|
||||||
DrawTextA(hdc, str, vlen, &rt, DT_LEFT);
|
SelectObject(hdc, fnt->hFont);
|
||||||
|
SetBkMode(hdc, OPAQUE);
|
||||||
|
SetBkColor(hdc, nBg);
|
||||||
|
SetTextColor(hdc, nFg);
|
||||||
|
|
||||||
|
if (useUnicode) {
|
||||||
|
/* get bounding rectangle */
|
||||||
|
GetTextExtentPoint32W(hdc, wbuf, vlen, &sz);
|
||||||
|
|
||||||
|
/* draw */
|
||||||
|
DrawTextW(hdc, wbuf, vlen, &rt, DT_LEFT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* get bounding rectangle */
|
||||||
|
GetTextExtentPoint32A(hdc, str, vlen, &sz);
|
||||||
|
|
||||||
|
/* draw */
|
||||||
|
DrawTextA(hdc, str, vlen, &rt, DT_LEFT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int bar_percent = status_string->bar_percent;
|
assert(sz.cy >= 0);
|
||||||
if (bar_percent > 0) {
|
|
||||||
/* calc bar length */
|
|
||||||
barrect.left = rt.left;
|
|
||||||
barrect.top = rt.top;
|
|
||||||
barrect.bottom = sz.cy;
|
|
||||||
if (bar_percent > 0)
|
|
||||||
barrect.right = (int)((bar_percent * sz.cx) / 100);
|
|
||||||
/* else
|
|
||||||
barrect.right = sz.cx; */
|
|
||||||
|
|
||||||
/* then draw hpbar on top of title */
|
rt.left += sz.cx;
|
||||||
FillRect(hdc, &barrect, back_brush);
|
cy = max(cy, sz.cy);
|
||||||
SetBkMode(hdc, TRANSPARENT);
|
|
||||||
SetTextColor(hdc, nBg);
|
|
||||||
|
|
||||||
if (useUnicode)
|
|
||||||
DrawTextW(hdc, wbuf, vlen, &barrect, DT_LEFT);
|
|
||||||
else
|
|
||||||
DrawTextA(hdc, str, vlen, &barrect, DT_LEFT);
|
|
||||||
}
|
|
||||||
DeleteObject(back_brush);
|
|
||||||
} else {
|
|
||||||
if (atr & HL_INVERSE) {
|
|
||||||
COLORREF tmp = nFg;
|
|
||||||
nFg = nBg;
|
|
||||||
nBg = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* prepare for drawing */
|
|
||||||
SelectObject(hdc, fnt->hFont);
|
|
||||||
SetBkMode(hdc, OPAQUE);
|
|
||||||
SetBkColor(hdc, nBg);
|
|
||||||
SetTextColor(hdc, nFg);
|
|
||||||
|
|
||||||
if (useUnicode) {
|
|
||||||
/* get bounding rectangle */
|
|
||||||
GetTextExtentPoint32W(hdc, wbuf, vlen, &sz);
|
|
||||||
|
|
||||||
/* draw */
|
|
||||||
DrawTextW(hdc, wbuf, vlen, &rt, DT_LEFT);
|
|
||||||
} else {
|
|
||||||
/* get bounding rectangle */
|
|
||||||
GetTextExtentPoint32A(hdc, str, vlen, &sz);
|
|
||||||
|
|
||||||
/* draw */
|
|
||||||
DrawTextA(hdc, str, vlen, &rt, DT_LEFT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
assert(sz.cy >= 0);
|
|
||||||
|
|
||||||
rt.left += sz.cx;
|
rt.left = left;
|
||||||
cy = max(cy, sz.cy);
|
rt.top += cy;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt.left = left;
|
|
||||||
rt.top += cy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BitBlt(front_buffer_hdc, 0, 0, width, height, hdc, 0, 0, SRCCOPY);
|
BitBlt(front_buffer_hdc, 0, 0, width, height, hdc, 0, 0, SRCCOPY);
|
||||||
|
|||||||
@@ -3015,18 +3015,6 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color,
|
|||||||
|
|
||||||
logDebug("mswin_status_update(%d, %p, %d, %d, %x, %p)\n", idx, ptr, chg, percent, color, condmasks);
|
logDebug("mswin_status_update(%d, %p, %d, %d, %x, %p)\n", idx, ptr, chg, percent, color, condmasks);
|
||||||
|
|
||||||
#if 0 // TODO: this code was dead ... do we need to respond to these updates?
|
|
||||||
switch (idx) {
|
|
||||||
case BL_RESET:
|
|
||||||
reset_state = TRUE;
|
|
||||||
/* FALLTHRU */
|
|
||||||
case BL_FLUSH:
|
|
||||||
/* FALLTHRU */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
|
|
||||||
nhassert(idx <= SIZE(_status_fields));
|
nhassert(idx <= SIZE(_status_fields));
|
||||||
@@ -3101,11 +3089,14 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send command to status window */
|
}
|
||||||
|
|
||||||
|
if (idx == BL_FLUSH || idx == BL_RESET) {
|
||||||
|
/* send command to status window to update */
|
||||||
ZeroMemory(&update_cmd_data, sizeof(update_cmd_data));
|
ZeroMemory(&update_cmd_data, sizeof(update_cmd_data));
|
||||||
update_cmd_data.status_lines = &_status_lines;
|
update_cmd_data.status_lines = &_status_lines;
|
||||||
SendMessage(mswin_hwnd_from_winid(WIN_STATUS), WM_MSNH_COMMAND,
|
SendMessage(mswin_hwnd_from_winid(WIN_STATUS), WM_MSNH_COMMAND,
|
||||||
(WPARAM) MSNH_MSG_UPDATE_STATUS, (LPARAM) &update_cmd_data);
|
(WPARAM)MSNH_MSG_UPDATE_STATUS, (LPARAM)&update_cmd_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user