bool Button::on_touch(const TouchEvent event) { switch(event.type) { case TouchEvent::Type::Start: set_highlighted(true); set_dirty(); return true; case TouchEvent::Type::End: set_highlighted(false); set_dirty(); if( on_select ) { on_select(*this); } return true; default: return false; } #if 0 switch(event.type) { case TouchEvent::Type::Start: flags.highlighted = true; set_dirty(); return true; case TouchEvent::Type::Move: { const bool new_highlighted = screen_rect().contains(event.point); if( flags.highlighted != new_highlighted ) { flags.highlighted = new_highlighted; set_dirty(); } } return true; case TouchEvent::Type::End: if( flags.highlighted ) { flags.highlighted = false; set_dirty(); if( on_select ) { on_select(*this); } } return true; default: return false; } #endif }
void Combobox::on_primary_button_press(int x, int y) { if (drop_down) { // Determine which item was selected, if any, and set the current item to it. drop_down = false; ungrab(); if (hover_item != -1) { current_item = hover_item; on_select(item_list[current_item]); } } else { drop_down = true; grab(); list_rect = Rect(Vector2i(rect.left, rect.top + get_box_offset()), Size(rect.get_width(), rect.get_height() * item_list.size())); on_pointer_move(x,y); } }
void WeeklyRout_InsertDia::down_move() { long lRow =m_FlexGrid.get_RowSel();//获取点击的行号 long lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 if (lRow!=m_FlexGrid.get_Rows()-1) m_FlexGrid.put_Row(++lRow); GRID_DOWN_MOVE on_select();//////////////////////// }
void WeeklyRout_InsertDia::up_move() { long lRow = m_FlexGrid.get_RowSel();//获取点击的行号 long lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 if (lRow!=1) m_FlexGrid.put_Row(--lRow); GRID_UP_MOVE on_select();//////////////////////// }
void Annual_Routines::down_move() { long lRow =m_FlexGrid.get_RowSel();//获取点击的行号 long lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 if (lRow!=m_FlexGrid.get_Rows()-1) m_FlexGrid.put_Row(++lRow); GRID_DOWN_MOVE on_select();//////////////////////// }
void Annual_Routines::up_move() { long lRow = m_FlexGrid.get_RowSel();//获取点击的行号 long lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 if (lRow!=1) m_FlexGrid.put_Row(--lRow); GRID_UP_MOVE on_select();//////////////////////// }
bool ImageButton::on_key(const KeyEvent key) { if( key == KeyEvent::Select ) { if( on_select ) { on_select(*this); return true; } } return false; }
void WeeklyRout_InsertDia::shift_tab_move() { long lRow = m_FlexGrid.get_RowSel();//获取点击的行号 long lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 if(lRow==1 && lCol==1) { } else if (lCol==1) { m_FlexGrid.put_Row(--lRow); m_FlexGrid.put_Col(m_FlexGrid.get_Cols()-1); } else { m_FlexGrid.put_Row(lRow); m_FlexGrid.put_Col(--lCol); } GRID_UP_MOVE on_select();//////////////////////// }
bool ImageButton::on_touch(const TouchEvent event) { switch(event.type) { case TouchEvent::Type::Start: set_highlighted(true); set_dirty(); return true; case TouchEvent::Type::End: set_highlighted(false); set_dirty(); if( on_select ) { on_select(*this); } return true; default: return false; } }
void WeeklyRout_InsertDia::tab_move() { long lRow = m_FlexGrid.get_RowSel();//获取点击的行号 long lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 if(lRow==m_FlexGrid.get_Rows()-1 && lCol==m_FlexGrid.get_Cols()-1) { } else if (lCol==m_FlexGrid.get_Cols()-1) { lRow++; lCol=1; m_FlexGrid.put_Row(lRow); m_FlexGrid.put_Col(1); } else { m_FlexGrid.put_Row(lRow); m_FlexGrid.put_Col(++lCol); } GRID_DOWN_MOVE on_select();//////////////////////// }
void WeeklyRout_InsertDia::ClickMsflexgrid1() { // TODO: 在此处添加消息处理程序代码 on_select(); }
void Annual_Routines::ClickMsflexgrid1() { // TODO: 在此处添加消息处理程序代码 on_select(); }
//================================================================================================= void FlowContainer::Update(float dt) { bool ok = false; group = -1; id = -1; if(mouse_focus) { if(IsInside(GUI.cursor_pos)) { ok = true; if(Key.Focus()) scroll.ApplyMouseWheel(); Int2 off(0, (int)scroll.offset); for(FlowItem* fi : items) { Int2 p = fi->pos - off + global_pos; if(fi->type == FlowItem::Item) { if(fi->group != -1 && PointInRect(GUI.cursor_pos, p, fi->size)) { group = fi->group; id = fi->id; if(allow_select && fi->state != Button::DISABLED) { GUI.cursor_mode = CURSOR_HAND; if(on_select && Key.Pressed(VK_LBUTTON)) { selected = fi; on_select(); return; } } } } else if(fi->type == FlowItem::Button && fi->state != Button::DISABLED) { if(PointInRect(GUI.cursor_pos, p, fi->size)) { GUI.cursor_mode = CURSOR_HAND; if(fi->state == Button::DOWN) { if(Key.Up(VK_LBUTTON)) { fi->state = Button::HOVER; on_button(fi->group, fi->id); return; } } else if(Key.Pressed(VK_LBUTTON)) fi->state = Button::DOWN; else fi->state = Button::HOVER; } else fi->state = Button::NONE; } } } scroll.mouse_focus = mouse_focus; scroll.Update(dt); } if(!ok) { for(FlowItem* fi : items) { if(fi->type == FlowItem::Button && fi->state != Button::DISABLED) fi->state = Button::NONE; } } }