Beispiel #1
0
SelectFont::SelectFont(QWidget *parent)
	: QWidget(parent)
{
	QHBoxLayout *layout = new QHBoxLayout;
	layout->setSpacing(5);

	fontEdit = new QLineEdit(this);
	fontEdit->setReadOnly(true);

	QPushButton *button = new QPushButton(tr("Select"), this);
	connect(button, SIGNAL(clicked()), this, SLOT(onClick()));

	layout->addWidget(fontEdit);
	layout->addWidget(button);

	setLayout(layout);
}
Beispiel #2
0
void SDL_GUI::GUI_Element::Update()
{
	bool inRect = rect.Contains(inputManager->GetMousePosition());

	if (!mouseIsOver && inRect)
	{
		mouseIsOver = true;

		if (onMouseOver != NULL)
			onMouseOver();
	}
	else if (mouseIsOver && !inRect)
	{
		mouseIsOver = false;
		performingClick = false;

		if (onMouseOut != NULL)
			onMouseOut();
	}

	if (inRect)
	{
		if (inputManager->MouseDown())
		{
			performingClick = true;

			if (onMouseDown != NULL)
				onMouseDown();
		}
		else if (inputManager->MouseUp())
		{
			if (onMouseUp != NULL)
				onMouseUp();

			if (performingClick)
			{
				performingClick = false;

				if (onClick != NULL)
					onClick();
			}
		}
	}
}
Beispiel #3
0
Edit::Edit(QWidget *parent, bool usesClear, QString standard, int maximumLetters) : QLineEdit(parent)
{
    button = new Label(parent);
    button->hide();

    valueStandart = standard;
    this->setText(valueStandart);
    this->setToolTip(valueStandart);

#if defined(Q_WS_X11)
    {
        QFont f("Sans Serif", 6);
        this->setFont(f);
    }
#endif

#if defined(Q_WS_WIN)
    {
        QFont f("MS Shell Dlq 2", 9);
        this->setFont(f);
    }
#endif

    if(usesClear)
    {
        button->setToolTip(tr("Limpar Campo"));
        button->setCursor(Qt::PointingHandCursor);
        connect(button,SIGNAL(onClick()),this,SLOT(Clear()));
        button->setPixmap(QPixmap(url_clear));
        useClear = true;
    }

    this->setMaxLength(maximumLetters);

    connections();

    setUpperCase(false);

    this->installEventFilter(this);

    hasNext = false;

    setAutomaticallyNextComponent(false);
}
Beispiel #4
0
void CButton::onEvent(Uint8 eventType)
{
	if(!display) return;
	int mouse_x = event.button.x;
	int mouse_y = event.button.y;

	if(onButton(mouse_x, mouse_y))
	{
		if(eventType == SDL_MOUSEBUTTONDOWN)
			onMouseDown();
		else if(eventType == SDL_MOUSEBUTTONUP)
			onClick();
		else if(eventType == SDL_MOUSEMOTION)
			onMouseOver();
	}
	else
		setImageState(getType());
		
}
Beispiel #5
0
		void Window::TestEvents(sf::Event &ev)
		{
			Events::EventArgs stdArg;
			OnEvent<Events::EventArgs>(GainedFocus, &GainedFocusAsync, stdArg);
			OnEvent<Events::EventArgs>(LostFocus, &LostFocusAsync, stdArg);
			OnEvent<Events::ResizeArgs>(Resize, &ResizeAsync, ev.size);
			OnEvent<Events::JoystickButtonArgs>(JoystickButtonPressed, &JoystickButtonPressedAsync, ev.joystickButton);
			OnEvent<Events::JoystickButtonArgs>(JoystickButtonRelease, &JoystickButtonReleaseAsync, ev.joystickButton);
			OnEvent<Events::JoystickArgs>(JoystickConnect, &JoystickConnectAsync, ev.joystickConnect);
			OnEvent<Events::JoystickArgs>(JoystickDisconnect, &JoystickDisconnectAsync, ev.joystickConnect);
			OnEvent<Events::JoystickMoveArgs>(JoystickMove, &JoystickMoveAsync, ev.joystickMove);
			onKeyPressed(ev.key);
			onKeyRelease(ev.key);
			onClick(ev.mouseButton);
			onReleaseMouse(ev.mouseButton);
			OnEvent<Events::EventArgs>(MouseEnter, &MouseEnterAsync, stdArg);
			OnEvent<Events::EventArgs>(MouseLeft, &MouseLeftAsync, stdArg);
			OnEvent<Events::MouseWheelArgs>(MouseWheel, &MouseWheelAsync, ev.mouseWheel);
			onTextType(ev.text);
		}
