Widget creation convenience methods
Widgets might be created using convenience methods implemented as instance methods of CwWidget or as class methods of CwShell and its subclasses. These convenience methods are sent to the widget that will be the new widget's parent. As a shell does not need a parent, shell creation convenience methods are sent to the class. Convenience methods are provided to create the following:
• All of the standard widgets; for example, CwPushButton, CwList, and CwTopLevelShell
• Commonly used configurations of some standard widgets; for example, CwRowColumn widgets preconfigured for use as menus or radio boxes
• Special pseudowidgets that appear to be composite arrangements of standard widgets; for example, scrolled list and scrolled text. Due to platform optimizations, such pseudowidgets might not actually be implemented as composites of platform widgets
Because convenience methods do not automatically manage the widgets that they create, the new widgets must be explicitly managed after they are created. In addition, because some convenience functions actually create composite widget subtrees, the widget returned might not be a direct child of the widget the creation message was sent to. For an example of this, see
"Scrolled lists".
Tip:
Widgets can also be created by sending messages directly to the widget classes. However, widgets created in this way bypass normal initialization and configuration, and might have different behavior than widgets created using convenience functions. Always use the convenience function to create a widget, if one is available.
The code fragment below illustrates how to create a push-button widget using a convenience method. Top level shells are created by sending a message directly to the CwTopLevelShell class.
| shell button |
shell := CwTopLevelShell
createApplicationShell: 'shell'
argBlock: nil.
button := shell
createPushButton: 'Button1'
argBlock: nil.
button manageChild.
shell realizeWidget.
Some convenience methods do more than create a widget. For example, the createScrolledList:argBlock: method creates a pseudowidget that appears, in many respects, to be a scrolled window, scroll bars, and a list widget. The relationship between the scrolled window, the scroll bars, and the list is defined such that the list can be scrolled using the scroll bars of the scrolled window. The create operation returns the list widget, and is treated by the application as any other list widget. However, the widget system created is tightly coupled and on some platforms might be implemented using a single widget, to maximize performance and platform look and feel. For these reasons, the application should not attempt to reconfigure the "hidden" parts of such pseudowidgets.
Tip:
Do not attempt to reconfigure the "hidden" parts of pseudowidgets such as scrolled lists or scrolled texts. A scrolled text or list might be implemented using a single platform widget and might not behave in exactly the same way as a CwText or CwList created as a child of a CwScrolledWindow.
Following is a list of the shell widget creation convenience methods that are class methods of CwShell and its subclasses:
• createPopupShell:parent:argBlock:
• createApplicationShell:argBlock:
Following is a list of the widget creation convenience methods that are instance methods of CwWidget:
• createArrowButton:argBlock:
• createBulletinBoard:argBlock:
• createBulletinBoardDialog:argBlock:
• createCascadeButton:argBlock:
• createComboBox:argBlock:
• createDialogShell:argBlock:
• createDrawingArea:argBlock:
• createDrawnButton:argBlock:
• createErrorDialog:argBlock:
• createForm:argBlock:
• createFormDialog:argBlock:
• createFrame:argBlock:
• createInformationDialog:argBlock:
• createLabel:argBlock:
• createList:argBlock:
• createMainWindow:argBlock:
• createMenuBar:argBlock:
• createMessageBox:argBlock:
• createMessageDialog:argBlock:
• createOptionMenu:argBlock:
• createPopupMenu:argBlock:
• createPromptDialog:argBlock:
• createPulldownMenu:argBlock:
• createPushButton:argBlock:
• createQuestionDialog:argBlock:
• createRadioBox:argBlock:
• createRowColumn:argBlock:
• createScale:argBlock:
• createScrollBar:argBlock:
• createScrolledList:argBlock:
• createScrolledText:argBlock:
• createScrolledWindow:argBlock:
• createSelectionBox:argBlock:
• createSelectionDialog:argBlock:
• createSeparator:argBlock:
• createSimpleCheckBox:argBlock:
• createSimpleMenuBar:argBlock:
• createSimpleOptionMenu:argBlock:
• createSimplePopupMenu:argBlock:
• createSimplePulldownMenu:argBlock:
• createSimpleRadioBox:argBlock:
• createText:argBlock:
• createToggleButton:argBlock:
• createWarningDialog:argBlock:
• createWorkArea:argBlock:
• createWorkingDialog:argBlock: