Prima

 view release on metacpan or  search on metacpan

Prima/Classes.pm  view on Meta::CPAN

	ownerFont         => 1,
	ownerHint         => 1,
	ownerShowHint     => 1,
	ownerPalette      => 1,
	packInfo          => undef,
	packPropagate     => 1,
	placeInfo         => undef,
	pointerIcon       => undef,
	pointer           => cr::Default,
	pointerType       => cr::Default,
	popup             => undef,
	popupColor             => cl::NormalText,
	popupBackColor         => cl::Normal,
	popupHiliteColor       => cl::HiliteText,
	popupHiliteBackColor   => cl::Hilite,
	popupDisabledColor     => cl::DisabledText,
	popupDisabledBackColor => cl::Disabled,
	popupLight3DColor      => cl::Light3DColor,
	popupDark3DColor       => cl::Dark3DColor,
	popupItems        => undef,
	right             => 200,
	scaleChildren     => 1,
	selectable        => 0,
	selected          => 0,
	selectedWidget    => undef,
	selectingButtons  => mb::Left,
	shape             => undef,
	showHint          => 1,
	syncPaint         => 0,
	tabOrder          => -1,

Prima/Classes.pm  view on Meta::CPAN

		designScale       => [ 0, 0],
		origin            => [ 0, 0],
		owner             => $::application,
		pointerHotSpot    => [ 0, 0],
		rect              => [ 0, 0, 100, 100],
		size              => [ 100, 100],
		sizeMin           => [ 0, 0],
		sizeMax           => [ 16384, 16384],
	);
	@$def{keys %WidgetProfile} = values %WidgetProfile;
	@$def{qw( font popupFont)} = ( $_[ 0]-> get_default_font, $_[ 0]-> get_default_popup_font);
	return $def;
}

