Wx-Demo

 view release on metacpan or  search on metacpan

lib/Wx/DemoModules/wxPropertyGrid.pm  view on Meta::CPAN

	$pg->Append( Wx::FlagsProperty->new('Some Flags', 'Some Flags',
		[ 'wxFLAG_DEFAULT', 'wxFLAG_FIRST', 'wxFLAG_SECOND', 'wxFLAG_THIRD', 'wxFLAG_FIFTH', 'wxFLAG_SIXTH', ],
		[ 0, 1, 2, 4, 8, 16, 32 ] , 10 ) );
	
	
    $pg->SetPropertyAttribute( 'Some Flags' , wxPG_BOOL_USE_CHECKBOX, 1 , wxPG_RECURSE);
	
	
	$pg->Append( Wx::CursorProperty->new('Cursor','Cursor') );
										 
    $pg->Append( Wx::PropertyCategory->new('Position', 'PositionCategory') );
    
	$pg->SetPropertyHelpString( 'PositionCategory', 'Change in items in this category will cause respective changes in Demo Frame.' );

    #// Let's demonstrate 'Units' attribute here
    
    #// Note that we use many attribute constants instead of strings here
    #// (for instance, wxPG_ATTR_MIN, instead of "min".
    
    
    $pg->Append( Wx::IntProperty->new('Height','Height',480) );
    $pg->SetPropertyAttribute('Height', wxPG_ATTR_MIN,   10 );
    $pg->SetPropertyAttribute('Height', wxPG_ATTR_MAX,   2048  );
    $pg->SetPropertyAttribute('Height', wxPG_ATTR_UNITS, 'Pixels');
    
    #// Set value to unspecified so that Hint attribute will be demonstrated
	$pg->SetPropertyValueUnspecified("Height");
    $pg->SetPropertyAttribute("Height", wxPG_ATTR_HINT,  "Enter new height for window");
    #
    #// Difference between hint and help string is that the hint is shown in
    #// an empty value cell, while help string is shown either in the
    #// description text box, as a tool tip, or on the status bar.
	
    $pg->SetPropertyHelpString("Height", "This property uses attributes \"Units\" and \"Hint\"." );

    $pg->Append( Wx::IntProperty->new('Width', 'Width', 640 ) );
    $pg->SetPropertyAttribute('Width', wxPG_ATTR_MIN, Wx::Variant->new(10) );
	
    $pg->SetPropertyAttribute('Width', wxPG_ATTR_MAX, Wx::Variant->new(2048) );
    $pg->SetPropertyAttribute('Width', wxPG_ATTR_UNITS, Wx::Variant->new('Pixels') );
    
    $pg->SetPropertyValueUnspecified('Width');
    $pg->SetPropertyAttribute('Width', wxPG_ATTR_HINT, "Enter new width for window" );
    $pg->SetPropertyHelpString("Width", "This property uses attributes \"Units\" and \"Hint\"." );
    
    $pg->Append( Wx::IntProperty->new('X','X', 10 ));
    $pg->SetPropertyAttribute('X', wxPG_ATTR_UNITS, '"Pixels"' );
    $pg->SetPropertyHelpString('X', "This property uses \"Units\" attribute." );
    
    $pg->Append( Wx::IntProperty->new( 'Y','Y',10 ));
    $pg->SetPropertyAttribute('Y', wxPG_ATTR_UNITS, 'Pixels');
    $pg->SetPropertyHelpString('Y', "This property uses \"Units\" attribute." );
    
    my $disabledHelpString = qq(This property is simply disabled. In order to have label disabled as well, \n);
	$disabledHelpString .= qq(you need to set wxPG_EX_GREY_LABEL_WHEN_DISABLED using SetExtraStyle.);
    
    $pg->Append( Wx::PropertyCategory->new('Environment','Environment') );
    $pg->Append( Wx::StringProperty->new('Operating System','Operating System',Wx::GetOsDescription()) );
    
	$pg->Append( Wx::StringProperty->new('User Name','User Name',
				( Wx::wxMSW() ) ? getlogin : (getpwuid($<))[0] ) );
	$pg->Append( Wx::DirProperty->new('User Local Data Directory','UserLocalDataDir',
				Wx::StandardPaths::Get()->GetUserLocalDataDir ) );
	
    #// Disable some of them
    $pg->DisableProperty( 'Operating System' );
    $pg->DisableProperty( 'User Name' );
    
    $pg->SetPropertyHelpString( 'Operating System', $disabledHelpString );
    $pg->SetPropertyHelpString( 'User Name', $disabledHelpString );
    
    # $pg->Append( Wx::PropertyCategory->new('More Examples','More Examples') );
    
    # Custom Property Classes ??
	
}

sub populate_with_examples {
	my $self = shift;
	my $pgman = $self->{manager};
    my $pg = $pgman->GetPage('Examples');



	my $spinprop = $pg->Append( Wx::IntProperty->new('SpinCtrl', 'SpinCtrl', 0 ) );
	
	# The second param below is the 'class name' you can use to apply any of the
	# builtin editors
	# Available class builtin names are:
	#  TextCtrl, Choice, ComboBox, TextCtrlAndButton,
	#  CheckBox, ChoiceAndButton, SpinCtrl, DatePickerCtrl
	
	$pg->SetPropertyEditor('SpinCtrl', 'SpinCtrl' );
	
    $pg->SetPropertyAttribute( 'SpinCtrl', wxPG_ATTR_MIN, -10 ); 
	$pg->SetPropertyAttribute( 'SpinCtrl', wxPG_ATTR_MAX, 16384 );
	$pg->SetPropertyAttribute( 'SpinCtrl', 'Step', 2 );
    $pg->SetPropertyAttribute( 'SpinCtrl', 'MotionSpin', 1 );
	$pg->SetPropertyAttribute( 'SpinCtrl', 'Wrap', 1 );

	
     ## Add bool property
	$pg->Append( Wx::BoolProperty->new( 'BoolProperty', 'BoolProperty', 0 ) );
	## Add bool property with check box
	{
		#use the returned value from append to access property directly
		my $prop = $pg->Append( Wx::BoolProperty->new( 'BoolProperty with CheckBox', 'BoolProperty with CheckBox', 0 ) );
		$prop->SetAttribute( wxPG_BOOL_USE_CHECKBOX, 1 );
		$prop->SetHelpString( 'Property attribute wxPG_BOOL_USE_CHECKBOX has been set to true.' );
	}

   
	{
		my $prop = $pg->Append( Wx::FloatProperty->new('FloatProperty','FloatProperty', 1234500.23) );
		$prop->SetAttribute("Min", -100.12);
	}
	
	# A string property that can be edited in a separate editor dialog.

	$pg->Append( Wx::LongStringProperty->new( 'LongStringProperty', 'LongStringProp',
		'This is a much longer string than the first one. Edit it by clicking the button.') );



( run in 2.028 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )