Ejemplo n.º 1
0
    void TextField::adjustSize()
    {
        setWidth(getFont()->getWidth(mText) + 6);
        adjustHeight();

        fixScroll();
    }
Ejemplo n.º 2
0
void TCommandLine::enterCommand(QKeyEvent* event)
{
    QString _t = toPlainText();
    mAutoCompletion = false;
    mTabCompletion = false;
    mTabCompletionCount = -1;
    mAutoCompletionCount = -1;
    mTabCompletionTyped = "";

    QStringList _l = _t.split("\n");
    for (int i = 0; i < _l.size(); i++) {
        mpHost->send(_l[i]);
    }
    if (!toPlainText().isEmpty()) {
        mHistoryBuffer = 0;
        setPalette(mRegularPalette);

        mHistoryList.removeAll(toPlainText());
        mHistoryList.push_front(toPlainText());
    }
    if (mpHost->mAutoClearCommandLineAfterSend) {
        clear();
    } else {
        selectAll();
    }
    adjustHeight();
}
Ejemplo n.º 3
0
void UIYabause::fixAspectRatio( int width )
{
	int aspectRatio = QtYabause::volatileSettings()->value( "Video/AspectRatio").toInt();

	switch( aspectRatio )
	{
		case 0:
			setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
			setMinimumSize( 0,0 );
			break;
		case 1:
		case 2:
		{
			int heightOffset = toolBar->height()+menubar->height();
			int height;

			if ( aspectRatio == 1 )
				height = 3 * ((float) width / 4);
			else
				height = 9 * ((float) width / 16);

			mouseYRatio = 240.0 / (float)height * 2.0 * (float)mouseSensitivity / 100.0;

         adjustHeight(height);

			setFixedHeight( height );
			break;
		}
	}
}
Ejemplo n.º 4
0
    void TextField::adjustSize()
    {
        const Rectangle& dim = mText->getDimension(getFont());
        setWidth(dim.width + 8);
        adjustHeight();

        fixScroll();
    }
Ejemplo n.º 5
0
 void DropDown::foldUp()
 {
     if (mDroppedDown)
     {
         mDroppedDown = false;
         adjustHeight();
         mInternalFocusHandler.focusNone();
     }
 }
Ejemplo n.º 6
0
    void DropDown::resizeToContent(bool recursiv) {
        if (mScrollArea != NULL) {
            mScrollArea->resizeToContent();
        }

        if (mListBox != NULL) {
            mScrollArea->resizeToContent();
        }
        adjustHeight();
    }
void MultilineTextEdit::keyPressEvent(QKeyEvent *e) {
    // commit text changes when pressing CTRL + Return or Enter
    if (((e->key() == Qt::Key_Return) || (e->key() == Qt::Key_Enter)) &&
        (e->modifiers() & Qt::ControlModifier)) {
        emit editingFinished();
        adjustHeight();
        e->accept();
    } else {
        QPlainTextEdit::keyPressEvent(e);
    }
}
Ejemplo n.º 8
0
    void DropDown::setListModel(ListModel *listModel)
    {
        mListBox->setListModel(listModel);

        if (mListBox->getSelected() < 0)
        {
            mListBox->setSelected(0);
        }

        adjustHeight();
    }
Ejemplo n.º 9
0
void ItemContainer::logic()
{
    gcn::Widget::logic();

    const int lastUsedSlot = mInventory->getLastUsedSlot();

    if (lastUsedSlot != mLastUsedSlot)
    {
        mLastUsedSlot = lastUsedSlot;
        adjustHeight();
    }
}
Ejemplo n.º 10
0
    DropDown::DropDown(ListModel *listModel,
                       ScrollArea *scrollArea,
                       ListBox *listBox)
    {
        setWidth(100);
        setFocusable(true);
        mDroppedDown = false;
        mPushed = false;
        mIsDragged = false;

        setInternalFocusHandler(&mInternalFocusHandler);

        mInternalScrollArea = (scrollArea == NULL);
        mInternalListBox = (listBox == NULL);

        if (mInternalScrollArea)
        {
            mScrollArea = new ScrollArea();
        }
        else
        {
            mScrollArea = scrollArea;
        }

        if (mInternalListBox)
        {
            mListBox = new ListBox();
        }
        else
        {
            mListBox = listBox;
        }

        mScrollArea->setContent(mListBox);
        add(mScrollArea);

        mListBox->addActionListener(this);
        mListBox->addSelectionListener(this);

        setListModel(listModel);

        if (mListBox->getSelected() < 0)
        {
            mListBox->setSelected(0);
        }

        addMouseListener(this);
        addKeyListener(this);
        addFocusListener(this);

        adjustHeight();
        setBorderSize(1);
    }
