Curses-Devkit

 view release on metacpan or  search on metacpan

Cdk.xs  view on Meta::CPAN

	chtype	dayAttrib = sv2chtype ($arg);
	chtype	monthAttrib = sv2chtype ($arg);
	chtype	yearAttrib = sv2chtype ($arg);
	chtype	highlight = sv2chtype ($arg);
	int	xPos = sv2int ($arg);
	int	yPos = sv2int ($arg);
	int	Box = sv2int ($arg);
	int	shadow = sv2int ($arg);
	CODE:
	{
	   CDKCALENDAR * calendarWidget = (CDKCALENDAR *)NULL;
	   char Title[1000];

	   checkCdkInit();

	   MAKE_TITLE (title,Title);

	   calendarWidget = newCDKCalendar (GCDKSCREEN,xPos,yPos,Title,
						day,month,year,
						dayAttrib,monthAttrib,yearAttrib,
						highlight,Box,shadow);

	   /* Check the return type. */
	   if (calendarWidget == (CDKCALENDAR *)NULL)
	   {
	      croak ("Cdk::Calendar Could not create widget. Is the window too small?\n");
	   }
	   else
	   {
	      RETVAL = calendarWidget;
	   }
	}
	OUTPUT:
	   RETVAL

void
Activate(object,...)
	CDKCALENDAR *	object
	PPCODE:
	{

Cdk/Cdk/Calendar.pm  view on Meta::CPAN

   my $mAttrib = Cdk::checkDef ($name, "Mattrib", $params{'Mattrib'}, "</24/B>");
   my $yAttrib = Cdk::checkDef ($name, "Yattrib", $params{'Yattrib'}, "</32/B>");
   my $highlight = Cdk::checkDef ($name, "Highlight", $params{'Highlight'}, "</40/B>");
   my $box = Cdk::checkDef ($name, "Box", $params{'Box'}, "TRUE");

   Cdk::Calendar::Set ($self->{'Me'}, $day, $month, $year, 
			$dAttrib, $mAttrib, $yAttrib, $box);
}

#
# This sets the calendar to a given date.
#
sub setDate
{
   my $self	= shift;
   my %params	= @_;
   my $name	= "$self->{'Type'}::setDate";

   # Set up the parameters passed in.
   my $day = Cdk::checkDef ($name, "Day", $params{'Day'}, -1);
   my $month = Cdk::checkDef ($name, "Month", $params{'Month'}, -1);
   my $year = Cdk::checkDef ($name, "Year", $params{'Year'}, -1);

   Cdk::Calendar::SetDate ($self->{'Me'}, $day, $month, $year);
}

#
# This gets the current date on the given calendar.
#
sub getDate
{
   my $self = shift;
   return (Cdk::Calendar::GetDate ($self->{'Me'}));
}

#
# This sets a marker in the calendar widget.
#
sub setMarker
{
   my $self	= shift;
   my %params	= @_;
   my $name	= "$self->{'Type'}::setMarker";

   # Set up the parameters passed in.
   my $day = Cdk::checkReq ($name, "Day", $params{'Day'});
   my $month = Cdk::checkReq ($name, "Month", $params{'Month'});
   my $year = Cdk::checkReq ($name, "Year", $params{'Year'});
   my $marker = Cdk::checkDef ($name, "Marker", $params{'Marker'}, "A_REVERSE");

   Cdk::Calendar::SetMarker ($self->{'Me'}, $day, $month, $year, $marker);
}

