Example #1
0
    void FalagardTabButton::render()
    {
        TabButton* w = (TabButton*)d_window;
        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();

		TabControl* tc = static_cast<TabControl*>(w->getParent()->getParent());

        String state;
		String prefix((tc->getTabPanePosition() == TabControl::Top) ? "Top" : "Bottom");

		if (w->isDisabled())
		    state = "Disabled";
		else if (w->isSelected())
		    state = "Selected";
		else if (w->isPushed())
		    state = "Pushed";
		else if (w->isHovering())
		    state = "Hover";
		else
		    state = "Normal";

        if (!wlf.isStateImageryPresent(prefix + state))
        {
            state = "Normal";
			if (!wlf.isStateImageryPresent(prefix + state))
				prefix = "";
        }

        wlf.getStateImagery(prefix + state).render(*w);
    }
Example #2
0
  // method to initialse the samples windows and events.
  bool initialise(CEGUI::GUIContext* guiContext)
  {
    d_guiContext = guiContext;
    d_usedFiles = CEGUI::String(__FILE__);

    // load font and setup default if not loaded via scheme
    Font& defaultFont = FontManager::getSingleton().createFromFile("DejaVuSans-12.font");
    // Set default font for the gui context
    guiContext->setDefaultFont(&defaultFont);

    // we will use of the WindowManager.
    WindowManager& winMgr = WindowManager::getSingleton();

    // load scheme and set up defaults
    SchemeManager::getSingleton().createFromFile(SKIN ".scheme");
    d_guiContext->getMouseCursor().setDefaultImage(SKIN "/MouseArrow");

    // load an image to use as a background
    if (!ImageManager::getSingleton().isDefined("SpaceBackgroundImage"))
      ImageManager::getSingleton().addFromImageFile("SpaceBackgroundImage", "SpaceBackground.jpg");

    // here we will use a StaticImage as the root, then we can use it to place a background image
    Window* background = winMgr.createWindow(SKIN "/StaticImage");
    // set area rectangle
    background->setArea(URect(cegui_reldim(0), cegui_reldim(0),
      cegui_reldim(1), cegui_reldim(1)));
    // disable frame and standard background
    background->setProperty("FrameEnabled", "false");
    background->setProperty("BackgroundEnabled", "false");
    // set the background image
    background->setProperty("Image", "SpaceBackgroundImage");
    // install this as the root GUI sheet
    d_guiContext->setRootWindow(background);

    // set tooltip styles (by default there is none)
    d_guiContext->setDefaultTooltipType(SKIN "/Tooltip");

    // load some demo windows and attach to the background 'root'
    background->addChild(winMgr.loadLayoutFromFile("TabControlDemo.layout"));

    TabControl* tc = static_cast<TabControl*>(background->getChild("Frame/TabControl"));

    // Add some pages to tab control
    tc->addTab(winMgr.loadLayoutFromFile("TabPage1.layout"));
    tc->addTab(winMgr.loadLayoutFromFile("TabPage2.layout"));

    WindowManager::getSingleton().DEBUG_dumpWindowNames("asd");

    static_cast<PushButton*>(
      background->getChild("Frame/TabControl/Page1/AddTab"))->subscribeEvent(
      PushButton::EventClicked,
      Event::Subscriber(&TabControlDemo::handleAddTab, this));

    // Click to visit this tab
    static_cast<PushButton*>(
      background->getChild("Frame/TabControl/Page1/Go"))->subscribeEvent(
      PushButton::EventClicked,
      Event::Subscriber(&TabControlDemo::handleGoto, this));

    // Click to make this tab button visible (when scrolling is required)
    static_cast<PushButton*>(
      background->getChild("Frame/TabControl/Page1/Show"))->subscribeEvent(
      PushButton::EventClicked,
      Event::Subscriber(&TabControlDemo::handleShow, this));

    static_cast<PushButton*>(
      background->getChild("Frame/TabControl/Page1/Del"))->subscribeEvent(
      PushButton::EventClicked,
      Event::Subscriber(&TabControlDemo::handleDel, this));

    RadioButton* rb = static_cast<RadioButton*>(
      background->getChild("Frame/TabControl/Page1/TabPaneTop"));
    rb->setSelected(tc->getTabPanePosition() == TabControl::Top);
    rb->subscribeEvent(
      RadioButton::EventSelectStateChanged,
      Event::Subscriber(&TabControlDemo::handleTabPanePos, this));

    rb = static_cast<RadioButton*>(
      background->getChild("Frame/TabControl/Page1/TabPaneBottom"));
    rb->setSelected(tc->getTabPanePosition() == TabControl::Bottom);
    rb->subscribeEvent(
      RadioButton::EventSelectStateChanged,
      Event::Subscriber(&TabControlDemo::handleTabPanePos, this));

    Scrollbar* sb = static_cast<Scrollbar*>(
      background->getChild("Frame/TabControl/Page1/TabHeight"));
    sb->setScrollPosition(tc->getTabHeight().d_offset);
    sb->subscribeEvent(
      Scrollbar::EventScrollPositionChanged,
      Event::Subscriber(&TabControlDemo::handleTabHeight, this));

    sb = static_cast<Scrollbar*>(
      background->getChild("Frame/TabControl/Page1/TabPadding"));
    sb->setScrollPosition(tc->getTabTextPadding().d_offset);
    sb->subscribeEvent(
      Scrollbar::EventScrollPositionChanged,
      Event::Subscriber(&TabControlDemo::handleTabPadding, this));

    refreshPageList();

    // From now on, we don't rely on the exceptions anymore, but perform nice (and recommended) checks
    // ourselves.

    return true;
  }