Beispiel #6
0
/*
class QSlotStorage : public QObject {
public:
    QSlotStorage() { }
    void onClick() {
	printf("QSlotStorage::onClicked()\n");
	fflush(stdout);
    }
};
*/
int main() {
    BApplication *app = new BApplication("application/x.vnd-Lemon-Nirvana");
    TestWindow *test = new TestWindow( BRect(30,30,700,500), "test1" );
    QWidget *widget = test->RootWidget();
    QCheckBox *check = new QCheckBox( widget ); 
    check->resize(100,200);
    QSlotStorage *storage = new QSlotStorage();

    QObject::connect(check, SIGNAL(clicked()), new QSlot(storage, SLOT(onClick())));
    KWQSignal *signal = check->findSignal(SIGNAL(clicked()));
    //printf("%s\n",signal->_name);
    signal->call();

    check->setText("Label sd fsd fsd fsd fsd fsd fsd fsd fsd fsd fsd fsd fs dfs df sd fsd fs fd");
    check->move(100,100);

    test->Show();
    app->Run();
    return 0;
}
Beispiel #7
0
bool UICenterItem::doTouchCanMove(int touchType,const CCPoint &touchPoint)
{
	if (!this->isVisible()) return false;
	switch(touchType)
	{
		case UICenterItem::TOUCH_DOWN:
		{
			if (checkIn(touchPoint))
			{
				inTouch = true;
				nowTouchPoint = touchPoint;
				initWithSpriteFrame(downShow);
				return  true;
			}
		}break;
		case UICenterItem::TOUCH_MOVE:
		{
			if (inTouch && canMove)
			{
				CCPoint nowPoint = getPosition();
				setPosition(ccp(nowPoint.x + touchPoint.x - nowTouchPoint.x,
                                  nowPoint.y + touchPoint.y - nowTouchPoint.y));
				nowTouchPoint = touchPoint;
				return true;
			}
		}break;
		case UICenterItem::TOUCH_END:
		{
			if (inTouch)
			{
				initWithSpriteFrame(upShow);
				if (checkIn(touchPoint))
					onClick();
			}

			inTouch = false;
			
		}break;
	}
	return false;
}
Beispiel #8
0
bool MouseControl::mouseEvent(SDL_Event &e)
{
	if (!_owner->isMouseOver())
	{
		if (_owner->window()->mouseOverWidget() == 5)
			std::cout << "11111" << std::endl;
		changeState(WS_NORMAL);
		return true;
	}

	std::cout << _owner->id() << ", " << _widgetState << std::endl;
	
	if (_widgetState == WS_DISABLE)
		return false;

	switch (e.type)
	{
	case SDL_MOUSEBUTTONDOWN:
		if (e.button.button == SDL_BUTTON_LEFT)
			changeState(WS_PRESS);
		break;
	case SDL_MOUSEBUTTONUP:
	{
		std::cout << "SDL_MOUSEBUTTONUP: "<< _widgetState <<", rl: "<<(int)e.button.button<< std::endl;
		if (e.button.button == SDL_BUTTON_LEFT)
		{
			std::cout << "WS_PRESS: " << std::endl;
			changeState(WS_OVER);

			//if (e.button.clicks == 1)
			onClick();
		}
	}
		break;
	default:
		changeState(WS_OVER);
		break;
	}

	return true;
}
Beispiel #9
0
bool cLed::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){
	bool result;
	eLedState oldState = state;
	if(onClick != NULL) result = onClick(me,id,mods);
	else{ // simple state toggle
		switch(state){
			case led_red:
			case led_green:
				state = led_off;
				break;
			case led_off:
				state = led_red;
		}
		result = true;
	}
	if(!triggerFocusHandler(me,id, oldState != led_off)){
		result = false;
		state = oldState;
	}
	return result;
}
Beispiel #10
0
Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    //创建控件
    m_label = new QLabel("phone-number list");
    m_lotteryButton = new QPushButton("enter lottery");
    m_numberListWidget = new QListWidget();

    //布局管理
    QVBoxLayout *layout = new QVBoxLayout(this);
    QHBoxLayout *actionLayout = new QHBoxLayout();
    actionLayout->addWidget(m_label);
    actionLayout->addStretch(1);
    actionLayout->addWidget(m_lotteryButton);
    actionLayout->addSpacing(1);
    layout->addLayout(actionLayout);
    layout->addWidget(m_numberListWidget);

    connect(m_lotteryButton,SIGNAL(clicked()),this,SLOT(onClick()));

    //读入数据
    dataLoader.load(DataLoader::Json);
    dataLoader.output(phoneNumbers);

