예제 #1
0
파일: MainFrm.cpp 프로젝트: skappert/mcp
LRESULT CMainFrame::OnToolbarReset(WPARAM wp,LPARAM)
{
	UINT uiToolBarId = (UINT) wp;

	switch (uiToolBarId)
	{
	case IDR_TOOLBAR2:
		{
		CMFCToolBarComboBoxButton deviceCombo(ID_LOADFILE, GetCmdMgr()->GetCmdImage(IDR_TOOLBAR2, FALSE), CBS_DROPDOWNLIST,150);
		m_wndLoadFileBar.ReplaceButton (ID_LOADFILE,deviceCombo);
		}
		break;

	case IDR_TOOLBAR3:
		{
		CMFCToolBarEditBoxButton editBox(ID_HTMEAS, 0, ES_AUTOHSCROLL, 80);
		m_wndGPS_HTMEAS.ReplaceButton (ID_HTMEAS, editBox);
		}
		break;

	case IDR_TOOLBAR4:
		{
		CMFCToolBarEditBoxButton editBox(ID_PROTONS, 0, ES_AUTOHSCROLL, 80);
		m_wndISOLDE_PROTONS.ReplaceButton (ID_PROTONS, editBox);
		}
		break;

	default:
		break;
	}

	return 0;
}
	void ClientChatNetPackageSender::onCtrlEditEnd(CCObject* sender)	{
		// note: the notification center spreads the function call
		//       to every registered observer
		//       so you have to explicitly check if 
		//       the sender is the object you want to deal with
		CCControlEditBox* editBox(dynamic_cast<CCControlEditBox*>(sender));
		if(editBox != nullptr)	{
			const char* editContent(editBox->getTextField()->getString());
			if(sl::isEmptyString(editContent) == false)	{
				if(editBox == _ctrlName)	{
					getPeer()->log(ELogType_Message, "%s name is:%s", __FUNCTION__, editContent);
					_name = editContent;
				}
				else if(editBox == _ctrlMessage)	{
					getPeer()->log(ELogType_Message, "%s message is:%s", __FUNCTION__, editContent);

					// we can now send this message ...
					SLAString message(editContent);
					this->sendChatLine(message);

					editBox->getTextField()->setString(nullptr);
				}
			}
		}
	}
	void ClientChatNetPackageSender::onCtrlEditEnd(CCObject* sender)	{
		// note: the notification center spreads the function call
		//       to every registered observer
		//       so you have to explicitly check if 
		//       the sender is the object you want to deal with
		CCControlEditBox* editBox(dynamic_cast<CCControlEditBox*>(sender));
		if(editBox != nullptr)	{
			const char* editContent(editBox->getTextField()->getString());
			if(sl::isEmptyString(editContent) == false)	{
				if(editBox == _ctrlName)	{
					getPeer()->log(ELogType_Message, "%s name is:%s", __FUNCTION__, editContent);
					_name = editContent;
				}
				else if(editBox == _ctrlMessage)	{
					getPeer()->log(ELogType_Message, "%s message is:%s", __FUNCTION__, editContent);

					// we can now send this message ...
					//Security Checks
					if (strlen(editContent) > 2000)
					{
						getPeer()->log(ELogType_Error, "ERROR text message is too long");
					}
					else if (strlen(editContent) == 0)
					{
						return;
					}

					CCDictionary* messageDictionary(CCDictionary::create());
					CCDictionary* singleMessageDictionary(CCDictionary::create());
					messageDictionary->setObject(singleMessageDictionary, "message");
					singleMessageDictionary->setObject(CCString::create(editContent),"content");
					singleMessageDictionary->setObject(CCString::create(_name),"sender");
					CCString* json = CCJSONConverter::strFrom(messageDictionary);

					const SLSize messageSize(2048);
					char message[messageSize];

					// zero out the data which have been send previously
					memset(message,0,sizeof(char) * messageSize);
					message[0] = (char)(NETMSG_ID_JSONOBJECT);
					strcat(message, json->getCString());
					sendData(message, (const int) strlen(message)+1);

					//OLD: we can now send this message ...
					//SLAString message(editContent);
					//this->sendChatLine(message);

					editBox->getTextField()->setString(nullptr);
				}
			}
		}
	}
	// TODO: @student : check this code - this is an example how to track edit box changes
	void PluginOptionsDialog::onPhysicsFrameRateChangedNotification(CCObject* sender)	{
		// note: the notification center spreads the function call
		//       to every registered observer
		//       so you have to explicitly check if 
		//       the sender is the object you want to deal with
		CCControlEditBox* editBox(dynamic_cast<CCControlEditBox*>(sender));
		if(editBox == _ctrlPhysicsFrameRate)	{
			// the value should have been serialized to the dataSource at this time 
			// so now we can check the dictionary value
			CCDictionary* dataSource(NetworkState::getInstanceDictionary(
				SL_SERIALIZEKEY_PLUGIN_GLOBAL_SETTINGS));
			double physicsFrameRate(Dictionary::getDouble(
				dataSource, SL_SERIALIZEKEY_PHYSICSFRAMERATE, 50.0));
			// and pass the value to the physics config
			PhysicsConfig::sharedInstance().setFrequency(physicsFrameRate);
		}
	}
