Ejemplo n.º 1
0
//-----------------------------------------------------------------------------
int ctkMenuButtonTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);

  QWidget topLevelWidget(0);
  QMenu* menu = new QMenu("menu");
  menu->addAction("extra choice 1");
  menu->addAction("extra choice 2");
  menu->addAction("extra choice 3");

  QPushButton button1("QPushButton with no menu");
  QPushButton button2("QPushButton with menu");
  button2.setMenu(menu);  
  ctkMenuButton button3("ctkMenuButton with no menu");
  ctkMenuButton button4("ctkMenuButton with menu");  
  button4.setMenu(menu);
  
  QVBoxLayout* layout = new QVBoxLayout;
  layout->addWidget(&button1);
  layout->addWidget(&button2);
  layout->addWidget(&button3);
  layout->addWidget(&button4);
  
  topLevelWidget.setLayout(layout);
  topLevelWidget.show();
  topLevelWidget.resize(200, 100);

  if (argc < 2 || QString(argv[1]) != "-I" )
    {
    QTimer::singleShot(200, &app, SLOT(quit()));
    }

  return app.exec();
}
Ejemplo n.º 2
0
static int
checkmouse(void)	/* return button touched if any */
{
	int c, b;
	char *p;
	extern int confirm(int);

	b = waitdown();
	last_but = 0;
	last_hit = -1;
	c = 0;
	if (button3(b)) {
		last_hit = emenuhit(3, &mouse, &mbut3);
		last_but = 3;
	} else if (button2(b)) {
		last_hit = emenuhit(2, &mouse, &mbut2);
		last_but = 2;
	} else {		/* button1() */
		pan();
		last_but = 1;
	}
	waitup();
	if (last_but == 3 && last_hit >= 0) {
		p = m3[last_hit];
		c = p[strlen(p) - 1];
	}
	if (c == '?' && !confirm(last_but))
		last_hit = -1;
	return last_but;
}
Ejemplo n.º 3
0
__interrupt void PORT2_ISR(void)
{
	if (P2IFG == BIT0)
		button0();

	if (P2IFG == BIT1)
		button1();

	if (P2IFG == BIT2)
		button2();

	if (P2IFG == BIT3)
		button3();

	if (P2IFG == BIT4)
		button4();

	if (P2IFG == BIT5)
		button5();

	if (P2IFG == BIT6)
		button6();

	if (P2IFG == BIT7)
		button7();
}
//-----------------------------------------------------------------------------
int ctkCheckablePushButtonTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);

  QWidget topLevel;
  ctkCheckablePushButton button1(QObject::tr("My very long text on button"));
  ctkCheckablePushButton button2(QObject::tr("Button2"));
  ctkCheckablePushButton button3(QObject::tr("Button3"));
  ctkCheckablePushButton button4(QObject::tr("Button4"));
  ctkCheckablePushButton button5(QObject::tr("Button5"));
  ctkCheckablePushButton button6(QObject::tr("Button6"));
  ctkCheckablePushButton button7(QObject::tr("Checkable PushButton"));
  ctkCheckablePushButton button8(QObject::tr("Connected, Not User Checkable"));
  ctkCheckablePushButton button9(QObject::tr("Connected, Not User Checkable"));
  ctkCheckablePushButton button10(QObject::tr("Not Connected, User Checkable"));
  ctkCheckablePushButton button11(QObject::tr("Not Connected, User Checkable"));
  ctkCheckablePushButton button12(QObject::tr("Checkbox Not User Checkable\nButton Checkable"));
  ctkCheckablePushButton button13(QObject::tr("Checkbox and Button User Checkable"));

  QVBoxLayout *layout= new QVBoxLayout;
  layout->addWidget(&button1);
  layout->addWidget(&button2);
  layout->addWidget(&button3);
  layout->addWidget(&button4);
  layout->addWidget(&button5);
  layout->addWidget(&button6);
  layout->addWidget(&button7);
  layout->addWidget(&button8);
  layout->addWidget(&button9);
  layout->addWidget(&button10);
  layout->addWidget(&button11);
  layout->addWidget(&button12);
  layout->addWidget(&button13);
  topLevel.setLayout(layout);

  topLevel.show();
  button1.setButtonTextAlignment(Qt::AlignRight | Qt::AlignVCenter);

  if (button1.buttonTextAlignment() != (Qt::AlignRight | Qt::AlignVCenter))
    {
    std::cerr << "ctkCheckablePushButton::setButtonTextAlignment failed."
              << std::endl;
    return EXIT_FAILURE;
    }

  button2.setIndicatorAlignment(Qt::AlignRight);

  if (button2.indicatorAlignment() != Qt::AlignRight)
    {
    std::cerr << "ctkCheckablePushButton::setIndicatorAlignment failed."
              << std::endl;
    return EXIT_FAILURE;
    }

  button3.setButtonTextAlignment(Qt::AlignCenter);
  button3.setIndicatorAlignment(Qt::AlignCenter);
  button3.setCheckable(true);
  
  button4.setCheckable(true);
  button4.toggle();
  
  button5.setButtonTextAlignment(Qt::AlignCenter);
  button5.setIndicatorAlignment(Qt::AlignRight);
  
  button6.setIndicatorAlignment(Qt::AlignTop);
  button7.setButtonTextAlignment(Qt::AlignCenter);
  button7.setIndicatorAlignment(Qt::AlignLeft);
  
  // Connected to button, not user checkable:
  button8.setCheckBoxUserCheckable(false);
  button8.setCheckState(Qt::Checked);
  button9.setCheckBoxUserCheckable(false);
  button9.setCheckState(Qt::Unchecked);

  // Not connected to button, user checkable:
  button10.setCheckBoxControlsButton(false);
  button10.setCheckState(Qt::Checked);
  button11.setCheckBoxControlsButton(false);
  button11.setCheckState(Qt::PartiallyChecked);

  button12.setCheckBoxControlsButton(false);
  button12.setCheckBoxUserCheckable(false);
  button12.setCheckable(true);
  button13.setCheckBoxControlsButton(false);
  button13.setCheckBoxUserCheckable(true);
  button13.setCheckable(true);

  if (argc < 2 || QString(argv[1]) != "-I" )
    {
    QTimer::singleShot(200, &app, SLOT(quit()));
    }

  return app.exec();
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
int ctkDirectoryButtonTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);
  
  QWidget topLevel;
  ctkDirectoryButton button;
  
  QIcon defaultIcon = button.style()->standardIcon(QStyle::SP_DirIcon);
  QIcon icon = button.style()->standardIcon(QStyle::SP_MessageBoxQuestion);
  QIcon icon2 = button.style()->standardIcon(QStyle::SP_DesktopIcon);

  ctkDirectoryButton button2(".");
  ctkDirectoryButton button3(icon, "..");
  
  QVBoxLayout* layout = new QVBoxLayout;
  layout->addWidget(&button);
  layout->addWidget(&button2);
  layout->addWidget(&button3);
  topLevel.setLayout(layout);
  
  button.setCaption("Select a directory");
  if (button.caption() != "Select a directory")
    {
    std::cerr << "ctkDirectoryButton::setCaption() failed." << std::endl;
    return EXIT_FAILURE;
    }

  if (button.icon().pixmap(20).toImage() !=
      defaultIcon.pixmap(20).toImage())
    {
    std::cerr << "ctkDirectoryButton::icon() failed." << std::endl;
    return EXIT_FAILURE;
    }

  button3.setIcon(icon2);
  if (button3.icon().pixmap(20).toImage() !=
      icon2.pixmap(20).toImage())
    {
    std::cerr << "ctkDirectoryButton::setIcon() failed." << std::endl;
    return EXIT_FAILURE;
    }
  
