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
	<maltafel>,
	10,
	{border => 10, flags => &Wx::wxALL|&Wx::wxGROW},
	<fav_select>,
	[
		<save>,
		{border => 20, flags => &Wx::wxLEFT},
		<save_all>,
		\1,
		{border => 20, flags => &Wx::wxRIGHT},
		<forget>, 
		{border => 0},
		<remember>
	],
],[ # 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},
			<friction>, 
		]],
		$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},
			<zoom>,
		]]
	],
],

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