Project

General

Profile

Reload on browser window...

Added by Łukasz Matuszewski over 11 years ago

I have app that creates menu in application class. It does it in constructor:

@

SyNaTPGApp::SyNaTPGApp(const WEnvironment& env)

: WApplication(env), m_firebird(0)

{

// ....

WTable *table = new WTable(this->root());

//table->resize(WLength(100, WLength::Percentage), WLength(100, WLength::Percentage));

table->setWidth(WLength(100, WLength::Percentage));

//..

this->createMenuAndContents(table);

//...

}

//...

void SyNaTPGApp::createMenuAndContents(WTable *table, bool activation)

{

table~~elementAt(0, 0)>addWidget(new MenuAndContents(this, &this->m_dm, activation));

table
elementAt(0, 0)~~>setWidth(WLength(100, WLength::Percentage));

//...

}

@

Then in MenuAndContents a do:

@

MenuAndContents::MenuAndContents(SyNaTPGApp *app, DatabaseModule *dm, bool activation)

: WContainerWidget(), m_dm(dm), m_app(app)

{

this->setWidth(WLength(100, WLength::Percentage));

this->m_contentsStack_ = new WStackedWidget();

WAnimation fade(WAnimation::Fade, WAnimation::Linear, 250);

this~~m_contentsStack_>setTransitionAnimation(fade);

// Show scrollbars when needed ...

//this
m_contentsStack_>setOverflow(WContainerWidget::OverflowAuto);

this
m_contentsStack_>setWidth(WLength(100, WLength::Percentage));

// ... and work around a bug in IE (see setOverflow() documentation)

//this
m_contentsStack_>setPositionScheme(Static);

this
m_contentsStack_~~>setStyleClass(MIR_STRCAT3(MIR_CSS_CONTENTS,\" ",MIR_CSS_MAIN_PAGE));

/*

  • Setup the menu (and submenus)
    */
    WMenu *menu = new WMenu(this->m_contentsStack_, Horizontal, 0);
    //menu->setRenderAsList(true);
    menu->setStyleClass(MIR_STRINGIFY(MIR_CSS_MENU_DROPDOWN));
    menu->setInternalPathEnabled();
    //menu->setInternalBasePath("/\");
    WMenuItem *mi, *miLogin;
    // tutaj tworzę wszystkie dostępne menu, ale schowane (tzn. WMenuItem->hide())

mi = this->addToMenu(menu, tr(MIR_MENU_SIGNOUT), new ControlsWidget(false, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

mi->setPathComponent(MIR_IPATH_SIGNOUT);

//mi~~itemWidget()~~>setStyleClass(MIR_STRINGIFY(MIR_CSS_MENU_DIR));

mi->hide();

if (!activation)

{

mi = this~~addToMenu(menu, tr(MIR_MENU_HELP), new HelpControls(this>m_app, menu, this->m_dm, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

mi->setPathComponent(MIR_IPATH_HELP);

//mi
itemWidget()~~>setStyleClass(MIR_STRINGIFY(MIR_CSS_MENU_DIR));

}

mi = this~~addToMenu(menu, tr(MIR_MENU_SETTINGS), new SettingsControls(this>m_app, menu, this->m_dm, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

mi->setPathComponent(MIR_IPATH_SETTINGS);

//mi
itemWidget()~~>setStyleClass(MIR_STRINGIFY(MIR_CSS_MENU_DIR));

mi->hide();

if (!activation)

{

mi = this->addToMenu(menu, "SyNaT", new ControlsWidget(false, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

mi->setPathComponent(MIR_IPATH_SYNAT);

//mi~~itemWidget()~~>setStyleClass(MIR_STRINGIFY(MIR_CSS_MENU_DIR));

}

mi = this~~addToMenu(menu, tr(MIR_MENU_GENRERECOGNITION), new GenreRecognitionControls(this~~>m_app, menu, this->m_dm, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

mi->setPathComponent(MIR_IPATH_GENRE_RECOGNITION);

mi->hide();

mi = this~~addToMenu(menu, tr(MIR_MENU_RECOGNIZEAUDIO), new RecognizeAudioControls(this~~>m_app, menu, this->m_dm, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

mi->setPathComponent(MIR_IPATH_RECOGNIZE_AUDIO);

mi->hide();

mi = this~~addToMenu(menu, tr(MIR_MENU_USERS), new UsersControls(this>m_app, menu, this->m_dm, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

//mi
itemWidget()~~>setStyleClass(MIR_STRINGIFY(MIR_CSS_MENU_DIR));

mi->setPathComponent(MIR_IPATH_USERS);

mi->hide();

mi = this~~addToMenu(menu, tr(MIR_MENU_EXPLORER), new ExplorerControls(this>m_app, menu, this->m_dm, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

//mi
itemWidget()~~>setStyleClass(MIR_STRCAT3(MIR_CSS_MENU_DIR, \" ", MIR_CSS_HOME_BACKGROUND));

mi->setIcon("images/home.png\");

mi->setPathComponent(MIR_IPATH_EXPLORER);

mi->hide();

mi = this~~addToMenu(menu, "", new TagExplorerControls(this~~>m_app, menu, this->m_dm, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

//mi->setAttributeValue("style", "display: none");

mi->setPathComponent(MIR_IPATH_TAGS_EXPLORER);

mi->hide();

SearchEngineControls *sec = new SearchEngineControls(this~~m_app, menu, this>m_dm, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM));

mi = this->addToMenu(menu, "", sec);

sec->setMenuItem(mi);

//mi->setAttributeValue("style", "display: none");

//mi
itemWidget()~~>setStyleClass(MIR_STRCAT3(MIR_CSS_MENU_DIR, \" \", MIR_CSS_DISPLAY_NONE));

mi->setPathComponent(MIR_IPATH_ADV_SEARCH);

mi->hide();

if (!activation)

{

miLogin = menu~~addItem("images/home.png", tr(MIR_MENU_SIGNIN), new LoginControls(this~~>m_app, menu, this->m_dm, true, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

//miLogin->setStyleClass(MIR_STRCAT3(MIR_CSS_MENU_DIR, \" \", MIR_CSS_HOME_BACKGROUND));

miLogin->setPathComponent(MIR_IPATH_SIGNIN);

menu->itemSelected().connect(this, &MenuAndContents::slt_menuItemSelected);

miLogin->select();

}

else

{

mi = menu~~addItem("", new ActivationControls(this>m_app, menu, this->m_dm, MIR_STRINGIFY(MIR_CSS_MARGIN_FOR_ANIM)));

//mi
itemWidget()~~>setStyleClass(MIR_STRCAT3(MIR_CSS_MENU_DIR, \" \", MIR_CSS_DISPLAY_NONE));

mi->setPathComponent(MIR_IPATH_ACTIVATION);

menu->itemSelected().connect(this, &MenuAndContents::slt_menuItemSelected);

mi->select();

}

/*

  • Add it all inside a layout
    */
    WTable *outerTable = new WTable(this);
    outerTable->setWidth(WLength(100, WLength::Percentage));
    WContainerWidget *wcwVertLayout = new WContainerWidget();
    wcwVertLayout->setWidth(WLength(100, WLength::Percentage));
    WVBoxLayout *vertLayout = new WVBoxLayout();
    vertLayout->addWidget(m_contentsStack_, --1);
    wcwVertLayout->setLayout(vertLayout);

this->m_localeChanger_en = new WPushButton();

this~~m_localeChanger_en>setStyleClass(MIR_STRINGIFY(MIR_CSS_LANG_BUTTON) \" \" MIR_STRINGIFY(MIR_CSS_LANG_BUTTON) "_en");

this
m_localeChanger_en>clicked().connect(this, &MenuAndContents::slt_localeAboutToBeChangedToEn);

this->m_localeChanger_pl = new WPushButton();

this
m_localeChanger_pl>setStyleClass(MIR_STRINGIFY(MIR_CSS_LANG_BUTTON) \" \" MIR_STRINGIFY(MIR_CSS_LANG_BUTTON) "_pl");

this
m_localeChanger_pl~~>clicked().connect(this, &MenuAndContents::slt_localeAboutToBeChangedToPl);

WContainerWidget *wcw = new WContainerWidget();

WContainerWidget *wcw1 = new WContainerWidget();

wcw1->setClearSides(Left | Right);

wcw1->addWidget(new WImage(WLink(MIR_SYNAT_LOGO)));

WContainerWidget *wcw2 = new WContainerWidget();

wcw2->setClearSides(Left | Right);

wcw2->setStyleClass(MIR_STRINGIFY(MIR_CSS_MENU));

wcw2~~addWidget(this>m_localeChanger_en);

wcw2
addWidget(this~~>m_localeChanger_pl);

wcw2->addWidget(menu);

wcw->addWidget(wcw1);

wcw->addWidget(wcw2);

wcw->setWidth(WLength(100, WLength::Percentage));

outerTable~~elementAt(0, 0)~~>addWidget(wcw);

outerTable~~elementAt(1, 0)>addWidget(wcwVertLayout);

//outerTable
elementAt(1, 0)>setHeight(WLength(100, WLength::Percentage));

//outerTable
elementAt(1, 0)~~>setVerticalAlignment(AlignMiddle);

wcw = new WContainerWidget();

wcw->setClearSides(Left | Right);

WTable *wt = new WTable(wcw);

wt~~elementAt(0, 0)~~>addWidget(new WImage(WLink(MIR_SYNAT_STOPKA)));

wt->setWidth(WLength(900, WLength::Pixel));

wt->setStyleClass(MIR_STRINGIFY(MIR_CSS_CENTERED));

wcw->setWidth(WLength(100, WLength::Percentage));

outerTable~~elementAt(2, 0)~~>addWidget(wcw);

//outerLayout->addLayout(vertLayout, 1);

// vertOuterLayout->setResizable(0, true);

}

@

When I reload the page the menu is working but this~~m_contentsStack_ has visibility:hidden and also jPlayer is not a function (I user jPlayer inside *Controls classes)~~ see attachment (the play is black triangle and stop is black square). I you need more support then ask.