#
# This removes a marker from the calendar widget.
#
sub removeMarker
{
   my $self	= shift;
   my %params	= @_;
   my $name	= "$self->{'Type'}::removeMarker";

   # Set up the parameters passed in.
   my $day = Cdk::checkReq ($name, "Day", $params{'Day'});
   my $month = Cdk::checkReq ($name, "Month", $params{'Month'});

FILES  view on Meta::CPAN

Mike Glover, Copyright 1995, 1996
------------------------------------------------------------------------------
This file lists all the files provided as an example of the Perl5 Cdk
extension.

examples Directory	Description
------------------------------------------------------------------------------
alphalist		Demonstrates the alphalist widget.
buttonbox		Demonstrates the buttonbox widget.
bind			Demonstrates how to use the bind function.
calendar		Demonstrates the calendar widget.
dialog			Demonstrates the dialog widget.
entry			Demonstrates the entry widget.
fselect			Demonstrates the file selector widget.
graph			Demonstrates the graph widget.
histogram		Demonstrates the histogram widget.
itemlist		Demonstrates the itemlist widget.
label			Demonstrates the label widget.
marquee			Demonstrates the marquee widget.
matrix			Demonstrates the matrix widget.
mentry			Demonstrates the mentry widget.

demos/bday  view on Meta::CPAN


# Set some global variables.
my %birthdays = ();
my %appointments = ();
my %anniversay = ();

# Initialize Cdk.
use Cdk;
Cdk::init();

# Create the calendar object.
my $calendar = new Cdk::Calendar ('Dattrib' => "</32/B>",
					'Mattrib' => "</5/B>",
					'Yattrib' => "</24/B>",
					'Highlight' => "</R>");

# Create the scrolling window.
my $swindow = new Cdk::Swindow ('Title' => "<C></B/5>Date Information",
					'Lines' => 300,
					'Height' => 4,
					'Width' => 50,
					'Ypos' => "BOTTOM");

# Set the key binding for the calendar widget.
$calendar->bind ('Key' => "m", 'Function' => sub { setMarkerCB ($calendar);});

# Set the post-process function for the calendar widget.
$calendar->postProcess ('Function' => sub { checkDatePP ($calendar);});

# Draw the scrolling window.
$swindow->draw();

# Let the user play.
for (;;)
{
   # Activate the object.
   my $ret = $calendar->activate();
}

# Exit Cdk.
Cdk::end();

#
# This checks if the current date has a marker set on it.
#
sub checkDatePP
{
   my $calendar = shift;
}

#
# This allows the user to create a marker.
#
sub setMarkerCB 
{
   my $calendar = shift;
   my @mesg = ("<C></B/5>What type of a marker is it?");
   my @buttons = ("</B/3>Birthday", "</B/5>Anniversary", "</B/30>Appointment");

   # Get the current date the marker is at.
   my ($day, $month, $year) = $calendar->getDate();

   # Ask the user what type of marker to add.
   my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons);
   my $choice = $dialog->activate();
   undef $dialog;

   # If they hit escape, tell them...
   if (!defined $choice)
   {
      popupLabel (["Escape Hit. No marker set."]);
      $calendar->draw();
      return;
   }

   # Check the choice.
   if ($choice == 0)
   {
      addBirthdayMarker ($day, $month, $year);
   }
   elsif ($choice == 1)
   {

examples/calendar  view on Meta::CPAN

# Purpose:
#	To demonstrate the Perl5 Cdk Calendar Widget

#
# Initialize Cdk.
#
use Cdk;
Cdk::init();

# Create the celendar object.
my $calendar = new Cdk::Calendar ();

# Activate the object.
my $ret = $calendar->activate();

# Exit Cdk.
Cdk::end();

fulldemo/cdkdemo  view on Meta::CPAN

   }
}

