/* --------------------------------------------------------------------- * ComboboxSetFocus * Handle EVENT_SETFOCUS events * --------------------------------------------------------------------- */ static void ComboboxSetFocusHook(void* w, void* lastfocus) { CUIWINDOW* win = (CUIWINDOW*) w; COMBOBOXDATA* data = (COMBOBOXDATA*) win->InstData; if (data) { WindowSetCursor(win, 0, 0); WindowCursorOn(); if (data->SetFocusHook) { data->SetFocusHook(data->SetFocusTarget, win, lastfocus); } } }
/* --------------------------------------------------------------------- * TerminalPaintHook * Handle PAINT events by redrawing the list view control * --------------------------------------------------------------------- */ static void TerminalPaintHook(void* w) { CUIWINDOW* win = (CUIWINDOW*) w; CUIRECT rc; TERMINALDATA* data; int yscroll; int ypos; int line; data = (TERMINALDATA*) win->InstData; if (!data) return; WindowGetClientRect(win, &rc); if ((rc.W <= 0)||(rc.H <= 0)) return; yscroll = WindowGetVScrollPos(win); ypos = 0; line = (data->FirstLine + yscroll) % MAX_TERMLINES; while (line != data->YCursor) { if (ypos < rc.H) { TerminalShowLine(win, ypos, line, &rc); ypos++; } line = (line + 1) % MAX_TERMLINES; } if (ypos < rc.H) { TerminalShowLine(win, ypos, line, &rc); ypos++; } ypos = ((data->YCursor - data->FirstLine + MAX_TERMLINES) % MAX_TERMLINES) - yscroll; WindowSetCursor(win, data->XCursor, ypos); }
/* --------------------------------------------------------------------- * 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); }