sub profile_check_in
{
	my ( $self, $p, $default) = @_;
	my $orgFont = exists $p-> { font} ? $p-> { font} : undef;
	my $owner = exists $p-> { owner} ? $p-> { owner} : $default-> { owner};
	$self-> SUPER::profile_check_in( $p, $default);
	delete $p-> { font} unless defined $orgFont;

Prima/Classes.pm  view on Meta::CPAN

	}
	for my $back (qw(backColor hiliteColor disabledBackColor light3DColor)) {
		unless (exists $p-> {$back}) {
			my $clr = Prima::Widget::fetch_resource(
				$cls, $name, 'Background',
				$back, $owner, fr::Color
			);
			$p-> {$back} = $clr if defined $clr;
		}
	}
	for my $fon (qw(font popupFont)) {
		my $f = Prima::Widget::fetch_resource(
			$cls, $name, 'Font', $fon, $owner, fr::Font);
		next unless defined $f;
		unless ( exists $p-> {$fon}) {
			$p-> {$fon} = $f;
		} else {
			for ( keys %$f) {
				$p-> {$fon}-> {$_} = $$f{$_}
					unless exists $p-> {$fon}-> {$_};
			}
		}
	}

	for ( $owner ? qw( color backColor showHint hint font): ()) {
		my $o_ = 'owner' . ucfirst $_;
		$p-> { $_} = $owner-> $_() if
			( $p-> { $o_} = exists $p-> { $_} ? 0 :
				( exists $p-> { $o_} ? $p-> { $o_} : $default-> {$o_}));
	}
	for ( qw( font popupFont)) {
		$p-> { $_} = {} unless exists $p-> { $_};
		$p-> { $_} = Prima::Widget-> font_match( $p-> { $_}, $default-> { $_});
	}

	if ( exists( $p-> { origin})) {
		$p-> { left  } = $p-> { origin}-> [ 0];
		$p-> { bottom} = $p-> { origin}-> [ 1];
	}

	if ( exists( $p-> { rect})) {

Prima/Classes.pm  view on Meta::CPAN

		if ( !exists( $p-> { width}) && exists( $p-> { right}) && exists( $p-> { left}));
	$p-> { right} = $p-> { left} + $p-> { width}
		if ( !exists( $p-> { right}) && exists( $p-> { width}) && exists( $p-> { left}));
	$p-> { left}  = $p-> { right} - $p-> { width}
		if ( !exists( $p-> { left}) && exists( $p-> { right}) && exists( $p-> { width}));
	$p-> { left}  = $p-> { right} - $default-> {width}
		if ( !exists( $p-> { left}) && !exists( $p-> { width}) && exists($p-> {right}));
	$p-> { right} = $p-> { left} + $default-> { width}
		if ( !exists( $p-> { right}) && !exists( $p-> { width}) && exists( $p-> { left}));

	if ( $p-> { popup}) {
		$p-> { popupItems} = $p-> {popup}-> get_items('');
		delete $p-> {popup};
	}

	my $current = exists $p-> { current} ? $p-> { current} : $default-> { current};
	if ( defined($owner) && !$current && !$owner-> currentWidget) {
		my $e = exists $p-> { enabled} ? $p-> { enabled} : $default-> { enabled};
		my $v = exists $p-> { visible} ? $p-> { visible} : $default-> { visible};
		$p-> {current} = 1 if $e && $v;
	}

	if ( exists $p-> {pointer}) {

Prima/Classes.pm  view on Meta::CPAN

}

sub capture               {($#_)?shift-> set_capture     (@_)   :return $_[0]-> get_capture;     }
sub centered              {($#_)?$_[0]-> set_centered(1,1)      :$_[0]-> raise_wo("centered");   }
sub dark3DColor           {return shift-> colorIndex( ci::Dark3DColor , @_)};
sub disabledBackColor     {return shift-> colorIndex( ci::Disabled    , @_)};
sub disabledColor         {return shift-> colorIndex( ci::DisabledText, @_)};
sub hiliteBackColor       {return shift-> colorIndex( ci::Hilite      , @_)};
sub hiliteColor           {return shift-> colorIndex( ci::HiliteText  , @_)};
sub light3DColor          {return shift-> colorIndex( ci::Light3DColor, @_)};
sub popupFont             {($#_)?$_[0]-> set_popup_font ($_[1])  :return Prima::Font-> new($_[0], "get_popup_font", "set_popup_font")}
sub popupColor            { return shift-> popupColorIndex( ci::NormalText  , @_)};
sub popupBackColor        { return shift-> popupColorIndex( ci::Normal      , @_)};
sub popupDisabledBackColor{ return shift-> popupColorIndex( ci::Disabled    , @_)};
sub popupHiliteBackColor  { return shift-> popupColorIndex( ci::Hilite      , @_)};
sub popupDisabledColor    { return shift-> popupColorIndex( ci::DisabledText, @_)};
sub popupHiliteColor      { return shift-> popupColorIndex( ci::HiliteText  , @_)};
sub popupDark3DColor      { return shift-> popupColorIndex( ci::Dark3DColor , @_)};
sub popupLight3DColor     { return shift-> popupColorIndex( ci::Light3DColor, @_)};

sub x_centered       {($#_)?$_[0]-> set_centered(1,0)      :$_[0]-> raise_wo("x_centered"); }
sub y_centered       {($#_)?$_[0]-> set_centered(0,1)      :$_[0]-> raise_wo("y_centered"); }

sub hint
{
	return $_[0]->get_hint unless $#_;
	$_[0]->set_hint( (( ref($_[1]) // '') eq 'SCALAR') ? $_[0]->_parse_markup(hint => $_[1]) : $_[1] );
}

Prima/InputLine.pm  view on Meta::CPAN

		charOffset     => 0,
		cursorVisible  => 1,
		cursorSize     => [ Prima::Application-> get_default_cursor_width, $font-> { height}],
		firstChar      => 0,
		dndAware       => 'Text',
		height         => 4 + $font-> { height} + 2,
		insertMode     => 0,
		maxLen         => 256,  # length $def{ text},
		passwordChar   => '*',
		pointerType    => cr::Text,
		popupItems     => [
			[ cut        => 'Cu~t'        => 'cut'       ],
			[ copy       => '~Copy'       => 'copy'      ],
			[ paste      => '~Paste'      => 'paste'     ],
			[ delete     => '~Delete'     => 'delete'    ],
			[],
			[select_all  => 'Select ~All' => 'select_all'],
			[undo        => '~Undo', 'Ctrl+Z', '^Z', 'undo'],
			[redo        => 'R~edo', 'Ctrl+Y', '^Y', 'redo'],
			['@rtl'      => '~RTL input', 'Ctrl+Shift+D', '^#D', 'toggle_rtl'],
			['@ligation' => '~Ligation', 'Ctrl+Shift+L', '^#L', 'toggle_ligation'],

Prima/InputLine.pm  view on Meta::CPAN

		} else {
			$self-> handle_input($chr);
		}
		$self-> selection(0,0);
		$self-> clear_event;
		$self-> end_undo_group;
		return;
	}
}

sub on_popup
{
	my $self = $_[0];
	my $p    = $self-> popup;

	my $sel = $self-> {selStart} != $self-> {selEnd};

	my $c    = $::application-> Clipboard;
	$c-> open;
	my $clip = $c-> format_exists('Text');
	$c-> close;

	$p-> enabled( 'copy',         $sel && not($self-> {writeOnly}));
	$p-> enabled( 'cut',          $sel && not($self-> {writeOnly}));

Prima/MDI.pm  view on Meta::CPAN

		dragMode              => undef,
		tabStop               => 0,
		tileable              => 1,
		titleHeight           => 0, # use system-default
		transparent           => 0,
		widgetClass           => wc::Window,
		windowState           => ws::Normal,
		clientClass           => 'Prima::Widget',
		clientProfile         => {},
		firstClick            => 1,
		popupItems            => [
			[ restore => '~Restore'  => 'Ctrl+F5' => '^F5' => q(restore)],
			[ min     => 'Mi~nimize' => q(minimize)],
			[ max     => 'Ma~ximize' => 'Ctrl+F10' => '^F10' => q(maximize)],
			[ move    => '~Move' => q(keyMove)],
			[ size    => '~Size' => q(keySize)],
			[],
			[ close   => '~Close' => 'Ctrl+F4' => '^F4' => sub { $_[0]-> close; } ],
		],
	);
	@$def{keys %prf} = values %prf;

Prima/MDI.pm  view on Meta::CPAN

		{ $self-> {$_} = 0; }
	my %profile = $self-> SUPER::init(@_);
	$self-> {zoomGrowMode} = $profile{growMode};
	for ( qw( titleHeight borderStyle borderIcons icon tileable windowState dragMode
		iconMin iconMax iconClose iconRestore iconMinPressed iconMaxPressed
		iconClosePressed iconRestorePressed
		))
		{ $self-> $_( $profile{ $_}); }
	$self-> {zoomRect} = [ $self-> rect];
	$self-> {miniRect} = [ 0, 0, $self-> sizeMin];
	$self-> popup-> autoPopup(0) if $self-> popup;
	$self-> {client} = $self-> insert( $profile{clientClass},
		rect         => [ $self-> get_client_rect],
		growMode     => gm::Client,
		pointerType  => cr::Arrow,
		name         => 'MDIClient',
		delegations  => ['Destroy'],
		%{$profile{clientProfile}},
	);
	$self-> update_popup_commands;
	return %profile;
}

sub on_paint
{
	my ( $self, $canvas) = @_;
	my @cl  = ( $self-> color, $self-> backColor);
	my @c3d   = ( $self-> light3DColor, $self-> dark3DColor);
	my @size  = $canvas-> size;
	my @csize = @size;

Prima/MDI.pm  view on Meta::CPAN

	my $part = $self-> xy2part( $x, $y);
	$self-> bring_to_front;
	$self-> select;
	return if
		$part eq q(client) or
		$part eq q(border) or
		$btn != mb::Left;

	if ( $part eq q(menu)) {
		# Win32 test results - we won't get on_click( double=1) after 'cancelling'
		# on_mousedown with popup - the system says it's no more a double click,
		# just a single click to popup. Moreover, in general this is correct. We could
		# catch second on_mousedown in system-defined timeout interval, but
		# this popup-canceling on_mousedown won't come to us either.
		my $delay = Prima::Application-> get_system_value( sv::DblClickDelay);
		$delay = 250 if $delay > 250;
		$self-> {exTimer} = Prima::Timer-> create(
			owner   => $self,
			timeout => $delay,
			onTick  => sub {
				my $self = $_[0]-> owner;
				$_[0]-> destroy;
				delete $self-> {exTimer};
				return unless $self-> alive || ! defined ( $self-> popup);

				my ( $w, $y, $bw)  = ( $self-> height, $self-> {titleY}, $self-> {border});
				$self-> popup-> popup(
					$bw, $w - $y - $bw,
					$bw, $w - $y - $bw, $bw + $y, $w - $bw
				);
			},
		);
		$self-> {exTimer}-> start;
		return;
	}

	if ( $part eq q(caption)) {

Prima/MDI.pm  view on Meta::CPAN

				$back ? $mdis[0]-> send_to_back : $x-> bring_to_front;
				$x-> select;
			}
			$self-> clear_event;
		} if (
			( $key == kb::Space) &&
			( $mod & km::Ctrl) &&
			( $self-> { borderIcons} & mbi::SystemMenu)
		) {
			my ( $w, $y, $bw)  = ( $self-> height, $self-> {titleY}, $self-> {border});
			$self-> popup-> popup(
				$bw, $w - $y - $bw,
				$bw, $w - $y - $bw, $bw + $y, $w - $bw
			);
			$self-> clear_event;
		}
	}
}

sub on_keydown
{

Prima/MDI.pm  view on Meta::CPAN

	return if $bi == $self-> {borderIcons};
	$self-> {borderIcons} = $bi;

	my $icos = 0;
	$icos++ if $bi & mbi::Minimize;
	$icos++ if $bi & mbi::Maximize;
	$icos++ if $bi & mbi::Close;

	$self-> { iconsAtRight} = $icos;

	$self-> update_popup_commands;
	$self-> update_size_min;
	$self-> sync_client;
	$self-> repaint;
}

sub set_border_style
{
	my ( $self, $bs) = @_;
	return if $bs == $self-> {borderStyle} or $bs < bs::None or $bs > bs::Dialog;

	$self-> {borderStyle} = $bs;
	my ( $bbx, $bby) = Prima::Application-> get_default_window_borders( $bs);
	$bbx = $bbx > 1 ? $bbx : (( $bbx > 0) ? 1 : 0);
	$bby = $bby > 1 ? $bby : (( $bby > 0) ? 1 : 0);
	$self-> {border} = $bbx > $bby ? $bby : $bbx;

	$self-> update_popup_commands;
	$self-> update_size_min;
	$self-> sync_client;
	$self-> repaint;
}

sub update_popup_commands
{
	my $self = $_[0];
	my $popup = $self-> popup;

	my ( $bi, $bs, $ws) = ( $self-> {borderIcons}, $self-> {borderStyle}, $self-> {windowState});

	$popup-> max-> enabled(( $bi & mbi::Maximize) && ( $ws != ws::Maximized));
	$popup-> min-> enabled(( $bi & mbi::Minimize) && ( $ws != ws::Minimized));
	$popup-> restore-> enabled(( $bi & (mbi::Minimize|mbi::Maximize)) && ( $ws != ws::Normal));
	$popup-> move-> enabled( $ws == ws::Normal);
	$popup-> size-> enabled(( $ws == ws::Normal) && ( $bs == bs::Sizeable));
}

sub set_window_state
{
	my ( $self, $ws) = @_;
	return if $ws == $self-> {windowState} or $ws < ws::Normal or $ws > ws::Maximized;
	my $ows = $self-> {windowState};

	my $popup = $self-> popup;
	if ( $ws == ws::Minimized) {
		return unless $self-> {borderIcons} & mbi::Minimize;
		$self-> {zoomRect} = [ $self-> rect] if $ows == ws::Normal;
		$self-> growMode( $self-> {zoomGrowMode}) if $ows == ws::Maximized;
		my @szMin = $self-> sizeMin;
		my ($x, $y) = ( $self-> {miniRect}-> [0], $self-> {miniRect}-> [1]);
		$self-> clipOwner(1) unless ($self-> {saveClipOwner} = $self-> clipOwner);

		# start calculating position for min-widnow
		my @sz = $self-> clipOwner ? $self-> owner-> size : $::application-> size;

Prima/MDI.pm  view on Meta::CPAN

			$x = ( $newID % $szmaxids[0]) * $szMin[0];
			$y = int ( $newID / $szmaxids[0]) * $szMin[1];
		}
		# end calculating position for min-widnow

		($self-> {miniRect}-> [0], $self-> {miniRect}-> [1]) = ( $x, $y);
		$self-> {miniRect}-> [2] = $self-> {miniRect}-> [0] + $szMin[0];
		$self-> {miniRect}-> [3] = $self-> {miniRect}-> [1] + $szMin[1];
		$self-> rect( @{$self-> {miniRect}});

		$popup-> enable( $_)  for ( qw( max restore move));
		$popup-> disable( $_) for ( qw( min size));
	} elsif ( $ws == ws::Maximized) {
		return unless $self-> {borderIcons} & mbi::Maximize;

		$self-> clipOwner(0)
			if $ows == ws::Minimized && !$self-> {saveClipOwner};
		delete $self-> {saveClipOwner};

		$self-> {miniRect} = [ $self-> rect] if $ows == ws::Minimized;
		$self-> {zoomRect} = [ $self-> rect] if $ows == ws::Normal;
		$self-> rect( 0, 0, $self-> clipOwner ? $self-> owner-> size : $::application-> size);
		$self-> {zoomGrowMode} = $self-> growMode;
		$self-> growMode( gm::Client);

		$popup-> enable( $_)  for ( qw( min restore));
		$popup-> disable( $_) for ( qw( max move size));
	} else {
		$self-> {windowState} = ws::Normal;
		return unless $self-> {borderIcons} & (mbi::Maximize|mbi::Minimize);

		$self-> clipOwner(0)
			if $ows == ws::Minimized && !$self-> {saveClipOwner};

		delete $self-> {saveClipOwner};
		$self-> {miniRect} = [ $self-> rect] if $ows == ws::Minimized;
		$self-> growMode( $self-> {zoomGrowMode}) if $ows == ws::Maximized;
		$self-> rect( @{$self-> {zoomRect}});
		$popup-> enable( $_)  for ( qw( max min move size));
		$popup-> disable( $_) for ( qw( restore));
	}
	$self-> {windowState} = $ws;
	$self-> update_popup_commands;
	$self-> notify(q(WindowState));
}


sub set_icon
{
	my ( $self, $icon) = @_;
	$self-> {icon} = $icon;
	$self-> repaint_title(q('left'));
}

Prima/MDI.pm  view on Meta::CPAN



=head1 Prima::MDI

Implements MDI window functionality. A subwindow widget consists of a titlebar,
titlebar buttons, and a client widget. The latter must be used as an insertion
target for all children widgets.

A subwindow can be moved and resized, both by mouse and keyboard.  These
functions, along with maximize, minimize, and restore commands are accessible
via the toolbar-anchored popup menu. The default set of commands is as follows:

	Close window              - Ctrl+F4
	Restore window            - Ctrl+F5 or a double click on the titlebar
	Maximize window           - Ctrl+F10 or a double click on the titlebar
	Go to next MDI window     - Ctrl+Tab
	Go to previous MDI window - Ctrl+Shift+Tab
	Invoke popup menu         - Ctrl+Space

The class mimics API of C<Prima::Window> class, and in some extent
L<Prima::Window> and this page share the same information.

=head2 Properties

=over

=item borderIcons INTEGER

Prima/Menus.pm  view on Meta::CPAN

	} else {
		$itemid = $self-> parent;
		$index  = $self-> parentIndex + @{ $self->{cache} } - 1;
	}

	$self->notify(qw(Submenu), $i);
	return unless $self->alive;

	$self->{submenu_index} = $i;

	my $submenu = $self->{submenu} = $self->insert( $self->root->popupClass,
		visible        => 0,
		root           => $self->root,
		parent         => $itemid,
		parentIndex    => $index,
		menu           => $self->menu,
		ownerColor     => 1,
		ownerBackColor => 1,
		ownerFont      => 1,
		( map { $_ , $self->$_() } 
			qw(hiliteColor hiliteBackColor disabledColor disabledBackColor)),

Prima/Menus.pm  view on Meta::CPAN

use vars qw(@ISA);
@ISA = qw(Prima::Menu::Common);

BEGIN { Prima::Menu::Common::_export_constants(); };

sub profile_default
{
	my %def = %{$_[ 0]-> SUPER::profile_default};
	return {
		%def,
		font           => Prima::Widget->get_default_popup_font,
		widgetClass    => wc::Popup,
		clipOwner      => 0,
		selectable     => 0,
	}
}

sub profile_check_in
{
	my ( $self, $p, $default) = @_;
	$p->{font} //= Prima::Widget->get_default_popup_font;
	$self-> SUPER::profile_check_in( $p, $default);
}

sub init
{
	my $self = shift;
	$self->{vertical} = 1;
	my %profile = $self-> SUPER::init(@_);
	$self->root($profile{root});
	$self->reset;

Prima/Menus.pm  view on Meta::CPAN


	alarm( 0.2, sub {
		my $f = $::application->get_focused_widget;
		$self->cancel unless $f && $f->isa('Prima::Menu::Common') && $f->root == $self->root;
	});
}

sub on_destroy { undef $_[0]->{hooks} }

sub itemClass   { $#_ ? $_[0]->{itemClass}   = $_[1] : $_[0]->{itemClass}  }
sub popupClass  { $#_ ? $_[0]->{popupClass}  = $_[1] : $_[0]->{popupClass}  }

package Prima::Menu::Popup;
use vars qw(@ISA);
@ISA = qw(Prima::Menu::Transient Prima::Menu::Root);

{
my %RNT = (
	%{Prima::Menu::Common-> notification_types()},
	MenuEnter  => nt::Default,
	MenuLeave  => nt::Default,

Prima/Menus.pm  view on Meta::CPAN

sub notification_types { return \%RNT; }
}

sub profile_default
{
	my %def = %{$_[ 0]-> SUPER::profile_default};
	return {
		%def,
		visible        => 0,
		itemClass      => 'Prima::Menu::Item',
		popupClass     => 'Prima::Menu::Transient',
		parent         => "",
		parentIndex    => 0,
		selectable     => 1,
	}
}

sub init
{
	my $self = shift;

	my %profile = $self-> SUPER::init(@_);
	$self->$_($profile{$_}) for qw(itemClass popupClass menu);
	return %profile;
}

sub root { $_[0] }
sub menu { $#_ ? $_[0]->set_menu($_[1]) : $_[0]->{menu} }

sub cancel
{
	my $self = shift;
	my $s = $self->{submenu};

Prima/Menus.pm  view on Meta::CPAN

		my $ss = $s->{submenu};
		$s->destroy;
		$s = $ss;
	}
	$self->{submenu} = undef;
	$self->{selectedItem} = -1;
	$self-> notify(q(MenuLeave));
	$self-> hide;
}

sub popup
{
	my ( $self, $x, $y ) = @_;
	unless ( defined($x) && defined($y)) {
		my @p = $self->owner->pointerPos;
		$x //= $p[0];
		$y //= $p[1];
	}
	my @sz = $self->size;
	my @dp = $::application->size;

Prima/Menus.pm  view on Meta::CPAN

}

sub profile_default
{
	my %def = %{$_[ 0]-> SUPER::profile_default};
	return {
		%def,
		font           => Prima::Window->get_default_menu_font,
		autoHeight     => 1,
		itemClass      => 'Prima::Menu::Item',
		popupClass     => 'Prima::Menu::Transient',
		parent         => "", # root menu item name
		selectable     => 1,
		widgetClass    => wc::Menu,
	}
}

sub profile_check_in
{
	my ( $self, $p, $default) = @_;
	$p-> {autoHeight} = 0 if !exists $p->{autoHeight} && (

Prima/Menus.pm  view on Meta::CPAN

}

sub init
{
	my $self = shift;

	$self->{autoHeight} = 1;
	$self->{vertical} = 0;
	my %profile = $self-> SUPER::init(@_);
	$self-> {lock_reset} = 1;
	$self->$_($profile{$_}) for qw(autoHeight menu itemClass popupClass);
	delete $self-> {lock_reset};
	$self->reset;

	return %profile;
}

sub root { $_[0] }
sub menu { $#_ ? $_[0]->set_menu($_[1]) : $_[0]->{menu} }

sub autoHeight

Prima/Menus.pm  view on Meta::CPAN

menus.

=head1 SYNOPSIS

	use Prima qw(Application Menus);
	my $w = Prima::MainWindow->new(
		accelItems => [['~File' => [
			['Exit' => sub { exit } ],
		]]],
		onMouseDown => sub {
			Prima::Menu::Popup->new(menu => $_[0]-> accelTable)->popup;
		},
		height => 100,
	);
	$w->insert( 'Prima::Menu::Bar',
		pack  => { fill => 'x', expand => 1},
		menu  => $w-> accelTable,
	);
	run Prima;

=for podview <img src="Prima/menu.gif">

Prima/VB/Classes.pm  view on Meta::CPAN

		class      => 'Prima::Widget',
		module     => 'Prima::Classes',
		profile    => {},
		selectable => 1,
		sizeable   => 1,
		marked     => 0,
		mainEvent  => undef,
		sizeMin    => [11,11],
		selectingButtons => 0,
		accelItems => [
			['altpopup',0,0, km::Shift|km::Ctrl|kb::F9, sub{
				$_[0]-> altpopup;
				$_[0]-> clear_event;
			}],
		],
		o_delta    => [0,0],
	);
	@$def{keys %prf} = values %prf;
	return $def;
}


Prima/VB/Classes.pm  view on Meta::CPAN

			$self-> {dirData} = [$xa, $ya];
			$self-> {prevRect} = [$self->rect];
			$self-> update_view;
			$VB::form-> {saveHdr} = $VB::form-> text;
			$self-> xorrect( @{$self-> {prevRect}});
			return;
		}
	}

	if ( $btn == mb::Right && $mod & km::Ctrl) {
		$self-> altpopup;
		$self-> clear_event;
		return;
	}
}

sub altpopup
{
	my $self  = $_[0];
	while ( 1) {
		my $p = $self-> bring( 'AltPopup');
		if ( $p) {
			$p-> popup( $self-> pointerPos);
			last;
		}
		last if $self == $VB::form;
		my $o = $self-> prf('owner');
		$self = ( $o eq $VB::form-> name) ? $VB::form : $VB::form-> bring( $o);
		last unless $self;
	}
}

sub on_mouseclick

Prima/VB/Classes.pm  view on Meta::CPAN

			my @o = $self-> origin;
			$self-> rect( @r);
			$self-> pointer( cr::Default);
			$self-> capture(0);
			$self-> {sizeAction} = 0;
			$VB::form-> text( $VB::form-> {saveHdr});
		}
	}
}

sub on_popup
{
	my $self = shift;
	my ($by_mouse, $x, $y) = @_;
	my $alt = $self-> bring('AltPopup');
	if ($alt) {
		my $aitems = $alt-> get_items('');
		my $pitems = $VB::form-> popup-> get_items('');
		my $p = Prima::Popup-> create(
				name => 'AltFormPopup',
				items => [
					@$pitems,
					[],
					[ '-' . $self-> name => '** ' . $self-> name . ' **' => qw(nope)],
					@$aitems,
				]
		);
		$p-> popup($self-> client_to_screen($x, $y));
		$self-> clear_event;
		return;
	}
}

sub on_keydown
{
	my ( $self, $code, $key, $mod) = @_;
	if ( $key == kb::Delete) {
		$self-> clear_event;

Prima/VB/Classes.pm  view on Meta::CPAN

	$self-> size(@{$def-> {size}});

	delete $def-> {$_} for qw (
		accelTable
		clipOwner
		current
		currentWidget
		delegations
		effects
		focused
		popup
		selected
		selectedWidget
		capture
		hintVisible
		widgets
		buffered

		left
		right
		top

Prima/VB/Classes.pm  view on Meta::CPAN

		mainEvent => 'onMouseClick',
	);
	@$def{keys %prf} = values %prf;
	return $def;
}

sub prf_types
{
	my $pt = $_[ 0]-> SUPER::prf_types;
	my %de = (
		menu          => [qw(accelTable popup)],
		menuItems     => [qw(accelItems popupItems)],
		color         => [qw(dark3DColor light3DColor disabledBackColor
			disabledColor hiliteBackColor hiliteColor popupColor
			popupBackColor popupHiliteColor popupHiliteBackColor
			popupDisabledColor popupDisabledBackColor
			popupLight3DColor popupDark3DColor
		)],
		font          => ['popupFont'],
		bool          => [qw(autoEnableChildren briefKeys buffered capture clipOwner
			centered current cursorVisible enabled firstClick focused
			hintVisible ownerColor ownerBackColor ownerFont ownerHint
			ownerShowHint ownerPalette scaleChildren
			selectable selected showHint syncPaint tabStop transparent
			visible x_centered y_centered originDontCare sizeDontCare
			packPropagate layered clipChildren
		)],
		iv            => [qw(bottom height left right top width)],
		tabOrder      => ['tabOrder'],

Prima/VB/Classes.pm  view on Meta::CPAN

		cursorPos
		cursorSize
		cursorVisible
		pointer
		pointerType
		pointerHotSpot
		pointerIcon
		scaleChildren
		selectable
		selectingButtons
		popupColor
		popupBackColor
		popupHiliteBackColor
		popupDisabledBackColor
		popupHiliteColor
		popupDisabledColor
		popupDark3DColor
		popupLight3DColor
		popupFont
		widgetClass
	);
}

package Prima::VB::Window;
use strict;
use vars qw(@ISA);
@ISA = qw(Prima::VB::Control);

sub prf_adjust_default

Prima/VB/Classes.pm  view on Meta::CPAN

				top    => $self-> {container}-> height,
				bottom => $bottom + 6,
			);
		}
	);

	$self-> {B} = $self-> {container}-> insert( 'Prima::VB::MenuOutline' =>
		origin => [ 0, $divx + 6],
		size   => [ 100, $h - $divx - 6],
		growMode => gm::Ceiling,
		popupItems => [
			['~New' => q(newnode),],
			['~Make node' => q(makenode),],
			['Convert to ~separator' => q(makeseparator),],
			['~Delete' => q(del),],
		],
		onSelectItem => sub {
			my ( $x, $l) = $_[0]-> get_item( $_[0]-> focusedItem);
			$self-> enter_menuitem( $x);
		},
	);

Prima/VB/Classes.pm  view on Meta::CPAN

	my $xb = $::application-> get_system_value( sv::XScrollbar);
	$self-> {B}-> insert( Button =>
		origin => [
			$self-> {B}-> indents()-> [0],
			$self-> {B}-> height - $xb - $self-> {B}-> indents()-> [3]
		],
		size   => [ ( $xb ) x 2],
		font   => { height => $xb - 4 * 0.8, style => fs::Bold },
		text   => 'X',
		growMode => gm::GrowLoY,
		onClick => sub { $self-> {B}-> popup-> popup($_[0]-> origin)},
	);

	$self-> {Div2} = $self-> {container}-> insert( 'Prima::VB::Divider' =>
		vertical => 1,
		origin => [ 100, 0],
		size   => [ 6, $h - 1],
		min    => 50,
		max    => 50,
		name   => 'Div',
		onChange => sub {

Prima/VB/Classes.pm  view on Meta::CPAN

{
	my $self = $_[0];
	my $h = $self-> {container}-> height;
	my $w = $self-> {container}-> width;
	my $fh = $self-> {container}-> font-> height;

	$self-> {A} = $self-> {container}-> insert( $self->outliner,
		origin => [ 0, $fh + 4],
		size   => [ $w - 1, $h - $fh - 4],
		growMode => gm::Client,
		popupItems => [
			['~New' => q(newnode),],
			['~Make node' => q(makenode),],
			['~Delete' => q(del),],
		],
		onSelectItem => sub {
			my ( $x, $l) = $_[0]-> get_item( $_[0]-> focusedItem);
			$self-> enter_menuitem( $x);
		},
	);
	$self-> {A}-> {master} = $self;
	my $xb = $self-> {A}-> {vScroll} ? $self-> {A}-> {vScrollBar}-> width : 0;
	$self-> {A}-> insert( Button =>
		origin => [
			$self-> {A}-> width - $xb - $self-> {A}-> indents()-> [2],
			$self-> {A}-> height - $xb - $self-> {A}-> indents()-> [3]
		],
		size   => [ ( $xb ) x 2],
		font   => { height => $xb - 4 * 0.8, style => fs::Bold },
		text   => 'X',
		growMode => gm::GrowLoX|gm::GrowLoY,
		onClick => sub { $self-> {A}-> popup-> popup($_[0]-> origin)},
	);
	$self-> {B} = $self-> {container}-> insert( InputLine =>
		origin => [ 0, 1],
		width  => $w,
		growMode => gm::Floor,
		text => '',
		onChange => sub {
			my ( $x, $l) = $self-> {A}-> get_item( $self-> {A}-> focusedItem);
			$self->on_b_change($x, $l, $self->{B}->text);
		},

Prima/VB/Classes.pm  view on Meta::CPAN

Maps X, Y point into part of widget. If result is not
equal to C<'client'> string, the event in X, Y point
must be ignored.

=item iterate_children SUB, @ARGS

Traverses all children widget in the hierarchy,
calling SUB routine with widget, self, and @ARGS
parameters on each.

=item altpopup

Invokes an alternative, class-specific popup menu, if present.
The popup object must be named C<'AltPopup'>.

=back

=head2 Events

=over

=item Load

Called when the widget is loaded from a file or the clipboard.

Prima/VB/VB.pl  view on Meta::CPAN

	my %prf = (
		sizeDontCare   => 0,
		originDontCare => 0,
		width          => 300,
		height         => 200,
		centered       => 1,
		class          => 'Prima::Window',
		module         => 'Prima::Classes',
		selectable     => 1,
		mainEvent      => 'onMouseClick',
		popupItems     => $VB::main-> menu-> get_items( 'edit'),
		ownerIcon      => 0,
	);
	@$def{keys %prf} = values %prf;
	return $def;
}

sub init
{
	my $self = shift;
	my %profile = $self-> SUPER::init(@_);

class/Application.c  view on Meta::CPAN

	opt_set(optSystemDrawable);
	CDrawable-> init( self, profile);
	list_create( &var->  widgets, 16, 16);
	list_create( &var->  modalHorizons, 0, 8);
	prima_guts.application = self;
	if ( !apc_application_create( self))
		croak( "Error creating application");
/* Widget init */
	SvHV_Font( pget_sv( font), &Font_buffer, "Application::init");
	my-> set_font( self, Font_buffer);
	SvHV_Font( pget_sv( popupFont), &Font_buffer, "Application::init");
	my-> set_popup_font( self, Font_buffer);
	{
		AV * av = ( AV *) SvRV( pget_sv( designScale));
		SV ** holder = av_fetch( av, 0, 0);
		if ( holder)
			var->  designScale. x = SvNV( *holder);
		else
			warn("Array panic on 'designScale'");
		holder = av_fetch( av, 1, 0);
		if ( holder)
			var->  designScale. y = SvNV( *holder);

class/Application.c  view on Meta::CPAN

		pset_i( showHint, 0);
		pset_c( name, "HintWidget");
		pset_sv( font, hintFont);
		var->  hintWidget = create_instance( hintClass);
		protect_object( var->  hintWidget);
		sv_free(( SV *) profile);
	}

	if ( SvOK( sv = pget_sv( accelItems)))
		my-> set_accelItems( self, sv);
	if ( SvOK( sv = pget_sv( popupItems)))
		my-> set_popupItems( self, sv);
	pdelete( accelTable);
	pdelete( accelItems);
	pdelete( popupItems);

	my-> set( self, profile);
	CORE_INIT_TRANSIENT(Application);
}

void
Application_done( Handle self)
{
	if ( self != prima_guts.application) return;
	unprotect_object( var-> hintTimer);

class/Application.c  view on Meta::CPAN

		if ( horizon == self)
			topShared = var->  topSharedModal;
		else
			topShared = PWindow( horizon)-> topSharedModal;
	}

	return ( !topShared || ( topShared == topFrame)) ? from : topShared;
}

static Handle
popup_win( Handle xTop)
{
	PWindow_vmt top = CWindow( xTop);
	if ( !top-> get_visible( xTop))
		top-> set_visible( xTop, 1);
	if ( top-> get_windowState( xTop) == wsMinimized)
		top-> set_windowState( xTop, wsNormal);
	top-> set_selected( xTop, 1);
	return xTop;
}

Handle
Application_popup_modal( Handle self)
{
	Handle ha = apc_window_get_active();
	Handle xTop;

	if ( var->  topExclModal) {
	/* checking exclusive modal chain */
		xTop = ( !ha || ( PWindow(ha)->modal == 0)) ? var->  exclModal : ha;
		while ( xTop) {
			if ( PWindow(xTop)-> nextExclModal) {
				CWindow(xTop)-> bring_to_front( xTop);
				xTop = PWindow(xTop)-> nextExclModal;
			} else {
				return popup_win( xTop);
			}
		}
	} else {
		if ( !var->  topSharedModal && var->  modalHorizons. count == 0)
			return NULL_HANDLE; /* return from if no shared modals active */
		/* checking shared modal chains */
		if ( ha) {
			xTop = ( PWindow(ha)->modal == 0) ? CWindow(ha)->get_horizon(ha) : ha;
			if ( xTop == prima_guts.application) xTop = var->  sharedModal;
		} else
			xTop = var->  sharedModal ? var->  sharedModal : var->  modalHorizons. items[ 0];

		while ( xTop) {
			if ( PWindow(xTop)-> nextSharedModal) {
				CWindow(xTop)-> bring_to_front( xTop);
				xTop = PWindow(xTop)-> nextSharedModal;
			} else {
				return popup_win( xTop);
			}
		}
	}

	return NULL_HANDLE;
}

Bool
Application_pointerVisible( Handle self, Bool set, Bool pointerVisible)
{

class/Application.cls  view on Meta::CPAN

	Handle  hintUnder;
	Handle  topExclModal;
	Handle  exclModal;
	Handle  topSharedModal;
	Handle  sharedModal;
	List    modalHorizons;
	Bool    wantUnicodeInput;

	c_only  Handle map_focus( Handle from);
	c_only  Handle top_frame( Handle from);
	c_only  Handle popup_modal();
}

class/Popup.c  view on Meta::CPAN

	opt_assign( optAutoPopup, pget_B( autoPopup));
	CORE_INIT_TRANSIENT(Popup);
}

void
Popup_update_sys_handle( Handle self, HV * profile)
{
	dPROFILE;
	Handle xOwner = pexist( owner) ? pget_H( owner) : var-> owner;
	if ( var-> owner && ( xOwner != var-> owner))
		((( PWidget) var-> owner)-> self)-> set_popup( var-> owner, NULL_HANDLE);
	if ( !pexist( owner)) return;
	if ( !apc_popup_create( self, xOwner))
		croak("Cannot create popup");
	var-> system = true;
}


Bool
Popup_autoPopup( Handle self, Bool set, Bool autoPopup)
{
	if ( set)
		opt_assign( optAutoPopup, autoPopup);
	return is_opt( optAutoPopup);
}

Bool
Popup_selected( Handle self, Bool set, Bool selected)
{
	if ( !set)
		return CWidget( var-> owner)-> get_popup( var->  owner) == self;
	if ( var-> stage > csFrozen)
		return false;
	if ( selected)
		CWidget( var-> owner)-> set_popup( var-> owner, self);
	else if ( my-> get_selected( self))
		CWidget( var-> owner)-> set_popup( var-> owner, NULL_HANDLE);
	return false;
}

void
Popup_popup( Handle self, int x, int y, int ancLeft, int ancBottom, int ancRight, int ancTop)
{
	int i;
	PWidget owner = ( PWidget) var-> owner;
	ColorSet color;
	Rect anchor;
	int stage = owner-> stage;
	if ( var-> stage > csNormal) return;
	anchor. left = ancLeft;
	anchor. bottom = ancBottom;
	anchor. right = ancRight;
	anchor. top = ancTop;
	owner-> stage = csFrozen;
	memcpy( color, owner-> popupColor, sizeof( ColorSet));
	for ( i = 0; i < ciMaxId + 1; i++)
		apc_menu_set_color( self, color[ i], i);
	memcpy( owner-> popupColor, color, sizeof( ColorSet));
	apc_menu_set_font( self, &owner-> popupFont);
	owner-> stage = stage;
	apc_popup( self, x, y, &anchor);
}

#ifdef __cplusplus
}
#endif

class/Popup.cls  view on Meta::CPAN

object Prima::Popup( Prima::AbstractMenu)
{
	property Bool autoPopup;
	property Bool selected;
	method void   init( HV * profile);
	method void   popup( int x, int y, int ancLeft = 0, int ancBottom = 0, int ancRight = 0, int ancTop = 0);
	import SV *   profile_default();
	c_only void   update_sys_handle( HV * profile);
}

class/Widget.c  view on Meta::CPAN

	my-> set_selectingButtons   ( self, pget_i( selectingButtons));
	my-> set_selectable         ( self, pget_B( selectable));
	my-> set_showHint           ( self, pget_B( showHint));
	my-> set_tabOrder           ( self, pget_i( tabOrder));
	my-> set_tabStop            ( self, pget_B( tabStop));
	my-> set_text               ( self, pget_sv( text));

	opt_assign( optScaleChildren, pget_B( scaleChildren));

	/* subcomponents props */
	my-> popupColorIndex( self, true, ciFore,         pget_i( popupColor)              );
	my-> popupColorIndex( self, true, ciBack,         pget_i( popupBackColor)          );
	my-> popupColorIndex( self, true, ciHiliteText,   pget_i( popupHiliteColor)        );
	my-> popupColorIndex( self, true, ciHilite,       pget_i( popupHiliteBackColor)    );
	my-> popupColorIndex( self, true, ciDisabledText, pget_i( popupDisabledColor)      );
	my-> popupColorIndex( self, true, ciDisabled,     pget_i( popupDisabledBackColor)  );
	my-> popupColorIndex( self, true, ciLight3DColor, pget_i( popupLight3DColor)       );
	my-> popupColorIndex( self, true, ciDark3DColor,  pget_i( popupDark3DColor)        );
	SvHV_Font( pget_sv( popupFont), &Font_buffer, "Widget::init");
	my-> set_popup_font  ( self, Font_buffer);
	if ( SvOK( sv = pget_sv( popupItems)))
		my-> set_popupItems( self, sv);
	if ( SvOK( sv = pget_sv( accelItems)))
		my-> set_accelItems( self, sv);

	/* size, position, enabling, visibility etc. runtime */
	{
		Point set, set2;
		AV * av;
		SV ** holder;
		NPoint ds = {1,1};

class/Widget.c  view on Meta::CPAN

		for ( i = 0; i < var-> widgets. count; i++)
			Object_destroy( var-> widgets. items[i]);
	}

	if ( var-> accelTable) {
		unprotect_object(var-> accelTable);
		//my-> detach( self, var-> accelTable, true);
		var-> accelTable = NULL_HANDLE;
	}

	if ( var-> popupMenu ) {
		unprotect_object(var-> popupMenu);
		//my-> detach( self, var-> popupMenu, true);
		var-> popupMenu = NULL_HANDLE;
	}

	inherited-> cleanup( self);
}


Bool
Widget_close( Handle self)
{
	Bool canClose;

class/Widget.c  view on Meta::CPAN

				my-> set_rect( self, r);
			}
			pdelete( left);
			pdelete( right);
			pdelete( top);
			pdelete( bottom);
			pdelete( width);
			pdelete( height);
		} /* count > 1 */
	}
	if ( pexist( popupFont))
	{
		SvHV_Font( pget_sv( popupFont), &Font_buffer, "Widget::set");
		my-> set_popup_font( self, Font_buffer);
		pdelete( popupFont);
	}
	if ( pexist( pointerIcon) && pexist( pointerHotSpot))
	{
		Point hotSpot;
		Handle icon = pget_H( pointerIcon);
		prima_read_point( pget_sv( pointerHotSpot), (int*)&hotSpot, 2, "Array panic on 'pointerHotSpot'");
		if ( icon != NULL_HANDLE && !kind_of( icon, CIcon)) {
			warn("Illegal object reference passed to Widget.set_pointer_icon");
			icon = NULL_HANDLE;
		}

class/Widget.c  view on Meta::CPAN


Font
Widget_get_default_font( char * dummy)
{
	Font font;
	apc_widget_default_font( &font);
	return font;
}

Font
Widget_get_default_popup_font( char * dummy)
{
	Font f;
	apc_popup_default_font( &f);
	return f;
}


NPoint
Widget_designScale( Handle self, Bool set, NPoint designScale)
{
	if ( !set)
		return var-> designScale;
	if ( designScale. x < 0) designScale. x = 0;

class/Widget.c  view on Meta::CPAN

	return my-> get_clipOwner( self) ? var-> owner : prima_guts.application;
}

Point
Widget_get_pointer_size( char*dummy)
{
	return apc_pointer_get_size( NULL_HANDLE);
}

Font
Widget_get_popup_font( Handle self)
{
	return var-> popupFont;
}

Handle
Widget_get_selectee( Handle self)
{
	if ( var-> stage > csFrozen) return NULL_HANDLE;
	if ( is_opt( optSelectable))
		return self;
	else if ( var-> currentWidget) {
		PWidget w = ( PWidget) var-> currentWidget;

class/Widget.c  view on Meta::CPAN

	}
	else {
		apc_font_pick( self, &font, & var-> font);
		opt_clear( optOwnerFont);
		apc_widget_set_font( self, & var-> font);
		my-> repaint( self);
	}
}

void
Widget_set_popup_font( Handle self, Font font)
{
	apc_font_pick( self, &font, &var-> popupFont);
}


/* static iterators */
static Handle
find_tabfoc( Handle self)
{
	int i;
	Handle toRet;
	for ( i = 0; i < var-> widgets. count; i++) {

class/Widget.c  view on Meta::CPAN

		p = apc_pointer_get_pos( self);
		apc_widget_map_points( self, false, 1, &p);
		return p;
	}
	apc_widget_map_points( self, true, 1, &p);
	apc_pointer_set_pos( self, p. x, p. y);
	return p;
}

Handle
Widget_popup( Handle self, Bool set, Handle popup)
{
	if ( var-> stage > csFrozen) return NULL_HANDLE;
	if ( !set)
		return var-> popupMenu;

	if ( popup && !kind_of( popup, CPopup)) return NULL_HANDLE;
	if ( var->popupMenu ) unprotect_object(var-> popupMenu);
	var-> popupMenu = popup;
	if ( var->popupMenu ) protect_object(var-> popupMenu);
	return NULL_HANDLE;
}

Color
Widget_popupColorIndex( Handle self, Bool set, int index, Color color)
{
	if (( index < 0) || ( index > ciMaxId)) return clInvalid;
	if ( !set)
		return var-> popupColor[ index];
	if ((( color & clSysFlag) != 0) && (( color & wcMask) == 0)) color |= wcPopup;
	var-> popupColor[ index] = color;
	return color;
}

SV *
Widget_popupItems( Handle self, Bool set, SV * popupItems)
{
	dPROFILE;
	enter_method;
	if ( var-> stage > csFrozen) return NULL_SV;
	if ( !set)
		return var-> popupMenu ?
			CAbstractMenu( var-> popupMenu)-> get_items( var-> popupMenu, "", true) : NULL_SV;

	if ( var-> popupMenu == NULL_HANDLE) {
		if ( SvTYPE( popupItems)) {
			HV * profile = newHV();
			pset_sv( items, popupItems);
			pset_H ( owner, self);
			my-> set_popup( self, create_instance( "Prima::Popup"));
			sv_free(( SV *) profile);
		}
	}
	else
		CAbstractMenu(var-> popupMenu)-> set_items(var-> popupMenu, popupItems);
	return popupItems;
}


Rect
Widget_rect( Handle self, Bool set, Rect r)
{
	enter_method;
	if ( !set) {
		Point p   = my-> get_origin( self);
		Point s   = my-> get_size( self);

class/Widget.cls  view on Meta::CPAN

{
#	user variables
	Handle    accelTable;	            # accelerator table
	Handle    currentWidget;	    # current widget pointer
	int       cursorLock;               # cursor lock count
	NPoint    designScale;              # font width and height for view design
	char   *  dndAware;                 # NULL for no, "1" for all formats, other for selected
	char   *  helpContext;              # help context string
	SV     *  hint;                     # hint tag text
	int       lockCount;                # lock count
	Font      popupFont;                # font for popup menu
	ColorSet  popupColor;               # colors for popup menu
	Handle    popupMenu;                # popup menu by default
	int       pointerType;              # pointer type, crXXX
	Point     pos;                      # last position
	int       selectingButtons;         # which mouse buttons can select a view
	Point     sizeMin;                  # default min size
	Point     sizeMax;                  # default max size
	int       tabOrder;                 # tab ordering number
	SV     *  text;                     # caption text
	int       widgetClass;              # predefined system class
	List      widgets;		       # list of child widgets
	Handle *  enum_lists;               # list of currently running enumerators

class/Widget.cls  view on Meta::CPAN

	property  int    geomHeight;
	property  Point  geomSize;
	property  int    geomWidth;
	property  int    growMode;
	property  Bool   firstClick;
	property  Bool   focused;
	property  SV *   helpContext;
	property  int    hintVisible;
	property  int    left;
	property  Bool   layered;
	property  Handle popup;
	property  SV *   popupItems;
	property  Bool   ownerBackColor;
	property  Bool   ownerColor;
	property  Bool   ownerFont;
	property  Bool   ownerHint;
	property  Bool   ownerShowHint;
	property  Bool   ownerPalette;
	property  Point  origin;
	property  SV  *  packInfo;
	property  SV  *  palette;
	property  SV  *  placeInfo;
	property  Point  pointerHotSpot;
	property  Handle pointerIcon;
	property  Point  pointerPos;
	property  int    pointerType;
	property  Color  popupColorIndex( int index);
	property  Bool   packPropagate;
	property  Rect   rect;
	property  int    right;
	property  Bool   scaleChildren;
	property  Bool   selectable;
	property  Bool   selected;
	property  Handle selectedWidget;
	property  int    selectingButtons;
	property  Handle shape;
	property  Bool   showHint;

class/Widget.cls  view on Meta::CPAN

	method   Bool     showing()                       => apc_widget_is_showing;
	method   Bool     unlock();
	method   void     update_view();
	c_only   void     update_sys_handle( HV * profile);
	c_only   Bool     validate_owner( Handle * newOwner, HV * profile);
	method   Bool     validate_rect( Rect rect)       => apc_widget_validate_rect;

#	properties read methods
	method   Bool     get_capture()                   => apc_widget_is_captured;
	static   Font     get_default_font( char * dummy = "");
	static   Font     get_default_popup_font( char * dummy = "");
	method   Rect     get_invalid_rect()              => apc_widget_get_invalid_rect;
	method   SV   *   get_handle();
	method   SV   *   get_hint();
	method   Bool     get_locked();
	method   int      get_mouse_state()               => apc_pointer_get_state;
	public   void     get_pack_slaves();
	method   Handle   get_parent();
	method   SV   *   get_parent_handle();
	public   void     get_place_slaves();
	static   Point    get_pointer_size( char * dummy = "");
	method   Font     get_popup_font();
	c_only   Handle   get_selectee();
	method   int      get_shift_state()               => apc_kbd_get_state;
	method   Point    get_virtual_size();
	public   void     get_widgets();
	method   SV   *   get_text();

#	properties write methods
	method   Bool     set_capture( Bool capture, Handle confineTo = NULL_HANDLE);
	method   void     set_centered( Bool x, Bool y);
	method   void     set_font( Font font);
	method   void     set_hint( SV * hint);
	method   void     set_popup_font( Font font);
	method   void     set_text( SV * text);

#	other
	method   void     on_paint( SV * canvas);
}

class/Widget/events.c  view on Meta::CPAN

		(oldP. x != event-> gen. P. x ||
			oldP. y != event-> gen. P. y)) {
		my-> notify( self, "<sPP", "Move", oldP, event-> gen. P);
		objCheck;
		if ( var->geometry == gtGrowMode && var-> growMode & gmCenter)
			my-> set_centered( self, var-> growMode & gmXCenter, var-> growMode & gmYCenter);
	}
}

static void
handle_popup( Handle self, PEvent event)
{
	enter_method;
	Handle org = self;
	my-> notify( self, "<siP", "Popup", event-> gen. B, event-> gen. P. x, event-> gen. P. y);
	objCheck;
	if ( evOK) {
		while ( self) {
			PPopup p = ( PPopup) CWidget( self)-> get_popup( self);
			if ( p && p-> self-> get_autoPopup(( Handle) p)) {
				Point px = event-> gen. P;
				apc_widget_map_points( org,  true,  1, &px);
				apc_widget_map_points( self, false, 1, &px);
				p-> self-> popup(( Handle) p, px. x, px. y ,0,0,0,0);
				CWidget( org)-> clear_event( org);
				return;
			}
			self = var-> owner;
		}
	}
}

static void
handle_size( Handle self, PEvent event)

class/Widget/events.c  view on Meta::CPAN

		case cmZOrderChanged:
			my-> notify( self, "<s", "ZOrderChanged");
			break;
		case cmClick:
			my-> notify( self, "<s", "Click");
			break;
		case cmColorChanged:
			if ( !kind_of( event-> gen. source, CPopup))
				my-> notify( self, "<si", "ColorChanged", event-> gen. i);
			else
				var-> popupColor[ event-> gen. i] =
					apc_menu_get_color( event-> gen. source, event-> gen. i);
			break;
		case cmFontChanged:
			if ( !kind_of( event-> gen. source, CPopup))
				my-> notify( self, "<s", "FontChanged");
			else
				apc_menu_get_font( event-> gen. source, &var-> popupFont);
			break;
		case cmMenu:
			if ( event-> gen. H) {
				char buffer[16], *context;
				context = ((( PAbstractMenu) event-> gen. H)-> self)-> make_id_context( event-> gen. H, event-> gen. i, buffer);
				my-> notify( self, "<sHs", "Menu", event-> gen. H, context);
			}
			break;
		case cmMouseClick:
			my-> notify( self, "<siiPi", "MouseClick",

class/Widget/events.c  view on Meta::CPAN

			break;
		case cmMenuCmd:
			if ( event-> gen. source)
				((( PAbstractMenu) event-> gen. source)-> self)-> 
					sub_call_id( event-> gen. source, event-> gen. i);
			break;
		case cmMove:
			handle_move(self, event);
			break;
		case cmPopup:
			handle_popup(self, event);
			break;
		case cmSize:
			handle_size( self, event);
			break;
		case cmDragBegin       :
			handle_drag_begin( self, event );
			break;
		case cmDragOver       :
			handle_drag_over( self, event );
			break;

class/Widget/events.c  view on Meta::CPAN

void Widget_on_keyup( Handle self, int code , int key , int shiftState ) {}
void Widget_on_menu( Handle self, Handle menu, char * variable) {}
void Widget_on_setup( Handle self) {}
void Widget_on_size( Handle self, Point oldSize, Point newSize) {}
void Widget_on_move( Handle self, Point oldPos, Point newPos) {}
void Widget_on_show( Handle self) {}
void Widget_on_hide( Handle self) {}
void Widget_on_hint( Handle self, Bool show) {}
void Widget_on_translateaccel( Handle self, int code , int key , int shiftState ) {}
void Widget_on_zorderchanged( Handle self) {}
void Widget_on_popup( Handle self, Bool mouseDriven, int x, int y) {}
void Widget_on_mouseclick( Handle self, int button , int shiftState , int x , int y , Bool dbl ) {}
void Widget_on_mousedown( Handle self, int button , int shiftState , int x , int y ) {}
void Widget_on_mouseup( Handle self, int button , int shiftState , int x , int y ) {}
void Widget_on_mousemove( Handle self, int shiftState , int x , int y ) {}
void Widget_on_mousewheel( Handle self, int shiftState , int x , int y, int z ) {}
void Widget_on_mouseenter( Handle self, int shiftState , int x , int y ) {}
void Widget_on_mouseleave( Handle self ) {}
void Widget_on_leave( Handle self) {}
*/

examples/buttons.pl  view on Meta::CPAN

	my %d = %{$self-> profile_default};
	my %readfilter = (
		x_centered  => 1,
		y_centered  => 1,
		centered    => 1,
		delegations => 1,
		designScale => 1,
	);
	my %hashed = (
		font      => 1,
		popupFont => 1,
		menuFont  => 1,
	);
	for ( keys %readfilter) { delete $d{$_}};
	for ( keys %d) {
		my @res = $self-> $_();
		$d{$_} = @res ? ($#res ? (
			$hashed{$_} ? {@res} : [@res]
		) : $res[0]) : undef;
	}
	return ref($self)-> create( %d, %profile);

examples/buttons2.pl  view on Meta::CPAN


use strict;
use warnings;

use Prima qw(Buttons StdBitmap Application);

my $w = Prima::MainWindow-> create(
	text=> "Handmade buttons",
	size => [ 300, 200],
	centered => 1,
	popupItems => [['Hallo!' => '']],
	designScale => [6,16],
);

$w-> insert( CheckBox =>
	origin => [ 10, 150],
	selectable => 1,
	text => "~Check box",
	hint => 'Check box!',
	popupItems => [['Hallo2!' => '']],
);

$w-> insert( Radio =>
	origin => [ 190, 150],
	selectable => 1,
	text => "~Radio button",
	hint => 'Radio!',
);

my $i = Prima::StdBitmap::icon( sbmp::GlyphCancel);

examples/canvas.pl  view on Meta::CPAN

	growMode => gm::Client,
	paneSize => [ 500, 500],
	hScroll => 1,
	vScroll => 1,
	name    => 'Canvas',
	buffered => 1,
	alignment => ta::Center,
	valignment => ta::Middle,
);

my $widget_popup =
[
	[ '~Move' => sub {
		my ( $self, $obj, $owner);
		return unless $obj = Prima::Canvas::Widget-> instance( $self = $_[0]);
		return unless $owner = $obj-> owner;
		my @pp = $owner-> object2screen(
			$obj-> left + $obj-> width / 2,
			$obj-> bottom + $obj-> height / 2);
		$owner-> pointerPos( @pp);
		$owner-> mouse_down( mb::Left, 0, @pp, 1);

examples/canvas.pl  view on Meta::CPAN

	if ( $obj eq 'Button') {
		$profile{widget} = Prima::Button-> create( owner => $c);
		$obj = 'Widget';
	}
	if ( $obj eq 'InputLine') {
		$profile{widget} = Prima::InputLine-> create( owner => $c);
		$profile{scalable} = 0;
		$obj = 'Widget';
	}
	if ( $obj eq 'Widget') {
		$profile{widget}-> popupItems( $widget_popup);
	}
	$profile{text} = "use Prima qw(Application);\nMainWindow-> create();\nrun Prima;"
		if $obj eq 'Text';
	$c-> focused_object( $c-> insert_object( "Prima::Canvas::$obj", %profile));
}

sub insert_from_menu
{
	my ( $self, $obj ) = @_;
	insert($self, $obj);

examples/dock.pl  view on Meta::CPAN


This is the demonstration of Prima::Dock and Prima::DockManager
modules. The window created is docking client, and it's able
to accept toolbars and panels, and toolbars in turn accept buttons.
buttons are very samplish; there are two panels, Edit and Banner,
that are docked in different ways.
Note the following unevident features:

=over 4

=item popup on the border of the window ( and the Customize command there)

=item dragging of buttons on the window and the extreior

=item dragging panels and toolbar to the exterior

=item storing of the geometry in the ~/.demo_dock file

=back

=cut

examples/dock.pl  view on Meta::CPAN

	return $def;
}

sub init
{
	my  $self = shift;
	my %profile = $self-> SUPER::init( @_);
	$self-> $_($profile{$_}) for qw(instance);
	$self-> {toolBarPopup} = $self-> insert( Popup =>
		autoPopup  => 0,
		items      => $self-> make_popupitems(),
	);
	$self-> {mainDock} = $self-> insert( FourPartDocker =>
		rect        => [ 0, 0, $self-> size],
		fingerprint => dmfp::Tools|dmfp::Toolbar|dmfp::Edit|dmfp::Horizontal|dmfp::Vertical,
		dockup      => $self-> instance,
		dockerCommonProfile => {
			hasPocket => 0,
			onPopup => sub { # all dockers would render this popup
				my ( $me, $btn, $x, $y) = @_;
				( $x, $y) = $self-> screen_to_client( $me-> client_to_screen($x, $y));
				$self-> {toolBarPopup}-> popup( $x, $y);
				$me-> clear_event;
			}
		},
		dockerProfileClient => { # allow docking only to Edit
			fingerprint => dmfp::Edit,
		},
		dockerProfileLeft   => { fingerprint => dmfp::Vertical|dmfp::Tools|dmfp::Toolbar },
		dockerProfileRight  => { fingerprint => dmfp::Vertical|dmfp::Tools|dmfp::Toolbar },
		dockerProfileTop    => { fingerprint => dmfp::Horizontal|dmfp::Tools|dmfp::Toolbar },
		dockerProfileBottom => { fingerprint => dmfp::Horizontal|dmfp::Tools|dmfp::Toolbar },
	);
	$self-> instance-> add_notification( 'ToolbarChange', \&on_toolbarchange, $self);
	$self-> instance-> add_notification( 'PanelChange',   \&on_toolbarchange, $self);
	$self-> instance-> add_notification( 'Command',   \&on_command, $self);
	return %profile;
}

sub make_popupitems
{
	my $items = $_[0]-> instance-> toolbar_menuitems( \&Menu_Check_Toolbars);
	# actually DockManager doesn't care if panel CLSID and toolbar name intermix.
	# this is the demonstration of resolving that clash
	$$_[0] .= ',toolbar' for @$items;
	push ( @$items, []);
	push ( @$items, @{$_[0]-> instance-> panel_menuitems( \&Menu_Check_Panels)});
	push ( @$items, []);
	push ( @$items, ['customize' => "~Customize..." => q(open_dockmanaging)]);
	return $items;

examples/dock.pl  view on Meta::CPAN


sub instance
{
	return $_[0]-> {instance} unless $#_;
	$_[0]-> {instance} = $_[1];
}


sub on_toolbarchange
{
	$_[0]-> {toolBarPopup}-> items( $_[0]-> make_popupitems());
}

sub on_command
{
	my ( $self, $instance, $command) = @_;
	$command =~ s/\://g;
	my $x = $self-> can( $command);
	return unless $x;
	$x-> ( $self);
}

examples/dock.pl  view on Meta::CPAN

	list => ["File::Open", "File::Close"],
	dock => $ww-> {mainDock}-> TopDocker,
	origin => [ 0, 0],
}, {
	name => "Edit",
	list => [ "Edit::OK", "Edit::Cancel", ],
	dock => $ww-> {mainDock}-> TopDocker,
	origin => [ 0, 0],
});

#$ww-> open_dockmanaging; # uncomment this for Customize window popup immediately

run Prima;

1;

examples/menu.pl  view on Meta::CPAN


	return @ret;
}

