Author Topic: CheckboxTree  (Read 6293 times)

quackerjeff

  • Community Member
  • Posts: 11
  • Hero Points: 1
CheckboxTree
« on: April 12, 2012, 11:17:49 PM »
OK, so I've narrowed down that I need to use or implement a CheckboxTree, but have no idea how to use it and assign it to a form component.  Does anyone have an idea how I need to get started to do this?

Thanks!

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: CheckboxTree
« Reply #1 on: April 13, 2012, 02:33:34 AM »
How did you determine that's what's required?
What are you trying to do with it?
Knowing more would help others give better answers, or suggest alternatives.

What I usually do would be to search for "CheckboxTree" under the macros\ directory of the SlickEdit installation, and examine how other macros use it.  It's a custom control for internal use by built in SE macros, but it isn't part of the Slick-C language per se, so it's not a documented component, and it probably isn't supported.

quackerjeff

  • Community Member
  • Posts: 11
  • Hero Points: 1
Re: CheckboxTree
« Reply #2 on: April 13, 2012, 09:59:33 AM »
The CheckboxTree is a base class derived by OptionsCheckboxTree and used by OptionsTree. If you go to "Tools -> Options", that Dialog Box uses a generic reusable form that if selecting "Export/Import Options" and choosing "Export Groups", will display the type of functionality I am trying to achieve.

Basically, I want to create the same functionality that the "Export Groups" has.  I want a TreeCtrl of check boxes such that if I click the parent checkbox it will automatically select it's children or unselect them. 

The code is hard to follow without having more knowledge of how the Slick-C language works when tying it to forms.  Also, it seems all of the docs and demos don't show  "Object Oriented" Slick-C, just procedural.

So, I discovered all of this by doing the research in the macros directory, but can't seem to get a grasp.
I have a form "gsform" that I designed with a TreeCtrl "ctltree1".  Here's what I have so far:


#pragma option(pedantic,on)
#region Imports
#include "slick.sh"
#require "sc/controls/CheckboxTree.e"
#require "se/options/ExportImportGroupManager.e"
#require "se/options/RelationTable.e"
#import "optionsxml.e"
#import "stdprocs.e"
#import "treeview.e"
#endregion

namespace se.options;

using namespace sc.controls.CheckboxTree;
defeventtab gsform;
void gsform.on_create()
{
    _control ctltree1;

    CheckboxTree cbTree (p_active_form._find_control("ctltree1"));
    cbTree.getWindowID()._TreeAddItem(0, "HELLO", TREE_ADD_AS_CHILD, 0, 0);
    cbTree.getWindowID()._TreeAddItem(1, "GOODBYE", TREE_ADD_AS_CHILD, 0, 0);
    cbTree.getWindowID()._TreeAddItem(1, "CIAO", TREE_ADD_AS_CHILD, 0, 0);
}


void ctlcancel.lbutton_up()
{
    _message_box("CANCEL");
    p_active_form._delete_window("");
}


void ctlok.lbutton_up()
{
    _message_box("OK");
    p_active_form._delete_window("done");
}


I just don't see any checkboxes, etc with my tree elements.

Thanks!

Graeme

  • Senior Community Member
  • Posts: 2821
  • Hero Points: 347
Re: CheckboxTree
« Reply #3 on: April 13, 2012, 11:07:19 AM »
I don't know what all that CheckboxTree code is for but as I mentioned here
http://community.slickedit.com/index.php/topic,7842.msg33491.html#msg33491

you should be able to see what to do by looking in gnucopts.e and searching for ctlWarningsTree.
I think you just use an ordinary _tree_view and you get checkboxes just by assigning the appropriate images for each node of the tree.  Have a look at _TreeSetCheckboxValue in gnucopts.e.
In stdcmds.e you can see this
      _pic_treecb_checked=load_picture(-1,'_cbck.bmp');
which is the image for the "checked" checkbox.
Search sysobjs.e for _cbck.bmp and you'll see some of the other forms that have "checkbox trees".

In slickedit, click help -> macro functions by category, then in the right hand pane near the bottom you'll see tree view events, methods and properties.  This is the "supported" API for the treeview  - although there's no tutorial in the help on how to use it but you can look at examples in the slick macro source e..g in gnucopts.e there is this

