PtFolder

PtFolder — A file-folder style container.

Synopsis

class PtFolder PtContainer
{
    folder_panes;           // PtWidget array 
    folder_selected_tab;    // short
    folder_tab_height;      // short
    folder_tabs;            // PtWidget array
}
		

Base Classes

PtWidget <-- PtBasic <-- PtContainer <-- PtFolder

Description

This widget is a folder that can contain virtual pages, which are accessed by PtFolderTabs. Each page is set up by creating a PtFolderTab, and then immediately assigning a PtPane to that tab. The PtPane and all of its children are displayed when the PtFolderTab is selected.

[Note]

This widget does not appear in the Photon documentation.

Instance Variables

folder_panes

An array of PtPanes contained in the folder.

folder_selected_tab

An integer specifying the selected tab. Tabs are numbered consecutively, starting with 1. If no tab is selected, or if a tab is reselected, the value of this variable is 0.

folder_tab_height

A number of pixels specifying the height of the tabs for this folder. Default is 19.

folder_tabs

An array of PtFolderTabs contained in the folder.

Example

This example, ex_PtFolder.g, is included in the product distribution.

#!/usr/cogent/bin/phgamma

/* This example demonstrates PtFolder and PtFolderTab.
 * It creates a folder with three tabs.  It also includes
 * a function that de_activates the set/unset toggle
 * feature of the tabs.
 */

require_lisp ("PhotonWidgets");

/* Here is the set/unset deactivation function.
 * It keeps a tab set until another tab is selected.
 */
function do_not_unset (widget)
{
   local	folder = PtWidgetParent (widget);

   if (folder.folder_selected_tab == 0)
   	widget.flags = Pt_SET;
}

function main ()
{
   init_ipc ("a","a");
   PtInit (nil);

   w = new (PtWindow);
   f = new (PtFolder);
   f.SetDim (300,200);

   /* We anchor the folder to the window to demonstrate how
    * the PtPane gets resized with the folder automatically.
    */
   f.anchor_flags = cons (0, -1);
   f.anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM |
     Pt_TOP_ANCHORED_TOP |
       Pt_LEFT_ANCHORED_LEFT |
         Pt_RIGHT_ANCHORED_RIGHT;

   /* Each tab must be a child of the folder, and the
    * pane for each tab should be the first child of that
    * tab. If the pane is created immediately after the
    * tab, you don't have to set the parent explicitly.
    */
   PtSetParentWidget (f);
   tab = new (PtFolderTab);
   tab.foldertab_text_string = "Tab #1";
   tab.flags = Pt_SET;
   PtAttachCallback (tab, Pt_CB_ACTIVATE, `do_not_unset(@tab));
   p1 = new (PtPane);
   p1.fill_color = 0xffaaaa;

   PtSetParentWidget (f);
   tab = new (PtFolderTab);
   tab.foldertab_text_string = "Tab #2";
   PtAttachCallback (tab, Pt_CB_ACTIVATE, `do_not_unset(@tab));
   p2 = new (PtPane);
   p2.fill_color = 0x00ddaa;

   /* Note: this tab retains the set/unset toggle feature.
    */
   PtSetParentWidget (f);
   tab = new (PtFolderTab);
   tab.foldertab_text_string = "Tab #3";
   p3 = new (PtPane);
   p3.fill_color = 0xccaaff;

   PtSetParentWidget (p1);
   b = new (PtButton);
   b.text_string = "Button 1";
   b.SetPos (60,50);

   PtSetParentWidget (p2);
   b = new (PtButton);
   b.text_string = "Button 2";
   b.SetPos (120,50);

   PtSetParentWidget (p3);
   b = new (PtButton);
   b.text_string = "Button 3";
   b.SetPos (180,50);

   PtRealizeWidget (w);
   PtMainLoop();
}

See Also

PtFolderTab, PtPane