예제 #1
0
// --------------------------------------------------------------------------------------------------------
void KWidgetArray::clear ()
{  
    while (children.empty() == false)
    {
        delete children.back();
        children.pop_back();
    }
    size.w = size.h = 0;
    getRootWidget()->layout();
}
예제 #2
0
DialogView::DialogView(const QString &path, QObject *parent):
    synthclone::DesignerView(path, parent)
{
    dialog = qobject_cast<QDialog *>(getRootWidget());
    assert(dialog);

    // XX: If the following line is uncommented, the size of the dialog set in
    // the .ui file changes.
    // dialog->layout()->setSizeConstraint(QLayout::SetFixedSize);

    dialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::Dialog |
                           Qt::WindowCloseButtonHint);
    dialog->setModal(true);
}
예제 #3
0
// protected methods of FFileDialog
//----------------------------------------------------------------------
void FFileDialog::adjustSize()
{
  int X, Y;
  std::size_t max_width;
  std::size_t max_height;
  std::size_t h;
  auto root_widget = getRootWidget();

  if ( root_widget )
  {
    max_width = root_widget->getClientWidth();
    max_height = root_widget->getClientHeight();
  }
  else
  {
    // fallback to xterm default size
    max_width = 80;
    max_height = 24;
  }

  h = max_height - 6;

  if ( h < 15 )  // minimum
    h = 15;

  if ( h > 30 )  // maximum
    h = 30;

  setHeight (h, false);
  X = 1 + int((max_width - getWidth()) / 2);
  Y = 1 + int((max_height - getHeight()) / 3);
  setPos(FPoint(X, Y), false);
  filebrowser.setHeight (h - 8, false);
  hidden.setY (int(h) - 4, false);
  cancel.setY (int(h) - 4, false);
  open.setY (int(h) - 4, false);
  FDialog::adjustSize();
  printPath(directory);
}
예제 #4
0
// onETouchEvent
// update touch event
bool CUIButton::onEvent( const SEvent& gameEvent)
{
	// if childs handle this event
    if ( CUIWidget::onEvent(gameEvent) == true )
        return true;
	
	// not available
	if ( (m_controlID != -1 && gameEvent.EventControlID != 0) || 
		m_buttonState == ButtonDisable || 
		m_visible == false )
		return false;

	bool ret = false;
    CUIWidget *root = getRootWidget();
    
	// process button action
	if ( gameEvent.EventType == EET_MOUSE_INPUT_EVENT && root->isLockActionOnChild() == false )
	{
		// check mouse hit this button
		core::position2di mousePos(gameEvent.MouseInput.X,gameEvent.MouseInput.Y);

        // check mouse over on button
		m_mouseOver = m_rect.isPointInside(mousePos);
        
		// when mouse out the button
		if ( m_mouseOver == false )
		{
			// mouse out
			if ( m_buttonState == ButtonFocus || m_buttonState == ButtonRelease )
                m_flashObj.gotoFrame("normal", true);

			m_buttonState = ButtonNormal;
		}
		else
		{
			if (gameEvent.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN || gameEvent.MouseInput.Event == EMIE_MOUSE_MOVED)
			{
				if ( m_buttonState == ButtonNormal )
				{
                    m_flashObj.gotoFrame("focus", true);
					m_buttonState = ButtonFocus;
				}
			}
			else if ( gameEvent.MouseInput.Event == EMIE_LMOUSE_LEFT_UP )
			{			
				if ( m_buttonState == ButtonFocus )
				{
                    // lock
                    root->lockActionOnChilld( true );
                    
                    // play anim
                    m_flashObj.gotoFrame("release", true);
					m_buttonState = ButtonRelease;
				}
			}

			// handle this event
			ret = true;
		}
	}
    else if ( gameEvent.EventType == EET_FSCOMMAND_EVENT )
    {
        const char *command = gameEvent.FSEvent.Command;
        const char *param   = gameEvent.FSEvent.Param;
        
        if ( strcmp("buttonStatus",  command) == 0 )
        {
            if ( strcmp("release", param) == 0 && m_buttonState == ButtonRelease )
            {                
                // unlock
                root->lockActionOnChilld( false );
                
                // hack for update text
                m_buttonLastState = ButtonRelease;
                if ( m_mouseOver )
                    m_buttonState = ButtonFocus;
                else
                    m_buttonState = ButtonNormal;
                
                // post press button event
                SEvent event;
                SEventButtonData button;
                
                event.EventType = EET_GAME_EVENT;
                event.GameEvent.EventID = (s32)EvtButtonRelease;
                
                button.buttonName = m_widgetName;
                button.data = this;
                event.GameEvent.EventData = &button;
                
                getIView()->getDevice()->postEventFromUser( event );
            }

			// update text
			replaceTextOnLabel();
        }       
    }

	return ret;
}