[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating a new gfxobj




Guido.Bosch@loria.fr (Guido Bosch) writes:
=> [ description of {editor-view}:scheme-editor deleted ]

=> Now I want to write a `create' method that just does the same
=> default initialization as `{editor-view}:create' for the {editor-view}
=> part, and may be some other initialization for the new slots. 
=> How can I reuse the {editor-view} initialization for my new object
=> type?

It is true that for all the gfxobjs, the create methods are not directly
reuseable.  That's because, typically, the create method takes all the 
necessary info (for the structure) and *returns* the object created.  So you 
can't just do a new of '{scheme-editor} and hope to pass that to the 
{editor-view}:create function to do the initialization.  That said, it should
be noted that most create methods take advantage of the function make-gfxobj
(Cf. The Core, Volume 3: "Graphical Objects within Centaur" pg 19) to do the 
necessary object-window coupling at the outermost level. 

However, i am unsure what makes your object a new *gfxobj*.  If you don't
change the image (the graphical aspects) or the behavior (NB: the editor-view
is a container object and does *not* have a behavior for mouse events since
all the subobjects receive the events), then perhaps you just want to create
an object that couples your data to an {editor-view}.  Then the {scheme-editor}
create function just calls {editor-view}:create and stores it in a field.
(Actually you would call the function make-ctview mentioned below if what you
 want is a ctedit in your editor-view.)

If you are sure the way to go is to have {scheme-editor}:create copy the
{editor-view}:create then here's a start for your function:

(de {scheme-editor}:create (obj frame <your-additional-data>)
    (let ((ed (new '{scheme-editor}))
	  (image)(w)(h)
	  )
	 ;; Takes apart the {view-frame} object passed as parameter
	 ({editor-view}:set-components ed obj frame) 
	 ;; Decide what's in your structure sizing all the pieces
	 (setq image ({editor-view}:compute-image ed))
	 (setq w (send 'display-width image))
	 (setq h (send 'display-height image))
	 ;; The image is a generic gfxobj with the computed image inside
	 (make-gfxobj ed 0 0 w h ({gfxobj}:create 0 0 w h image))
	 ;; Making all the subparts visible for when ed is eventually mapped.
	 (send 'show (send 'head-banner ed))
	 (send 'show (send 'button-column ed))
	 (send 'show (send 'scroll-object ed))
	 (send 'show (send 'frame ed))
	 ed))


This done, you now have all the necessary structure but nothing on the screen.
Note that users, if they want to create instances of ctviews do *not* call 
{editor-view}:create.  What is provided are the two functions make-ctview and 
make-clipview.  (Cf. Mantle, Volume 2: "The User Interface Manual" pg 15)

This provides the connection for creating the ctedit, attaching the necessary
resource information for the eventual display structure of the ctedit, and 
building a communication network that is used by the ctedit.  This code is
in a state of flux that represents a move from an old-style customization to
the use of resources for such personalizations.  i hope to change this for 
version 1.3, thus what follows is an at-your-own-risk proposition.

NB: we will continue to provide make-ctview and make-clipview functions and 
these will be maintained.  That is, we provide a way for the user to create
all the auxillary ctview objects he wants.  However, in the code below things
like "new-initialzie-ctedit", "{ctedit}:parameters", are marked for removal.

With all the warnings out of the way :-), here's your equivalent convenience 
function to have your new {scheme-editor} on the screen.  

(de make-scheme-view ()
    (lets ((ct (new-initialize-ctedit (copy {ctedit}:parameters)))
	   (se ({scheme-editor}:create ct (circopy {ctview}:frame)))
	  )
	 ({ctedit}:set-query ct
			     ({query}:build ({query}:null)
					    #:centaur:core-name
					    "Centaur" ))
	 (send 'MapRequest (current-manager) ct se)
	 se))


Hope this helps.  i tested it "chez moi".  Got a scheme-editor on the screen
where i could read in and edit my favorite metal program.  

	see you 
	janet