#ifdef USE_QFILEDIALOG_OPTIONS
  button.setOptions(QFileDialog::ShowDirsOnly | QFileDialog::ReadOnly);
  if (button.options() != (QFileDialog::ShowDirsOnly |
                           QFileDialog::ReadOnly))
#else
  button.setOptions(ctkDirectoryButton::ShowDirsOnly |
                    ctkDirectoryButton::ReadOnly);
  
  if (button.options() != (ctkDirectoryButton::ShowDirsOnly |
                           ctkDirectoryButton::ReadOnly))
#endif
    {
    std::cerr<< "ctkDirectoryButton::setOptions failed" << std::endl;
    return EXIT_FAILURE;
    }

  QSignalSpy spyDirectoryChanged(&button, SIGNAL(directoryChanged(const QString&)));
  QSignalSpy spyDirectorySelected(&button, SIGNAL(directorySelected(const QString&)));

  button.setDirectory(QDir::home().absolutePath());
  if ( QDir(button.directory()) != QDir::home() ||
       spyDirectoryChanged.count() != 1 || 
       spyDirectorySelected.count() != 1)
    {
    std::cerr<< "ctkDirectoryButton::setDirectory failed" << button.directory().toStdString() << std::endl;
    return EXIT_FAILURE;
    }

  spyDirectoryChanged.clear();
  spyDirectorySelected.clear();
  // set it again... just to check that it doesn't fire a new signal
  button.setDirectory(QDir::home().absolutePath());

  if ( QDir(button.directory()) != QDir::home() ||
       spyDirectoryChanged.count() != 0 || 
       spyDirectorySelected.count() != 1)
    {
    std::cerr<< "ctkDirectoryButton::setDirectory failed" << button.directory().toStdString() << std::endl;
    return EXIT_FAILURE;
    }

  topLevel.show();

  if (argc < 2 || QString(argv[1]) != "-I" )
    {
    QTimer::singleShot(200, &app, SLOT(quit()));
    }

  QTimer::singleShot(100, &button, SLOT(browse()));

  return app.exec();
}
Ejemplo n.º 6
0
void QtCalculator::pb3toggled(bool myboolean){
  if(myboolean)
    button3();
  if(pb3->isOn() && (!key_pressed))
    pb3->setOn(FALSE);
}
Ejemplo n.º 7
0
	int main(const std::vector<CL_String> &args)
	{
		try
		{
			CL_GUIManager gui;

			CL_ResourceManager resources("../../../Resources/GUIThemeLuna/resources.xml");

			CL_GUIWindowManagerSystem wm;
			gui.set_window_manager(wm);

			CL_GUIThemeDefault theme;
			theme.set_resources(resources);
			gui.set_theme(theme); 
			//gui.set_css_document("theme.css");
			gui.set_css_document("../../../Resources/GUIThemeLuna/theme.css");

			CL_DisplayWindowDescription win_desc;
			win_desc.set_allow_resize(true);
			win_desc.set_title("Button WM System Test Application");
			win_desc.set_position(CL_RectPS(200, 200, 320, 240), false);
			CL_Window window(&gui, win_desc);
			window.func_close().set(this, &App::on_close, &window);
	
			CL_PushButton button(&window);
			button.set_geometry(CL_RectPS(10, 10, 160, 40));
			button.set_text("Button 1");

			CL_PushButton button2(&window);
			button2.set_geometry(CL_RectPS(10, 50, 160, 40));
			button2.set_text("Button 2");
			button2.set_enabled(false);

			CL_PushButton button3(&window);
			button3.set_geometry(CL_RectPS(10, 90, 160, 40));
			button3.set_text("Button 3");
 
			CL_CheckBox check1(&window);
			check1.set_geometry(CL_RectPS(10, 130, 160, 21));
			check1.set_text("Check Box 1");

			CL_CheckBox check2(&window);
			check2.set_geometry(CL_RectPS(10, 160, 160, 21));
			check2.set_text("Check Box 2");
			check2.set_enabled(false);

			CL_CheckBox check3(&window);
			check3.set_geometry(CL_RectPS(10, 190, 160, 21));
			check3.set_text("Check Box 3");

			gui.exec();
		}
		catch (CL_Exception e)
		{
			CL_ConsoleWindow console("Console");
			CL_Console::write_line(e.message);
			console.display_close_message();
		}

		return 0;
	}