sub widgetHelp
{
   my ($helpfile, $topic, $helpviewer);
   my $helpdir		= $ENV{'CDKHELPDIR'}	|| "./help";

   # Define the widget help files.
   my @helpFiles = ("alphalist.help",
			"calendar.help",
			"dialog.help",
			"entry.help",
			"fselect.help",
			"graph.help",	
			"histogram.help",
			"itemlist.help",
			"label.help",
			"marquee.help",
			"matrix.help",
			"menu.help",

fulldemo/help/calendar.help  view on Meta::CPAN

</R>Purpose<!R>
The Cdk calendar widget is a simple little widget which allows a user to
play with a calendar. 

</R>Construction Options<!R>
The calendar widget is defined using the following syntax. The variable
</B>$calendarObject<!B> contains the reference to the entry object.
<C></B>$calendarObject = new Cdk::Calendar ( options );
 
The options are defined in the following table.

</U>Option      Default Value       Type       Purpose<!U>
Day         The current day     Scalar     The day of the calendar.
            of the month.
Month       The current month   Scalar     The month of the calendar.
Year        The current year    Scalar     The year of the calendar.
Dattrib     Normal              Scalar     The attribute of the days.
Mattrib     Normal              Scalar     The attribute of the month name.
Yattrib     Normal              Scalar     The attribute of the year.
Highlight   Reverse             Scalar     The highlight attribute of the cursor.
Filler      .                   Scalar     The default field character.
Xpos        Center              Scalar     This is the position of the window on the X axis.
Ypos        Center              Scalar     This is the position of the window on the Y axis.
Box         True                Scalar     This Boolean states whether the dialog box will have a box drawn around it.
Shadow      False               Scalar     This Boolean states whether the dialog box will have a shadow on the box.

</R>Available Methods<!R>
</B>activate<!B>
Activation of an object means to make the object available for use. The
following example demonstrates how to activate a entry widget.
<C></B>($day, $month, $year) = $calendarObject->activate ();

The variables </B>$day<!B>, </B>$month<!B>, </B>$year<!B> is the date
of the calendar when it exited.

</B>inject<!B>
This function injects a single character into the widget. The following
examples demonstrates how to call the inject method.
<C></B>$calendarObject->inject ( options );

The options are defined in the following table.
</U>Option      Default Value       Type       Purpose<!U>
Shadow      Required             Scalar     The character to inject into the widget.

If you are injecting a special character into the widget, then you can
use a pre-defined value to represent the key.

<C><#UL><#HL(11)><#TT><#HL(14)><#UR>
<C><#VL></U>Key         <#VL>Key Value      <!U><#VL>

fulldemo/help/calendar.help  view on Meta::CPAN

<C><#VL>Delete      <#VL>KEY_DELETE     <#VL>
<C><#VL>Backspace   <#VL>KEY_BACKSPACE  <#VL>
<C><#VL>Page Up     <#VL>KEY_PPAGE      <#VL>
<C><#VL>Page Down   <#VL>KEY_NPAGE      <#VL>
<C><#VL>Home        <#VL>KEY_HOME       <#VL>
<C><#VL>End         <#VL>KEY_END        <#VL>
<C><#VL>Escape      <#VL>KEY_ESC        <#VL>
<C><#LL><#HL(11)><#BT><#HL(14)><#LR>

</B>setDate<!B>
Sets the current date of the calendar field.
<C></B>$calendarObject->setDate ( options );

The options are defined in the following table.

</U>Option      Default Value       Type       Purpose<!U>
Day         Required            Scalar     The day of the calendar.
Month       Required            Scalar     The month of the calendar.
Year        Required            Scalar     The year of the calendar.

</B>bind<!B>
The bind method binds keys to events. The binding is specific to the individual
objects. The following example demonstrates how to call the bind method.
<C></B>$calendarObject->bind ( options );

The options are defined in the following table.

</U>Option      Default Value       Type       Purpose<!U>
Key         Required            Scalar     This is the character to bind the event to.
Function    Required            Scalar     This is the name of the callback function.

</B>preProcess<!B>
The </B>preProcess<!B> function sets a process to be run before the key entered
is processed. If this function returns a value of 0, then the key injected
into the widget will not be processed; otherwise the character will be
processed as normal.  The following example demonstrates how to call the
preProcess method.
<C></B>$calendarObject->preProcess ( options );

The options are defined in the following table.

</U>Option      Default Value       Type       Purpose<!U>
Function    Required            Scalar     This is the name of the
                                           callback function.

To create a pre-process callback the following code segment demonstrates
how to do it properly.

fulldemo/help/calendar.help  view on Meta::CPAN

If the pre-process function returns a value of 0 the key hit will
not be injected into the widget. This allows the programmer to
selectively pick which characters will or will not get injected
into the widget.

The </B>postProcess<!B> function sets a process to be run before the key entered
is processed. If this function returns a value of 0, then the key injected
into the widget will not be processed; otherwise the character will be
processed as normal.  The following example demonstrates how to call the
postProcess method.
<C></B>$calendarObject->postProcess ( options );

The options are defined in the following table.

</U>Option      Default Value       Type       Purpose<!U>
Function    Required            Scalar     This is the name of the
                                           callback function.

To create a post-process callback the following code segment demonstrates
how to do it properly.

fulldemo/help/calendar.help  view on Meta::CPAN

<C><#VL>Backspace   <#VL>KEY_BACKSPACE  <#VL>
<C><#VL>Page Up     <#VL>KEY_PPAGE      <#VL>
<C><#VL>Page Down   <#VL>KEY_NPAGE      <#VL>
<C><#VL>Home        <#VL>KEY_HOME       <#VL>
<C><#VL>End         <#VL>KEY_END        <#VL>
<C><#VL>Escape      <#VL>KEY_ESC        <#VL>
<C><#LL><#HL(11)><#BT><#HL(14)><#LR>
</B>draw<!B>
This method draws the object on the screen. The following example demonstrates
how to call the draw method.
<C></B>$calendarObject->draw ( options );
 
The options are defined in the following table.

</U>Option      Default Value       Type       Purpose<!U>
Box         True                Scalar     Draws the window with a box around it.

</B>erase<!B>
This method removes the object from the screen. This does </B/U>NOT<!B!U> 
destroy the object. The following example demonstrates how to call the erase 
method.
<C></B>$calendarObject->erase ();

</B>raise<!B>
The raise method raises the widget to the top of the screen. This means if there
were any widgets obscuring part of the view, raising the object would bring the
complete object into view. The following example demonstrates how to call the 
raise method.
<C></B>$calendarObject->raise();

</B>lower<!B>
The lower method lowers the object so it doesn't obscure the view of any other 
objects. The following example demonstrates how to call the lower method.
<C></B>$calendarObject->lower();

</B>register<!B>
The register method registers the object to the default screen. This does </R>NOT<!R>
have to be called since the objects are registered automatically. This method
should be called if the </B>unregister<!B> method was called. The following
example demonstrates how to call the register method.
<C></B>$calendarObject->register();

</B>unregister<!B>
The unregister method should be called when a widget, which is part of the
default screen, needs to be taken away temporarily. This does not delete or free
the object, it just unmaps it from any future screen refreshes. The object can
be registered by calling the </B>register<!B> method. The following example
demonstrates how to call the unregister method.
<C></B>$calendarObject->unregister();

</B>getwin<!B>
This method returns a pointer to the window of the object. Not much use for this
yet. It will be useful in the future when the drawing methods are added. The
following example demonstrates how to call the getwin method.
<C></B>$calendarObject->getwin();

</R>Default Key Bindings<!R>
Since this widget is 'driven' by the entry field, the default key bindings
of the entry field apply to this widget. There are however extra bindings
which have been applied. They are as follows:

</U>Key               Action<!U>
TAB               Tries to complete the word in the entry field.
Key Up            Scrolls the list one item backward.
Page Up           Scrolls the list one page backward.

fulldemo/help/calendar.help  view on Meta::CPAN

Return            Returns what is currently displayed in the entry field.
Escape            Exits the widget and returns undef.

</R>Tips & Tricks<!R>
None.

</R>Physical Restrictions<!R>
Same as the scrolling list.

</R>Example Use Of The Widget<!R>
<F=../examples/calendar>

<C><#HL(70)>
<C>Document Created: June, 1996
<C>Document Revised: July, 1996

fulldemo/help/general.help  view on Meta::CPAN

There are currently 22 widgets available in Cdk, with more coming. What they 
are and what they do is in the following table.

<C><#UL><#HL(13)><#TT><#HL(51)><#UR>
<C><#VL></R> Widget Name  <!R></U><#VL><!U></R>Purpose                                             <!R><#VL>
<C><#VL>Alphalist     <#VL>Provides a list of words which the user can select  <#VL>
<C><#VL>              <#VL>from. Allows you to narrow the seach by entering    <#VL>
<C><#VL>              <#VL>a few initial characters of thw words being         <#VL>
<C><#VL></U>              <#VL>sought after to narrow the search.                  <!U><#VL>
<C><#VL></U>Buttonbox     <#VL>Creates a widget with numerous buttons.             <!U><#VL>
<C><#VL></U>Calendar      <#VL>Creates a simple calendar widget.                   <!U><#VL>
<C><#VL>Dialog        <#VL>Prompts the user with a message, and the user       <#VL>
<C><#VL></U>              <#VL>can pick an answer from the buttons provided.       <!U><#VL>
<C><#VL></U>Entry         <#VL>Allows the user to enter information.               <!U><#VL>
<C><#VL>File Selector <#VL>A file selector built from Cdk base widgets.        <#VL>
<C><#VL>              <#VL>This example shows how to create more complicated   <#VL>
<C><#VL></U>              <#VL>widgets using the Cdk widget library.               <!U><#VL>
<C><#VL></U>Graph         <#VL>Draws a graph.                                      <!U><#VL>
<C><#VL></U>Histogram     <#VL>Draws a histogram.                                  <!U><#VL>
<C><#VL>Item List     <#VL>Creates a pop up field which allows the user to     <#VL>
<C><#VL>              <#VL>select one of several choices in a small field. Very<#VL>



( run in 0.487 second using v1.01-cache-2.11-cpan-5dc5da66d9d )