static sk_sp<SkImage> make_picture_image() { SkPictureRecorder recorder; draw_contents(recorder.beginRecording(SkRect::MakeIWH(kWidth, kHeight))); return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(), SkISize::Make(kWidth, kHeight), nullptr, nullptr, SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB()); }
void draw_listbox(LISTBOX *l) { if (l->draw_proc) (*l->draw_proc)(l); else draw_box(l->title, l->x, l->y, l->w, l->h, TRUE); draw_contents(l); }
void draw_askbox(LISTBOX *l) { draw_box(l->title, l->x, l->y, l->w, l->h, TRUE); draw_contents(l); hi_vid(); goto1(l->x+4, l->y+2); mywrite((char *)l->parent); pch('?'); n_vid(); }
void widget::draw() { if (hidden() || !dirty()) return; bg_restore(); clip_rect_setter clipper(video().getSurface(), &clip_rect_, clip_); draw_contents(); update_rect(rect_); set_dirty(false); }
void widget::draw() { if (hidden() || !dirty()) return; bg_restore(); util::scoped_ptr<clip_rect_setter> clipper(NULL); if (clip_) clipper.assign(new clip_rect_setter(video().getSurface(), clip_rect_)); draw_contents(); update_rect(rect_); set_dirty(false); }
void widget::draw() { if (hidden() ) //|| !dirty()) // KP: always assume dirty with openGL rendering return; bg_restore(); util::scoped_ptr<clip_rect_setter> clipper(NULL); if (clip_) clipper.assign(new clip_rect_setter(/*video().getSurface(),*/ clip_rect_)); draw_contents(); // update_rect(rect_); // set_dirty(false); }
void menu::draw() { if(hidden()) { return; } /* if(!dirty()) { for(std::set<int>::const_iterator i = invalid_.begin(); i != invalid_.end(); ++i) { if(*i == -1) { SDL_Rect heading_rect = inner_location(); heading_rect.h = heading_height(); bg_restore(heading_rect); style_->draw_row(*this,0,heading_rect,HEADING_ROW); //update_rect(heading_rect); } else if(*i >= 0 && *i < int(item_pos_.size())) { const unsigned int pos = item_pos_[*i]; const SDL_Rect& rect = get_item_rect(*i); bg_restore(rect); style_->draw_row(*this,pos,rect, (!out_ && pos == selected_) ? SELECTED_ROW : NORMAL_ROW); //update_rect(rect); } } invalid_.clear(); return; } */ invalid_.clear(); bg_restore(); util::scoped_ptr<clip_rect_setter> clipper(NULL); if(clip_rect()) clipper.assign(new clip_rect_setter(/*video().getSurface(),*/ *clip_rect())); draw_contents(); // update_rect(location()); set_dirty(false); }
LRESULT debugview_info::view_proc(UINT message, WPARAM wparam, LPARAM lparam) { // handle a few messages switch (message) { // paint: redraw the last bitmap case WM_PAINT: { PAINTSTRUCT pstruct; HDC const dc = BeginPaint(m_wnd, &pstruct); draw_contents(dc); EndPaint(m_wnd, &pstruct); break; } // keydown: handle debugger keys case WM_SYSKEYDOWN: if (wparam != VK_F10) return DefWindowProc(m_wnd, message, wparam, lparam); // (fall through) case WM_KEYDOWN: { if (m_owner.handle_key(wparam, lparam)) { m_owner.set_ignore_char_lparam(lparam); } else { switch (wparam) { case VK_UP: m_view->process_char(DCH_UP); m_owner.set_ignore_char_lparam(lparam); break; case VK_DOWN: m_view->process_char(DCH_DOWN); m_owner.set_ignore_char_lparam(lparam); break; case VK_LEFT: if (GetAsyncKeyState(VK_CONTROL) & 0x8000) m_view->process_char(DCH_CTRLLEFT); else m_view->process_char(DCH_LEFT); m_owner.set_ignore_char_lparam(lparam); break; case VK_RIGHT: if (GetAsyncKeyState(VK_CONTROL) & 0x8000) m_view->process_char(DCH_CTRLRIGHT); else m_view->process_char(DCH_RIGHT); m_owner.set_ignore_char_lparam(lparam); break; case VK_PRIOR: m_view->process_char(DCH_PUP); m_owner.set_ignore_char_lparam(lparam); break; case VK_NEXT: m_view->process_char(DCH_PDOWN); m_owner.set_ignore_char_lparam(lparam); break; case VK_HOME: if (GetAsyncKeyState(VK_CONTROL) & 0x8000) m_view->process_char(DCH_CTRLHOME); else m_view->process_char(DCH_HOME); m_owner.set_ignore_char_lparam(lparam); break; case VK_END: if (GetAsyncKeyState(VK_CONTROL) & 0x8000) m_view->process_char(DCH_CTRLEND); else m_view->process_char(DCH_END); m_owner.set_ignore_char_lparam(lparam); break; case VK_ESCAPE: m_owner.set_default_focus(); m_owner.set_ignore_char_lparam(lparam); break; case VK_TAB: if (GetAsyncKeyState(VK_SHIFT) & 0x8000) m_owner.prev_view(this); else m_owner.next_view(this); m_owner.set_ignore_char_lparam(lparam); break; } } break; } // char: ignore chars associated with keys we've handled case WM_CHAR: if (m_owner.check_ignore_char_lparam(lparam)) { if (waiting_for_debugger() || !seq_pressed()) { if (wparam >= 32 && wparam < 127) { if (m_view->cursor_supported()) m_view->set_cursor_visible(true); m_view->process_char(wparam); } else { return DefWindowProc(m_wnd, message, wparam, lparam); } } } break; // gaining focus case WM_SETFOCUS: if (m_view->cursor_supported()) m_view->set_cursor_visible(true); break; // losing focus case WM_KILLFOCUS: if (m_view->cursor_supported()) m_view->set_cursor_visible(false); break; // mouse click case WM_LBUTTONDOWN: { debug_view_xy topleft = m_view->visible_position(); debug_view_xy newpos; newpos.x = topleft.x + GET_X_LPARAM(lparam) / metrics().debug_font_width(); newpos.y = topleft.y + GET_Y_LPARAM(lparam) / metrics().debug_font_height(); m_view->process_click(DCK_LEFT_CLICK, newpos); SetFocus(m_wnd); break; } // hscroll case WM_HSCROLL: { debug_view_xy topleft = m_view->visible_position(); topleft.x = process_scroll(LOWORD(wparam), (HWND)lparam); m_view->set_visible_position(topleft); machine().debug_view().flush_osd_updates(); break; } // vscroll case WM_VSCROLL: { debug_view_xy topleft = m_view->visible_position(); topleft.y = process_scroll(LOWORD(wparam), (HWND)lparam); m_view->set_visible_position(topleft); machine().debug_view().flush_osd_updates(); break; } // everything else: defaults default: return DefWindowProc(m_wnd, message, wparam, lparam); } return 0; }
void button::release(){ state_ = NORMAL; draw_contents(); }
LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam) { // handle a few messages switch (message) { // paint: draw bezels as necessary case WM_PAINT: { PAINTSTRUCT pstruct; HDC dc = BeginPaint(m_wnd, &pstruct); draw_contents(dc); EndPaint(m_wnd, &pstruct); break; } // keydown: handle debugger keys case WM_KEYDOWN: if (handle_key(wparam, lparam)) set_ignore_char_lparam(lparam); break; // char: ignore chars associated with keys we've handled case WM_CHAR: if (check_ignore_char_lparam(lparam)) { if (waiting_for_debugger() || !seq_pressed()) return DefWindowProc(m_wnd, message, wparam, lparam); } break; // activate: set the focus case WM_ACTIVATE: if (wparam != WA_INACTIVE) set_default_focus(); break; // get min/max info: set the minimum window size case WM_GETMINMAXINFO: { MINMAXINFO *minmax = (MINMAXINFO *)lparam; minmax->ptMinTrackSize.x = m_minwidth; minmax->ptMinTrackSize.y = m_minheight; minmax->ptMaxSize.x = minmax->ptMaxTrackSize.x = m_maxwidth; minmax->ptMaxSize.y = minmax->ptMaxTrackSize.y = m_maxheight; break; } // sizing: recompute child window locations case WM_SIZE: case WM_SIZING: recompute_children(); InvalidateRect(m_wnd, NULL, FALSE); break; // mouse wheel: forward to the first view case WM_MOUSEWHEEL: { static int units_carryover = 0; UINT lines_per_click; if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines_per_click, 0)) lines_per_click = 3; int const units = GET_WHEEL_DELTA_WPARAM(wparam) + units_carryover; int const clicks = units / WHEEL_DELTA; units_carryover = units % WHEEL_DELTA; int const delta = clicks * lines_per_click; int viewnum = 0; POINT point; // figure out which view we are hovering over GetCursorPos(&point); ScreenToClient(m_wnd, &point); HWND const child = ChildWindowFromPoint(m_wnd, point); if (child) { for (viewnum = 0; viewnum < MAX_VIEWS; viewnum++) { if ((m_views[viewnum] != NULL) && m_views[viewnum]->owns_window(child)) break; } if (viewnum == MAX_VIEWS) break; } // send the appropriate message to this view's scrollbar if (m_views[viewnum] != NULL) m_views[viewnum]->send_vscroll(delta); break; } // activate: set the focus case WM_INITMENU: update_menu(); break; // command: handle a comment case WM_COMMAND: if (!handle_command(wparam, lparam)) return DefWindowProc(m_wnd, message, wparam, lparam); break; // close: close the window if it's not the main console case WM_CLOSE: if (m_is_main_console) { debugger().hide_all(); debug_cpu_get_visible_cpu(machine())->debug()->go(); } else { destroy(); } break; // destroy: close down the window case WM_NCDESTROY: m_wnd = NULL; debugger().remove_window(*this); break; // everything else: defaults default: return DefWindowProc(m_wnd, message, wparam, lparam); } return 0; }
int fsel_proc(int key, char *s, int *len, int *cpos) { if ((ascii(key)==CR) || (ascii(key)==LF)) { if ((*len > 0) && ((s[*len-1] == '\\') || (s[*len-1] == '/'))) { fill_filelist(s); hi_vid(); return TRUE; } } if (key==UP_ARROW) { if (filebox.count > 0) { if (filebox.current >= 0) filebox.current--; else filebox.current = filebox.scroll; if (filebox.current < 0) filebox.current = 0; if (filebox.current < filebox.scroll) filebox.scroll = filebox.current; goto changed; } } else if (key==DOWN_ARROW) { if (filebox.count > 0) { if (filebox.current >= 0) filebox.current++; else filebox.current = filebox.scroll; if (filebox.current >= filebox.count) filebox.current = filebox.count-1; if (filebox.current >= filebox.scroll + filebox.height) filebox.scroll = filebox.current - filebox.height + 1; goto changed; } } else if (key==PAGE_UP) { if (filebox.count > 0) { if (filebox.current >= 0) filebox.current -= filebox.height - 1; else filebox.current = filebox.scroll; if (filebox.current < 0) filebox.current = 0; if (filebox.current < filebox.scroll) filebox.scroll = filebox.current; goto changed; } } else if (key==PAGE_DOWN) { if (filebox.count > 0) { if (filebox.current >= 0) filebox.current += filebox.height - 1; else filebox.current = filebox.scroll; if (filebox.current >= filebox.count) filebox.current = filebox.count-1; if (filebox.current >= filebox.scroll + filebox.height) filebox.scroll = filebox.current - filebox.height + 1; goto changed; } } else if (ascii(key)==TAB) { if (filebox.current >= 0) goto changed; } else if (key==-1) fill_filelist(s); hi_vid(); return FALSE; changed: strcpy(s, filebox.data[filebox.current].text); *len = *cpos = strlen(s); draw_contents(&filebox); hi_vid(); return TRUE; }
int fsel_mouse(int x, int y, char *s, int *len) { int c, gap; int selitem; int first = TRUE; int changed; int d; #ifdef TARGET_CURSES int count = 0; #endif if ((m_x < filebox.x) || (m_x >= filebox.x + filebox.w) || (m_y < filebox.y) || (m_y >= filebox.y + filebox.h) || (m_b & 2)) return ESC; if (filebox.count <= 0) return 0; do { delay(10); selitem = -1; changed = d = FALSE; if (mouse_inside_list(&filebox)) { filebox.current = get_mouse_item(&filebox); if (filebox.current >= filebox.count) filebox.current = filebox.count - 1; else selitem = filebox.current; changed = TRUE; } else { if ((m_y < filebox.y + filebox.yoff) && (filebox.scroll > 0)) { filebox.scroll--; filebox.current = filebox.scroll; changed = d = TRUE; } else if ((m_y >= filebox.y + filebox.yoff + filebox.height) && (filebox.scroll < filebox.count - filebox.height)) { filebox.scroll++; filebox.current = filebox.scroll + filebox.height - 1; if (filebox.current >= filebox.count) filebox.current = filebox.count-1; changed = d = TRUE; } } if (changed) { hide_mouse(); draw_contents(&filebox); strcpy(s, filebox.data[filebox.current].text); goto1(x, y); hi_vid(); if (strlen(s) > 54) { gap = strlen(s) - 54; pch('.'); pch('.'); pch('.'); pch(' '); mywrite(s+gap+4); } else { gap = 0; mywrite(s); } for (c=strlen(s)-gap; c<54; c++) pch(' '); goto2(x+strlen(s+gap), y); *len = strlen(s); display_mouse(); } if (d) delay(20); if ((first) && (selitem >= 0)) if (!mouse_dclick(FALSE)) if (mouse_dclick(TRUE)) return CR; first = FALSE; refresh_screen(); #ifdef TARGET_CURSES if (d) { if (count++ >= 10) m_b = 0; } else while (m_b) #endif poll_mouse(); } while(m_b); clear_keybuf(); return 0; }
void fill_filelist(char *path) { char b[256]; int c; FILENODE *node; int redraw = FALSE; int old; strcpy(b, path); #if (defined TARGET_DJGPP) || (defined TARGET_WIN) strcpy(get_fname(b), "*.*"); #else strcpy(get_fname(b), "*"); #endif cleanup_filename(b); if (stricmp(b, filepath) != 0) { empty_filelist(); do_for_each_file(b, add_to_filelist, 0); do_for_each_directory(b, add_to_filelist, 0); if (filebox.count > 0) { filebox.data = malloc(sizeof(LISTITEM)*filebox.count); if (filebox.data) { node = filenode; for (c=0; c<filebox.count; c++) { filebox.data[c].text = node->name; filebox.data[c].data = -1; filebox.data[c].click_proc = NULL; filebox.data[c].draw_proc = NULL; filebox.data[c].comment = NULL; node = node->next; } } else errno = ENOMEM; } redraw = TRUE; strcpy(filepath, b); } old = filebox.current; filebox.current = -1; if (path[0]) { char *p = get_fname(path); int len = strlen(p); if (p[0]) { for (c=0; c<filebox.count; c++) { if (strnicmp(p, get_fname(filebox.data[c].text), len)==0) { filebox.current = c; break; } } } } if (filebox.current != old) { if (filebox.current != -1) { while (filebox.current < filebox.scroll) filebox.scroll--; while (filebox.current >= filebox.scroll+filebox.height) filebox.scroll++; } redraw = TRUE; } if (redraw) { if (errno==0) draw_contents(&filebox); else { filebox.current = -1; filebox.count = -1; draw_contents(&filebox); hi_vid(); goto1(filebox.x+filebox.xoff+1, filebox.y+filebox.yoff); mywrite("Error: "); mywrite(err()); } } }
int do_listbox(LISTBOX *l, int *oklist, int *cancellist, int init_key, int instant_mouse) { int key; int *pos; int done; int ret; int c; char *b = save_screen(l->x, l->y, l->w, l->h); int is_key; hide_c(); draw_listbox(l); l->key = init_key; l->key2 = -1; display_mouse(); while (m_b) { poll_mouse(); if ((instant_mouse) && ((m_b & 2) || (mouse_inside_list(l)) || ((mouse_inside_parent(l)) && (get_mouse_item(l->parent) != l->parent->current)))) break; } do { if (l->key == -1) { while (!input_waiting()) { poll_mouse(); if (m_b) break; } if (input_waiting()) { key = input_char().key; is_key = TRUE; } else { int ox, oy, ob; int sel_item; int first = TRUE; key = 0; is_key = FALSE; while (m_b) { if ((m_b & 2) && (!(l->flags & LISTBOX_USE_RMB))) { key = ESC; is_key = TRUE; break; } sel_item = -1; if (mouse_inside_list(l)) { l->current = get_mouse_item(l); if (l->current >= l->count) l->current = l->count-1; else sel_item = l->current; } hide_mouse(); draw_contents(l); display_mouse(); if (first) { if (sel_item >= 0) { if (l->flags & LISTBOX_MOUSE_OK) { key = CR; is_key = TRUE; break; } if (!(l->flags & LISTBOX_MOUSE_OK2)) { if (!mouse_dclick(FALSE)) { if (mouse_dclick(TRUE)) { key = CR; is_key = TRUE; break; } } } } else if (mouse_outside_list(l)) { if (l->flags & LISTBOX_MOUSE_CANCEL) { key = ESC; is_key = TRUE; break; } } first = FALSE; } if (mouse_inside_parent(l)) { if (l->flags & LISTBOX_MOUSE_CANCEL) { key = ESC; is_key = TRUE; break; } } if (l->flags & LISTBOX_SCROLL) { int changed = FALSE; if ((m_y < l->y + l->yoff) && (l->scroll > 0)) { l->scroll--; l->current = l->scroll; m_y = -1; changed = TRUE; } else if ((m_y >= l->y + l->yoff + l->height) && (l->scroll < l->count - l->height)) { l->scroll++; l->current = l->scroll + l->height - 1; if (l->current >= l->count) l->current = l->count-1; m_y = -1; changed = TRUE; } if (changed) { hide_mouse(); draw_contents(l); display_mouse(); delay(20); } } do { ox = m_x; oy = m_y; ob = m_b; poll_mouse(); } while ((m_x == ox) && (m_y == oy) && (m_b == ob) && (m_b) && (!input_waiting())); if ((!m_b) && (sel_item >= 0) && (l->flags & LISTBOX_MOUSE_OK2)) { key = CR; is_key = TRUE; break; } } } } else { key = l->key; l->key = l->key2; l->key2 = -1; is_key = TRUE; } done = FALSE; if (is_key) { pos = oklist; while (*pos) { if ((*pos == key) || (ascii(key)==CR) || (ascii(key)==LF)) { if ((l->current >= 0) && (l->current < l->count)) { hide_mouse(); if (l->data[l->current].click_proc) ret = (l->data[l->current].click_proc) (l, l->data+l->current); else ret = l->data[l->current].data; if (ret >= 0) { l->key = key; restore_screen(l->x, l->y, l->w, l->h, b); show_c(); return ret; } else { hide_c(); display_mouse(); } } done = TRUE; break; } pos++; } if (!done) { pos = cancellist; while (*pos) { if ((*pos == key) || (ascii(key)==ESC)) { hide_mouse(); l->key = key; restore_screen(l->x, l->y, l->w, l->h, b); show_c(); return -1; } pos++; } } if (!done) { if (key==LEFT_ARROW) l->current--; else if (key==UP_ARROW) l->current -= l->width; else if (key==RIGHT_ARROW) l->current++; else if (key==DOWN_ARROW) l->current += l->width; else if (key==PAGE_UP) l->current -= l->width * l->height - 1; else if (key==PAGE_DOWN) l->current += l->width * l->height - 1; else if (key==K_HOME) l->current = 0; else if (key==K_END) l->current = l->count-1; else if (l->process_proc) if ((*l->process_proc)(l, key)) goto skip; for (c=0; c<l->count; c++) if (tolower(l->data[c].text[0]) == tolower(ascii(key))) { l->current = c; if (l->flags & LISTBOX_FASTKEY) l->key = oklist[0]; break; } skip: if (l->current < 0) { if (l->flags & LISTBOX_WRAP) l->current = MAX(0, l->count-1); else l->current = 0; } else if (l->current >= l->count) { if (l->flags & LISTBOX_WRAP) l->current = 0; else l->current = MAX(0, l->count-1); } while (l->current < l->scroll) l->scroll -= l->width; while (l->current >= l->scroll+l->width*l->height) l->scroll += l->width; } } hide_mouse(); draw_contents(l); display_mouse(); } while (TRUE); }