void spicker::handle_inside_event(Event &ev, image *screen, InputManager *inm) { switch (ev.type) { case EV_MOUSE_MOVE : { if (activate_on_mouse_move()) { int me; if (vert) me=last_sel+(ev.mouse_move.y-m_pos.y)/item_height(); else me=last_sel+(ev.mouse_move.x-m_pos.x)/item_width(); if (me<t && me>=0) { if (cur_sel!=me) { cur_sel=me; scroll_event(last_sel,screen); note_new_current(screen,inm,me); } } } } break; case EV_MOUSE_BUTTON : { int me; if (vert) me=last_sel+(ev.mouse_move.y-m_pos.y)/item_height(); else me=last_sel+(ev.mouse_move.x-m_pos.x)/item_width(); if (me<t && me>=0) { if (m) { if (ev.mouse_button) { if (ok_to_select(me)) { set_select(me,!get_select(me)); scroll_event(last_sel,screen); inm->grab_focus(this); } } else last_click=-1; } else if (ok_to_select(me)) { if (cur_sel==me) note_selection(screen,inm,me); else { cur_sel=me; scroll_event(last_sel,screen); note_new_current(screen,inm,me); } } } } break; } }
void CScrollBar::OnLButtonDown( wxMouseEvent& event ) { int x = event.m_x, y = event.m_y, w, h; this->GetClientSize(&w, &h); if ( m_rcSBT.Contains(x, y) || m_rcSBLC.Contains(x, y) || m_rcSBRC.Contains(x, y) ) { m_ld = true; this->CaptureMouse(); m_pos = m_min_pos + ((double)((x - m_rcSBT.width/2 - m_rcSBLA.width)*m_range)/(double)(w - 2*m_rcSBLA.width - m_rcSBT.width)); if (m_pos < m_min_pos) m_pos = m_min_pos; if (m_pos > m_max_pos) m_pos = m_max_pos; this->Refresh(false); wxScrollEvent scroll_event(wxEVT_SCROLL_THUMBTRACK, 0, m_pos, 0); wxEvtHandler *handler = m_pParent->GetEventHandler(); handler->ProcessEvent(scroll_event); } else if ( m_rcSBLA.Contains(x, y) ) { this->ScrollLeft(); } else if ( m_rcSBRA.Contains(x, y) ) { this->ScrollRight(); } }
void scroller::handle_down(image *screen, InputManager *inm) { if (vert && sx < t - 1) { draw_widget(screen, 1); sx++; draw_widget(screen, 0); scroll_event(sx, screen); } }
void scroller::handle_up(image *screen, InputManager *inm) { if (vert && sx > 1) { draw_widget(screen, 1); sx--; draw_widget(screen, 0); scroll_event(sx, screen); } }
void pick_list::handle_inside_event(Event &ev, image *screen, InputManager *inm) { if (ev.type==EV_MOUSE_MOVE && activate_on_mouse_move()) { int sel=last_sel+(ev.mouse_move.y-m_pos.y)/(wm->font()->Size().y+1); if (sel!=cur_sel && sel<t && sel>=0) { cur_sel=sel; scroll_event(last_sel,screen); } } else if (ev.type==EV_MOUSE_BUTTON) { int sel=last_sel+(ev.mouse_move.y-m_pos.y)/(wm->font()->Size().y+1); if (sel<t && sel>=0) { if (sel==cur_sel) wm->Push(new Event(id,(char *)this)); else { cur_sel=sel; scroll_event(last_sel,screen); } } } else if (ev.type==EV_KEY && ev.key==JK_ENTER) wm->Push(new Event(id,(char *)this)); else if (ev.type==EV_KEY) { int found=-1; if (key_hist_total<20) key_hist[(int)(key_hist_total++)]=ev.key; for (int i=0; i<t && found==-1; i++) { if ((int)strlen(lis[i].name)>=key_hist_total && memcmp(lis[i].name,key_hist,key_hist_total)==0) found=i; } if (found!=-1) { sx=found; cur_sel=found; scroll_event(sx,screen); } else key_hist_total=0; } }
void pick_list::handle_down(image *screen, InputManager *inm) { if (cur_sel < t - 1) cur_sel++; else return; if (cur_sel > sx + th - 1) { draw_widget(screen, 1); sx = cur_sel - th + 1; draw_widget(screen, 0); } scroll_event(sx, screen); }
void pick_list::handle_up(image *screen, InputManager *inm) { if (cur_sel > 0) cur_sel--; else return; if (cur_sel < sx) { draw_widget(screen, 1); sx = cur_sel; draw_widget(screen, 0); } scroll_event(sx, screen); }
void scroller::set_x (int x, image *screen) { if (x<0) x=0; if (x>=t) x=t-1; if (x!=sx) { draw_widget(screen,1); sx=x; draw_widget(screen,0); scroll_event(sx,screen); } }
void CScrollBar::ScrollRight() { if (m_pos < m_max_pos) { m_pos++; this->Refresh(false); wxScrollEvent scroll_event(wxEVT_SCROLL_THUMBTRACK, 0, -1, 0); wxEvtHandler *handler = m_pParent->GetEventHandler(); handler->ProcessEvent(scroll_event); } }
void tile_picker::handle_inside_event(event &ev, image *screen, InputManager *inm) { if (ev.type==EV_MOUSE_BUTTON) { int sel=((ev.mouse_move.y-y)/pich()*wid)+(ev.mouse_move.x-x)/picw()+last_sel; if (sel<t && sel>=0 && sel!=get_current()) { set_current(sel); scroll_event(last_sel, screen); } } }
void CScrollBar::ScrollLeft() { if (m_pos > m_min_pos) { m_pos--; this->Refresh(false); wxScrollEvent scroll_event(wxEVT_SCROLL_THUMBTRACK, 0, -2, 0); wxEvtHandler *handler = m_pParent->GetEventHandler(); handler->ProcessEvent(scroll_event); } }
void spicker::handle_up(image *screen, InputManager *inm) { if (vert && cur_sel > 0) { cur_sel--; if (cur_sel < sx) { draw_widget(screen, 1); last_sel = sx = cur_sel; draw_widget(screen, 0); } scroll_event(last_sel, screen); note_new_current(screen, inm, cur_sel); } }
void spicker::handle_down(image *screen, InputManager *inm) { if (vert && cur_sel < t - 1) cur_sel++; else return; if (cur_sel > sx + r - 1) { draw_widget(screen, 1); last_sel = sx = cur_sel - r + 1; draw_widget(screen, 0); } scroll_event(sx, screen); note_new_current(screen, inm, cur_sel); }
void scroller::draw_first(image *screen) { if (sx >= t) sx = t - 1; draw(0, screen); screen->widget_bar(b1x(), b1y(), b1x() + bw() - 1, b1y() + bh() - 1, wm->bright_color(), wm->medium_color(), wm->dark_color()); screen->widget_bar(b2x(), b2y(), b2x() + bw() - 1, b2y() + bh() - 1, wm->bright_color(), wm->medium_color(), wm->dark_color()); show_icon(screen, b1x() + 2, b1y() + 2, bw() - 4, bh() - 4, b1()); show_icon(screen, b2x() + 2, b2y() + 2, bw() - 4, bh() - 4, b2()); int x1, y1, x2, y2; dragger_area(x1, y1, x2, y2); screen->bar(x1, y1, x2, y2, wm->black()); screen->bar(x1 + 1, y1 + 1, x2 - 1, y2 - 1, wm->medium_color()); draw_widget(screen, 0); scroll_event(sx, screen); }
void CScrollBar::OnMouseMove( wxMouseEvent& event ) { if ( m_ld ) { int x = event.m_x, y = event.m_y, w, h; this->GetClientSize(&w, &h); m_pos = m_min_pos + ((double)((x - m_rcSBT.width/2 - m_rcSBLA.width)*m_range)/(double)(w - 2*m_rcSBLA.width - m_rcSBT.width)); if (m_pos < m_min_pos) m_pos = m_min_pos; if (m_pos > m_max_pos) m_pos = m_max_pos; this->Refresh(false); wxScrollEvent scroll_event(wxEVT_SCROLL_THUMBTRACK, 0, m_pos, 0); wxEvtHandler *handler = m_pParent->GetEventHandler(); handler->ProcessEvent(scroll_event); } }
void spicker::set_x(int x, image *screen) { cur_sel=x; sx=x; scroll_event(x,screen); }
void scroller::handle_event(Event &ev, image *screen, InputManager *inm) { int mx=ev.mouse_move.x,my=ev.mouse_move.y; switch (ev.type) { case EV_MOUSE_BUTTON : { if (ev.mouse_button && drag==-1) { if (mx>=b1x() && mx<b1x()+bw() && my>=b1y()-2 && my<b1y()+bh()) { if (sx>0) { draw_widget(screen,1); sx--; draw_widget(screen,0); scroll_event(sx,screen); } } else if (mx>=b2x() && mx<b2x()+bw() && my>=b2y() && my<=b2y()+bh()) { if (sx<t-1) { draw_widget(screen,1); sx++; draw_widget(screen,0); scroll_event(sx,screen); } } else { int dx1,dy1,dx2,dy2; dragger_area(dx1,dy1,dx2,dy2); if (mx>=dx1 && mx<=dx2 && my>=dy1 && my<=dy2) { int x1,y1,x2,y2; wig_area(x1,y1,x2,y2); if (mx>=x1 && mx<=x2 && my>=y1 && my<=y2) { drag=sx; inm->grab_focus(this); } else if (t>1) { int nx=mouse_to_drag(mx,my); if (nx!=sx && nx>=0 && nx<t) { draw_widget(screen,1); sx=nx; draw_widget(screen,0); scroll_event(sx,screen); } } } else handle_inside_event(ev,screen,inm); } } else if (!ev.mouse_button && drag!=-1) { inm->release_focus(); drag=-1; } } break; case EV_MOUSE_MOVE : { if (drag!=-1) { int nx=mouse_to_drag(mx,my); if (nx<0) nx=0; else if (nx>=t) nx=t-1; if (nx!=sx) { draw_widget(screen,1); sx=nx; draw_widget(screen,0); scroll_event(sx,screen); } } else if ( activate_on_mouse_move()) { int x1,y1,x2,y2; wig_area(x1,y1,x2,y2); if (mx>=m_pos.x && mx<=m_pos.x+l-1 && my>=m_pos.y && my<=m_pos.y+h-1) handle_inside_event(ev,screen,inm); } } break; case EV_KEY : { switch (ev.key) { case JK_LEFT : { handle_left(screen,inm); } break; case JK_RIGHT : { handle_right(screen,inm); } break; case JK_UP : { handle_up(screen,inm); } break; case JK_DOWN : { handle_down(screen,inm); } break; default : handle_inside_event(ev,screen,inm); } } break; } }