sub create_custom_menu
{
	my @icons = map { Prima::StdBitmap::image($_) } sbmp::CheckBoxUnchecked, sbmp::CheckBoxChecked;
	return [ '@?' => "~Custom" => sub { print "Custom\n" } => {
		onMeasure => sub {
			my ( $self, $menu, $ref) = @_;
			my ($w, $h) = ( $self->owner->get_text_width( $menu-> text, 1 ), $self->owner->popupFont->height );
			my $i = $icons[ $menu->checked ];
			my $isz = $menu-> check_icon_size;
			my $dx = ( $isz > $i-> width ) ? $isz : $i-> width;
			@$ref = ($w + 20 + $dx, $h + 20);
		},
		onPaint => sub {
			my ( $self, $menu, $canvas, $selected, $x1, $y1, $x2, $y2) = @_;
			my @p = ( cl::Black, cl::White );
			@p = reverse @p if $selected;
			$canvas-> new_gradient(palette => \@p)->bar($x1, $y1, $x2, $y2, 1);
			$canvas-> font( $self-> owner->popupFont );
			$canvas-> color(cl::Yellow);

			my $i = $icons[ $menu->checked ];
			my $isz = $menu-> check_icon_size;
			my $dx = ( $isz > $i-> width ) ? $isz : $i-> width;
			$canvas-> draw_text( $menu->text, $x1 + 2 + $dx, $y1, $x2, $y2, dt::VCenter|dt::DrawMnemonic);
			$canvas-> put_image(
				$x1 + (( $isz > $i-> width ) ? ( $menu-> check_icon_size - $i-> width) / 2 : 0),
				($y2 + $y1 - $i->height) / 2, $i);
		},

examples/outline.pl  view on Meta::CPAN

use warnings;
use Prima qw(Application Outlines);

my $w = Prima::MainWindow-> create(
	size => [ 200, 200],
	designScale => [7, 16],
);
my $o = $w-> insert(
	DirectoryOutline =>
	#StringOutline =>
	popupItems => [
		['Delete this' => sub{
			my ( $x, $l) = $_[0]-> get_item( $_[0]-> focusedItem);
			$_[0]-> delete_item( $x);
		}],
		['Insert updir below' => sub{
			my ( $x, $l) = $_[0]-> get_item( $_[0]-> focusedItem);
			my ( $p, $o) = $_[0]-> get_item_parent( $x);
			$_[0]-> insert_items( $p, $o + 1, [
				[ $^O =~ /win32/ ? 'C:' : '/', ''], [], 0
			]);

examples/ownerchange.pl  view on Meta::CPAN

use Prima qw(Buttons Application);

my $w = Prima::Window-> create(
	name       => "D1",
	text    => "Window Number One",
	origin     =>  [ 100, 300],
	designScale => [7, 16],
	borderStyle=> bs::Sizeable,
	size       =>  [ 350, 100],
	backColor  => cl::Green,
	popupItems => [["Change owner"=> sub { $_[0]-> popup-> owner (( $_[0]-> name eq "D1") ? $::application-> D2 : $::application-> D1); }]],
	menuItems  => [["Change owner"=> sub { $_[0]-> menu-> owner (( $_[0]-> name eq "D1") ? $::application-> D2 : $::application-> D1); }]],
	onTimer    => sub { $_[0]-> backColor(($_[0]-> backColor == cl::Green) ? cl::LightGreen : cl::Green)},
	onMouseDown => sub {
	my ( $self, $btn, @k) = @_;
		$_[0]-> borderStyle( ($btn  == mb::Left) ? bs::Dialog : bs::Sizeable);
	},
);

my $w2 = Prima::Window-> create(
	name      => "D2",

include/apricot.h  view on Meta::CPAN

#define cmWindowState   (0x0000001A|ctDiscardable) /* generates when window state changed */
CM(WindowState)
#define cmTimer          0x0000001C                /* WM_TIMER analog */
CM(Timer)
#define cmClick          0x0000001D                /* common click */
CM(Click)
#define cmCalcBounds    (0x0000001E|ctPassThrough) /* query on change size */
CM(CalcBounds)
#define cmPost           0x0000001F                /* posted message */
CM(Post)
#define cmPopup          0x00000020                /* interactive popup request */
CM(Popup)
#define cmExecute        0x00000021                /* dialog execution start */
CM(Execute)
#define cmSetup          0x00000022                /* first message for alive and active widget */
CM(Setup)
#define cmHint           0x00000023                /* hint show/hide message */
CM(Hint)
#define cmDragBegin      0x00000024                /* Drag'n'drop aware */
CM(DragBegin)
#define cmDragOver       0x00000025                /*         constants */

include/apricot.h  view on Meta::CPAN


extern Bool
apc_dnd_set_aware( Handle self, Bool is_target );

extern int
apc_dnd_start( Handle self, int actions, Bool default_pointers, Handle * counterpart);

extern Handle
apc_dnd_get_clipboard( Handle self );

/* Menus & popups */

typedef struct _MenuItemReg {   /* Menu item registration record */
	char * variable;             /* perl variable name */
	char * text;                 /* menu text */
	char * accel;                /* accelerator text */
	int    key;                  /* accelerator key, kbXXX */
	int    id;                   /* unique id */
	char * perlSub;              /* sub name */
	Handle bitmap;               /* bitmap if not nil */
	SV *   code;                 /* code if not nil */

include/apricot.h  view on Meta::CPAN

extern Bool
apc_menu_item_set_key( Handle self, PMenuItemReg m);

extern Bool
apc_menu_item_set_text( Handle self, PMenuItemReg m);

extern ApiHandle
apc_menu_get_handle( Handle self);

extern Bool
apc_popup_create( Handle self, Handle owner);

extern PFont
apc_popup_default_font( PFont font);

extern Bool
apc_popup( Handle self, int x, int y, Rect * anchor);

/* Timer */
extern Bool
apc_timer_create( Handle self);

extern Bool
apc_timer_destroy( Handle self);

extern int
apc_timer_get_timeout( Handle self);

include/unix/guts.h  view on Meta::CPAN

	Handle self;                                                        \
	struct {                                                            \
		unsigned application           : 1;                         \
		unsigned bitmap                : 1;                         \
		unsigned dbm                   : 1;                         \
		unsigned drawable              : 1;                         \
		unsigned icon                  : 1;                         \
		unsigned image                 : 1;                         \
		unsigned menu                  : 1;                         \
		unsigned pixmap                : 1;                         \
		unsigned popup                 : 1;                         \
		unsigned timer                 : 1;                         \
		unsigned widget                : 1;                         \
		unsigned window                : 1;                         \
		COMPONENT_SYS_DATA_ALIGN                                    \
	} type;                                                             \
	XrmQuarkList q_class_name;                                          \
	XrmQuarkList q_instance_name;                                       \
	int n_class_name;                                                   \
	int n_instance_name

include/unix/guts.h  view on Meta::CPAN



#define XT_IS_APPLICATION(x)    ((x)->type.application)
#define XT_IS_BITMAP(x)         ((x)->type.bitmap)
#define XT_IS_DBM(x)            ((x)->type.dbm)
#define XT_IS_DRAWABLE(x)       ((x)->type.drawable)
#define XT_IS_ICON(x)           ((x)->type.icon)
#define XT_IS_IMAGE(x)          ((x)->type.image)
#define XT_IS_MENU(x)           ((x)->type.menu)
#define XT_IS_PIXMAP(x)         ((x)->type.pixmap)
#define XT_IS_POPUP(x)          ((x)->type.popup)
#define XT_IS_TIMER(x)          ((x)->type.timer)
#define XT_IS_WIDGET(x)         ((x)->type.widget)
#define XT_IS_WINDOW(x)         ((x)->type.window)

typedef struct _drawable_sys_data
{
	COMPONENT_SYS_DATA;
	XDrawable udrawable;
	XDrawable gdrawable;
	XWindow parent;

include/win32/win32guts.h  view on Meta::CPAN

	NONCLIENTMETRICSW ncmData;           // windows system data
	List           transp;               // transparent controls list
	int            top_windows;          // count of top-level windows in app
	Bool           sys_focus_disabled;   // focus system disabled
	Bool           sys_focus_granted;    // SetFocus() was called inside apc_widget_set_focused
	Bool           sys_focus_dialog;     // system dialog is in action
	UINT           error_mode;           // SetErrorMode() result
	DWORD          version;              // GetVersion() cached result
	Point          cmDOUBLECLK;          // cached SM_CxDOUBLECLK values
	int            mouse_timer;          // is mouse timer started
	Bool           popup_active;         // flag to avoid double popup activation
	Bool           pointer_invisible;
	HWND           console;              // win32-bound console window
	Bool           dont_xlate_message;   // one-time stopper to TranslateMessage() call
	int            utf8_prepend_0x202D;  // newer windows do automatic bidi conversion, this is to cancel it
	WCHAR *      (*alloc_utf8_to_wchar_visual)(const char*,int,int*);
	ULONG_PTR      gdiplus_token;        // GDI+ handle
	Handle         clipboards[2];
	Bool           ole_initialized;
	void*          dnd_data_sender;      // IDropTarget.DragEnter.DataObject dnd storage object
	void*          dnd_data_receiver;    // CLIPBOARD_DND storage object

pod/Prima/Menu.pod  view on Meta::CPAN

           ]],
        ],
    );

    sub open_file
    {
        # enable 'save' menu item
        $window-> menu-> save_file-> enable;
    }

    $window-> popupItems( $window-> menuItems);

=head1 DESCRIPTION

The document describes interfaces of Prima::AbstractMenu
class, and its three descendants - Prima::Menu, Prima::Popup,
and Prima::AccelTable, all aimed at different targets.
Prima::AbstractMenu is a descendant of Prima::Component class,
and its specialization is handling of menu items, held in
a tree-like structure. Descendants of Prima::AbstractMenu
are designed to be attached to widgets and windows, to serve

pod/Prima/Menu.pod  view on Meta::CPAN

the pop-up key or mouse buttons combination,
in response to Prima::Widget's C<Popup> notification.

If C<::selected> is set to 1, then a menu object
is visualized in the system pop-up menu, otherwise it is not.
This behavior allows widget to host multiple
menu objects without clashing.
When a Prima::Popup object gets 'selected', it displaces
the previous 'selected' menu Prima::Popup object.
Prima::Widget
property C<::popup> then points to the menu object, and
C<::popupItems> is an alias for C<::items> menu class property.
Prima::Widget's properties C<::popupFont> and C<::popupColorIndex>
are used as visualization hints.

A Prima::Popup object can be visualized
explicitly, by means of C<popup> method. The
implicit visualization by the user is happened only
if the C<::autoPopup> property is set to 1.

Prima::Popup provides new C<popup> method
and new C<::autoPopup> property.

=head2 Prima::AccelTable

This class is destined for a more limited functionality than Prima::Menu and Prima::Popup,
primarily for mapping key strokes to predefined actions.
Prima::AccelTable objects are never visualized, and
consume no system resources, although full menu
item management syntax is supported.

pod/Prima/Menu.pod  view on Meta::CPAN

SCALAR can be either an anonymous sub or a method name,
defined in the menu object owner's name space.
Both called with three parameters -
the owner of a menu object, the menu object itself and
the name of the menu item.

=item autoPopup BOOLEAN

Only in Prima::Popup

If set to 1 in selected state, calls C<popup()> action
in response to C<Popup> notification, when the user
presses the default key or mouse button combination.

If 0, the pop-up menu can not be executed implicitly.

Default value: 1

=item autoToggle NAME, SCALAR / Prima::MenuItem::autoToggle SCALAR.

Manages autoToggle flag for a menu item. When set, C<checked> option is flipped

pod/Prima/Menu.pod  view on Meta::CPAN

Returns no value.

=item is_separator NAME

Returns true if the item is a separator, false otherwise

=item is_submenu NAME

Returns true if the item has submenu, false otherwise

=item popup X_OFFSET, Y_OFFSET, [ LEFT = 0, BOTTOM = 0, RIGHT = 0, TOP = 0 ]

Only in Prima::Popup

Executes the system-driven pop-up menu, in location near
(X_OFFSET,Y_OFFSET) pixel on the screen, with items from C<::items>
tree. The pop-up menu is hinted to be positioned so that
the rectangle, defined by (LEFT,BOTTOM) - (RIGHT,TOP) coordinates
is not covered by the first-level menu. This is useful when a pop-up
menu is triggered by a button widget, for example.

pod/Prima/Widget.pod  view on Meta::CPAN


First, if the C<::ownerFont> property is set to 1,
then font of the owner is copied to the widget, and
is maintained all the time while the property is true.
If it is not, the default font values read from the system.

The default font metrics for a widget returned by C<get_default_font()>
method, that often deals with system-dependent and user-selected
preferences ( see L</"Additional resources"> ). Because a widget can host
an eventual Prima::Popup object, it contains
C<get_default_popup_font()> method, that returns the default font
for the popup objects. The dynamic popup font settings governed,
naturally, by the C<::popupFont> property. Prima::Window extends the
functionality to C<get_default_menu_font()> and the C<::menuFont> property.

Dynamic change of the font property results in the
C<FontChanged> notification.

=head1 Additional resources

The resources, operated via Prima::Widget class but not that
strictly bound to the widget concept, are gathered in this
section. The section includes overview of pointer, cursor,

pod/Prima/Widget.pod  view on Meta::CPAN


The widget can also operate the C<::hintVisible> property,
that shows or hides the hint label immediately, if the mouse pointer
is inside the widget's boundaries.

=head2 Menu objects

The default functionality of Prima::Widget coexists with two kinds of the Prima::AbstractMenu
descendants - Prima::AccelTable and Prima::Popup ( Prima::Window
is also equipped with Prima::Menu reference). The C<::items> property of these objects
are accessible through C<::accelItems> and C<::popupItems>, whereas
the objects themselves - through C<::accelTable> and C<::popup>,
correspondingly. As mentioned in L</"User input">,
these objects hook the user keyboard input and call the programmer-defined
callback subroutine if the key stroke
equals to one of their table values. As for C<::accelTable>, its
function ends here. C<::popup> provides access to a context pop-up menu,
which can be invoked by either right-clicking or pressing a
system-dependent key combination. As a little customization,
the C<::popupColorIndex> and C<::popupFont> properties are introduced.
( C<::popupColorIndex> is multiplexed to C<::popupColor>,
C<::popupHiliteColor>, C<::popupHiliteBackColor>, etc etc
properties exactly like the C<::colorIndex> property ).

The font and color of a menu object might not always be writable (Win32).

The Prima::Window class provides equivalent methods for the menu bar, introducing
C<::menu>, C<::menuItems>, C<::menuColorIndex> ( with multiplexing ) and
C<::menuFont> properties.

=head2 User-specified resources

pod/Prima/Widget.pod  view on Meta::CPAN

   cr::User                    user-defined icon

All constants except C<cr::User> and C<cr::Default> present a system-defined
pointers, their icons and hot spot offsets. C<cr::User> is a sign that
an icon object was specified explicitly via C<::pointerIcon> property.
C<cr::Default> is a way to tell that a widget inherits its owner pointer type,
no matter is it a system-defined pointer or a custom icon.

See also: C<pointerHotSpot>, C<pointerIcon>, C<pointer>

=item popup OBJECT

Manages a Prima::Popup object associated with a widget.
The purpose of the popup object is to show a context menu
when the user right-clicks or selects the corresponding keyboard
combination. Prima::Widget can host many children objects,
Prima::Popup as well. But only the one that is set in
C<::popup> property will be activated automatically.

The popup object can be destroyed safely; its cancellation
can be done either via C<popup(undef)> or C<destroy()> call.

See also: C<Prima::Menu>, C<Popup>, C<Menu>,
C<popupItems>, C<popupColorIndex>, C<popupFont>

=item popupColorIndex INDEX, COLOR

Maintains eight color properties of a pop-up context menu,
associated with a widget. INDEX must be one of C<ci::XXX> constants
( see C<::colorIndex> property ).

See also: C<popupItems>, C<popupFont>, C<popup>

=item popupColor COLOR

Basic foreground in a popup context menu color.

See also: C<popupItems>, C<popupColorIndex>, C<popupFont>, C<popup>

=item popupBackColor COLOR

Basic background in a popup context menu color.

See also: C<popupItems>, C<popupColorIndex>, C<popupFont>, C<popup>

=item popupDark3DColor COLOR

Color for drawing dark shadings in a popup context menu.

See also: C<popupItems>, C<popupColorIndex>, C<popupFont>, C<popup>

=item popupDisabledColor COLOR

Foreground color for disabled items in a popup context menu.

See also: C<popupItems>, C<popupColorIndex>, C<popupFont>, C<popup>

=item popupDisabledBackColor COLOR

Background color for disabled items in a popup context menu.

See also: C<popupItems>, C<popupColorIndex>, C<popupFont>, C<popup>

=item popupFont %FONT

Maintains the font of a pop-up context menu, associated with a widget.

See also: C<popupItems>, C<popupColorIndex>, C<popup>

=item popupHiliteColor COLOR

Foreground color for selected items in a popup context menu.

See also: C<popupItems>, C<popupColorIndex>, C<popupFont>, C<popup>

=item popupHiliteBackColor COLOR

Background color for selected items in a popup context menu.

See also: C<popupItems>, C<popupColorIndex>, C<popupFont>, C<popup>

=item popupItems [ ITEM_LIST ]

Manages items of a Prima::Popup object associated with a widget.
The ITEM_LIST format is same as C<Prima::AbstractMenu::items>
and is described in L<Prima::Menu>.

See also: C<popup>, C<popupColorIndex>, C<popupFont>

=item popupLight3DColor COLOR

Color for drawing light shadings in a popup context menu.

See also: C<popupItems>, C<popupColorIndex>, C<popupFont>, C<popup>

=item rect X_LEFT_OFFSET Y_BOTTOM_OFFSET X_RIGHT_OFFSET Y_TOP_OFFSET

Maintains the rectangular boundaries of a widget relative
to its owner ( or to the screen if C<::clipOwner> is set to 0 ).

See also: C<bottom>, C<right>, C<top>, C<left>, C<origin>,
C<width>, C<height>, C<size>
C<growMode>, C<Move>, C<Size>, C<get_virtual_size>,
C<sizeMax>, C<sizeMin>

pod/Prima/Widget.pod  view on Meta::CPAN

=head2 Get-methods

=over

=item get_default_font

Returns the default font for a Prima::Widget class.

See also: C<font>

=item get_default_popup_font

Returns the default font for a Prima::Popup class.

See also: C<font>

=item get_invalid_rect

Returns the result of successive calls C<invalidate_rect()>,
C<validate_rect()> and C<repaint()>, as a rectangular area
( four integers ) that cover all invalid regions in a widget.

pod/Prima/Widget.pod  view on Meta::CPAN

   kb::Delete   kb::Home    kb::Left   kb::Up
   kb::Right    kb::Down    kb::PgUp   kb::Prior
   kb::PageUp   kb::PgDn    kb::Next   kb::PageDown
   kb::End      kb::Begin   kb::Select kb::Print
   kb::PrintScr kb::Execute kb::Insert kb::Undo
   kb::Redo     kb::Menu    kb::Find   kb::Cancel
   kb::Help     kb::Break   kb::BackTab

=back

See also: C<KeyUp>, C<briefKeys>, C<key_down>, C<help>, C<popup>,
C<tabOrder>, C<tabStop>, C<accelTable>

=item KeyUp CODE, KEY, MOD

Sent to the focused widget when the user releases a key.
CODE contains an eventual character code, KEY is one of C<kb::XXX>
constants, MOD is a combination of the modifier keys
pressed when the event occurred ( C<km::XXX> ).

See also: C<KeyDown>, C<key_up>

pod/Prima/Widget.pod  view on Meta::CPAN

=item Menu MENU VAR_NAME

Called before the user-navigated menu ( pop-up
or pull-down ) is about to show another level of
submenu on the screen. MENU is Prima::AbstractMenu
descendant, that children to a widget, and VAR_NAME
is the name of the menu item that is about to be shown.

Used for making changes in the menu structures dynamically.

See also: C<popupItems>

=item MouseClick BUTTON, MOD, X, Y, NTH

Called when a mouse click ( button is pressed, and then
released within system-defined interval of time ) is
happened in the widget area. BUTTON is one of C<mb::XXX>
constants, MOD is a combination of C<km::XXX> constants,
reflecting pressed modifier keys during the event,
X and Y are the mouse pointer coordinates. NTH
is an integer, set to 0 if it was a single click,

pod/Prima/Widget.pod  view on Meta::CPAN

C<colorIndex>, C<font>

=item Popup BY_MOUSE, X, Y

Called by the system when the user presses a key or mouse
combination defined for a context pop-up menu execution.
By default executes the associated Prima::Popup object,
if it is present. If the event flag is cleared during the
execution of callbacks, the pop-up menu is not shown.

See also: C<popup>

=item Setup

This message is posted right after C<Create> notification,
and comes first from the event loop. Prima::Widget does not
use it.

=item Show

Triggered by a successive C<visible(1)> call

pod/Prima/X11.pod  view on Meta::CPAN

=item *

widget_font - Widget::get_default_font.

=back

All of the global font properties can only be set via C<Prima> class, no
application name is recognized. Also, these properties are identical to
C<--font>, C<--menu-font>, C<--caption-font>, C<--msg-font>, and
C<--widget-font> command-line arguments.  The per-widget properties are C<font>
and C<popupFont>, of class C<Font>, settable via XRDB only:

   Prima*Dialog.font: my-fancy-dialog-font
   Prima.FontDialog.font: some-conservative-font

By default, Prima font is 12.Helvetica .

=head2 X core fonts

The values of the font entries are standard XLFD strings, the default
C<*-*-*-*-*-*-*-*-*-*-*-*-*-*-*> pattern, where each star character can be

unix/color.c  view on Meta::CPAN


static Color standard_button_colors[]      = { COLORSET_GRAY     };
static Color standard_checkbox_colors[]    = { COLORSET_GRAY     };
static Color standard_combo_colors[]       = { COLORSET_GRAY     };
static Color standard_dialog_colors[]      = { COLORSET_GRAY     };
static Color standard_edit_colors[]        = { COLORSET_PANEL    };
static Color standard_inputline_colors[]   = { COLORSET_PANEL    };
static Color standard_label_colors[]       = { COLORSET_GRAY     };
static Color standard_listbox_colors[]     = { COLORSET_PANEL    };
static Color standard_menu_colors[]        = { COLORSET_ALT_GRAY };
static Color standard_popup_colors[]       = { COLORSET_ALT_GRAY };
static Color standard_radio_colors[]       = { COLORSET_GRAY     };
static Color standard_scrollbar_colors[]   = { COLORSET_ALT_GRAY };
static Color standard_slider_colors[]      = { COLORSET_GRAY     };
static Color standard_widget_colors[]      = { COLORSET_ALT_GRAY };
static Color standard_window_colors[]      = { COLORSET_GRAY     };
static Color standard_application_colors[] = { COLORSET_GRAY     };

static Color* standard_colors[] = {
	NULL,
	standard_button_colors,		/* Prima.Button.* */
	standard_checkbox_colors,		/* Prima.Checkbox.* */
	standard_combo_colors,		/* Prima.Combo.* */
	standard_dialog_colors,		/* Prima.Dialog.* */
	standard_edit_colors,		/*   ...etc... */
	standard_inputline_colors,
	standard_label_colors,
	standard_listbox_colors,
	standard_menu_colors,
	standard_popup_colors,
	standard_radio_colors,
	standard_scrollbar_colors,
	standard_slider_colors,
	standard_widget_colors,
	standard_window_colors,
	standard_application_colors,
};

static const int MAX_COLOR_CLASS = sizeof(standard_colors) / sizeof( standard_colors[ 0]) - 1;

unix/event.c  view on Meta::CPAN

				md = md-> next;
			}
			return;
		}

		syntetic_mouse_move(); /* XXX - simulated MouseMove event for compatibility reasons */

		if (!XT_IS_WINDOW(XX))
			frame = C_APPLICATION-> top_frame( prima_guts.application, self);
		if ( C_APPLICATION-> map_focus( prima_guts.application, frame) != frame) {
			C_APPLICATION-> popup_modal( prima_guts.application);
			break;
		}

		if ( XT_IS_WINDOW(XX)) {
			e. cmd = cmActivate;
			SELF_MESSAGE(e);
			if (( PObject( self)-> stage == csDead) ||
				( ev-> xfocus. detail == NotifyNonlinearVirtual)) return;
		}

unix/font.c  view on Meta::CPAN

	}

	XX-> font = kf;
	if ( !xft_metrics) {
		XX-> guillemots = XTextWidth( kf-> fs, ">>", 2);
	} else {
#ifdef USE_XFT
		XX-> guillemots = prima_xft_get_text_width( kf, ">>", 2, toAddOverhangs, NULL, NULL);
#endif
	}
	if ( !XX-> type. popup && X_WINDOW) {
		if (( kf-> font. height + 4) != X(PComponent(self)-> owner)-> menuHeight) {
			prima_window_reset_menu( PComponent(self)-> owner, kf-> font. height + MENU_ITEM_GAP * 2);
			XResizeWindow( DISP, X_WINDOW, XX-> w-> sz.x, XX-> w-> sz.y = kf-> font. height + MENU_ITEM_GAP * 2);
		} else if ( !XX-> paint_pending) {
			XClearArea( DISP, X_WINDOW, 0, 0, XX-> w-> sz.x, XX-> w-> sz.y, true);
			XX-> paint_pending = true;
		}
	}
	return true;
}

unix/menu.c  view on Meta::CPAN

	Bool vertical = w != &XX-> wstatic, layered;
	PMenuItemReg m = w->m;
	PUnixMenuItem ix;
	int lastIncOk = 1;
	PCachedFont kf = XX-> font;
	uint32_t *xft_map8 = NULL;
	PWindow owner = ( PWindow)(PComponent( w-> self)-> owner);

#ifdef USE_XFT
	{
		const char * encoding = ( XX-> type. popup) ?
			owner-> popupFont. encoding :
			owner-> menuFont. encoding;
		xft_map8 = prima_xft_map8( encoding);
	}
#endif
	layered = vertical ? false : X(owner)->flags. layered;

	free_unix_items( w);
	w-> num = item_count( w);
	ix = w-> um = malloc( sizeof( UnixMenuItem) * w-> num);
	if ( !ix) return;

unix/menu.c  view on Meta::CPAN

			GCGraphicsExposures | GCCapStyle | GCLineWidth,
			&gcv
		);
		draw. c  = XX->argb_c;
	} else {
		draw. gc = guts. menugc;
		draw. c  = XX->c;
	}
