(modulediva-panelmzscheme
(require (lib"etc.ss")
(lib"list.ss")
(lib"class.ss")
(lib"plt-match.ss")
(lib"mred.ss""mred")
(lib"framework.ss""framework")
"voice-message.ss""diva-central.ss")
(providediva-panel:frame-mixin)
;;
;; TABS
;;
;; Here we are handling the tabs for the 300 versions of DrScheme.
;; Have a look at an example. We are considering the definitions window.
;; The definitions window is made of two classes, the canvas one and the text one.
;; The canvas stands for the containing box, the window,
;; and the text stands for the content of the window, i.e. the Scheme code which is currently edited.
;; When we are switching from a tab to another one, DrScheme changes only the content of the definitions window,
;; that is the text object. Thus in facts the field of the canvas object of the definitions window which knows
;; what to draw is replaced by the text object of the tab getting the focus.
;; There is a little problem/bug: in the documentation, set-editor takes two arguments
;; (send an-editor-canvas set-editor edit redraw?) -> void
;; but when DrScheme starts, it tells us that the method set-editor takes only one argument... :-(
;; A work around of that is our overriding method can accept two arguments,
;; but call the super one with only one.
;; So what we want here is when we are switching from a tab to another one,
;; to save the current Diva-state of the window so that when we are coming back, the window is as we left it.
;; Thus, two things to be done:
;; * save the current Diva-state
;; * restore the Diva-state of the new content.
;; NB: we have to test if the previous edit and the new are not false because they can be so.
;; for instance, when DrScheme starts, the canvas is made before the text, so the first value is false for the current edit.
(define (diva-panel:frame-mixinsuper%)
(classsuper%
(inherit;get-canvas
;caret-hidden?
;blink-caret
get-diva-centralget-area-container)
(super-instantiate ())
(definearea (get-area-container))
;; defining and adding the container of the DivaStuffs.
(definediva-container-panel
(newvertical-panel%
[parentarea]
[stretchable-heightfalse]
[stretchable-widthtrue]))
(define (diva-displayed?)
(memberdiva-container-panel (sendareaget-children)))
(define/public (diva-panel-show)
(diva-label"DivaScheme: command mode")
(diva-message"")
(unless (diva-displayed?)
(sendareachange-children (lambda (children) `(,@children,diva-container-panel)))))
(define/public (diva-panel-hide)
(when (diva-displayed?)
(sendareachange-children (lambda (children) (remqdiva-container-panelchildren)))))
;; The Voice Label, Message and Question Panel.
(definediva-label/message/question-panel
(make-objectvoice-label/message/question-panel%diva-container-panel))
(define/public (diva-labellabel)
(senddiva-label/message/question-panelvoice-labellabel))
(define/public (diva-messagemessage . args)
(send/applydiva-label/message/question-panelvoice-messagemessageargs))
(define/public (diva-questionquestiondefaultcancelanswer)
(senddiva-label/message/question-panelvoice-questionquestiondefaultcancelanswer))
;; Initially, hide the panel.
(diva-panel-hide))))