Article View: comp.windows.x
Article #37446Re: Toolkit decisions (was: XView v. other toolkits, advice
From: Niels Mayer
Date: Tue, 27 Feb 1990 21:47
Date: Tue, 27 Feb 1990 21:47
104 lines
4390 bytes
4390 bytes
In article <9002261946.AA00365@snowking.Eng.Sun.COM> tomj@eng.sun.COM (Tom Jacobs) writes:
>Mike, the concept of a toolkit being object-oriented is not strictly
>limited to Smalltalk-style environments. XView is an object-oriented
>system with static subclassing. This simply means that the heirarchy
>of classes need to be defined at compile time (the same is true of the X
>Intrinsics).
This is probably drifting off the original topic (what was it anyways?)...
Since we're talking about using OOP with Xt and/or Xview, I thougt I'd
throw this in:
WINTERP uses XLISP's OOP extension to allow the instantiable Motif widgets
to be subclassed "dynamically". XLISP's OOP extension is somewhat
smalltalk-like. WINTERP uses the C-implemented Motif widgets but makes
them look like XLISP objects, which can be subclassed. You can also add
and/or override "methods" on widget classes (for example, adding a
:FIND-FILE method to the XM_TEXT_WIDGET_CLASS)...
Here's a trivially simple example of using a subclassed widget in WINTERP
in order to simplify the use of a "radio box" selection mechanism:
; -*-Lisp-*-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; File: radiobox2.lsp
; RCS: $Header: radiobox2.lsp,v 1.1 89/11/25 04:00:36 mayer Exp $
; Description: A better (?) way of creating a radio box, using subclassing of
; togglebutton. Note that this version doesn't waste as much
; memory as radiobox1.lsp because it defines a single
; entry-callback on the rowcolumn widget instead of forcing each
; toggle-button to have separate copies of very similar
; callback-closures. Just load this file to see the example.
; Author: Niels Mayer, HPLabs
; Created: Sat Nov 25 01:24:00 1989
; Modified: Sat Nov 25 01:26:42 1989 (Niels Mayer) mayer@hplnpm
; Language: Lisp
; Package: N/A
; Status: X11r4 contrib tape release
;
; (c) Copyright 1989, Hewlett-Packard Company.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq toplevel_w
(send TOP_LEVEL_SHELL_WIDGET_CLASS :new
:XMN_GEOMETRY "500x500+1+1"
:XMN_TITLE "Radio-Box-Test #2"
:XMN_ICON_NAME "Radio-Box-Test #2"
))
(setq rowcol_w
(send XM_ROW_COLUMN_WIDGET_CLASS :new :managed :radio_box "rc" toplevel_w
))
(send toplevel_w :realize)
(send rowcol_w :set_callback :xmn_entry_callback
'(CALLBACK_ENTRY_WIDGET
CALLBACK_ENTRY_SET)
'(
(if CALLBACK_ENTRY_SET
(send CALLBACK_ENTRY_WIDGET :print-which-button)
)
))
;; make a subclass of XM_TOGGLE_BUTTON_GADGET_CLASS
(setq My_Toggle_Button
(send Class :new
'(button_name) ;a new ivar for this subclass
'() ;no class variables for subclass
XM_TOGGLE_BUTTON_GADGET_CLASS))
;; override XM_TOGGLE_BUTTON_GADGET_CLASS's instance initializer
(send My_Toggle_Button :answer :isnew '(name &rest args)
'(
(setq button_name name)
(apply 'send-super `(:isnew ,@args
:xmn_label_string ,name))
))
;; add a method that prints which button
(send My_Toggle_Button :answer :print-which-button '()
'(
(format T "option ~A selected\n" button_name)
))
;; put up 20 toggle buttons inside the radio-box/row-column manager
(do*
(;; local vars
(i 0 (1+ i))
)
(;; test and return
(eql i 20)
)
;; body
(send My_Toggle_Button :new (format nil "Button ~A" i) :managed rowcol_w)
)
-------------------------------------------------------------------------------
Niels Mayer -- hplabs!mayer -- mayer@hplabs.hp.com
Human-Computer Interaction Department
Hewlett-Packard Laboratories
Palo Alto, CA.
*
Technical Details
Message-ID:
<4882@hplabsz.HPL.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!lll-winken!ncis.tis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!hplabsz!mayerReferences:
<9002261946.AA00365@snowking.Eng.Sun.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!lll-winken!ncis.tis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!hplabsz!mayer From: mayer@hplabsz.HPL.HP.COM (Niels Mayer) Newsgroups: comp.windows.x Subject: Re: Toolkit decisions (was: XView v. other toolkits, advice Message-ID: <4882@hplabsz.HPL.HP.COM> Date: 27 Feb 90 21:47:46 GMT References: <9002261946.AA00365@snowking.Eng.Sun.COM> Reply-To: mayer@hplabs.hp.com (Niels Mayer) Organization: Hewlett-Packard Labs, Software Technology Lab, Palo Alto, CA. Lines: 104