home *** CD-ROM | disk | FTP | other *** search
- sc.m and sctext.m: scrolling windows. [see also: textview.e]
-
- The object `scrollwin' contained in sc.m is a general purpose window with
- scrollbars that will display any items of information. `scrolltext' in the
- module sctext.m inherits from scrollwin and implements a scrolling window with
- text. It is very easy (and encouraged) to inherit from either of these
- objects and implement your own scrolling windows (EDBG, for example, uses two
- further objects that inherit from scrolltext and display memory/registers).
-
- members and methods of OBJECT scrollwin:
-
- NEW scrollwinptr.open(title,x,y,sx,sy,screen=NIL,ownidcmp=0,ownhandle=NIL)
-
- The constructor is called with some obvious arguments. With ownidcmp you can
- for example attach menus to the window. ownhandle is a callback PROC with one
- arg (the intuimessage). Will raise "scrl" if it can't get what if wants
- (window etc.).
-
- quit:=handle()
-
- will handle messages to the window. May call your callback or some of the
- extra_ methods below. If quit=TRUE the user clicked the close gadget.
-
- END scrollwinptr
-
- closes the window.
-
- refreshwindow()
-
- refresh the window manually if you change something about the data
- represented. normally this is done by the window automatically.
-
- The extra_ methods are the ones you are supposed to override to implement the
- display of the actual data (if you just want to use scrolltext, skip these):
-
- extra_init(screen)
-
- called from open(). Do any initialisations here if you wish.
-
- extra_exit()
-
- same for end().
-
- px,py:=extra_unit()
-
- called by the object when it wants to know how big the items being displayed
- are (i.e. (1,1) for pixels, (fontwidth,fontheight) for text etc.). The
- default method returns (1,1).
-
- ux,uy:=extra_max()
-
- called by the object to ask the number of objects being displayed. this
- should be somewhere between (1,1) and (32767,32767).
-
- extra_refresh(x,y,xsize,ysize,xoff,yoff,win:PTR TO window)
-
- The core. This method is called when the area of your data denoted by
- (x,y,xsize,ysize) is currently visible (problably because the user scrolled it
- there), and needs to be rendered. Note that these four numbers are in units
- of your data, not pixels! You can use `win' to render the data, from (pixel)
- offsets (xoff,yoff) in the window.
-
- As an example, say you're displaying a text with a font of 8x8 pixels, the
- text has 100 lines and 80 columns. The user has resized the window such that
- it has space for 10 lines of text and 40 columns, and scolled to the middle of
- it. The call will then look like (for example):
-
- extra_refresh(20,45,40,10,12,4,win)
-
- the area to be rendered is thus (320,80) in size. Of course you can optimize
- refreshing by using scrolling instead of re-rendering, you should implement
- this yourself though (scrolltext does that).
-
- ux,uy:=where(px,py)
-
- finds the element denoted by those (pixel) coordinates, as you might receive
- them in an intuimessage on a mouse click. The returned 2 coordinates take
- care of position of the scrollers and unit size.
-
- settop(newtop=0,dorefresh=TRUE)
-
- manually sets the top of the area being displayed. do not use too often
- as it might confuse the user.
-
- window:PTR TO window
-
- the only instance variable. careful when using this.
-
- The scrolltext object inherits from scrollwin. You should call open / handle
- / end etc. on it as usual. scrollwin redefines the extra_ methods of
- scrollwin to implement text-specific scrolling. Following methods are added:
-
- settext(textlist,width)
-
- The constructor for this object. textlist should be an E list of
- nil-terminated strings. width is the maximum width to display, i.e. usually
- the maximum width of these strings. Call open() as the first method after
- this one.
-
- active(cur,dorefresh=TRUE)
-
- Will set the current active line. This will be graphically marked by inverting the
- line. If this method is never called there will be no active line display.
-
- uy:=getactive()
-
- asks what the currently active line is.
-
- as an example of all this, please see the extremely simple textview.e
-