Ejemplo n.º 8
0
    bool PlayerInputStruct::pollEvents(PlayerInputStruct &oldInputs, GameEvent &e)
    {
        //Check if the given event is already a game input event.
        if(e.type() != GameEvent::GameInput)
        {
            e = event::GameInput();
        }

        if(oldInputs.action() != action()) {
            e.gameInput.setControl(GameControl::ACTION);
            e.gameInput.setState(action());
            oldInputs.setAction(action());
            return true;
        }
        if(oldInputs.up() != up()) {
            e.gameInput.setControl(GameControl::UP);
            e.gameInput.setValue(up());
            oldInputs.setUp(up());
            return true;
        }
        if(oldInputs.down() != down()) {
            e.gameInput.setControl(GameControl::DOWN);
            e.gameInput.setValue(down());
            oldInputs.setDown(down());
            return true;
        }
        if(oldInputs.left() != left()) {
            e.gameInput.setControl(GameControl::LEFT);
            e.gameInput.setValue(left());
            oldInputs.setLeft(left());
            return true;
        }
        if(oldInputs.right() != right()) {
            e.gameInput.setControl(GameControl::RIGHT);
            e.gameInput.setValue(right());
            oldInputs.setRight(right());
            return true;
        }
        if(oldInputs.button1() != button1()) {
            e.gameInput.setControl(GameControl::BUTTON1);
            e.gameInput.setState(button1());
            oldInputs.setButton1(button1());
            return true;
        }
        if(oldInputs.button2() != button2()) {
            e.gameInput.setControl(GameControl::BUTTON2);
            e.gameInput.setState(button2());
            oldInputs.setButton2(button2());
            return true;
        }
        if(oldInputs.button3() != button3()) {
            e.gameInput.setControl(GameControl::BUTTON3);
            e.gameInput.setState(button3());
            oldInputs.setButton3(button3());
            return true;
        }
        if(oldInputs.button4() != button4()) {
            e.gameInput.setControl(GameControl::BUTTON4);
            e.gameInput.setState(button4());
            oldInputs.setButton4(button4());
            return true;
        }
        if(oldInputs.button5() != button5()) {
            e.gameInput.setControl(GameControl::BUTTON5);
            e.gameInput.setState(button5());
            oldInputs.setButton5(button5());
            return true;
        }
        if(oldInputs.button6() != button6()) {
            e.gameInput.setControl(GameControl::BUTTON6);
            e.gameInput.setState(button6());
            oldInputs.setButton6(button6());
            return true;
        }
        return false;
    }