Ejemplo n.º 11
0
    TextField::TextField()
    {
        mCaretPosition = 0;
        mXScroll = 0;

        setFocusable(true);

        addMouseListener(this);
        addKeyListener(this);
        adjustHeight();
        setBorderSize(1);
    }
void MultilineTextEdit::focusOutEvent(QFocusEvent *e) {
    if (showContextMenu_) {
        return;
    }

    emit editingFinished();
    adjustHeight();
    // clear text selection
    QTextCursor cursor(textCursor());
    cursor.clearSelection();
    setTextCursor(cursor);

    QPlainTextEdit::focusOutEvent(e);
}
Ejemplo n.º 13
0
void UIYabause::resizeIntegerScaling()
{
   if (!VIDCore || VIDCore->id != VIDCORE_SOFT)
      return;

   if (isFullScreen() || emulateMouse)
      return;

   VolatileSettings* vs = QtYabause::volatileSettings();

   if (!vs->value("Video/EnableIntegerPixelScaling").toBool())
      return;

   int multiplier = vs->value("Video/IntegerPixelScalingMultiplier").toInt();

   if (multiplier % 2 != 0)
      return;

   int vdp2width = 0;
   int vdp2height = 0;
   int vdp2interlace = 0;

   if (!VIDCore->GetNativeResolution)
      return;

   VIDCore->GetNativeResolution(&vdp2width, &vdp2height, &vdp2interlace);

   if (vdp2width == 0 || vdp2height == 0)
      return;

   int width = 0;
   int height = 0;

   if (vdp2width < 640)
      width = vdp2width * multiplier;
   else
      width = vdp2width * (multiplier / 2);

   if (!vdp2interlace)
      height = vdp2height * multiplier;
   else
      height = vdp2height * (multiplier / 2);

   mYabauseGL->resize(width, height);

   adjustHeight(height);

   setMinimumSize(width, height);
   resize(width, height);
}
Ejemplo n.º 14
0
QgsBrowserPropertiesWrapLabel::QgsBrowserPropertiesWrapLabel( const QString& text, QWidget* parent )
    : QTextEdit( text, parent )
{
  setReadOnly( true );
  setFrameStyle( QFrame::NoFrame );
  setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
  QPalette pal = palette();
  pal.setColor( QPalette::Base, Qt::transparent );
  setPalette( pal );
  setLineWrapMode( QTextEdit::WidgetWidth );
  setWordWrapMode( QTextOption::WrapAnywhere );
  connect( qobject_cast<QObject*>( document()->documentLayout() ), SIGNAL( documentSizeChanged( QSizeF ) ),
           this, SLOT( adjustHeight( QSizeF ) ) );
  setMaximumHeight( 20 );
}
Ejemplo n.º 15
0
    void DropDown::dropDown()
    {
        if (!mDroppedDown)
        {
            mDroppedDown = true;
            mFoldedUpHeight = getHeight();
            adjustHeight();

            if (getParent())
            {
                getParent()->moveToTop(this);
            }
        }

        mListBox->requestFocus();
    }
