Wx::Perl::Smart::* (technical advantages of GCL)

As en extention of my last post, where I introduced the first rough ideas of the still changing GCL syntax, I want to write now about further advantages of the DSL I created this new namespace for. Yes it reminds a bit on smartmatch, but that's wanted, because these modules that implement the functionalities of GCL in the Wx realm (second planned target is Prima because I cant install Gtk2 here) and there is a lot things going on depending on the type of the value, exactly like in smartmatch. Plus the Wx::Perl::* namespace will be more free for other normal modules that do far less magic.

I now added to the Wx::Perl::Smart::Frame class a SubscribeWidgets method. This will free you from severel problems.

1.) Depending on the input it creates widgets for you with minimal data needed which (no -1 params anymore) declutteres your program greatly and you get kinda getter/setter for them for free. (most understand SetValue, some have other methods)

2.) You don't have to care about the parenting anyway because thats handeled by smart sizers.

3.) it automatically hides all widgets so only widgets. so only things that are part of the layout show up. This is handy while playing with the layout. When you comment something in the layout it stays hidden and will not popup in left upper corner, like in usual WxPerl code where you have to somment also the code that created the widget.

4.) It beautifies the GCL syntax. Instead of $widgetvar or $app->{'widgetname'} (second is much more likesly since you will process similar widgets by common routines) you have now just to write which is an even Perl 6 compatible syntax. Not to mention you can give widgets an ID while there are autogenerated by GCL, to play with them later.

[   # left part
	{border => 10, flags => &Wx::wxALL|&Wx::wxGROW},
		{border => 20, flags => &Wx::wxLEFT},
		{border => 20, flags => &Wx::wxRIGHT},
		{border => 0},
],[ # right half
	-TabbedBox =>  [ 
		$l18n{'oscillators'} => [[
			{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
			-LabeledBox => [ $l18n{'frequency'} => [<frequency_x>, <frequency_y>, <y_invers>]],
			-LabeledBox => [ $l18n{'start_amp'} => [<amplitude_x>, <amplitude_y>  ]],
			-LabeledBox => [ $l18n{'rotation'}  => [<rotation_dir>, <rotation>     ]],
			{border => 10},
		$l18n{'visuals'} => [[
			{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
			-LabeledBox => [ $l18n{'line'}  => [<length>,      <density>,    <thickness>   ]],
			-LabeledBox => [ $l18n{'color'} => [<start_colour>, <flow_colour>, <scale_colour>]],
			{border => 10},

As you can see GCL also supports now tabbed panels (WxNotebook) and next issue will be a possible integration of localisation and other strings.

Leave a comment

About lichtkind

user-pic Kephra, Articles, Books, Perl, Programming