GtkD: New widget

Johnson Jones via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 20 18:45:25 PDT 2017


Hey Mike, I bet you can answer this!

I'd like to extend a widget to add some functionality.

class MyBox : Box
{
	protected GtkBox* gtkBox;

	import std.typecons;
	_gtk.Box Wrapped;
	mixin Proxy!Wrapped;

	public this(Box b)
	{
		this.gtkBox = b.getBoxStruct();
		super(gtkBox, false);
	}

}

Trying something like the above does extend the box, as far as 
allowing one to replace it, I think(using the code);

auto b = new MyBox(W1);
auto p = W1.getParent();
auto c = cast(Box)W4;
c.remove(W1);
c.add(b);

So, W4 is the main boxx, W1 is the box inside the main box I 
replaced with the new box b.

When running that code, nothing changes, which, assuming we are 
actually using the new box, then that is fine.

But I'm pretty sure that gtk never has a clue about `MyBox`? I 
say this because I'd like to simply modify the reported sizes of 
the box.

A gtkBox is not the same as a gtk.Box.

It seems like the best I can do is use a gtk.Container and 
inherit from that.


e.g.,

class FixableSizedBox : Container
{
	protected GtkContainer* gtkContainer;

	import std.typecons;
	_gtk.Container Wrapped;
	mixin Proxy!Wrapped;

	public this(Container b)
	{
		this.gtkContainer = b.getContainerStruct();
		super(gtkContainer, false);
	}

}

But even the GtkD container doesn't seem to contain any code to 
deal with handling the sizes.


All I'm really looking to do is set the size of a container to 
whatever I want.



More information about the Digitalmars-d-learn mailing list