PM notebook widget
The PM notebook widget (EwPMNotebook) is used to create notebooks with the look and feel of the OS/2 notebook control. By manipulating the values of a few resources, a PM notebook widget can be made to adopt the range of looks available from the native PM notebook control. Following is an example of a PM notebook widget:

PM notebook
A notebook's image can be oriented so that the pages appear to turn vertically, like a flip chart, or horizontally, like a book. If the value of the orientation resource is set to XmHORIZONTAL, the binding will be drawn along the left side. If it is set to XmVERTICAL, the binding will appear on the top or bottom depending on the value of the backPagePosition resource.
A PM notebook is displayed as a graphic representation of a stack of pages. Images of page edges can be drawn so that later pages are above and to the right, or below and to the right of previous pages. This behavior is controlled by the value of the backPagePosition resource. It can be set to XmTOPRIGHT or XmBOTTOMRIGHT.
PM notebooks distinguish between different kinds of pages, called major and minor pages. When a page is created, its tabType resource specifies whether it is a major page (XmMAJOR), minor page (XmMINOR), or neither (XmNONE). The tabs for major pages are always displayed. A minor page is associated with the major page that precedes it. It only appears when its major page is on the top of the notebook. Pages that are not major or minor pages do not have displayable tabs. They can only be reached by using page buttons to traverse all of the pages.
The combination of orientation and backPagePosition resources determines how major and minor tabs are positioned. Major tabs are always drawn opposite the binding. Minor tabs, which only appear when the major tab they follow is brought to the top, are drawn on the remaining page side.
The value of the bindingType resource determines what type of binding is drawn along the "bound" edge of the notebook's collection of pages. Options include no binding (XmNONE), a spiral binding (XmSPIRAL), or a solid binding (XmSOLID).
The following example creates a PM notebook with several pages, each of which lists the messages understood by a class. A single base page is created that shares its widgets with the remaining pages.
Object subclass: #PMNotebookExample
instanceVariableNames: 'list '
classVariableNames: "
poolDictionaries: 'CwConstants EwConstants '
open
"Create the necessary widgets."
| shell notebook |
shell := CwTopLevelShell
createApplicationShell: 'shell'
argBlock: [:w | w
title: 'Notebook Example';
width: 512;
height: 384].
notebook := shell
createPMNotebook: 'notebook'
argBlock: [:w | w
bindingType: XmSPIRAL;
orientation: XmVERTICAL;
backPagePosition: XmBOTTOMRIGHT;
majorTabWidth: (CgFontStruct default textWidth: 'ClassDescription')].
notebook manageChild.
self createPagesOn: notebook.
shell realizeWidget
createPagesOn: aNotebook
"Create some pages on the given notebook."
| basePage |
"Create the page that will define the widgets used by all pages."
basePage := aNotebook
createPage: 'basePage'
argBlock: [:w | w tabLabel: 'Object'].
basePage manageChild.
basePage
addCallback: XmNpageEnterCallback
receiver: self
selector: #pageEnter:clientData:callData:
clientData: 'Object'.
list := basePage
createList: 'list'
argBlock: [:w | w
topAttachment: XmATTACHFORM;
rightAttachment: XmATTACHFORM;
leftAttachment: XmATTACHFORM;
bottomAttachment: XmATTACHFORM].
list manageChild.
"Create the rest of the pages."
#('Behavior' 'ClassDescription' 'Class' 'Metaclass') do: :name |
| aPage |
aPage := aNotebook
createPage: name
argBlock: [:w | w tabLabel: name]
sharingWith: basePage.
aPage
addCallback: XmNpageEnterCallback
receiver: self
selector: #pageEnter:clientData:callData:
clientData: name;
manageChild]
pageEnter: widget clientData: clientData callData: callData
"A notebook page has just been brought to the front. Fill in its values."
list items:
((Smalltalk at: clientData asGlobalKey) selectors collect: [
:s | s asString])
Last modified date: 12/21/2017