Code: [Select]
int ctlWarningsTree.lbutton_up,' '()
{
   int index = _TreeCurIndex();
   if(index > 0) {
      // get the bitmap information in the tree
      int pic, state, arrayIndex, value;
      _TreeGetInfo(index, state, pic);
      arrayIndex = _TreeGetUserInfo(index);

      // toggle the picture
      if(pic == _pic_treecb_checked) {
         pic = _pic_treecb_unchecked;
         value = 0;
      } else {
         pic = _pic_treecb_checked;
         value = 1;
      }

      _TreeSetInfo(index, state, pic, pic);

Graeme

  • Senior Community Member
  • Posts: 2821
  • Hero Points: 347
Re: CheckboxTree
« Reply #4 on: April 13, 2012, 11:21:05 AM »
To create a form with a treeview on it, go to macro on the main menu, then "new form" to open the form designer.  In the properties dialog. give the form a name.  Also in the properties dialog, click the tree control image (bottom right) from the list on the left, then on the form, click and drag to create whatever size treectrl you want.  In the properties dialog, give the treectrl a name.  Then double click on the tree control on the form and you can then create an event handler for the tree control  - e.g. select on_create and you'll be asked for the name of the file for where the code should go.  Go back to the form you created, then right click and select save, then close the form.  To open the form in design mode again, use macro menu -> open form  (or press Ctrl+Shift+Space when the form is active/showing).  To save the form in "source form", create a new slick c file of your own, and use macro menu -> "insert form or menu source" and you'll see the source code for your form.

Also, in the slick c installation docs folder, have a look at SlickCMacroBestPractices.pdf

Graeme

quackerjeff

  • Community Member
  • Posts: 11
  • Hero Points: 1
Re: CheckboxTree
« Reply #5 on: April 15, 2012, 12:02:01 PM »
Here's the deal, Graeme, I don't have those chck bmp's and and source is different for me.
I am developing this Macro on SlickEdit for Mac Native and low and behold, the source for
those macros are different.  My Linux version has everything that you have stated, but the Mac version doesn't.  The gnucopts.e for mac doesn't have the ctlWarningsTree.lbutton_up
where as the linux version does.  Maybe now you see why I having so much struggle.

Hmmm...does that me one macro cannot work on the other platforms?

Graeme

  • Senior Community Member
  • Posts: 2821
  • Hero Points: 347
Re: CheckboxTree
« Reply #6 on: April 15, 2012, 01:05:00 PM »
mmm, ok.  I'll try and find time to download the beta version of V17 for windows that has the QT framework and have a look.  You could try creating a GNU C++ test project and then open the GNU options dialog (an option to run it turns up in the build menu).  You could maybe trying opening the _gnuc_options_form in design mode  -  on the macro menu click "open form" and look for _gnuc_options_form and see what the name of the treeview component is.

I've been previously told that all the slick c widgets and properties will be the same in the QT version of slickedit as in previous slickedit so I'm not sure why gnucopts.e doesn't have cltWarningsTree any more.



quackerjeff

  • Community Member
  • Posts: 11
  • Hero Points: 1
Re: CheckboxTree
« Reply #7 on: April 15, 2012, 01:18:00 PM »
It has the same variable, but just not the lbutton_up event and a few more differences.

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: CheckboxTree
« Reply #8 on: April 15, 2012, 05:35:40 PM »
Looks like the tree view has built in support for checkboxes now.

See use of _TreeGetCheckState and _TreeSetCheckState in gnucopts.e.

Also it looks like here's what lbutton_up was replaced with:

Code: [Select]
int ctlAdvancedTree.on_change(int reason,int index)
{
   switch ( reason ) {
   case CHANGE_CHECK_TOGGLED:
      advancedTreeCheckToggle(index);
      break;
   }
   return 0;
}

quackerjeff

  • Community Member
  • Posts: 11
  • Hero Points: 1
Re: CheckboxTree
« Reply #9 on: April 15, 2012, 10:44:31 PM »
Yes, they do, and wouldn't you know TreeSetCheckState is not documented in my SlickEdit List of Macro by Categories.  So, thanks a million for this.  Now, I just have to figure out how to index my child nodes a little further than the default and show some sort of arrow for parent nodes.  Any ideas there?