Author Topic: Automatically adding a toolbar form  (Read 4783 times)

byates

  • Senior Community Member
  • Posts: 106
  • Hero Points: 8
Automatically adding a toolbar form
« on: March 21, 2009, 07:22:31 PM »
Does anyone know how to make a macro that will install a user toolbar form?  I have several custom toolbars that I have to manually install each time I do a clean install of SE (View->Toolbars->Customize...).   I have looked through the stock macros, and the closest function I could find was _tbAddForm().  It doesn't seem to be used anywhere, and when I try it, my form is added to the toolbar menu, but it is displayed incorrectly.  All of the buttons are missing.

Thanks!

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Automatically adding a toolbar form
« Reply #1 on: March 21, 2009, 08:32:18 PM »
As of SE 2008 there was no API to do that.  The only way is to examine the native macro code that creates toolbars, and do the same things yourself (there seems to be a lot of stuff and it's a little bit involved).  I haven't personally done so, because I don't want to have to maintain a custom CreateToolbar function as the editor changes over time.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Automatically adding a toolbar form
« Reply #2 on: March 22, 2009, 08:12:43 AM »
I've been using a batch macro as you see in the code below to re-create my toolbars.  If you look in vusrdefs.e and search for def_toolbartab, you'll see where it stores your toolbar info.  If you look in tbprops.e, at the ctlnew.lbutton_up() function, you'll see code that does a similar thing with def_toolbartab.  To execute a batch macro, you just type it's name on the slick command line - you don't prefix it with "load".  To get vusrdefs.e updated, you have to change some other configuration setting - possibly calling _config_modify_flags in the batch macro would save having to do that but I've never bothered.

Normally I would let slick create my toolbars just by running vusrdefs.e from an existing configuration, but due to a limit of approx 1048 characters in the def_macfiles string in vusrdefs.e, I usually manually edit vusrdefs.e and assign an empty string to def_macfiles, which means my toolbars don't get created because the associated forms don't exist.  Hence I load all my macros and toolbars "manually".  Slick 2009 has an export options feature but it doesn't look like it includes toolbars  - also, in slick 2009 release version, it currently doesn't work because it creates an invalid zip file for some reason.

Graeme


Code: [Select]
#pragma option(redeclvars,on)
#include 'slick.sh'
#include 'toolbar.sh'
#include 'cvs.sh'
#include 'subversion.sh'
#import "toolbar.e"

defmain()
{
  _TOOLBAR *p1__TOOLBAR;

  p1__TOOLBAR=&def_toolbartab[def_toolbartab._length()];
  p1__TOOLBAR->FormName='GFilemanForm1';
  p1__TOOLBAR->tbflags=14;
  p1__TOOLBAR->restore_docked=1;
  p1__TOOLBAR->show_x=8490;
  p1__TOOLBAR->show_y=4695;
  p1__TOOLBAR->show_width=6030;
  p1__TOOLBAR->show_height=5880;
  p1__TOOLBAR->docked_bbside=3;
  p1__TOOLBAR->docked_row=1;
  p1__TOOLBAR->docked_x=75;
  p1__TOOLBAR->docked_y=0;
  p1__TOOLBAR->docked_width=4545;
  p1__TOOLBAR->docked_height=11820;
  p1__TOOLBAR->tabgroup=3;
  p1__TOOLBAR->tabOrder=0;
  p1__TOOLBAR->auto_width=0;
  p1__TOOLBAR->auto_height=0;
  p1__TOOLBAR=&def_toolbartab[def_toolbartab._length()];
  p1__TOOLBAR->FormName='GFilemanForm2';
  p1__TOOLBAR->tbflags=14;
  p1__TOOLBAR->restore_docked=0;

  // etc ...

}