/* --------------------------------------------------------------------- * ListboxNcPaintHook * Handle PAINT events by redrawing the groupbox control * --------------------------------------------------------------------- */ static void ListboxNcPaintHook(void* w, int size_x, int size_y) { CUIWINDOW* win = (CUIWINDOW*) w; CUIRECT rc; int len; rc.W = size_x; rc.H = size_y; rc.X = 0; rc.Y = 0; if ((rc.W <= 0)||(rc.H <= 0)) return; if (win->HasBorder) { box(win->Frame, 0, 0); if (win->HasVScroll && (size_y > 2)) { WindowPaintVScroll(win, 1, size_y - 2); } } else if (win->HasVScroll) { WindowPaintVScroll(win, 0, size_y - 1); } if (win->IsEnabled) { SetColor(win->Frame, win->Color.HilightColor, win->Color.WndColor, FALSE); } else { SetColor(win->Frame, win->Color.InactTxtColor, win->Color.WndColor, FALSE); } if (!win->Text || (win->Text[0] == 0) || (!win->HasBorder)) return; len = wcslen(win->Text); if (len > rc.W - 4) { len = rc.W - 4; } MOVEYX(win->Frame, 0, 2); PRINTN(win->Frame, win->Text, len); if (rc.W > 2) { MOVEYX(win->Frame, 0, 1); PRINT(win->Frame, _T(" ")); MOVEYX(win->Frame, 0, len + 2); PRINT(win->Frame, _T(" ")); } }
/* --------------------------------------------------------------------- * TermShowLine * Show a terminal text line * --------------------------------------------------------------------- */ static void TerminalShowLine(CUIWINDOW* win, int ypos, int line, CUIRECT* rc) { TERMINALDATA* data = win->InstData; WINDOW* w = win->Win; int x, attr; wchar_t* text = data->Lines[line]; BYTE* cols = data->Colors[line]; attr = cols[0]; SetColor(w,attr >> 4,attr & 0x0F,FALSE); MOVEYX(w, ypos, 0); for (x = 0; x < rc->W; x++) { if (x < MAX_TERMCOLS) { if (cols[x] != attr) { attr = cols[x]; SetColor(w,attr >> 4,attr & 0x0F,FALSE); } PRINTN(w, &text[x], 1); } else { break;
/* --------------------------------------------------------------------- * CbDropdownPaintHook * Handle PAINT events by redrawing the control * --------------------------------------------------------------------- */ static void CbDropdownPaintHook(void* w) { CUIWINDOW* win = (CUIWINDOW*) w; CUIRECT rc; COMBOBOXDATA* data; COMBOBOXITEM* item; int pos; int cursor; int index; int len; int x,y; data = (COMBOBOXDATA*) win->InstData; if (!data) return; WindowGetClientRect(win, &rc); if ((rc.W <= 0)||(rc.H <= 0)) return; pos = WindowGetVScrollPos(win); index = 0; y = 0; cursor = 0; item = data->FirstItem; while(item) { if ((index >= pos) && (index < pos + rc.H)) { len = wcslen(item->ItemText); if (index == data->SelIndex) { SetColor(win->Win, win->Color.SelTxtColor, win->Color.WndSelColor, TRUE); cursor = y; } else { if (win->IsEnabled) { SetColor(win->Win, win->Color.WndTxtColor, win->Color.WndColor, FALSE); } else { SetColor(win->Win, win->Color.InactTxtColor, win->Color.WndColor, FALSE); } } MOVEYX(win->Win, y, 0); for (x = 0; x < rc.W; x++) { if ((x > 0) && (x <= len)) { PRINTN(win->Win, &item->ItemText[x - 1], 1); } else { PRINT(win->Win, _T(" ")); } } y ++; } else if (index >= pos + rc.H) { break; } index++; item = (COMBOBOXITEM*) item->Next; } WindowSetCursor(win, 0, cursor); }
/* --------------------------------------------------------------------- * ComboboxPaintHook * Handle PAINT events by redrawing the edit control * --------------------------------------------------------------------- */ static void ComboboxPaintHook(void* w) { CUIWINDOW* win = (CUIWINDOW*) w; CUIRECT rc; COMBOBOXDATA* data; int x; int len; int index; const wchar_t* text = _T(""); data = win->InstData; if (!data) return; WindowGetClientRect(win, &rc); if (rc.W <= 0) return; index = data->DropdownState ? data->SelIndex : data->CtrlSelIndex; if (index >= 0) { COMBOBOXITEM* item = ComboboxGetItem(data, index); if (item) { text = item->ItemText; } } len = wcslen(text); if (win->IsEnabled) { SetColor(win->Win, win->Color.SelTxtColor, win->Color.WndSelColor, TRUE); } else { SetColor(win->Win, win->Color.InactTxtColor, win->Color.WndSelColor, TRUE); } MOVEYX(win->Win, 0, 0); for(x = 0; x < rc.W - 3; x++) { if (x < len) { PRINTN(win->Win, &text[x], 1); } else { PRINT(win->Win, _T(" ")); } } if (win->IsEnabled) { SetColor(win->Win, win->Color.WndTxtColor, win->Color.WndColor, TRUE); } else { SetColor(win->Win, win->Color.InactTxtColor, win->Color.WndSelColor, TRUE); } if (rc.W > 3) { MOVEYX(win->Win, 0, x); PRINT(win->Win, _T("[v]")); } WindowSetCursor(win, 0, 0); }