//    phoneNumbers.push_back("17778543214");
//    phoneNumbers.push_back("13524896482");
//    phoneNumbers.push_back("19504632458");
//    phoneNumbers.push_back("84095463217");
//    phoneNumbers.push_back("15069874352");
//    phoneNumbers.push_back("12654138524");
//    phoneNumbers.push_back("15965478512");

    //使用迭代器遍历QVector
    QVector<QString>::iterator p;
    for(p=phoneNumbers.begin(); p < phoneNumbers.end(); p++)
    {
        m_numberListWidget->addItem(*p);
    }

}
Beispiel #11
0
colorizer::colorizer(QWidget *parent):QWidget(parent)
{
	QSettings settings(QSettings::IniFormat, QSettings::UserScope, "$h@d0WFoXx","Julia");
	QDesktopWidget *desktop = new QDesktopWidget;
	move(desktop->screenGeometry().width()/2 - 390, desktop->screenGeometry().height()/2 + 100);
	restoreGeometry(settings.value("colorizer/geometry").toByteArray());
	img = QImage(QSize(40,210), QImage::Format_RGB32);
	inMotion = false;
	ticks.append(new check(this));
	ticks[0]->move(30,0);
	ticks[0]->setFixed(true);
	
	ticks.append(new check(this));
	ticks[1]->move(30,200);
	ticks[1]->setColor(QColor(Qt::blue));
	ticks[1]->setFixed(true);
	
	setFixedSize(40,210);
	connect(ticks[0], SIGNAL(onClick()), this, SLOT(newTick()));
	connect(ticks[0], SIGNAL(changed()), this, SIGNAL(changed()));
	connect(ticks[1], SIGNAL(changed()), this, SIGNAL(changed()));

}
Beispiel #12
0
TeamForm::TeamForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TeamForm)
{
    ui->setupUi(this);
    QSettings settings;
    QStringList known = settings.value("team_domains").toStringList();
    known.sort(Qt::CaseInsensitive);
    ui->listWidget->addItems(known);
    if(known.isEmpty()){ 
      ui->radio_newteam->setChecked(true);
      ui->radio_knownteam->setEnabled(false);
      ui->listWidget->setEnabled(false);
      ui->lineEdit->setFocus();
    }else{ ui->radio_knownteam->setChecked(true); }
    ui->pushButton->setEnabled(false);
    connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged()));
    connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(onTextChanged()) );
    connect(ui->radio_newteam, SIGNAL(toggled(bool)), this, SLOT(onTextChanged()) );
    connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(onClick()));
    setWindowIcon(QIcon(QString("://images/png/icon32.png")));
    onTextChanged();
}
Beispiel #13
0
void RSpriteItem::onMouseEvent(int button, int state, int x, int y)
{
    if (button == REvent::MouseLeftButton) {
        if (state == REvent::MouseDown) {
            RVector worldPoint = RTransUtils::worldSpacePoint(mProjection, mCamera, mTransformation, RVector(x, y));
            mIsPressed = false;

            if (worldPoint.x() > mX && worldPoint.x() < mX + mWidth &&
                    worldPoint.y() > mY && worldPoint.y() < mY + mHeight) {
                mIsPressed = true;
            }

        } else {
            if (mIsPressed) {
                RVector worldPoint = RTransUtils::worldSpacePoint(mProjection, mCamera, mTransformation, RVector(x, y));
                if (worldPoint.x() > mX && worldPoint.x() < mX + mWidth &&
                        worldPoint.y() > mY && worldPoint.y() < mY + mHeight) {
                    onClick(x, y);
                }
            }
            mIsPressed = false;
        }
    }
}
Beispiel #14
0
Datei: gui.cpp Projekt: SL-RU/rpb
void GUIList::Input(INPUT_ACTIONS ia)
{
  if(ia == up)
    {
      curPos--;
      if(curPos < 0)
	{
	  curPos = data->size() - 1;
	}
    }
  if(ia == down)
    {
      curPos++;
      if(curPos >= data->size())
	{
	  curPos = 0;
	}
    }
  if(ia == ok)
    {
      if(onClick != 0 && data->size() > 0)
	onClick(data->at(curPos)->id, data->at(curPos)->txt);
    }
}
Beispiel #15
0
void MessageDialog::addButtons(const Buttons &f) {
	_actionLayout.setSpacing(8);
	_actionLayout.setContentsMargins(0, 8, 0, 8);
	_actionLayout.addStretch();
	if (f.testFlag(Button::NoButton)) return;
	if (align() == Align::Ltr) {
		if (f.testFlag(Button::Cancel)) {
			_cancel = new FlatButton("CANCEL", this);
			_actionLayout.addWidget(_cancel);
			QObject::connect(_cancel, SIGNAL(clicked()), this, SLOT(onClick()));
		}
		if (f.testFlag(Button::OK)) {
			_ok = new FlatButton("OK", this);
			_actionLayout.addWidget(_ok);
			QObject::connect(_ok, SIGNAL(clicked()), this, SLOT(onClick()));
		}
		if (f.testFlag(Button::No)) {
			_no = new FlatButton("No", this);
			_actionLayout.addWidget(_no);
			QObject::connect(_no, SIGNAL(clicked()), this, SLOT(onClick()));
		}
		if (f.testFlag(Button::Yes)) {
			_yes = new FlatButton("YES", this);
			_actionLayout.addWidget(_yes);
			QObject::connect(_yes, SIGNAL(clicked()), this, SLOT(onClick()));
		}
		if (f.testFlag(Button::Close)) {
			_close = new FlatButton("CLOSE", this);
			_actionLayout.addWidget(_close);
			QObject::connect(_close, SIGNAL(clicked()), this, SLOT(onClick()));
		}

		if (f.testFlag(Button::Dicard)) {
			_dicard = new FlatButton("DISCARD", this);
			_actionLayout.addWidget(_dicard);
			QObject::connect(_dicard, SIGNAL(clicked()), this, SLOT(onClick()));
		}
	}
}
Beispiel #16
0
bool cPict::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where){
	if(onClick != NULL) return onClick(me,id,mods);
	else return false;
}
Beispiel #17
0
bool ButtonBase::onProcessMessage(Message* msg)
{
  switch (msg->type()) {

    case kFocusEnterMessage:
    case kFocusLeaveMessage:
      if (isEnabled()) {
        if (m_behaviorType == kButtonWidget) {
          // Deselect the widget (maybe the user press the key, but
          // before release it, changes the focus).
          if (isSelected())
            setSelected(false);
        }

        // TODO theme specific stuff
        invalidate();
      }
      break;

    case kKeyDownMessage: {
      KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
      KeyScancode scancode = keymsg->scancode();

      // If the button is enabled.
      if (isEnabled()) {
        bool mnemonicPressed =
          ((msg->altPressed() || msg->cmdPressed()) &&
           isMnemonicPressed(keymsg));

        // For kButtonWidget
        if (m_behaviorType == kButtonWidget) {
          // Has focus and press enter/space
          if (hasFocus()) {
            if ((scancode == kKeyEnter) ||
                (scancode == kKeyEnterPad) ||
                (scancode == kKeySpace)) {
              setSelected(true);
              return true;
            }
          }

          // Check if the user pressed mnemonic.
          if (mnemonicPressed) {
            setSelected(true);
            return true;
          }
          // Magnetic widget catches ENTERs
          else if (isFocusMagnet() &&
                   ((scancode == kKeyEnter) ||
                    (scancode == kKeyEnterPad))) {
            manager()->setFocus(this);

            // Dispatch focus movement messages (because the buttons
            // process them)
            manager()->dispatchMessages();

            setSelected(true);
            return true;
          }
        }
        // For kCheckWidget or kRadioWidget
        else {
          /* if the widget has the focus and the user press space or
             if the user press Alt+the underscored letter of the button */
          if ((hasFocus() && (scancode == kKeySpace)) || mnemonicPressed) {
            if (m_behaviorType == kCheckWidget) {
              // Swap the select status
              setSelected(!isSelected());
              invalidate();
            }
            else if (m_behaviorType == kRadioWidget) {
              if (!isSelected()) {
                setSelected(true);
              }
            }
            return true;
          }
        }
      }
      break;
    }

    case kKeyUpMessage:
      if (isEnabled()) {
        if (m_behaviorType == kButtonWidget) {
          if (isSelected()) {
            generateButtonSelectSignal();
            return true;
          }
        }
      }
      break;

    case kMouseDownMessage:
      switch (m_behaviorType) {

        case kButtonWidget:
          if (isEnabled()) {
            setSelected(true);

            m_pressedStatus = isSelected();
            captureMouse();
          }
          return true;

        case kCheckWidget:
          if (isEnabled()) {
            setSelected(!isSelected());

            m_pressedStatus = isSelected();
            captureMouse();
          }
          return true;

        case kRadioWidget:
          if (isEnabled()) {
            if (!isSelected()) {
              m_handleSelect = false;
              setSelected(true);
              m_handleSelect = true;

              m_pressedStatus = isSelected();
              captureMouse();
            }
          }
          return true;
      }
      break;

    case kMouseUpMessage:
      if (hasCapture()) {
        releaseMouse();

        if (hasMouseOver()) {
          switch (m_behaviorType) {

            case kButtonWidget:
              generateButtonSelectSignal();
              break;

            case kCheckWidget:
              {
                // Fire onClick() event
                Event ev(this);
                onClick(ev);

                invalidate();
              }
              break;

            case kRadioWidget:
              {
                setSelected(false);
                setSelected(true);

                // Fire onClick() event
                Event ev(this);
                onClick(ev);
              }
              break;
          }
        }
        return true;
      }
      break;

    case kMouseMoveMessage:
      if (isEnabled() && hasCapture()) {
        bool hasMouse = hasMouseOver();

        m_handleSelect = false;

        // Switch state when the mouse go out
        if ((hasMouse && isSelected() != m_pressedStatus) ||
            (!hasMouse && isSelected() == m_pressedStatus)) {
          if (hasMouse)
            setSelected(m_pressedStatus);
          else
            setSelected(!m_pressedStatus);
        }

        m_handleSelect = true;
      }
      break;

    case kMouseEnterMessage:
    case kMouseLeaveMessage:
      // TODO theme stuff
      if (isEnabled())
        invalidate();
      break;
  }

  return Widget::onProcessMessage(msg);
}
Beispiel #18
0
ColorButton::ColorButton(QWidget *parent)
	: QPushButton(parent)
{
	connect(this, SIGNAL(clicked()), this, SLOT(onClick()));
}
Beispiel #19
0
UpdateBtn::UpdateBtn(QWidget *parent, Window *window, const QString &text) : SysBtn(parent, st::sysUpd, text), wnd(window) {
	connect(this, SIGNAL(clicked()), this, SLOT(onClick()));
}
Beispiel #20
0
/*!
 * \brief Banner::mousePressEvent called by the Qt Event System
 */