#ifdef USE_XFT
	if ( kf-> xft) {
		char * encoding = ( XX-> type. popup) ?
			owner-> popupFont. encoding :
			owner-> menuFont. encoding;
		draw. xft_map8 = prima_xft_map8( encoding);
		draw. xft_drawable = XftDrawCreate( DISP, win,
			draw.layered ? guts. argb_visual. visual : guts. visual. visual,
			draw.layered ? guts. argbColormap : guts. defaultColormap);
		descent = kf-> xft-> descent;
	} else
#endif
	descent = kf-> fs->max_bounds.descent;

unix/menu.c  view on Meta::CPAN

	}
	if ( guts. currentMenu != self) {
		int rev;
		if ( ev-> type == ButtonRelease) return;
		if ( guts. currentMenu)
			prima_end_menu();
		if ( focus)
			XX-> focus = focus;
		else
			XGetInputFocus( DISP, &XX-> focus, &rev);
		if ( !XX-> type. popup) {
			Handle topl = PComponent( self)-> owner;
			Handle who  = ( Handle) hash_fetch( guts.windows, (void*)&XX-> focus, sizeof(XX-> focus));
			while ( who) {
				if ( XT_IS_WINDOW(X(who))) {
					if ( who != topl) XX-> focus = PComponent( topl)-> handle;
					break;
				}
				who = PComponent( who)-> owner;
			}
		}

unix/menu.c  view on Meta::CPAN

	apc_timer_stop( MENU_TIMER);
	if ( !XX-> focused) return;
	/* navigation */
	w = XX-> focused;
	m = w-> m;
	switch (keysym) {
	case XK_Left:
	case XK_KP_Left:
		if ( w == &XX-> wstatic) { /* horizontal menu */
			d--;
		} else if ( w != XX-> w) { /* not a popup root */
			if ( w-> prev) menu_window_delete_downlinks( XX, w-> prev);
			if ( w-> prev == &XX-> wstatic) {
				d--;
				piles = 1;
			} else
				return;
		}
		break;
	case XK_Right:
	case XK_KP_Right:

unix/menu.c  view on Meta::CPAN

	memcpy( font, &XX-> font-> font, sizeof( Font));
	return font;
}

Bool
apc_menu_set_color( Handle self, Color color, int i)
{
	DEFMM;
	if ( i < 0 || i > ciMaxId) return false;
	XX-> rgb[i] = prima_map_color( color, NULL);
	if ( !XX-> type.popup) {
		if ( X(PWidget(self)-> owner)-> menuColorImmunity) {
			X(PWidget(self)-> owner)-> menuColorImmunity--;
			return true;
		}
		if ( X_WINDOW) {
			prima_palette_replace( PWidget(self)-> owner, false);
			if ( !XX-> paint_pending) {
				XClearArea( DISP, X_WINDOW, 0, 0, XX-> w-> sz.x, XX-> w-> sz.y, true);
				XX-> paint_pending = true;
			}

unix/menu.c  view on Meta::CPAN

	return true;
}

ApiHandle
apc_menu_get_handle( Handle self)
{
	return NULL_HANDLE;
}

Bool
apc_popup_create( Handle self, Handle owner)
{
	DEFMM;
	apc_menu_destroy( self);
	XX-> type.menu = true;
	XX-> type.popup = true;
	return true;
}

PFont
apc_popup_default_font( PFont f)
{
	memcpy( f, &guts. default_menu_font, sizeof( Font));
	return f;
}

Bool
apc_popup( Handle self, int x, int y, Rect *anchor)
{
	DEFMM;
	PMenuItemReg m;
	PMenuWindow w;
	XWindow dummy;
	PDrawableSysData owner;
	int dx, dy;

	prima_end_menu();
	if (!(m=TREE)) return false;

unix/menu.c  view on Meta::CPAN

		menu_reconfigure( menu);
		repal = true;
		/* make it immune to necessary color change calls */
		XX-> menuColorImmunity = ciMaxId + 1;
	}
	prima_window_reset_menu( self, y);
	if ( repal) prima_palette_replace( self, false);
	if ( menu) {
		int i;
		Bool layered = XF_LAYERED(XX);
		XX->flags.layered = false; /* we need non-layered colors for popup menus */
		for ( i = 0; i <= ciMaxId; i++) {
			M(menu)-> c[i] = prima_allocate_color( self,
				prima_map_color( PWindow(self)-> menuColor[i], NULL), NULL);
		}
		i = MENU_PALETTE_SIZE - 1;
		M(menu)-> c[i] = prima_allocate_color( self, 0x404040, NULL);
		XX->flags.layered = layered;
		M(menu)-> layered = XX->flags. layered;
		if ( M(menu)-> layered ) {
			for ( i = 0; i <= ciMaxId; i++) 



( run in 2.827 seconds using v1.01-cache-2.11-cpan-364913b4093 )