Ejemplo n.º 16
0
void TCommandLine::historyUp(QKeyEvent *event)
{
    if( mHistoryList.size() < 1 ) return;
    if( (textCursor().selectedText().size() == toPlainText().size()) || (toPlainText().size() == 0) )
    {
        if( toPlainText().size() != 0) mHistoryBuffer++;
        if( mHistoryBuffer >= mHistoryList.size() ) mHistoryBuffer = mHistoryList.size()-1;
        if( mHistoryBuffer < 0 ) mHistoryBuffer = 0;
        setPlainText( mHistoryList[mHistoryBuffer] );
        selectAll();
        adjustHeight();
    }
    else
    {
        mAutoCompletionCount++;
        handleAutoCompletion();
    }
}
Ejemplo n.º 17
0
void TCommandLine::processNormalKey(QEvent* event)
{
    QPlainTextEdit::event(event);
    adjustHeight();

    if (mpHost->mAutoClearCommandLineAfterSend) {
        mHistoryBuffer = -1;
    } else {
        mHistoryBuffer = 0;
    }
    if (mTabCompletionOld != toPlainText()) {
        mUserKeptOnTyping = true;
        mAutoCompletionCount = -1;
    } else {
        mUserKeptOnTyping = false;
    }
    spellCheck();
}
Ejemplo n.º 18
0
void TCommandLine::historyDown(QKeyEvent* event)
{
    if (mHistoryList.empty()) {
        return;
    }
    if ((textCursor().selectedText().size() == toPlainText().size()) || (toPlainText().size() == 0)) {
        mHistoryBuffer--;
        if (mHistoryBuffer >= mHistoryList.size()) {
            mHistoryBuffer = mHistoryList.size() - 1;
        }
        if (mHistoryBuffer < 0) {
            mHistoryBuffer = 0;
        }
        setPlainText(mHistoryList[mHistoryBuffer]);
        selectAll();
        adjustHeight();
    } else {
        mAutoCompletionCount--;
        handleAutoCompletion();
    }
}
Ejemplo n.º 19
0
// This function overrides the QWidget::event() and should return true if the
// event was recognized, otherwise it should return false. If the recognized
// event was accepted (see QEvent::accepted), any further processing such as
// event propagation to the parent widget stops.
bool TCommandLine::event(QEvent* event)
{
    const Qt::KeyboardModifiers allModifiers = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier;
    if (event->type() == QEvent::KeyPress) {
        auto * ke = dynamic_cast<QKeyEvent*>(event);

        // Shortcut for keypad keys
        if ((ke->modifiers() & Qt::KeypadModifier) && mpKeyUnit->processDataStream(ke->key(), (int)ke->modifiers())) {
            ke->accept();
            return true;

        }

        switch (ke->key()) {
        case Qt::Key_Space:
            if ((ke->modifiers() & (allModifiers & ~(Qt::ShiftModifier))) == Qt::NoModifier) {
                // Ignore the <SHIFT> modifier only - keeps some users happy!
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                mTabCompletionTyped.clear();
                mAutoCompletionTyped.clear();
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }
                mLastCompletion.clear();
                break;

            } else {
                // Process as a possible key binding if there are ANY modifiers
                // other than just a <SHIFT> one; may actaully be configured as
                // a non-breaking space when used with a modifier!
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Backtab:
            // <BACKTAB> is usually internally generated by SHIFT used in
            // conjunction with TAB - so ignore just the SHIFT key:
            if ((ke->modifiers() & (allModifiers & ~(Qt::ShiftModifier))) == Qt::ControlModifier) {
                // Switch to PREVIOUS profile tab when used with <CTRL> (and
                // implicit <SHIFT>):
                int currentIndex = mudlet::self()->mpTabBar->currentIndex();
                int count = mudlet::self()->mpTabBar->count();
                if (currentIndex - 1 < 0) {
                    mudlet::self()->mpTabBar->setCurrentIndex(count - 1);
                } else {
                    mudlet::self()->mpTabBar->setCurrentIndex(currentIndex - 1);
                }
                ke->accept();
                return true;

            } else if ((ke->modifiers() & (allModifiers & ~(Qt::ShiftModifier))) ==  Qt::NoModifier) {
                // Process as plain <BACKTAB> - (ignoring implicit <SHIFT>)
                handleTabCompletion(false);
                adjustHeight();
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers
                // other than just the ignored <SHIFT> and the possible <CTRL>:
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Tab:
            if ((ke->modifiers() & allModifiers) == Qt::ControlModifier) {
                // Switch to NEXT profile tab
                int currentIndex = mudlet::self()->mpTabBar->currentIndex();
                int count = mudlet::self()->mpTabBar->count();
                if (currentIndex + 1 < count) {
                    mudlet::self()->mpTabBar->setCurrentIndex(currentIndex + 1);
                } else {
                    mudlet::self()->mpTabBar->setCurrentIndex(0);
                }
                ke->accept();
                return true;

            } else if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                handleTabCompletion(true);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers
                // other than just the Ctrl one
                // CHECKME: What about system foreground application switching?
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_unknown:
            qWarning() << "ERROR: key unknown!";
            break;

        case Qt::Key_Backspace:
            if ((ke->modifiers() & (allModifiers & ~(Qt::ControlModifier|Qt::ShiftModifier))) == Qt::NoModifier) {
                // Ignore state of <CTRL> and <SHIFT> keys
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }

                if (mTabCompletionTyped.size() >= 1) {
                    mTabCompletionTyped.chop(1);
                    mAutoCompletionTyped.chop(1);
                }
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                mLastCompletion.clear();
                QPlainTextEdit::event(event);

                adjustHeight();

                return true;
            } else {
                // Process as a possible key binding if there are ANY modifiers
                // other than <CTRL> and/or <SHIFT>
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Delete:
            if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }

                if (mTabCompletionTyped.size() >= 1) {
                    mTabCompletionTyped.chop(1);
                    mAutoCompletionTyped.chop(1);
                } else {
                    mTabCompletionTyped.clear();
                    mAutoCompletionTyped.clear();
                    mUserKeptOnTyping = false;
                }
                mAutoCompletionCount = -1;
                mTabCompletionCount = -1;
                mLastCompletion.clear();
                QPlainTextEdit::event(event);
                adjustHeight();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Return: // This is the main one (not the keypad)
            if ((ke->modifiers() & allModifiers) == Qt::ControlModifier) {
                // If Ctrl-Return is pressed - scroll to the bottom of text:
                mpConsole->mLowerPane->mCursorY = mpConsole->buffer.size();
                mpConsole->mLowerPane->hide();
                mpConsole->buffer.mCursorY = mpConsole->buffer.size();
                mpConsole->mUpperPane->mCursorY = mpConsole->buffer.size();
                mpConsole->mUpperPane->mIsTailMode = true;
                mpConsole->mUpperPane->updateScreenView();
                mpConsole->mUpperPane->forceUpdate();
                ke->accept();
                return true;

            } else if ((ke->modifiers() & allModifiers) == Qt::ShiftModifier) {
                textCursor().insertBlock();
                ke->accept();
                return true;

            } else if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                // Do the normal return key stuff only if NO modifiers are used:
                enterCommand(ke);
                mAutoCompletionCount = -1;
                mAutoCompletionTyped.clear();
                mLastCompletion.clear();
                mTabCompletionTyped.clear();
                mUserKeptOnTyping = false;
                mTabCompletionCount = -1;
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    clear();
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }
                adjustHeight();
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                // other than just the Shift or just the Control modifiers
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Enter:
            // This is usually the Keypad one, so may come with
            // the keypad modifier - but if so it may never be reached because
            // of the keypad modifier interception done before this switch...
            if ((ke->modifiers() & (allModifiers & ~(Qt::KeypadModifier))) == Qt::NoModifier) {
                // Do the "normal" return key action if no or just the keypad
                // modifier is present:
                enterCommand(ke);
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                mLastCompletion.clear();
                mTabCompletionTyped.clear();
                mAutoCompletionTyped.clear();
                mUserKeptOnTyping = false;
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    clear();
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }
                adjustHeight();
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                // other than just the Keypad modifier
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Down:
#if defined(Q_OS_MACOS)
            if ((ke->modifiers() & allModifiers) == (Qt::ControlModifier|Qt::KeypadModifier)) {
#else
            if ((ke->modifiers() & allModifiers) == Qt::ControlModifier) {
#endif
                // If EXACTLY <Ctrl>-Down is pressed (special case for macOs -
                // also sets KeyPad modifier)
                moveCursor(QTextCursor::Down, QTextCursor::MoveAnchor);
                ke->accept();
                return true;

#if defined(Q_OS_MACOS)
            } else if ((ke->modifiers() & allModifiers) == Qt::KeypadModifier) {
#else
            } else if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
#endif
                // If EXACTLY Down is pressed without modifiers (special case
                // for macOs - also sets KeyPad modifier)
                historyDown(ke);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                // other than just the Control modifier (or keypad modifier on
                // macOs)
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Up:
#if defined(Q_OS_MACOS)
            if ((ke->modifiers() & allModifiers) == (Qt::ControlModifier|Qt::KeypadModifier)) {
#else
            if ((ke->modifiers() & allModifiers) == Qt::ControlModifier) {
#endif
                // If EXACTLY <Ctrl>-Up is pressed (special case for macOs -
                // also sets KeyPad modifier)
                moveCursor(QTextCursor::Up, QTextCursor::MoveAnchor);
                ke->accept();
                return true;

#if defined(Q_OS_MACOS)
            } else if ((ke->modifiers() & allModifiers) == Qt::KeypadModifier) {
#else
            } else if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
#endif
                // If EXACTLY Up is pressed without modifiers (special case for
                // macOs - also sets KeyPad modifier)
                historyUp(ke);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                // other than just the Control modifier (or keypad modifier on
                // macOs)
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_Escape:
            if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                // Escape from tab completion mode if used with NO modifiers
                selectAll();
                mAutoCompletion = false;
                mTabCompletion = false;
                mTabCompletionTyped.clear();
                mAutoCompletionTyped.clear();
                mUserKeptOnTyping = false;
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                setPalette(mRegularPalette);
                if (mpHost->mAutoClearCommandLineAfterSend) {
                    mHistoryBuffer = -1;
                } else {
                    mHistoryBuffer = 0;
                }
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_PageUp:
            if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                mpConsole->scrollUp(mpHost->mScreenHeight);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_PageDown:
            if ((ke->modifiers() & allModifiers) == Qt::NoModifier) {
                mpConsole->scrollDown(mpHost->mScreenHeight);
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                return processPotentialKeyBinding(ke);

            }

        case Qt::Key_C:
            if (((ke->modifiers() & allModifiers) == Qt::ControlModifier)
                && (mpConsole->mUpperPane->mSelectedRegion != QRegion(0, 0, 0, 0))) {

                // Only process as a Control-C if it is EXACTLY those two keys
                // and no other AND there is a selection active in the TConsole
                mpConsole->mUpperPane->slot_copySelectionToClipboard();
                ke->accept();
                return true;

            } else {
                // Process as a possible key binding if there are ANY modifiers,
                if (processPotentialKeyBinding(ke)) {
                    return true;

                } else {
                    processNormalKey(event);
                    return false;

                }
            }

        default:
            // Process as a possible key binding if there are ANY modifiers,
            if (processPotentialKeyBinding(ke)) {
                return true;

            } else {
                processNormalKey(event);
                return false;

            }
        }
    }

    return QPlainTextEdit::event(event);
}

void TCommandLine::focusInEvent(QFocusEvent* event)
{
    textCursor().movePosition(QTextCursor::Start);
    textCursor().movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, mSelectedText.length());

    mpConsole->mUpperPane->forceUpdate();
    mpConsole->mLowerPane->forceUpdate();
    QPlainTextEdit::focusInEvent(event);
}
void MultilineTextEdit::resizeEvent(QResizeEvent *e) {
    QPlainTextEdit::resizeEvent(e);
    adjustHeight();
}
Ejemplo n.º 21
0
int main()
{
	bool all_waypoint_reached = 0, waypoint_1_reached = 0, waypoint_2_reached = 0, waypoint_3_reached = 0, startingpoint_reached = 0; 
	float waypoint_1_LAT = 0, waypoint_1_LONG = 0, minFlyHeight, maxFlyHeight, distanceToWaypoint = 20;
	float startingLAT, startingLONG, currLAT = 0, currLONG = 0; 
	long millisCount = 0, puttimer, requestDelay, httpWait;
	int NextEvent = 0,firstrun;
	
	init();
	init3G_GPS_Module();
	
	// Init GPS module
	GPSInfo.initGPS();

	for (int i = 0; i< 10;i++)
	{
		GPSInfo.updateGPSPosition();
	}
	startingLAT = GPSInfo.getLat();
	startingLONG = GPSInfo.getLong();
	
	com.initialGet();
	delay(40000);
	
	int values = com.putURL();
	delay(4000);
	
	com.putDroneStatus(startingLAT,startingLONG);
	delay(40000);
	puttimer = millis();
	do
	{
		
		
		if (millis()-puttimer > 300000)
		{
			int values = com.putURL();
			delay(4000);
			com.putDroneStatus(startingLAT,startingLONG);
			puttimer = millis();
		}
		// check for nextevent, if nextevent == 0 - stay in loop
		waypoints = com.getwayPoints();
	} while (waypoints == NULL);
	
	// Drone is ready for takeoff.
	
				
	drone.initMotors();
	drone.armMotors();
	THROTTLE = 22000;
	minFlyHeight = 10;
	maxFlyHeight = 40;
	
	while(all_waypoint_reached != true)
	{
		millisCount = millis();
		
		while(waypoint_1_reached != true)
		{
			
			while(drone.checkIfControllerIsOn() == true)	// Check for controller
			{
					
			}
						
// 			GPSInfo.updateGPSPosition();
// 			currLAT = GPSInfo.getLat();
// 			currLONG = GPSInfo.getLong();
			waypoint_1_LAT = waypoints[0].getlat();
			waypoint_1_LONG = waypoints[0].getlong();
 			distanceToWaypoint = drone.calDistToTarget(startingLAT, startingLONG, waypoint_1_LAT, waypoint_1_LONG);
		
			if(distanceToWaypoint < 15)
			{
				waypoint_1_reached = true;
			}
		
			else
			{			
				
				adjustHeight(minFlyHeight, maxFlyHeight);
				heightFLAG = 1;
 				adjustBearing(startingLAT, startingLONG, waypoint_1_LAT, waypoint_1_LONG, heightFLAG);	

// 				flyForward(heightFLAG, bearingFLAG);			
// 				
// 				if(millis() - millisCount > 40000)
// 				{
// 					communication.put_isOnline_CurrPos(currLAT, currLONG);
// 					millisCount = millis();
// 				}

			}
		}
		
		all_waypoint_reached = true;
	}	
}       
Ejemplo n.º 22
0
    void DropDown::setListModel(ListModel *listModel)
    {
        mListBox->setListModel(listModel);

        adjustHeight();
    }