Ejemplo n.º 9
0
int
waitchar(void)
{
	Event e;
	int c;
	char c2;
	int newmouse;
	int wasblocked;
	int kbdchar = -1;
	char echobuf[3*BSIZE];
	static int lastc = -1;


	for(;;) {
		if(resize_flag)
			resize();
		wasblocked = blocked;
		if(backp)
			return(0);
		if(ecanmouse() && (button2() || button3()))
			readmenu();
		if(snarffp) {
			if((c = Bgetc(snarffp)) < 0) {
				if(lastc != '\n')
					write(outfd,"\n",1);
				Bterm(snarffp);
				snarffp = 0;
				if(lastc != '\n') {
					lastc = -1;
					return('\n');
				}
				lastc = -1;
				continue;
			}
			lastc = c;
			c2 = c;
			write(outfd, &c2, 1);
			return(c);
		}
		if(!blocked && host_avail())
			return(rcvchar());
		if(kbdchar > 0) {
			if(blocked)
				resize();
			if(cs->raw) {
				switch(kbdchar){
				case Kup:
					sendfk("up key");
					break;
				case Kdown:
					sendfk("down key");
					break;
				case Kleft:
					sendfk("left key");
					break;
				case Kright:
					sendfk("right key");
					break;
				case Kpgup:
					sendfk("page up");
					break;
				case Kpgdown:
					sendfk("page down");
					break;
				case KF|1:
					sendfk("F1");
					break;
				case KF|2:
					sendfk("F2");
					break;
				case KF|3:
					sendfk("F3");
					break;
				case KF|4:
					sendfk("F4");
					break;
				case KF|5:
					sendfk("F5");
					break;
				case KF|6:
					sendfk("F6");
					break;
				case KF|7:
					sendfk("F7");
					break;
				case KF|8:
					sendfk("F8");
					break;
				case KF|9:
					sendfk("F9");
					break;
				case KF|10:
					sendfk("F10");
					break;
				case KF|11:
					sendfk("F11");
					break;
				case KF|12:
					sendfk("F12");
					break;
				case '\n':
					echobuf[0] = '\r';
					sendnchars(1, echobuf);
					break;
				case '\r':
					echobuf[0] = '\n';
					sendnchars(1, echobuf);
					break;
				default:
					echobuf[0] = kbdchar;
					sendnchars(1, echobuf);
					break;
				}
			} else if(canon(echobuf,kbdchar) == SCROLL) {
				if(!blocked)
					bigscroll();
			} else
				strcat(echo_input,echobuf);
			blocked = 0;
			kbdchar = -1;
			continue;
		}
		curson(wasblocked);	/* turn on cursor while we're waiting */
		do {
			newmouse = 0;
			switch(eread(blocked ? Emouse|Ekeyboard :
					       Emouse|Ekeyboard|Ehost, &e)) {
			case Emouse:
				mouse = e.mouse;
				if(button2() || button3())
					readmenu();
				else if(resize_flag == 0) {
					/* eresized() is triggered by special mouse event */
					newmouse = 1;
				}
				break;
			case Ekeyboard:
				kbdchar = e.kbdc;
				break;
			case Ehost:
				set_host(&e);
				break;
			default:
				perror("protocol violation");
				exits("protocol violation");
			}
		} while(newmouse == 1);
		cursoff();	/* turn cursor back off */
	}
}