Ejemplo n.º 1
0
void SelectionWindow::Input(){
    if (skip){
        return;
    }
    UIBase::Input();
    Point pos = Point(InputManager::GetInstance().GetMouseX(),InputManager::GetInstance().GetMouseY());
    if (IsInside(pos.x,pos.y) && InputManager::GetInstance().MousePress(1) ){
        SetFocused(true);
    }
    if (!IsInside(pos.x,pos.y) &&  (InputManager::GetInstance().MouseRelease(1) || InputManager::GetInstance().MousePress(1)) ){
        SetFocused(false);
    }
    if (selectedOption != -1){
        if (InputManager::GetInstance().KeyPress(SDLK_DOWN)){
            selectedOption++;
            if (selectedOption >= optionCounter){
                selectedOption = 0;
            }
        }
        if (InputManager::GetInstance().KeyPress(SDLK_UP)){
            selectedOption--;
            if (selectedOption < 0){
                selectedOption = optionCounter-1;
            }
        }
        if (InputManager::GetInstance().KeyPress(SDLK_SPACE) || InputManager::GetInstance().KeyPress(SDLK_RETURN) || InputManager::GetInstance().KeyPress(SDLK_z) ){
            functions[option[selectedOption]](this,option[selectedOption]);
        }
        if (InputManager::GetInstance().KeyPress(SDLK_x) ){
            Back(this);
        }
    }
}
BOOL  CXTPRibbonControlTab::OnSetSelected(int bSelected)
{
	if (bSelected == m_bSelected)
		return FALSE;

	if (IsKeyboardSelected(bSelected) && !GetRibbonBar()->IsRibbonMinimized())
		m_pParent->SetPopuped(-1);

	m_bSelected = bSelected;

	m_pParent->OnControlSelected(bSelected, this);

	if (IsKeyboardSelected(bSelected))
	{
		SetFocused(TRUE);
	}

	if (!bSelected)
	{
		SetFocused(FALSE);
		PerformMouseMove(m_pParent->GetSafeHwnd(), CPoint(-1, -1));
	}
	else
	{
		AccessibleNotifyWinEvent(EVENT_OBJECT_FOCUS , GetParent()->GetSafeHwnd(), GetID(), GetCurSel() + 1);
	}

	return TRUE;
}
Ejemplo n.º 3
0
void NumberInput::Input(){
    UIBase::Input();
    Point pos = Point(InputManager::GetInstance().GetMouseX(),InputManager::GetInstance().GetMouseY());
    if (IsInside(pos.x,pos.y)){
        if (InputManager::GetInstance().MousePress(1)){
            SetFocused(true);
        }
    }else{
        if (InputManager::GetInstance().MousePress(1)){
            SetFocused(false);
        }
    }
    if (focused){
        int key = InputManager::GetInstance().IsAnyKeyPressed();

        if (key != -1 || delayDelete <= 0){
            std::stringstream S;

            if (key == SDLK_BACKSPACE || delayDelete <= 0){
                if (txt.GetText().size() > 1){
                    txt.SetText(txt.GetText().substr(0,txt.GetText().size()-1));
                }else{
                    txt.SetText("0");
                }
                delayDelete = key == SDLK_BACKSPACE ? 5.0f : 1.0f;
            }else if(key >= 42 && key <= 59){
                if (txt.GetText() != "0"){
                    S << txt.GetText() << (char)key;
                }else{
                    S << (char)key;
                }
                txt.SetText(S.str());

            }
            if (addr != nullptr){
                (*addr) = GetNumber();
            }
        }

    }


}
Ejemplo n.º 4
0
UIBase::UIBase(){
    mother = nullptr;
    Show();
    SetFocused(false);
    close = false;
    alpha = 255;
    Color[0] = 100;
    Color[1] = 100;
    Color[2] = 110;
    Color[3] = 255;
    style = UIStyle::BaseStyle;
    MouseInside = false;
    GenerateId();
    UiName = utils::format("uiobj%.4d",ID);
}
Ejemplo n.º 5
0
/** Remove a Window from the array */
void EventMgr::DelWindow(Window *win)
{
	bool focused = (last_win_focused == win);
	if (focused) {
		last_win_focused = NULL;
	}
	if (last_win_mousefocused == win) {
		last_win_mousefocused = NULL;
	}
	if (last_win_over == win) {
		last_win_over = NULL;
	}
	if (function_bar == win) {
		function_bar = NULL;
	}

	if (windows.size() == 0) {
		return;
	}

	int pos = -1;
	std::vector< Window*>::iterator m;
	for (m = windows.begin(); m != windows.end(); ++m) {
		pos++;
		if ( (*m) == win) {
			(*m) = NULL;
			std::vector< int>::iterator t;
			for (t = topwin.begin(); t != topwin.end(); ++t) {
				if ( (*t) == pos) {
					topwin.erase( t );
					if (focused && topwin.size() > 0) {
						//revert focus to new top window
						SetFocused(windows[topwin[0]], NULL);
					}
					return;
				}
			}
			Log(WARNING, "EventManager", "Couldn't delete window!");
		}
	}
}
Ejemplo n.º 6
0
SelectionWindow::SelectionWindow(Rect dimensions):UIBase(){
    UI_REGISTER(SelectionWindow);
    box = dimensions;
    optionCounter = 0;
    mother = nullptr;
    box.x = dimensions.x;
    box.y = dimensions.y;
    OnMousePress = [=](UIBase*w,int button,Point pos){
        SetFocused(true);
    };
    selectedOption = -1;
    arrow = Text(style.fontfile,style.fontSize,style.txtstyle,">", {style.fg[0],style.fg[1],style.fg[2]} );
    Back = [=](UIBase *b){
    };
    title = new Label(Point(dimensions.w/2 -16,2),std::string(""),this);
    title->style.fg[0] = 255;
    title->style.txtstyle = TEXT_BLENDED;
    AddComponent(title);


}
Ejemplo n.º 7
0
void FlexGrid::OnChildRequestedFocus(UiViewModel &child)
{
	if (!IsFocused()) {
		RequestFocus();
	}

	if (IsFocused()) {
		// Switch focus to the new child, if possible.
		if (focusedCell) {
			rows[focusedCell->first][focusedCell->second]->DropFocus();
			focusedCell = boost::none;
		}
		if (child.TryFocus()) {
			//TODO: Track focus on the cell, and track coords in the cell.
			focusedCell = FindChild(&child);
			SetFocused(true);
		}
		else {
			// The child that requested focus refused to take the focus.
			RelinquishFocus(Control::Nav::NEUTRAL);
		}
	}
}
Ejemplo n.º 8
0
void FlexGrid::SetFocusedCell(size_t row, size_t col)
{
	focusedCell = std::make_pair(row, col);
	SetFocused(true);
}
void CXTPRibbonControlTab::OnUnderlineActivate()
{
	SetFocused(TRUE);
}