void Banner::mousePressEvent( QMouseEvent *)
{
  emit onClick();
}
Beispiel #21
0
void Slide::connections()
{
    connect(Delay,SIGNAL(timeout()),SLOT(nextSlide()));

    connect(timerPoint,SIGNAL(timeout()),SLOT(mouseOn()));

    connect(lRightArrow,SIGNAL(onClick()),SLOT(onClick_lRightArrow()));

    connect(lLefttArrow,SIGNAL(onClick()),SLOT(onClick_lLefttArrow()));

    connect(lB0,SIGNAL(onClick()),SLOT(onClick_lB0()));
    connect(lB1,SIGNAL(onClick()),SLOT(onClick_lB1()));
    connect(lB2,SIGNAL(onClick()),SLOT(onClick_lB2()));
    connect(lB3,SIGNAL(onClick()),SLOT(onClick_lB3()));
    connect(lB4,SIGNAL(onClick()),SLOT(onClick_lB4()));

    connect(Slide0,SIGNAL(onClick()),SLOT(onClick_slide0()));
    connect(Slide1,SIGNAL(onClick()),SLOT(onClick_slide1()));
    connect(Slide2,SIGNAL(onClick()),SLOT(onClick_slide2()));
    connect(Slide3,SIGNAL(onClick()),SLOT(onClick_slide3()));
    connect(Slide4,SIGNAL(onClick()),SLOT(onClick_slide4()));

    connect(this,SIGNAL(onNow(bool)),SLOT(mouseOn_slide(bool)));
}
Beispiel #22
0
	void WireframeActor::Update(long gameTime) //WireframeActor's default update. velocity variables change velocity of WireframeActor
	{
		prevclicked = clicked;

	    x += (float)xvelocity;
	    y += (float)yvelocity;
	
	    xSpeed = x - xprev;
	    ySpeed = y - yprev;
	
	    xprev = x;
	    yprev = y;
		
		long prevTouchId = currentTouchId;
		
		bool onmouseenter = false;
		bool onmouseleave = false;
		bool onclick = false;
		bool onrelease = false;
		
	    if(mouseOver())
	    {
			bool prevMouseOver = mouseover;
	    	if(!mouseover)
	    	{
	    		mouseover=true;
	    		if(isEventEnabled(EVENT_MOUSEENTER))
	    		{
	    			onmouseenter = true;
	    		}
	    	}
	    	if(!prevMouseOver && !Application::checkPrevTouchActive(touchId))
	    	{
	    		clicked = true;
	    		if(isEventEnabled(EVENT_MOUSECLICK))
	    		{
	    			onclick = true;
	    		}
	    	}
	    }
	    else if(mouseover)
		{
			mouseover=false;
			if(isEventEnabled(EVENT_MOUSELEAVE))
			{
	    		onmouseleave = true;
			}
		}
	    if(clicked && prevMouseover && !Application::checkTouchActive(prevTouchId))
	    {
	    	clicked = false;
	    	if(isEventEnabled(EVENT_MOUSERELEASE))
			{
	    		onrelease = true;
			}
	    }
		
		if(prevclicked && !Application::checkTouchActive(currentTouchId))
		{
			clicked = false;
		}
		
		prevMouseover = mouseover;
		currentTouchId = touchId;
		
		if(onmouseenter)
		{
			onMouseEnter();
		}
		if(onclick)
		{
			onClick();
		}
		if(onmouseleave)
		{
			onMouseLeave();
		}
		if(onrelease)
		{
			onRelease();
		}
	}