예제 #5
0
파일: ChildFrm.cpp 프로젝트: skappert/mcp
LRESULT CChildFrame::OnToolbarReset(WPARAM wp,LPARAM)
{
	UINT uiToolBarId = (UINT) wp;

	switch (uiToolBarId)
	{
	case IDR_TOOLBAR5:
		{
		CMFCToolBarEditBoxButton editBox(ID_SAVEFILE, 0, ES_AUTOHSCROLL, 85);
		m_SaveDialog.ReplaceButton (ID_SAVEFILE, editBox);
		}
		break;
	default:
		break;
	}

	return 0;
}
예제 #6
0
ccClippingBoxTool::ccClippingBoxTool(QWidget* parent)
	: ccOverlayDialog(parent)
	, Ui::ClippingBoxDlg()
	, m_clipBox(0)
{
	setupUi(this);

	setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);

	connect(editBoxToolButton,				SIGNAL(clicked()), this, SLOT(editBox()));
	connect(extractContourToolButton,		SIGNAL(clicked()), this, SLOT(extractContour()));
	connect(removeLastContourToolButton,	SIGNAL(clicked()), this, SLOT(removeLastContour()));
	connect(exportButton,					SIGNAL(clicked()), this, SLOT(exportCloud()));
	connect(exportMultButton,				SIGNAL(clicked()), this, SLOT(exportMultCloud()));
	connect(resetButton,					SIGNAL(clicked()), this, SLOT(reset()));
	connect(closeButton,					SIGNAL(clicked()), this, SLOT(closeDialog()));

	connect(showInteractorsCheckBox, SIGNAL(toggled(bool)), this, SLOT(toggleInteractors(bool)));

	connect(thickXDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(thicknessChanged(double)));
	connect(thickYDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(thicknessChanged(double)));
	connect(thickZDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(thicknessChanged(double)));

	connect(minusXShiftToolButton,	SIGNAL(clicked()), this, SLOT(shiftXMinus()));
	connect(plusXShiftToolButton,	SIGNAL(clicked()), this, SLOT(shiftXPlus()));
	connect(minusYShiftToolButton,	SIGNAL(clicked()), this, SLOT(shiftYMinus()));
	connect(plusYShiftToolButton,	SIGNAL(clicked()), this, SLOT(shiftYPlus()));
	connect(minusZShiftToolButton,	SIGNAL(clicked()), this, SLOT(shiftZMinus()));
	connect(plusZShiftToolButton,	SIGNAL(clicked()), this, SLOT(shiftZPlus()));

	viewButtonsFrame->setEnabled(true);
    connect(viewUpToolButton,		SIGNAL(clicked()),	this,	SLOT(setTopView()));
    connect(viewDownToolButton,		SIGNAL(clicked()),	this,	SLOT(setBottomView()));
    connect(viewFrontToolButton,	SIGNAL(clicked()),	this,	SLOT(setFrontView()));
    connect(viewBackToolButton,		SIGNAL(clicked()),	this,	SLOT(setBackView()));
    connect(viewLeftToolButton,		SIGNAL(clicked()),	this,	SLOT(setLeftView()));
    connect(viewRightToolButton,	SIGNAL(clicked()),	this,	SLOT(setRightView()));

	s_maxEdgeLength = -1.0;
	//s_lastContourUniqueIDs.clear();
	removeLastContourToolButton->setEnabled(false);
}
예제 #7
0
int main(int argc, char *argv[])
{
    Q_UNUSED(argc)
    Q_UNUSED(argv)

    //////////////////////////////////////////////////////////////////
    /// Init GraphicSystem singleton
    GraphicSystem::initialize("GraphicSystemTest", "data/fonts/DejaVuSans.ttf");
    //////////////////////////////////////////////////////////////////



    //////////////////////////////////////////////////////////////////
    /// Get pointers of GraphicSystem
    sf::RenderWindow *window;
    window = GraphicSystem::instance()->getWindow();

    tgui::Gui *gui;
    gui = GraphicSystem::instance()->getGUI();
    //////////////////////////////////////////////////////////////////



    //////////////////////////////////////////////////////////////////
    /// Create widgets
    tgui::Picture::Ptr picture((*gui));
    picture->load("data/others/Linux.jpg");

    tgui::Button::Ptr button((*gui));
    button->load(THEME_CONFIG_FILE);
    button->setPosition(40, 25);
    button->setText("Quit");
    button->setCallbackId(1);
    button->bindCallback(tgui::Button::LeftMouseClicked);
    button->setSize(300, 40);

    tgui::ChatBox::Ptr chatbox((*gui));
    chatbox->load(THEME_CONFIG_FILE);
    chatbox->setSize(200, 100);
    chatbox->setTextSize(20);
    chatbox->setPosition(400, 25);
    chatbox->addLine("Line 1", sf::Color::Red);
    chatbox->addLine("Line 2", sf::Color::Blue);
    chatbox->addLine("Line 3", sf::Color::Green);
    chatbox->addLine("Line 4", sf::Color::Yellow);
    chatbox->addLine("Line 5", sf::Color::Cyan);
    chatbox->addLine("Line 6", sf::Color::Magenta);

    tgui::Checkbox::Ptr checkbox((*gui));
    checkbox->load(THEME_CONFIG_FILE);
    checkbox->setPosition(40, 80);
    checkbox->setText("Checkbox");
    checkbox->setSize(32, 32);

    tgui::ChildWindow::Ptr child((*gui));
    child->load(THEME_CONFIG_FILE);
    child->setSize(200, 100);
    child->setBackgroundColor(sf::Color(80, 80, 80));
    child->setPosition(400, 460);
    child->setTitle("Child window");
    child->setIcon("data/others/icon.jpg");

    tgui::ComboBox::Ptr comboBox((*gui));
    comboBox->load(THEME_CONFIG_FILE);
    comboBox->setSize(120, 21);
    comboBox->setPosition(210, 440);
    comboBox->addItem("Item 1");
    comboBox->addItem("Item 2");
    comboBox->addItem("Item 3");
    comboBox->setSelectedItem("Item 2");

    tgui::EditBox::Ptr editBox((*gui));
    editBox->load(THEME_CONFIG_FILE);
    editBox->setPosition(40, 200);
    editBox->setSize(300, 30);

    tgui::Label::Ptr label((*gui));
    label->load(THEME_CONFIG_FILE);
    label->setText("Label");
    label->setPosition(40, 160);
    label->setTextColor(sf::Color(200, 200, 200));
    label->setTextSize(24);

    tgui::ListBox::Ptr listBox((*gui));
    listBox->load(THEME_CONFIG_FILE);
    listBox->setSize(150, 120);
    listBox->setItemHeight(20);
    listBox->setPosition(40, 440);
    listBox->addItem("Item 1");
    listBox->addItem("Item 2");
    listBox->addItem("Item 3");

    tgui::LoadingBar::Ptr loadingbar((*gui));
    loadingbar->load(THEME_CONFIG_FILE);
    loadingbar->setPosition(40, 330);
    loadingbar->setSize(300, 30);
    loadingbar->setValue(35);

    tgui::MenuBar::Ptr menu((*gui));
    menu->load(THEME_CONFIG_FILE);
    menu->setSize(window->getSize().x, 20);
    menu->addMenu("File");
    menu->addMenuItem("File", "Load");
    menu->addMenuItem("File", "Save");
    menu->addMenuItem("File", "Exit");
    menu->bindCallback(tgui::MenuBar::MenuItemClicked);
    menu->setCallbackId(2);

    sf::Texture texture;
    texture.loadFromFile("data/others/ThinkLinux.jpg");

    tgui::Panel::Ptr panel((*gui));
    panel->setSize(200, 140);
    panel->setPosition(400, 150);
    panel->setBackgroundTexture(&texture);

    tgui::RadioButton::Ptr radioButton((*gui));
    radioButton->load(THEME_CONFIG_FILE);
    radioButton->setPosition(40, 120);
    radioButton->setText("Radio Button");
    radioButton->setSize(32, 32);

    tgui::Slider::Ptr slider((*gui));
    slider->load(THEME_CONFIG_FILE);
    slider->setVerticalScroll(false);
    slider->setPosition(40, 250);
    slider->setSize(300, 25);
    slider->setValue(2);

    tgui::Scrollbar::Ptr scrollbar((*gui));
    scrollbar->load(THEME_CONFIG_FILE);
    scrollbar->setVerticalScroll(false);
    scrollbar->setPosition(40, 290);
    scrollbar->setSize(300, 25);
    scrollbar->setMaximum(5);
    scrollbar->setLowValue(3);

    tgui::Slider2d::Ptr slider2d((*gui));
    slider2d->load("data/widgets/Slider2d/Black.conf");
    slider2d->setPosition(400, 300);
    slider2d->setSize(200, 150);

    tgui::SpinButton::Ptr spinButton((*gui));
    spinButton->load(THEME_CONFIG_FILE);
    spinButton->setPosition(40, 410);
    spinButton->setVerticalScroll(false);
    spinButton->setSize(40, 20);

    tgui::SpriteSheet::Ptr spritesheet((*gui));
    spritesheet->load("data/others/ThinkLinux.jpg");
    spritesheet->setCells(4, 4);
    spritesheet->setVisibleCell(2, 3);
    spritesheet->setSize(160, 120);
    spritesheet->setPosition(620, 25);

    tgui::Tab::Ptr tab((*gui));
    tab->load(THEME_CONFIG_FILE);
    tab->setPosition(40, 370);
    tab->add("Item 1");
    tab->add("Item 2");
    tab->add("Item 3");

    tgui::TextBox::Ptr textBox((*gui));
    textBox->load(THEME_CONFIG_FILE);
    textBox->setPosition(210, 470);
    textBox->setSize(180, 120);
    textBox->setTextSize(16);

    comboBox->moveToFront();
    //////////////////////////////////////////////////////////////////



    //////////////////////////////////////////////////////////////////
    /// Start main loop
    while(window->isOpen())
    {
        GraphicSystem::instance()->injectPreUpdate(0);

        sf::Event event;
        while(GraphicSystem::instance()->pollWindowEvent(event))
        {
            if(event.type == sf::Event::Closed)
                window->close();

            GraphicSystem::instance()->handleGUIEvent(event);
        }

        tgui::Callback callback;
        while(GraphicSystem::instance()->pollGUICallback(callback))
        {
            if(callback.id == 1)
                window->close();

            else if(callback.id == 2)
            {
                if(callback.text == "Exit")
                    window->close();
            }
        }

        GraphicSystem::instance()->injectPostUpdate(0);
    }
    //////////////////////////////////////////////////////////////////



    //////////////////////////////////////////////////////////////////
    /// Destroy GraphicSystem
    GraphicSystem::shutdown();
    //////////////////////////////////////////////////////////////////

    return 0;
}