Ejemplo n.º 23
0
DropDown::DropDown(const Widget2 *const widget,
                   ListModel *const listModel,
                   const bool extended,
                   const Modal modal,
                   ActionListener *const listener,
                   const std::string &eventId) :
    ActionListener(),
    BasicContainer(widget),
    KeyListener(),
    MouseListener(),
    FocusListener(),
    SelectionListener(),
    mPopup(CREATEWIDGETR(PopupList, this, listModel, extended, modal)),
    mShadowColor(getThemeColor(ThemeColorId::DROPDOWN_SHADOW)),
    mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
    mPadding(1),
    mImagePadding(2),
    mSpacing(0),
    mFoldedUpHeight(0),
    mSelectionListeners(),
    mExtended(extended),
    mDroppedDown(false),
    mPushed(false),
    mIsDragged(false)
{
    mAllowLogic = false;
    mFrameSize = 2;
    mForegroundColor2 = getThemeColor(ThemeColorId::DROPDOWN_OUTLINE);

    mPopup->setHeight(100);

    // Initialize graphics
    if (instances == 0 && theme)
    {
        // Load the background skin
        for (int i = 0; i < 2; i ++)
        {
            Skin *const skin = theme->load(dropdownFiles[i], "dropdown.xml");
            if (skin)
            {
                if (!i)
                    mSkin = skin;
                const ImageRect &rect = skin->getBorder();
                for (int f = 0; f < 2; f ++)
                {
                    if (rect.grid[f])
                    {
                        rect.grid[f]->incRef();
                        buttons[f][i] = rect.grid[f];
                        buttons[f][i]->setAlpha(mAlpha);
                    }
                    else
                    {
                        buttons[f][i] = nullptr;
                    }
                }
                if (i)
                    theme->unload(skin);
            }
            else
            {
                for (int f = 0; f < 2; f ++)
                    buttons[f][i] = nullptr;
            }
        }

        // get the border skin
        theme->loadRect(skinRect, "dropdown_background.xml", "");
    }

    instances++;

    setWidth(100);
    setFocusable(true);
    setListModel(listModel);

    if (mPopup->getSelected() < 0)
        mPopup->setSelected(0);

    addMouseListener(this);
    addKeyListener(this);
    addFocusListener(this);

    adjustHeight();
//    mPopup->setForegroundColorAll(getThemeColor(ThemeColorId::DROPDOWN),
//        getThemeColor(ThemeColorId::DROPDOWN_OUTLINE));
    mForegroundColor = getThemeColor(ThemeColorId::DROPDOWN);
    mForegroundColor2 = getThemeColor(ThemeColorId::DROPDOWN_OUTLINE);

    if (!eventId.empty())
        setActionEventId(eventId);

    if (listener)
        addActionListener(listener);

    mPopup->adjustSize();

    if (mSkin)
    {
        mSpacing = mSkin->getOption("spacing");
        mFrameSize = CAST_U32(mSkin->getOption("frameSize"));
        mPadding = mSkin->getPadding();
        mImagePadding = mSkin->getOption("imagePadding");
    }
    adjustHeight();
}
Ejemplo n.º 24
0
bool TCommandLine::event( QEvent * event )
{
    if( event->type() == QEvent::KeyPress )
    {
        QKeyEvent *ke = static_cast<QKeyEvent *>( event );
        //qDebug()<<"modifier="<<ke->modifiers()<<" key="<<ke->key();
        switch( ke->key() )
        {
            case Qt::Key_Space:
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                mTabCompletionTyped = "";
                mAutoCompletionTyped = "";
                if( mpHost->mAutoClearCommandLineAfterSend )
                    mHistoryBuffer = -1;
                else
                    mHistoryBuffer = 0;
                mLastCompletion = "";
                break;

            case Qt::Key_Backtab:
                handleTabCompletion( false );
                ke->accept();
                adjustHeight();
                return true;
                break;

            case Qt::Key_Tab:
                handleTabCompletion( true );
                ke->accept();
                return true;
                break;

            case Qt::Key_unknown:
                qWarning()<<"ERROR: key unknown!";
                break;

            case Qt::Key_Backspace:
                if( mpHost->mAutoClearCommandLineAfterSend )
                    mHistoryBuffer = -1;
                else
                    mHistoryBuffer = 0;
                if( mTabCompletionTyped.size() >= 1 )
                {
                    mTabCompletionTyped.chop(1);
                    mAutoCompletionTyped.chop(1);
                    mTabCompletionCount = -1;
                    mAutoCompletionCount = -1;
                    mLastCompletion = "";
                }
                else
                {
                    mTabCompletionCount = -1;
                    mAutoCompletionCount = -1;
                    mLastCompletion = "";
                }
                QPlainTextEdit::event(event);

                adjustHeight();

                return true;

            case Qt::Key_Delete:
                if( mpHost->mAutoClearCommandLineAfterSend )
                    mHistoryBuffer = -1;
                else
                    mHistoryBuffer = 0;
                if( mTabCompletionTyped.size() >= 1 )
                {
                    mTabCompletionTyped.chop(1);
                    mAutoCompletionTyped.chop(1);
                    mTabCompletionCount = -1;
                    mAutoCompletionCount = -1;
                    mLastCompletion = "";
                }
                else
                {
                    mTabCompletionCount = -1;
                    mAutoCompletionCount = -1;
                    mLastCompletion = "";
                    mTabCompletionTyped = "";
                    mAutoCompletionTyped = "";
                    mUserKeptOnTyping = false;
                    mTabCompletionCount = -1;
                    mAutoCompletionCount = -1;
                }
                QPlainTextEdit::event(event);
                adjustHeight();
                return true;
                break;

            case Qt::Key_Return:
                if( ke->modifiers() & Qt::ControlModifier )
                {
                    mpConsole->console2->mCursorY = mpConsole->buffer.size();//
                    mpConsole->console2->hide();
                    mpConsole->buffer.mCursorY = mpConsole->buffer.size();
                    mpConsole->console->mCursorY = mpConsole->buffer.size();//
                    mpConsole->console->mIsTailMode = true;
                    mpConsole->console->updateScreenView();
                    mpConsole->console->forceUpdate();
                    ke->accept();
                    return true;
                }
                else if( ke->modifiers() & Qt::ShiftModifier )
                {
                    textCursor().insertBlock();
                    /*if( ! textCursor().movePosition(QTextCursor::Down, QTextCursor::KeepAnchor) )
                    {
                        textCursor().insertBlock();
                    }*/
                    ke->accept();
                    return true;
                }
                else
                {
                    enterCommand(ke);
                    mTabCompletionCount = -1;
                    mAutoCompletionCount = -1;
                    mLastCompletion = "";
                    mTabCompletionTyped = "";
                    mAutoCompletionTyped = "";
                    mUserKeptOnTyping = false;
                    mTabCompletionCount = -1;
                    mAutoCompletionCount = -1;
                    if( mpHost->mAutoClearCommandLineAfterSend )
                    {
                        clear();
                        mHistoryBuffer = -1;
                    }
                    else
                        mHistoryBuffer = 0;
                    adjustHeight();
                    ke->accept();
                    return true;
                }
                break;

            case Qt::Key_Enter:
                enterCommand(ke);
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                mLastCompletion = "";
                mTabCompletionTyped = "";
                mAutoCompletionTyped = "";
                mUserKeptOnTyping = false;
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                if( mpHost->mAutoClearCommandLineAfterSend )
                {
                    clear();
                    mHistoryBuffer = -1;
                }
                else
                    mHistoryBuffer = 0;
                adjustHeight();
                ke->accept();
                return true;
                break;

            case Qt::Key_Down:
                if( ke->modifiers() & Qt::ControlModifier )
                {
                    moveCursor(QTextCursor::Down, QTextCursor::MoveAnchor);
                    ke->accept();
                    return true;
                }
                else
                {
                    historyDown(ke);
                    ke->accept();
                    return true;
                }
                break;

            case Qt::Key_Up:
                if( ke->modifiers() & Qt::ControlModifier )
                {
                    moveCursor(QTextCursor::Up, QTextCursor::MoveAnchor );
                    ke->accept();
                    return true;
                }
                else
                {
                    historyUp(ke);
                    ke->accept();
                    return true;
                }
                break;

            case Qt::Key_Escape:

                selectAll();
                mAutoCompletion = false;
                mTabCompletion = false;
                mTabCompletionTyped = "";
                mAutoCompletionTyped = "";
                mUserKeptOnTyping = false;
                mTabCompletionCount = -1;
                mAutoCompletionCount = -1;
                setPalette( mRegularPalette );
                if( mpHost->mAutoClearCommandLineAfterSend )
                    mHistoryBuffer = -1;
                else
                    mHistoryBuffer = 0;
                ke->accept();
                return true;
                break;

            case Qt::Key_PageUp:
                mpConsole->scrollUp( mpHost->mScreenHeight );
                ke->accept();
                return true;
                break;

            case Qt::Key_PageDown:
                mpConsole->scrollDown( mpHost->mScreenHeight );
                ke->accept();
                return true;
                break;

            case Qt::Key_C:
                if( ke->modifiers() & Qt::ControlModifier )
                {
                     if( mpConsole->console->mSelectedRegion != QRegion( 0, 0, 0, 0 ) )
                     {
                         mpConsole->console->copySelectionToClipboard();
                         ke->accept();
                         return true;
                     }
                }
                break;

            default:

                if( mpKeyUnit->processDataStream( ke->key(), (int)ke->modifiers() ) )
                {
                    ke->accept();
                    return true;
                }
                else
                {
                    QPlainTextEdit::event( event );
                    adjustHeight();

                    if( mpHost->mAutoClearCommandLineAfterSend )
                        mHistoryBuffer = -1;
                    else
                        mHistoryBuffer = 0;
                    if( mTabCompletionOld != toPlainText() )//text() )
                    {
                        mUserKeptOnTyping = true;
                        mAutoCompletionCount = -1;
                    }
                    else
                    {
                        mUserKeptOnTyping = false;
                    }
                    spellCheck();
                    return false;
                }
        }

    }

    return QPlainTextEdit::event( event );
}
Ejemplo n.º 25
0
 void DropDown::adjustSize() {
     adjustHeight();
 }
Ejemplo n.º 26
0
void ItemContainer::widgetResized(const gcn::Event &event)
{
    mGridColumns = std::max(1, getWidth() / BOX_WIDTH);
    adjustHeight();
}