Beispiel #23
0
//Actual graphics stuff contained here
int main( int argc, char* args[] )
{
	//start everything, make a window
	if( !init() )
	{
		printf( "couldn't initialize\n" );
	}
	else
	{
		if( !loadMedia() )
		{
			printf( "couldn't 'load media'\n" );
		}
		else
		{
		
			if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 ) {
		        printf("Audio creation failed %s\n", Mix_GetError());
		        return 1;    
		    }
		
		    blop = Mix_LoadWAV("blop.wav");
		    if(!blop){
		        printf("Could not open sound effect %s\n", Mix_GetError());
		    }	
		    
		    cheer = Mix_LoadWAV("cheer.wav");
		    if(!cheer){
		        printf("Could not open sound effect %s\n", Mix_GetError());
		    }	
		    
		    
			bool quit = false;

			//Event handler
			SDL_Event e;

			//While window should be open + running
			while( !quit ){
				
				if (!over) {
					
					while (SDL_PollEvent(&e)){
			        	 if (e.type == SDL_QUIT){
			         		 quit = 1;
			    	 	} else if (e.type == SDL_MOUSEBUTTONDOWN) {
				            onClick(e.button.x, e.button.y);
	//		    	 		quit=1; //comment out (for testing)--working
			         	}
			      	}
					
					
					//Handle events
					while( SDL_PollEvent( &e ) != 0 )
					{
						//close window
						if( e.type == SDL_QUIT )
						{
							quit = true;
						}
					}
	
					//Clear screen
					SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
					SDL_RenderClear( gRenderer );
					
					//Blue horizontal line, for scorekeeping box
					SDL_SetRenderDrawColor( gRenderer, 0x00, 0x00, 0xFF, 0xFF );		
					SDL_RenderDrawLine( gRenderer, 0, SCREEN_HEIGHT / 10, SCREEN_WIDTH/8, SCREEN_HEIGHT / 10 );
	
					//point tallies	
					int j;		
					for (j=0; j<points;j++){
						int h;
						for( h = SCREEN_HEIGHT/70; h < 6*SCREEN_HEIGHT/70; h++ )
						{
							SDL_RenderDrawPoint( gRenderer, (j+1)*(SCREEN_WIDTH / 8)/(points), h );
						}
//						SDL_RenderDrawLine( gRenderer, 0,10,20,10);
					}
					
					//vertical line for scorekeeping box
					for( int i = 0; i < SCREEN_HEIGHT/10; i++ )
					{
						SDL_RenderDrawPoint( gRenderer, SCREEN_WIDTH / 8, i );
					}
					
					if(clickX!=-1 && clickY!=-1){ //draw click radius
						SDL_SetRenderDrawColor( gRenderer, 0x00, 0x00, 0x00, 0xFF ); //black
						drawOutline();
					} 
			
						
					if (time==0) {
						time =1;
						
						//create balls of random color and put it in array
						int num;
						double tempx;
						double tempy;
						int temp, neg;
						for (num=0; num<numBalls; num++) {
							
							tempx=0;
						    tempy=0;
							
							//get random color using rand() and switch statements
							temp = rand() % 9; //num between 0 and 8
							
							Ball *newOne = new Ball;
							newOne->currX=rand()%SCREEN_WIDTH;
							newOne->currY=rand()%SCREEN_HEIGHT;
							newOne->color=temp;
							
							//set random dx and dy values
							while (tempx==0 && tempy==0) { //don't want both to be 0s, so if you get randomly 2 0s, redo until don't
							
	//							printf("loop to find speeds--should show up 50 times");//WORKING
								//find ranodm dx value, pos or neg
								neg = rand()%2; //0 or 1
								if (neg==1){
									neg=1;
								} else{
									neg=-1;
								}
								tempx= neg*( (rand()%20) +4);
							
								//find random dy value, pos or neg
								neg = rand()%2; //0 or 1
								if (neg==1){
									neg=1;
								} else{
									neg=-1;
								}
								tempy= neg*( (rand()%20) +4); 
							}
							newOne->dx= tempx;
							newOne->dy= tempy;
							
							//put this new ball into array
							array[num] = *newOne ;//address of the ball populates the array
						}
						
						//now we have the array of pointers to all the balls... now we should do something with it (display them)
						
						int k;
						for (k=0; k<numBalls; k++){
							
							setColor(array[k].color);
								
							drawCircle(array[k].currX, array[k].currY); //draw circle			
						
						}
						
					} //<--first time only if statement ends
						
					if (time == 1){ //if not the first time
										
						int y;
						for (y=0; y<numBalls; y++) { 
									
							//handling bounces and corner behaviors
							if(onL(array[y].currX, array[y].currY)){ //if hits y (vertical) walls, change the x sign		
								array[y].dx= abs(array[y].dx);	
							} 
							if (onR(array[y].currX, array[y].currY)){ //if hits x (horizontal floors/cieling), change the y sign
								array[y].dx= -1*abs(array[y].dx);
							} 
							if (onT(array[y].currX, array[y].currY)){ //if hits x (horizontal floors/cieling), change the y sign
								array[y].dy= abs(array[y].dy);
							} 
							if (onB(array[y].currX, array[y].currY)){ //if hits x (horizontal floors/cieling), change the y sign
								array[y].dy= -1*abs(array[y].dy);
							}
								
							update(y);
							
							
							setColor(array[y].color);
							
							drawCircle(array[y].currX, array[y].currY); //draw circle
							
						
						}//<--for each ball
						
					} //<--end of not first time loop
					
					SDL_RenderPresent( gRenderer ); //update screen
					
					if(levelUp){
						clickX=-1;
						clickY=-1;
						sleep(1.2); //pause 1.2 seconds
						level();
					}
				}//<--end of "not over" if statement	
			}//<--end of "while(!quit) loop"
		
			erase();
			close();
				
		}
			
	}
		
	return 0;
}
Beispiel #24
0
		void Button::triggerClick()
		{
			onClick();
		}
