void MultiViewWidget::splitView(Qt::Orientation orient,
                                ContainerWidget *container)
{
  QVBoxLayout *widgetLayout = qobject_cast<QVBoxLayout *>(container->parent());
  QSplitter *split = qobject_cast<QSplitter *>(container->parent());
  if (!widgetLayout)
    if (container->parent() == this)
      widgetLayout = qobject_cast<QVBoxLayout *>(layout());
  if (widgetLayout) {
    QSplitter *splitter = new QSplitter(orient, this);
    widgetLayout->removeWidget(container);
    widgetLayout->addWidget(splitter);
    splitter->addWidget(container);
    container = createContainer();
    splitter->addWidget(container);
    QList<int> sizes;
    int s = Qt::Horizontal ? splitter->size().width() / 2
                           : splitter->size().height() / 2;
    sizes << s << s;
    splitter->setSizes(sizes);
  }
  else if (split) {
    QSplitter *splitter = new QSplitter(orient, this);
    int idx = split->indexOf(container);
    splitter->addWidget(container);
    container = createContainer();
    splitter->addWidget(container);
    split->insertWidget(idx, splitter);
    QList<int> sizes;
    int s = Qt::Horizontal ? splitter->size().width() / 2
                           : splitter->size().height() / 2;
    sizes << s << s;
    splitter->setSizes(sizes);
  }
}
示例#2
0
void ContainerManagerWorker::
run()
{
  switch(container_action_)
  {
    case ContainerAction::Create:
      createContainer(data_);
      break;

    case ContainerAction::Destroy:
      destroyContainer();
      break;

    case ContainerAction::Install:
      installPackage(data_);
      break;

    case ContainerAction::Remove:
      removePackage(data_);
      break;

    case ContainerAction::Update:
      updateContainer();
      break;

    default:
      break;
  }
}
示例#3
0
void
parseNextBkToken (RDFFile f, char* token)
{
 /*	printf(token); */
  if (token[0] == '<') {
    bkStateTransition(f, token);
  } else {
    /* ok, we have a piece of content.
       can be the title, or a description or */
    if ((f->status == IN_TITLE) || (f->status == IN_H3) || 
	(f->status == IN_ITEM_TITLE)) {
      if (IN_H3 && gBkFolderDate) {
	char url[150];
	RDF_Resource newFolder;
	sprintf(url, "%s%s.rdf", gBkFolderDate, token);
	newFolder = createContainer(url);
	addSlotValue(f,newFolder, gCoreVocab->RDF_parent, f->stack[f->depth-1], 
		     RDF_RESOURCE_TYPE, true);
	freeMem(gBkFolderDate);
	gBkFolderDate = NULL;
	f->lastItem = newFolder;
      }
      addSlotValue(f, f->lastItem, gCoreVocab->RDF_name, 
		   copyString(token), RDF_STRING_TYPE, true);
      if (startsWith("Personal Toolbar", token) && (containerp(f->lastItem)))
	nlocalStoreAssert(gLocalStore, f->lastItem, gCoreVocab->RDF_instanceOf, 
			  gNavCenter->RDF_PersonalToolbarFolderCategory, 
			  RDF_RESOURCE_TYPE, true);
    } else if (f->status == IN_ITEM_DESCRIPTION) {
      addDescription(f, f->lastItem, token);
    }
  }
}
示例#4
0
	//---------------------------------------------------------------------
    void Profiler::initialize() 
	{


        // create a new overlay to hold our Profiler display
        mOverlay = OverlayManager::getSingleton().create("Profiler");
        mOverlay->setZOrder(500);

        // this panel will be the main container for our profile bars
        mProfileGui = createContainer();

        OverlayElement* element;

        // we create an initial pool of 50 profile bars
        for (uint i = 0; i < mMaxDisplayProfiles; ++i) {

            // this is for the profile name and the number of times it was called in a frame
            element = createTextArea("profileText" + StringConverter::toString(i), 90, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, 14, "", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

            // this indicates the current frame time
            element = createPanel("currBar" + StringConverter::toString(i), 0, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, mBarIndent, "Core/ProfilerCurrent", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

            // this indicates the minimum frame time
            element = createPanel("minBar" + StringConverter::toString(i), mBarLineWidth, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, "Core/ProfilerMin", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

            // this indicates the maximum frame time
            element = createPanel("maxBar" + StringConverter::toString(i), mBarLineWidth, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, "Core/ProfilerMax", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

            // this indicates the average frame time
            element = createPanel("avgBar" + StringConverter::toString(i), mBarLineWidth, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, "Core/ProfilerAvg", false);
            mProfileGui->addChild(element);
            mProfileBars.push_back(element);

			// this indicates the text of the frame time
			element = createTextArea("statText" + StringConverter::toString(i), 20, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, 14, "", false);
			mProfileGui->addChild(element);
			mProfileBars.push_back(element);
        }

        // throw everything all the GUI stuff into the overlay and display it
        mOverlay->add2D(mProfileGui);
        mOverlay->show();

    }
void Main :: createInsertCritterForm()
{
	_formInsertCritter = createForm(950, 400, false);
	_formInsertCritter->setPosition(-_formInsertCritter->getWidth(), -_formInsertCritter->getHeight());

	mInsertOK_1 = createButton(_formInsertCritter, "Insert", "", Vector2(120,330), Vector2(180, 40));
	mInsertOK_25 = createButton(_formInsertCritter, "Insert x 25", "", Vector2(320,330), Vector2(180, 40));
	mInsertOK_500 = createButton(_formInsertCritter, "Insert x 500", "", Vector2(520,330), Vector2(180, 40));
	mInsertCancel = createButton(_formInsertCritter, "Cancel", "", Vector2(740,330), Vector2(120, 40));
	mInsertCritterGenome = createContainer(_formInsertCritter, true, Vector2(20,20), Vector2(720, 56));
	mInsertClear = createButton(_formInsertCritter, "Clear", "", Vector2(755,28), Vector2(80, 40));
	updateInsertCritterForm();
	setInsertCritterFormVisible(false);

	set<char> availableInstructions = InstructionSet::getAllAvailableInstructions();

	float x = 20;
	float y = 80;
	for (set<char>::iterator i = availableInstructions.begin(); i != availableInstructions.end(); i++)
	{
        bool supportsConditions = InstructionSet::instructionSupportsConditions(*i);
        
        string idAlways, idIf, idNotIf;
        if (supportsConditions) {
            idAlways += (*i | eAlways);
        }
        else {
			idAlways += (*i | eAlways);
        }
        idIf += (*i | eIf);
        idNotIf += (*i | eNotIf);

        float yb = y;
		Button * pInstruction = createButton(_formInsertCritter, " ", idAlways.c_str(), Vector2(x, yb), Vector2(60, 60));
		mInsertInstructionButtons.push_back(pInstruction);

		if (supportsConditions) {
			yb += 60;

			Button * pInstructionIf = createButton(_formInsertCritter, " ", idIf.c_str(), Vector2(x, yb), Vector2(60, 60));
			mInsertInstructionButtons.push_back(pInstructionIf);
			yb += 60;

			Button * pInstructionNotIf = createButton(_formInsertCritter, " ", idNotIf.c_str(), Vector2(x, yb), Vector2(60, 60));
			mInsertInstructionButtons.push_back(pInstructionNotIf);
		}
		x += 60;
	}

	createControlHeader(_formInsertCritter, "Click on the instructions above to build your genome, then press 'Insert x 500'.\nClick on 'What is this?' for a full description of each instruction.",
		Vector2(40,250), Vector2(900, 60), Vector4(1,1,1,1));
}
  virtual void startElement(const string_type& namespaceURI,
                            const string_type& localName,
                            const string_type& qName,
                            const SAX::Attributes<string_type, string_adaptor>& atts)
  {
    if(container_ == 0)
    {
      container_ = createContainer(namespaceURI, localName, qName, atts);
      return;
    } // if(item_ == 0)

    if(createChild(namespaceURI, localName, qName, atts))
      return;

    throw SAX::SAXException(string_adaptor::asStdString(qName) + " <- Sorry, don't know about that yet :)");
  } // startElement
示例#7
0
void
AssemblyImpl::instantiate ()
throw(Components::CreateFailure)
{
	Components::CCMHome_var home;
	Components::Deployment::Container_var container;
	Components::Deployment::ComponentServer_var component_server;
	std::vector < HomeInstanceData > ::iterator iter;
	
	// for each hostcollocation
	std::vector < HostData > ::iterator host_iter;
	for(host_iter = data_.hosts_.begin(); 
		host_iter != data_.hosts_.end(); 
		host_iter++)
	{
		// for each processcollocation
		std::vector < ProcessData > ::iterator process_iter;
		for(process_iter = (*host_iter).processes.begin(); 
			process_iter != (*host_iter).processes.end();
			process_iter++)
		{
			component_server = createComponentServer((*host_iter).host);
			(*process_iter).server = Components::Deployment::ComponentServer::_duplicate(component_server);

			// for each homeplacement
			for(iter = (*process_iter).homes.begin(); 
				iter != (*process_iter).homes.end(); 
				iter++)
			{
				container = createContainer(component_server);
				(*iter).container = Components::Deployment::Container::_duplicate(container);
				home = instantiateHome( container, (*iter) );
				instantiateComponents( home, (*iter) );
			}
		}
	}

	// for each existing home
	for(iter = data_.existing_homes_.begin();
		iter != data_.existing_homes_.end();
		iter++)
	{
		home = instantiateHome( container, (*iter) );
		instantiateComponents( home, (*iter) );
	}
}
void MultiViewWidget::addWidget(QWidget *widget)
{
  if (widget) {
    ContainerWidget *container = createContainer(widget);
    m_children << container;
    if (m_children.size() == 1) {
      QVBoxLayout *widgetLayout = qobject_cast<QVBoxLayout *>(layout());
      if (!widgetLayout) {
        widgetLayout = new QVBoxLayout;
        widgetLayout->setContentsMargins(0, 0, 0, 0);
        setLayout(widgetLayout);
      }
      widgetLayout->addWidget(container);
    }
    widget->installEventFilter(m_activeFilter);
    setActiveWidget(widget);
  }
}
void MultiViewWidget::removeView()
{
  ContainerWidget *container = qobject_cast<ContainerWidget *>(sender());
  if (container) {
    QSplitter *splitter = qobject_cast<QSplitter *>(container->parent());
    if (splitter && splitter->count() == 2) {
      // Get its parent, and insert the other widget into it, delete this widget.
      QSplitter *splitterParent = qobject_cast<QSplitter *>(splitter->parent());
      QWidget *moveWidget = splitter->widget(0);
      if (moveWidget == container)
        moveWidget = splitter->widget(1);
      setActiveWidget(moveWidget);
      if (splitterParent) {
        int idx = splitterParent->indexOf(splitter);
        splitterParent->insertWidget(idx, moveWidget);
        splitter->deleteLater();
      }
      else if (splitter->parent() == this) {
        // No more splits - back to single view widget.
        QVBoxLayout *layoutParent = qobject_cast<QVBoxLayout *>(layout());
        if (layoutParent) {
          layoutParent->addWidget(moveWidget);
          layoutParent->removeWidget(splitter);
          splitter->deleteLater();
        }
      }
    }
    else if (container->parent() == this) {
      // Delete the current container, and create the option container.
      QVBoxLayout *vLayout = qobject_cast<QVBoxLayout *>(layout());
      container->deleteLater();
      ContainerWidget *newContainer = createContainer();
      vLayout->addWidget(newContainer);
      setActiveWidget(newContainer);
    }
  }
}
示例#10
0
int main(int argc, char *argv[]) {
    namespace po = boost::program_options;

    std::string privateKeyFile;
    std::string publicKeyFile;

    po::options_description general("General options");
    general.add_options()
        ("help", "produce help message")
        ("generate-rsa,g",
            "generate RSA keys and save to public.key and private.key")
        ("publickey",
            po::value<std::string>(&publicKeyFile)
                ->default_value("public.key"),
            "path to publickey (default \"public.key\"")
        ("privatekey",
            po::value<std::string>(&privateKeyFile)
                ->default_value("private.key"),
            "path to private key (default \"private.key\"");

    po::options_description openContainer("Open existing container");
    openContainer.add_options()
        ("open,o", po::value<std::string>(), "open existing container")
        ("unpack,u", po::value<std::string>(),
            "unpack selected files to directory")
        ("unpackAll,U", po::value<std::string>(),
            "unpack all files to directory")
        ("add,a", "add selected files");

    po::options_description createContainer("Create new container");
    createContainer.add_options()
        ("create,c", po::value<std::string>(), "create new container");

    po::options_description hidden("Hidden options");
    hidden.add_options()
        ("input-file", po::value<std::vector<std::string>>(),
            "input container file");


    po::options_description cmdlineOptions;
    cmdlineOptions
        .add(general)
        .add(openContainer)
        .add(createContainer)
        .add(hidden);

    po::positional_options_description p;
    p.add("input-file", -1);

    po::variables_map vm;
    po::store(po::command_line_parser(argc, argv).
        options(cmdlineOptions).positional(p).run(), vm);
    po::notify(vm);

    if (vm.count("help")) {
        std::cout
            << "Usage: CryptoContainer [options] <input or output files>"
            << std::endl;
        std::cout << general << "\n";
        std::cout << openContainer << "\n";
        std::cout << createContainer << "\n";
        return 1;
    }

    if (vm.count("generate-rsa")) {
        std::cout << "Generating RSA keys" << std::endl;
        auto RSAKeys = cc::generateRSAKeys();

        // Save public key
        std::cout << "Public key... ";
        cc::saveKeyToFile<CryptoPP::RSA::PublicKey>("public.key",
                                                     RSAKeys.second);
        std::cout << "OK" << std::endl;

        // Save private key
        std::cout << "Private key... ";
        cc::saveKeyToFile<CryptoPP::RSA::PrivateKey>("private.key",
                                                     RSAKeys.first);
        std::cout << "OK" << std::endl;

        return 1;
    }

    if (vm.count("create")) {
        std::cout << "Create container" << std::endl;

        if (!vm.count("input-file")) {
            std::cout << "Error: Need select input files" << std::endl;
            return -1;
        }

        if (!boost::filesystem::exists(publicKeyFile)) {
            std::cout << "Error: Public key doesn't exists" << std::endl;
            return -1;
        }

        if (boost::filesystem::is_directory(vm["create"].as<std::string>())) {
            std::cout << "Error: Path direct to directory" << std::endl;
            return -1;
        }

        auto publicKey =
            cc::loadKeyFromFile<CryptoPP::RSA::PublicKey>(publicKeyFile);

        auto container =
            cc::Container::openNewContainer(vm["create"].as<std::string>(),
                                            publicKey);

        if (!container) {
            std::cout << "invalid key or can't open file" << std::endl;
            return -1;
        }

        const auto pathsToPack =
            vm["input-file"].as<std::vector<std::string>>();
        for (auto &input : pathsToPack) {
            container->addFileOrFolder(input);
        }

        std::cout << "Wait a while..." << std::endl;
        container->save();
        std::cout << "Created " << vm["create"].as<std::string>()
            << " container" << std::endl;

        return 0;
    }

    if (vm.count("open")) {
        std::cout << "Open existed container" << std::endl;

        if (!boost::filesystem::exists(publicKeyFile)) {
            std::cout << "Error: Public key doesn't exists" << std::endl;
            return -1;
        }

        if (!boost::filesystem::exists(privateKeyFile)) {
            std::cout << "Error: Private key doesn't exists" << std::endl;
            return -1;
        }

        auto privateKey =
            cc::loadKeyFromFile<CryptoPP::RSA::PrivateKey>(privateKeyFile);

        auto publicKey =
            cc::loadKeyFromFile<CryptoPP::RSA::PublicKey>(publicKeyFile);

        auto container = cc::Container::openExistedContainer(
            vm["open"].as<std::string>(), publicKey, privateKey);

        if (!container) {
            std::cout << "Can't open container" << std::endl;
            return -1;
        }

        std::cout << "Wait a while..." << std::endl;

        if (vm.count("unpackAll")) {
            const std::string path = vm["unpackAll"].as<std::string>();
            container->unpackAll(path);
            std::cout << "Unpacked all data to: " << path << std::endl;
            return 0;
        } else if (vm.count("unpack")) {
            const std::string targetPath = vm["unpack"].as<std::string>();

            const auto pathsToUnpack =
                vm["input-file"].as<std::vector<std::string>>();

            for (auto& path : pathsToUnpack) {
                std::cout << "Unpack: " << path << std::endl;
                container->unpack(path, targetPath);
            }

            std::cout << "Unpacked all data to: " << targetPath << std::endl;

            return 0;
        } else if (vm.count("add")) {
            const auto pathsToPack =
                vm["input-file"].as<std::vector<std::string>>();

            for (auto &input : pathsToPack) {
                container->addFileOrFolder(input);
            }

            container->save();
            std::cout << "Added" << std::endl;
        } else {
            std::cout << "Invalid command!" << std::endl;
        }
    }

    return 0;
}
MyContainer& MyContainer::init()
{
 winText << "Sample";
 createContainer();
 return(*this);
}
示例#12
0
ContainerProp* PropFactory::createContainer(){
	return createContainer(new vector<Item*>());
}
OWindow& OContainerBase::inherit(const HWND hwndDlg)
{
 OWindow::inherit(hwndDlg);
 createContainer();
 return(*this);
}