MANUAL.COLORS(6) — OpenWindows 3.0
NAME
manual.colors − TNT Color Chooser demo
DISCLAIMER
This program is furnished on an AS IS basis as a demonstration of TNT applications programming.
SYNOPSIS
manual.colors
DESCRIPTION
Manual.colors is referred to by The NeWS Toolkit Reference Manual in the introduction. An overview of the program design may be found immediately preceding the program text. What follows here is a brief description of each section of the code. The subheadings that follow correspond to commented lines of the same name in the source.
PS-1:
A subclass of ClassCanvas is defined, with three instance variables to hold the hue, saturation, and brightness parameters of a color. The class also has a class variable, /TextFont, to hold a default font for the display string.
The /PreviewColor method will be called while a slider is being dragged. It takes a value and a control instance (one of the sliders) as arguments. The name is retrieved from the control, which will coincide with one of the canvas instance variables, and then the value is normalized and stored in that instance variable. The canvas is then repainted with /ShowColor
The /ChooseColor method first calls /PreviewColor , then prints a string representation of the current color in RGB and HSB models to the footer of the window.
The /ShowColor method calculates a starting point for drawing the display string, sets the current color from the canvas instance variables, and draws the string.
The /Paint method fills the background and paints the display string with /ShowColor
PS-2:
A window, color canvas, and control panel are craeted first. Then there is a forall loop over an array consisting of three names. Each name will be the name of a slider, and corresponds to the instance variable in the canvas of the same name. The canvas is set as the target of each of the sliders, and the previewer and notifier procedures of each slider are set to methods in the canvas subclass. Finally, each slider is given an initial value of 80.
Three labels are then created for the sliders.
PS-3:
The sliders are added to the control panel, using calculated layout. The Hue slider is positioned so that its northeast corner coincides with that of the parent panel. The Saturation and Brightness sliders are positioned so that the center of each slider’s top edge is 10 points below the center of the previous slider’s bottom edge. The labels are positioned so that the east edge of each label is 5 units to the left of the west edge of the corresponding slider, and aligned horizontally.
Finally, the panel and canvas are added to the window. The /addclient methods in the last two lines refer to the method inherited by windows from ClassBorderBag; see the chapter on ClassBorderBag in the Reference Manual.
PS-4:
The window is placed, activated, and mapped. See the discussion in the ClassCanvas chapter of the Reference Manual. The Local Event Manager process is placed in a new process group, and the connection established with psh is closed.
SEE ALSO
The NeWS Toolkit Reference Manual
NeWS 2.1 Programmer’s Guide
OPEN LOOK Graphical User Interface Functional Specification
NOTES
PostScript is a trademark of Adobe Systems, Inc.
NeWS is a trademark of Sun Microsystems, Inc.
OPEN LOOK is a trademark of AT&T.
Sun Release 4.1 — Last change: 03/07/91