Beispiel #25
0
void ClickableArea::clickLeft(tribool down, bool previousState)
{
	if (down)
		onClick();
}
Beispiel #26
0
LockBtn::LockBtn(QWidget *parent, MainWindow *window) : SysBtn(parent, st::sysLock), wnd(window) {
	connect(this, SIGNAL(clicked()), this, SLOT(onClick()));
}
Beispiel #27
0
void    MapItem::mousePressEvent(QMouseEvent *)
{
  emit	onClick();
}
Beispiel #28
0
CloseBtn::CloseBtn(QWidget *parent, Window *window) : SysBtn(parent, st::sysCls), wnd(window) {
	connect(this, SIGNAL(clicked()), this, SLOT(onClick()));
}
Beispiel #29
0
AddCategory::AddCategory(QWidget *parent) : QPushButton(parent)
{
    connect(this, SIGNAL(released()), this, SLOT(onClick()));
}
Beispiel #30
0
void PollButton::update()
{
	if (input.isButtonPressed(sf::Mouse::Button::Left) && (sf::FloatRect(pos, dimensions).contains(level->getCursorPos())))
	{
		onClick(this);
	}
	else if (polling)
	{
		std::string actions[ACTIONS] = {
			"swing",
			"thrust",
			"throw",
			"jump",
			"crouch",
			"sprint",
			"move_right",
			"move_left",
		};
		
		unsigned int joyID;
		if (input.findController(joyID))
		{
			config.controller.setJoystickID(joyID);
		}
		
		if (pollPos < ACTIONS)
		{
			label = actions[pollPos];
			je::Controller::Bind b(config.controller.getLastInputAsBind());
			if (b.device != je::Controller::Bind::Device::Invalid)
			{
				config.controller.setKeybinds(actions[pollPos], {b});
				//std::cout << actions[pollPos] << ": " << b.key << "\n";
				std::cout << pollPos << "\n";

				++pollPos;
			}
		}
		else if (pollPos == ACTIONS)
		{
			label = "Aim right (left click for mouse aim)";
			je::Controller::AxisBind bind(config.controller.getLastAxisMovementAsBind());
			if (bind.device != je::Controller::AxisBind::Device::Invalid)
			{
				config.controller.setAxis("aim_x", bind);
				++pollPos;
			}
			else if (input.isButtonPressed(sf::Mouse::Button::Left))
			{
				config.controller.setAxis("aim_x", je::Controller::AxisBind(je::Controller::AxisBind::MouseAxis::X, false, je::Controller::AxisBind::Interval(-128, 128), nullptr));
				++pollPos;
			}
		}
		else if (pollPos == ACTIONS + 1)
		{
			label = "Aim Down (left click for mouse aim)";
			je::Controller::AxisBind bind(config.controller.getLastAxisMovementAsBind());
			if (bind.device != je::Controller::AxisBind::Device::Invalid)
			{
				config.controller.setAxis("aim_y", bind);
				++pollPos;
			}
			else if (input.isButtonPressed(sf::Mouse::Button::Left))
			{
				config.controller.setAxis("aim_y", je::Controller::AxisBind(je::Controller::AxisBind::MouseAxis::Y, false, je::Controller::AxisBind::Interval(-128, 128), nullptr));
				++pollPos;
			}
		}
		else
		{
			pollPos = 0;
			polling = false;
			label = "P1 Controls";
		}
	}
}