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 » U++ Library support » U++ Widgets - General questions or Mixed problems » Proper SplitterFrame removal++
Proper SplitterFrame removal++ [message #58221] Mon, 28 March 2022 08:51 Go to next message
luoganda is currently offline  luoganda
Messages: 194
Registered: November 2016
Experienced Member
1st question is more about c++, but anyway:
I have this struct.
struct SCtrl:Ctrl{
	void Paint(Draw& w)override{
		...
	}
};
Array<Ctrl> ctrls;
Array<SCtrl> sctrls;
ctrls.Create<Button>(); //this is ok
sctrls.Create<Button>(); //this produces error(no matching member function for call to 'Add')

Can the last one be done, so that SCtrl is somehow subclassed but still used as Ctrl to be used as Button,...?
Any idea how to do this properly? maybe provide copyCtor?
~~~~

2nd question:
Simple app is included in attachment.
I would want a layout design something like foobar2000(win) or deadbeef(linux) has.
Could someone check that and try to correct it
and do it properly - since i don't know fully how SplitterFrame works and how i would do this properly.
When i add frames - it's ok(altough now childFrames are added and are children of parent ctrls - which when clicking on parent and removing it - children are then also removed, i would want to remove only SplitterFrame on which i click->Remove, but for this nonChildren would probably need to be used - siblings - altough i don't know if this is possible with SplitterFrames to do it properly).
When i remove it - problems happens, see and try code.

How to properly remove frames?
if i call sc->spl.FrameRemove(); instead of par->RemoveFrame(sc->spl) i get segmentation fault via repaint(this is called from SCtrl::RightUp...)

pwnd points to global main window,
when called from childCtrl - pfrom points to that from SCtrl::RightUp

SCtrl& AddSplitter(int where,Ctrl *pfrom){
	//SSplitterFrame& spl=splitters.Create<SSplitterFrame>();
	//spl.FrameAdd(InsetFrame());
	SCtrl& sc=ctrls.Create<SCtrl>();
	sc.spl.Set(sc.SizePos(),100,where);
	if(!pfrom)pfrom=pwnd; sc.frmid=pfrom->GetFrameCount();
	pfrom->AddFrame(sc.spl);
	return sc;
}

void NewPanel(int where,Ctrl *pfrom){
	SCtrl&ctrl=AddSplitter(where,pfrom);
	//ctrl.ctrl.Create<Button>();
	//Button&b=*(Button*)ctrl.ctrl.Get();b.SetLabel("Marana");b.LeftPos(20,100);b.TopPos(20,40);
	////ctrl.ctrl->Add(b);
}
Re: Proper SplitterFrame removal++ [message #58402 is a reply to message #58221] Tue, 17 May 2022 15:34 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
luoganda wrote on Mon, 28 March 2022 08:51
1st question is more about c++, but anyway:
I have this struct.
struct SCtrl:Ctrl{
	void Paint(Draw& w)override{
		...
	}
};
Array<Ctrl> ctrls;
Array<SCtrl> sctrls;
ctrls.Create<Button>(); //this is ok
sctrls.Create<Button>(); //this produces error(no matching member function for call to 'Add')

Can the last one be done, so that SCtrl is somehow subclassed but still used as Ctrl to be used as Button,...?


You can only Create instances of classes that are derived from T. Button is descendant of Ctrl, but not SCtrl.

Quote:

Any idea how to do this properly? maybe provide copyCtor?


Do what? Smile

Mirek
Re: Proper SplitterFrame removal++ [message #58458 is a reply to message #58402] Wed, 25 May 2022 21:58 Go to previous messageGo to next message
luoganda is currently offline  luoganda
Messages: 194
Registered: November 2016
Experienced Member
1st question:
"Do what?"
I am subclassing Ctrl as SCtrl,
and i would like to use it - like it's written - in Array<SCtrl> sctrl;
How to do that? since now it throws error - like it's written in 1st post.

2nd question:
i observed how frames are done in foobar2000(windows) and deadbeef(linux).
Like i have suspected, both programs don't have an option to pick-and-point with mouse
to delete just any children, but have an option to delete/replace parent(which also deletes all it's children).
This is easier(recommended if one want's to stay sane Smile ), and is also how i am
currently doing it - but more sophisticated method would be to pick and delete any child of a child of a child...
Re: Proper SplitterFrame removal++ [message #58480 is a reply to message #58458] Tue, 31 May 2022 11:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
luoganda wrote on Wed, 25 May 2022 21:58
1st question:
"Do what?"
I am subclassing Ctrl as SCtrl,
and i would like to use it - like it's written - in Array<SCtrl> sctrl;


sctrl.Add();

However you are doing sctrl.Create<Button>(). Not sure what you expect THAT to do. In any case, as Button does not have SCtrl as base class, you cannot do that.

Anyway, if your aim is to mix Button and SCtrl in the Array, just use

Array<Ctrl> ctrls;

ctrls.Create<SCtrl>();
ctrls.Create<Button>();
Re: Proper SplitterFrame removal++ [message #58485 is a reply to message #58221] Tue, 31 May 2022 16:35 Go to previous message
luoganda is currently offline  luoganda
Messages: 194
Registered: November 2016
Experienced Member
ahh, it seems i wrote
a typo there, it must have been the moon Smile .
sctrls.Create<Button>(); //this produces error(no matching member function for call to 'Add')

Yes, it should be sctrls.Create<SCtrl>(); or just the usual thing sctrls.Add(); <- that's why that error

Anyway,thanks for reply.

By the way,
RegExp seems is still a little buggy - not sure why - even with new perlRegExp version,
for now i propose to encapsulate standards c++ regexp as upp RegExp,
and encapsulate perlRegExp as RegExp2(if one needs some specific feature of it),
so when (probably faster) perlRegExp is fixed, it is simply again put in RegExp class.
Previous Topic: [FEATURE] Common horizontal scroll on Shift+mouse wheel
Next Topic: How would I virtualize a scrollable view to dynamically load Ctrls?
Goto Forum:
  


Current Time: Wed Apr 24 02:56:30 CEST 2024

Total time taken to generate the page: 0.02725 seconds