[racket] Embedding DrRacket

From: Jukka Tuominen (jukka.tuominen at finndesign.fi)
Date: Wed Nov 3 08:27:58 EDT 2010

That does great job hiding the middle panel, thanks! (see below the updated code). However, that either wasn't what I really was after. Sorry for not being able to explain it well.

I'm trying to embed the full featured DrRacket GUI inside the middle panel. Including menus, toolbars, definition field, (possibly interaction field), search/replace bar, statusbar (anything missing?). Have the shortcuts, drag-and-drops working, etc. If necessary, the menus could go under a menu button, like [define..] in DrRacket's toolbar.

I try to explain the reason behind a little. I have an app that can browse through objects of different kind. For a text object, I would embed a text editor in the middle panel. In case of a scheme object, I would embed a full-powered and self-sufficient scheme editor, i.e. DrRacket. You could then edit, debug, and save the change on the spot without ever leaving the app or opening extra views.

Building a DrRacket plugin isn't desirable either, since most times you would just view a random, non-scheme object without editing it.

I hope this explains my (not so small) challenge a bit better.

br, jukka

;; Improved Version 
((lambda ()
   
   (define frame
     (new frame%
          (parent #f)
          (label "Embedded Editor")
          (border 5)
          (min-width 400)
          (min-height 225)))
   
   (define vertical-panel-top
     (new vertical-panel%
          (parent frame)
          (style '(border))))
   
   ;; Replace the following definition
   (define vertical-panel-editor
     (new vertical-panel%
          (parent frame)
          (style '(border))))
   
   (define vertical-panel-bottom
     (new vertical-panel%
          (parent frame)
          (style '(border))
          (alignment (list 'center 'bottom))))
   
   (define button-evaluate
     (new
      button%
      (parent vertical-panel-bottom)
      (label "Hide Editor")
      (callback (lambda (button event)(send frame change-children (lambda (l) (remq vertical-panel-editor l)))))
      (style '())
      (enabled #t)
      (vert-margin 2)
      (horiz-margin 2)
      (min-width 0)
      (min-height 0)
      (stretchable-width #f)
      (stretchable-height #f)))
   
   (send frame show #t)))

> -----Original Message-----
> From: robby.findler at gmail.com [mailto:robby.findler at gmail.com]On Behalf
> Of Robby Findler
> Sent: 03 November 2010 13:34
> To: Jukka Tuominen
> Cc: users at racket-lang.org
> Subject: Re: [racket] Embedding DrRacket
> 
> 
> I think I misunderstood your original query.
> 
> You can't change the parent, but you can tell a parent not to show a
> child by calling the change-children method. Something like this in
> your code:
> 
> (send frame change-children (lambda (l) (remq vertical-panel-editor l)))
> 
> Robby
> 
> On Wed, Nov 3, 2010 at 5:00 AM, Jukka Tuominen
> <jukka.tuominen at finndesign.fi> wrote:
> >
> > Thanks Robby,
> >
> > I'll look into your suggestion. I'm still hesitating whether I 
> will manage with my very limited skills to gather all pieces one 
> by one, and have them actually working smoothly with each other 
> Like DrRacket does. This is very uncertain terrain to me. 
> Preferably, I had something I could just place between two panels 
> and change the parent to point to one level up. And it should run 
> inside a lambda, not leaving any assignments behind. Something like this:
> >
> >
> > ((lambda ()
> >
> >   (define frame
> >     (new frame%
> >      (parent #f)
> >      (label "Embedded Editor")
> >      (border 5)
> >      (min-width 400)
> >      (min-height 225)))
> >
> >   (define vertical-panel-top
> >     (new vertical-panel%
> >      (parent frame)
> >      (style '(border))))
> >
> >   ;; Replace the following definition
> >   (define vertical-panel-editor
> >     (new vertical-panel%
> >      (parent frame)
> >      (style '(border))))
> >
> >   (define vertical-panel-bottom
> >     (new vertical-panel%
> >      (parent frame)
> >      (style '(border))))
> >
> >   (send frame show #t)))
> >
> >
> > Is there any solution to this, you could think of?
> >
> >
> > br, jukka
> >
> >
> >> -----Original Message-----
> >> From: robby.findler at gmail.com [mailto:robby.findler at gmail.com]On Behalf
> >> Of Robby Findler
> >> Sent: 03 November 2010 02:10
> >> To: Jukka Tuominen
> >> Cc: users at racket-lang.org
> >> Subject: Re: [racket] Embedding DrRacket
> >>
> >>
> >> Try just using frame:standard-menus% in place of frame%. You will need
> >> to change the parents of any panels you create from the frame to the
> >> result of calling the get-area-container method (you'll get an error
> >> that points you in the right direction).
> >>
> >> That may not be exactly all of the right menus, but hopefully that'll
> >> get you started.
> >>
> >> Robby
> >>
> >> On Tue, Nov 2, 2010 at 6:25 PM, Jukka Tuominen
> >> <jukka.tuominen at finndesign.fi> wrote:
> >> >
> >> > Hi,
> >> >
> >> > I have made a lambda function that draws a frame with several
> >> panels. Now,
> >> > I've been trying to figure out how to embed DrRacket's 
> GUI/functionality
> >> > inside one of these panels, so I could show/hide it as 
> needed. The way
> >> > DrRacket gathers all bits and mixins in the initializing 
> process, seems
> >> > overwhelming to me (I'm not a programmer). I managed to get a simple
> >> > scheme:text% editor working, which does some of the things I 
> need, but I
> >> > really need fully functional IDE in order to avoid constant 
> copy/pasting
> >> > between this app and DrRacket.
> >> >
> >> > As far as I have understood, the menus require frame as their
> >> parent, but is
> >> > there a way to create a bundle of some kind I could just give a
> >> panel as a
> >> > parent?
> >> >
> >> > Any help is greatly appreciated.
> >> >
> >> > br, jukka
> >> >
> >> >
> >> > |  J U K K A   T U O M I N E N
> >> > |  m a n a g i n g   d i r e c t o r  M. A.
> >> > |
> >> > |  Finndesign  Kauppiaankatu 13, FI-00160 Helsinki, Finland
> >> > |  mobile +358 50 5666290
> >> > |  jukka.tuominen at finndesign.fi  www.finndesign.fi
> >> >
> >> >
> >> > _________________________________________________
> >> >  For list-related administrative tasks:
> >> >  http://lists.racket-lang.org/listinfo/users
> >> >
> >>
> >
> > _________________________________________________
> >  For list-related administrative tasks:
> >  http://lists.racket-lang.org/listinfo/users
> >
> 



Posted on the users mailing list.