Author Topic: Is there a way to make my own dockable tool window?  (Read 7129 times)

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Is there a way to make my own dockable tool window?
« on: March 10, 2008, 11:15:37 PM »
Q:  Is there a way to create a form (or some other window/thing) that can dock like the built in dockable windows do?

I'm getting started with SlickEdit, and am starting to write a bunch of macros to customize the editor to my liking.  I am thrilled at how customizable the editor is.  Ideally, I'd like to write my own dockable tool window to replace the built in Preview window.

Specifically, the Preview window isn't laid out quite how I'd like, and there is too much unused screen real estate for my liking.  Ideally maybe the SlickEdit folks can have an option to select the layout I'd like (which I'll describe in a moment), but even if that is added, I am still very interested in being able to create my own dockable forms to extend the editor more elegantly.

Current Preview Layout:  So first, here is how the Preview window is currently laid out:

Code: [Select]
+-----------------------------------------------------------------+
| Preview                                                     [X] |
+-------------------+----------------------------------------+----+
| symbol1           | filename                               |    |
| symbol2           +----------------------------------------+    |
|                   | comments                               |Tool|
|                   |                                        |bar |
|                   |                                        |    |
+-------------------+----------------------------------------+    |
| source                                                     |    |
+------------------------------------------------------------+----+

The vertical toolbar on the right has some dead space above it and also gets cut off on the bottom at the default height, the source portion of the window is very small (it can be resized, but doing so takes away from the main editing area, of course), the comments portion is big, the filename above it takes up a lot of space, and the symbols portion frequently is mostly blank due to short symbol lists.

Desired Alternative Layout:  So here is an alternative that I imagine, and would like to code up myself if there is a way to make my own dockable tool windows, or perhaps see a variation of this built into the editor:

Code: [Select]
+-----------------------------------------------------------------+
| Preview - filename                                          [X] |
+-------------------+----------------------------------------+----+
| symbol1           | source or comments                     |Tool|
| symbol2           |                                        |bar |
|                   |                                        |    |
|                   |                                        |    |
|                   |                                        |    |
|                   |                                        |    |
|                   |                                        |    |
+-------------------+----------------------------------------+----+

And the "source or comments" pane could have four modes:  only source, only comments, auto, both.  The "auto" mode would show a comment if one exists, otherwise show the source.  The "both" mode would show a comment window above a source window.  Personally I would use the "only source" mode.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Is there a way to make my own dockable tool window?
« Reply #1 on: March 11, 2008, 12:06:34 AM »
You could try this patch which is already there: http://community.slickedit.com/index.php?topic=2396.msg9972#msg9972
Maybe you can also use it as starting point for your further enhancements. Please post the result when it's done - sounds promising !
HS2

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Is there a way to make my own dockable tool window?
« Reply #2 on: March 11, 2008, 01:43:14 AM »
Awesome, thanks very much.

I found this too http://community.slickedit.com/index.php?topic=463.msg1882#msg1882, which says how to create a toolbar based on a form, and the custom toolbar can indeed be dockable.

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Is there a way to make my own dockable tool window?
« Reply #3 on: March 11, 2008, 10:48:07 AM »
Something else you might be interested to know about is clipboard inheritance - look for "clipboard inheritance" in the help index.  Using clipboard inheritance you can do something like this.

1. Using the form designer, create a new form of your own (on the Macro menu select new form), leave it empty but save and close it.

2. Open the preview toolbar and with the focus on this toolbar, press Ctrl-Shift-Space.  The form for the toolbar will open in "designer mode"  - you can change the look of the form in this mode (you shouldn't do that though).  In the properties dialog you can see the name of the form is _tbtagwin_form.  Double click one of the buttons on the form and select the lbutton_up event and you should be taken to the relevant event handler code in the tagwin.e module.

3. With the focus on the _tbtagwin_form in design mode (title bar shows "Preview"),  press Ctrl A - all widgets on the form should appear as selected.  Press Ctrl C to copy the contents of the form.

4. Close the _tbtagwin_form and open your own previously created form in the form designer (or create a new one right now) and with the focus on your new form, press Ctrl V.  All the widgets from the tagwin form will be pasted to your own form and the event handlers for your own form will use the event handlers for the tagwin form which use the code in tagwin.e.

5. Now you can modify your own form to your hearts content without affecting the original tagwin form  - however, if you want to modify tagwin.e, you might want to create your own copy.


To see the event handlers for your own form, open an empty file and use the "insert form or menu source" option on the macro menu.  The source code corresponding to your form will appear (you can also see it in vusrobjs.e in your config folder).  If you inspect it you will see several lines similar to the following
      p_eventtab=_tbtagwin_form.ctltaglist;

This shows that the event handler for the ctltaglist treeview uses the event handler for the ctltaglist treeview on the _tbtagwin_form.

If you copy tagwin.e from the slick "macros" installation folder to your own config folder and load it, your file will replace the installation tagwin.e file.  Any time you want to revert to the installation tagwin.e, just browse to it and use "load module" from the macros menu.  The problem with creating your own version of tagwin.e is that when an upgrade comes along, your version of tagwin.e might no longer be compatible  - you might be able to track the changes to the installation tagwin.e though, and apply them to your own file.

Copying the existing tagwin form isn't necessarily the best way, but something to think about.

Graeme