Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Adding Tab and Slaves to a TabCtrl
Adding Tab and Slaves to a TabCtrl [message #48418] Mon, 03 July 2017 14:43 Go to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
When I try adding a tab and some slaves to a TabCtrl widget, the tab is covering everything and the slaves are not visible anymore.
The TabCtrl and the other widgets are all set in a layout file.

Slaving code:
tab_settings.Add(t_("Language"))
    .Slave(&lng_language)
    .Slave(&txt_lang_check)
    .Slave(&b_preview)
    .Slave(&txt_preview);


If I don't slave the widgets they are still visible on top of the tab but you can't change tabs then so it is a problem.
I tested tabbing already when I started working with U++ a few weeks ago and it worked fine but now it doesn't and I can't remember what I did different.
Any ideas?


Greetings
Daniel
Re: Adding Tab and Slaves to a TabCtrl [message #48420 is a reply to message #48418] Mon, 03 July 2017 15:03 Go to previous messageGo to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
Ok never mind my first question. I just realized that the TabCtrl can only have one widget and because I hide the last one I slave it does not appear.
But changing it to a structure with a ParentCtrl did not change anything. Nothing is shown in my tab.
This is the code I use now:
ParentCtrl languageCtrl;
languageCtrl
    << lng_language
    << txt_lang_check
    << b_preview
    << txt_preview;
    
tab_settings.Add(languageCtrl.SizePos(), t_("Language"));


Greetings
Daniel
Re: Adding Tab and Slaves to a TabCtrl [message #48446 is a reply to message #48420] Tue, 04 July 2017 12:07 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
try this :
    tab_settings.Add(lng_language.SizePos(), "lng_language");
    tab_settings.Add(txt_lang_check.SizePos(), "txt_lang_check");
    tab_settings.Add(b_preview.SizePos(), "b_preview");
    tab_settings.Add(txt_preview.SizePos(), "txt_preview");


regards
omari.
Re: Adding Tab and Slaves to a TabCtrl [message #48447 is a reply to message #48446] Tue, 04 July 2017 12:14 Go to previous messageGo to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
That only adds tabs for every widget and is not putting every widget in one tab.
So no that is not working for me.


Greetings
Daniel
Re: Adding Tab and Slaves to a TabCtrl [message #48448 is a reply to message #48447] Tue, 04 July 2017 12:31 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
ah, in this case, you need coordinate and size of each widget.
ParentCtrl languageCtrl;
languageCtrl
    << lng_language.LeftPos(0, 20)
    << txt_lang_check.LeftPos(22, 20)
    << b_preview.LeftPos(42, 20)
    << txt_preview.LeftPos(62, 20);
    
tab_settings.Add(languageCtrl.SizePos(), t_("Language"));

or you can use designer like this example : TabDlg


regards
omari.
Re: Adding Tab and Slaves to a TabCtrl [message #48449 is a reply to message #48448] Tue, 04 July 2017 12:46 Go to previous messageGo to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
Ok I guess the TabDlg option should work.
But for better understanding on the first option:
I have a .lay file where the positions are all set. Why should I need to reset it again?
And by the way it doesn't work if I add the positioning again Wink


Greetings
Daniel
Re: Adding Tab and Slaves to a TabCtrl [message #48452 is a reply to message #48449] Tue, 04 July 2017 13:24 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
this is a bout of code, not a complet test case.
can you post your .lay content, then i can use it in order to provide a complet solution .


regards
omari.
Re: Adding Tab and Slaves to a TabCtrl [message #48453 is a reply to message #48452] Tue, 04 July 2017 13:42 Go to previous messageGo to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
This is my current calling code:
SettingsWindow::SettingsWindow()
{
    m_language = GetCurrentLanguage();
    
    CtrlLayout(*this, t_("Settings"));
    InitTabs();
        
    b_ok <<= THISBACK(OnClickOK);
    b_cancel <<= THISBACK(OnClickCancel);
}

void SettingsWindow::InitTabs()
{
    ParentCtrl languageCtrl;
    /*languageCtrl.AddChild(&lng_language);
    languageCtrl.AddChild(&txt_lang_check);
    languageCtrl.AddChild(&b_preview);
    languageCtrl.AddChild(&txt_preview);
    /**/ // did not work as well
    languageCtrl
        << lng_language
        << txt_lang_check
        << b_preview
        << txt_preview;
    /**/
    tab_settings.Add(languageCtrl.SizePos(), t_("Language"));
    txt_preview.Show(false);
    b_preview <<= THISBACK(OnClickPreview);
    
    m_retriever // header -> CtrlRetriever m_retriever
        (lng_language, m_language) // header -> int m_language
    ;
}


And this is the .lay:
LAYOUT(SettingsLayout, 250, 300)
	ITEM(TabCtrl, tab_settings, LeftPosZ(0, 250).TopPosZ(0, 300))
	ITEM(Button, b_ok, SetLabel(t_("OK")).LeftPosZ(10, 100).BottomPosZ(10, 30))
	ITEM(Button, b_cancel, SetLabel(t_("Cancel")).RightPosZ(10, 100).BottomPosZ(10, 30))
	ITEM(LNGCtrl, lng_language, LeftPosZ(30, 190).TopPosZ(50, 30))
	ITEM(StaticText, txt_lang_check, SetText(t_("Press the preview button.")).SetFont(StdFontZ(11)).LeftPosZ(30, 190).TopPosZ(90, 30))
	ITEM(Button, b_preview, SetLabel(t_("Preview")).LeftPosZ(30, 50).TopPosZ(125, 20))
	ITEM(StaticText, txt_preview, SetText(t_("English text")).SetAlign(ALIGN_CENTER).SetFont(StdFontZ(16)).SetFrame(ThinInsetFrame()).LeftPosZ(30, 190).TopPosZ(150, 100))
END_LAYOUT


Thanks for your effort Thumbs Up


Greetings
Daniel
Re: Adding Tab and Slaves to a TabCtrl [message #48455 is a reply to message #48453] Tue, 04 July 2017 14:12 Go to previous message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
1 - the new .Lay
LAYOUT(SettingsLayout, 250, 300)
	ITEM(TabCtrl, tab_settings, LeftPosZ(0, 250).TopPosZ(0, 300))
END_LAYOUT

LAYOUT(languageCtrlLayout, 256, 328)
	ITEM(Button, b_ok, SetLabel(t_("OK")).LeftPosZ(16, 100).BottomPosZ(22, 30))
	ITEM(Button, b_cancel, SetLabel(t_("Cancel")).RightPosZ(16, 100).BottomPosZ(22, 30))
	ITEM(LNGCtrl, lng_language, LeftPosZ(36, 190).TopPosZ(18, 30))
	ITEM(StaticText, txt_lang_check, SetText(t_("Press the preview button.")).SetFont(StdFontZ(11)).LeftPosZ(36, 190).TopPosZ(58, 30))
	ITEM(Button, b_preview, SetLabel(t_("Preview")).LeftPosZ(36, 50).TopPosZ(93, 20))
	ITEM(StaticText, txt_preview, SetText(t_("English text")).SetAlign(ALIGN_CENTER).SetFont(StdFontZ(16)).SetFrame(ThinInsetFrame()).LeftPosZ(36, 190).TopPosZ(118, 100))
END_LAYOUT



2 - in SettingsLayout class, add the instance
class SettingsLayout : public ..
{
...
    WithlanguageCtrlLayout<ParentCtrl> languageCtrl;
...
};


3 - add a CtrlLayout in the constructor, and refere to tab widget by languageCtrl.x:
SettingsWindow::SettingsWindow()
{
    m_language = GetCurrentLanguage();
    
    CtrlLayout(*this, t_("Settings"));
    CtrlLayout(languageCtrl);                  // Line Added
    InitTabs();
        
    languageCtrl.b_ok <<= THISBACK(OnClickOK);  // line modified
    languageCtrl.b_cancel <<= THISBACK(OnClickCancel);   // line modified
}


4 - InitTab:
void SettingsWindow::InitTabs()
{


    tab_settings.Add(languageCtrl.SizePos(), t_("Language"));
    languageCtrl.txt_preview.Show(false);
    languageCtrl.b_preview <<= THISBACK(OnClickPreview);
    
    m_retriever // header -> CtrlRetriever m_retriever
        (languageCtrl.lng_language, m_language) // header -> int m_language
    ;
}


regards
omari.
Previous Topic: Switching layout inside class
Next Topic: Example Serial pak
Goto Forum:
  


Current Time: Thu Mar 28 22:41:18 CET 2024

Total time taken to generate the page: 0.01029 seconds