Page 5 of 6

Re: Simple PropertyGrid

Posted: Sun Dec 30, 2012 12:50 am
by Guimauve
Hello everyone,

OK in the attempt to make SectionName milti-line compliant I have completely screwed up the Gadget relocating calculation. I will not give up on this just yet but it will take more time than expect. I will probably need to re-code differently this calculation system form the scratch. Just one question, about the section Open/Close button vertical position, in the case on multi-line Section name would you like to have the vertical alignment :

Code: Select all

       xxxxxxxxx
xxxxx  x
x + x  x Single line Section name
xxxxx  x
       xxxxxxxxx

       xxxxxxxxx
xxxxx  x
x + x  x Multi-Line Section name (Style #1)
xxxxx  x
       x
       x
       x
       x
       xxxxxxxxx
      
       xxxxxxxxx
       x
       x
xxxxx  x
x + x  x Multi-Line Section name (Style #2)
xxxxx  x
       x
       x
       xxxxxxxxx
Anyway and as requested, commands to Expand/Collapse specific or all sections. The V1.1.6 source code can be downloaded here : http://pages.videotron.com/gsaumure/fil ... Gadget.zip

Edit : A mistake I make on Expand/Collapse commands forced me to upgrade again to V1.1.7. The download link will remain the same and sorry for those you have already downloaded the V1.1.6.

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Mon Dec 31, 2012 1:19 am
by Andre
Hi Guimauve,

thanks a lot for your fast updates :-)

I wasn't able to fully implement the latest update (v1.1.7) into the GeoWorld enviroment and test the new functions. This will probably need 1-2 days until New Year...

For the multi-line section titles I would prefer the Style #1, as it looks more intuitive for me (similar to close buttons etc. always in the top-left corner). As you currently seem to have implemented the Style #2, I would be happy if you can provide the Style #1 at least as an optional flag...

The Expand/Collapse functions still need to be tested.

Re: Simple PropertyGrid

Posted: Tue Jan 01, 2013 2:40 pm
by Andre
Hi Guimauve,

after further testing, I can confirm that the new Expand/Collapse functions work as expected.
But there seems to a problem with collapsing section with listicon (maybe all larger gadgets?) included.

See the following screenshot with damaged display after collapsing:
Image

Btw... happy New Year! :D

Re: Simple PropertyGrid

Posted: Tue Jan 01, 2013 4:57 pm
by Guimauve
Hello Andre,

In fact the Expand/Collapse don't work at all except for the Open/Close Button, all gadget within the section remain visible while they should be hidden. I will try to do my best to solve this in the next 2 hours otherwise you will have to wait to the next week-end for the corrected code.

I think when this lib work as expected, I will have to make a choice between real life and programming. My current workload is simply to large to be handle by only one I have to cut somewhere.

And happy new year to all of you.

Edit : OK I got it in 25 minutes, now Expand/Collapse work as expected. The V1.1.8 source code can be downloaded here : http://pages.videotron.com/gsaumure/fil ... Gadget.zip

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Tue Jan 01, 2013 11:09 pm
by Andre
Thanks Guimauve for the latest update, expand/collapse work now fantastic! :-)

I fully understand, if you have other priorities... at least credits for your work are sure, as soon our project goes public.

Even if you don't have the time to add a possibility for placing the [+] in PropertySections higher than one line, according to my needs (want to put the [+] into the top-left corner of the section title - the Style #1 mentioned above), can you just give me a tip, where I can change this myself?

The reason, why I think the Style #1 would be 'more intuitive' / 'looking more logical' can (hopefully) be seen in the following screenshot, where the [+] looks a bit like placed at the "false" position:
Image

Thanks again!


///Edit///

I've extended the following procedure to offer also a test for all available sections, instead of only testing for one specified section (give -1 as parameter 'SectionNo'). Maybe someone can need it... Note: Declaring of this procedure earlier in the code is needed, because of their recursive use!

Code: Select all

Procedure GetPropertyGridSectionOpenCloseState(PropertyGridID, SectionNo)
  ; Function for checking one section (the given 'SectionNo') or all (-1 as 'SectionNo' parameter) property
  ; sections, if they are opened or not.
  ;- Testing for all sections by giving 'SectionNo = -1' added by Andre on 1st Jan. 2013
  
  Protected CurrentSection, NumberOfSections, SectionState, AllSectionsOpened = 1
  
  Protected *PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
  
  If *PropertyGridDataA <> #Null
    
    If SectionNo = -1
      
      NumberOfSections = GetPropertyGridSectionCount(PropertyGridID) - 1
      For CurrentSection = 0 To NumberOfSections
        SectionState = GetPropertyGridSectionOpenCloseState(PropertyGridID, CurrentSection)
        ;  SectionState can be: 1 = opened, 0 = closed, -1 = empty section
        ; Debug "'Section' " + Str(CurrentSection) + " has the state: " + Str(SectionState)
        AllSectionsOpened = AllSectionsOpened & SectionState
        ;  AllSectionsOpened will only be '1', if all sections are opened
      Next
      ProcedureReturn AllSectionsOpened
      
    ElseIf SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
      
      If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
        ProcedureReturn GetPropertyGridItemOpened(GetPropertyGridDataItems(*PropertyGridDataA))
      EndIf
      
    EndIf    
    
  EndIf
  
EndProcedure

Re: Simple PropertyGrid

Posted: Wed Jan 02, 2013 3:05 pm
by Guimauve
Hello Andre,

If you can wait to the next week-end by then I will be able to complete the new Position calculation system. For the command you have created, I will add it to the lib and give credit to you this addon.

A little off topic, for the moment I'm very buzy but it's just a transition phase. For the 3 or 4 comming week it will be very difficult for me to find time for programming. But after that everything should retrun to normal.

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Wed Jan 02, 2013 7:34 pm
by Andre
Hi Guimauve,
If you can wait to the next week-end by then I will be able to complete the new Position calculation system. For the command you have created, I will add it to the lib and give credit to you this addon.
Thanks :-)

It's no problem for me to wait a bit....

If you want to provide a very flexible solution for positioning the [+] button, I would suggest a new parameter to the section creation like this:

Code: Select all

Enumeration
  #P_SectionOpenClosePos_Top     ; Style #1, preferred by Andre
  #P_SectionOpenClosePos_Middle ; Style #2, actually implemented in v1.1.8
  #P_SectionOpenClosePos_Bottom
EndEnumeration

Procedure AddPropertyGridSection(PropertyGridID, SectionName.s, IsOpen.b = #True, P_SectionNameHeight = #PropertyGrid_DefaultItemHeight, P_SectionOpenClosePosition = #P_SectionOpenClosePos_Top)

Re: Simple PropertyGrid

Posted: Sat Jan 05, 2013 11:22 pm
by Guimauve
Hello everyone,

OK this week I'm finally be able to make thing to work but the position calculation system is the same as previous one except the addition of an extra constant for Section default height. Because on Linux many gadgets with height smaller than 30 pixels don't work very well, the ComboBoxGadget() is a very good example.

For the moment the Open/Close button are placed close to the top position of the Section name. The buttons is not vertically centred anymore. and I'm not sure if I really want to add other options. Also prototypes commands to Lock/Unlock section has been added to the lib, feel free to test and post back suggestions for improvement.

The V1.1.9 source code can be downloaded here : http://pages.videotron.com/gsaumure/fil ... Gadget.zip

Edit : I have completely forget to update the GetPropertyGridSectionOpenCloseState() done by Andre in version 1.1.9. So I have just uploaded the V1.2.0, the download link is the same.

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Mon Jan 07, 2013 11:40 pm
by Andre
Hi Guimauve,

thanks again for your update. I've included the new code into my project. All is working fine for my needs now! :D
I like the new place (top-left corner) of the open-close button.... it's the logical place I think and other options shouldn't be needed...

Please be aware to add following code at top of the code (without you will get a compiler error):

Code: Select all

Declare GetPropertyGridSectionCount(PropertyGridID)
Even if I don't need it myself for now, I've tested the new lock/unlock functions: They seem to work good, except the following (step by step for testing):
- one or more sections are already opened/expanded
- then the lock function is executed
- now the open-close button can still be clicked
- the section will not be collapsed correctly (the gadgets inside are still visible)

I think, that collapsing of the section(s) shouldn't happen (they should stay as they are, when the lock is done). But the click on the open-close button(s) shouldn't be processed then...


Furthermore I've changed the GetPropertyGridSectionCount() another time to fit my own needs, probably the following code is also interesting for other people and/or for including into the official package:

Code: Select all

Procedure GetPropertyGridSectionOpenCloseState(PropertyGridID, SectionNo)
  ; Function for checking one section (the given 'SectionNo') or all (-1 as 'SectionNo' parameter) property
  ; sections, if they are opened or not.
  ;- Testing for all sections by giving 'SectionNo = -1' added by Andre on 1st Jan. 2013
  ;  changed and improved on 4th Jan. 2013.
  
  Protected CurrentSection, NumberOfSections, SectionState
  Protected ClosedSections, EmptySections, OpenSections
  
  Protected *PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
  
  If *PropertyGridDataA <> #Null
    
    If SectionNo = -1
      
      NumberOfSections = GetPropertyGridSectionCount(PropertyGridID) - 1
      For CurrentSection = 0 To NumberOfSections
        SectionState = GetPropertyGridSectionOpenCloseState(PropertyGridID, CurrentSection)
        ;  SectionState can be: 1 = opened, 0 = closed, -1 = empty section
        ; Debug "'Section' " + Str(CurrentSection) + " has the state: " + Str(SectionState)
        Select SectionState
          Case -1 : EmptySections + 1
          Case 0  : ClosedSections + 1
          Case 1  : OpenSections + 1
        EndSelect
      Next
      ; Debug "Empty / Closed / Open sections: " + Str(EmptySections) + " / " + Str(ClosedSections) + " / " + Str(OpenSections) 
      
      If OpenSections > 0 And ClosedSections > 0
        ; => the CollapseAll button should be activated, and the ExpandAll should be too (because of still closed sections)
        SectionState = 4
      ElseIf OpenSections > 0 And ClosedSections = 0
        ; => the CollapseAll button should be activated, but the ExpandAll not (because there are no closed sections anymore)
        SectionState = 3
      ElseIf OpenSections = 0 And ClosedSections > 0
        ; => the CollapseAll button should be deactivated (because there aren't any opened sections), but the ExpandAll should be activated (because there are closed sections)
        SectionState = 2
      ElseIf OpenSections = 0 And ClosedSections = 0
        ; => the CollapseAll and ExpandAll buttons should be both deactivated (because there aren't any opened/closed sections, maybe only empty sections)
        SectionState = 1
      Else
        ; this option shouldn't occure, just in case...
        SectionState = 0
      EndIf
      ProcedureReturn SectionState
      
      
    ElseIf SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
      
      If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
        ProcedureReturn GetPropertyGridItemOpened(GetPropertyGridDataItems(*PropertyGridDataA))
      EndIf
      
    EndIf    
    
  EndIf
  
EndProcedure

Re: Simple PropertyGrid

Posted: Sun Jan 13, 2013 2:02 pm
by Guimauve
Hello everyone,

OK the new modification done by Andre added, and Lock/Unlock problem solved.
The V1.2.1 source code can be downloaded here : http://pages.videotron.com/gsaumure/fil ... Gadget.zip

This will probably the last update from me this month. Two professional programming projects are in the WIP and now my time as to be spend to them only.
Sorry to let you down, but if you have more development idea feel free to post them here, perhaps they will be added when all pro project will be completed.

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Tue Mar 12, 2013 8:43 am
by swan
Thanx all for their contribution to this, I think it's great.
I've been playing with it to include into my small project.
It would be great if GetPropertyGridSectionItemDescription() existed so we can view the label text that was dynamically added. Sorry I'm not smart enough to figure it out, however I've done a bit of a hack workaround for now (linklist).
:D

Re: Simple PropertyGrid

Posted: Sat Feb 08, 2014 10:57 am
by Thorsten1867
The download link is doesn't work. :(

Re: Simple PropertyGrid

Posted: Sat Apr 04, 2015 8:05 am
by swan
Have used this now on a couple of small projects and works quite well.
However I really need to be able to get & set the text description of a propertygridgadget after adding it. I'm hoping someone may have figured this out over the last year or so.
Cheers ....

Re: Simple PropertyGrid

Posted: Sun Apr 05, 2015 1:32 am
by Danilo
swan wrote:However I really need to be able to get & set the text description of a propertygridgadget after adding it. I'm hoping someone may have figured this out over the last year or so.
Something like this?

Code: Select all

Procedure.i SetSectionName(PropertyGridGadget, section.i, sectionName.s)
    *memory.PropertyGridData = GetGadgetData(PropertyGridGadget)
    If *memory
        ForEach *memory\Items()
            If *memory\Items()\SectionButtonGadget = section
                SetGadgetText( *memory\Items()\SectionDescriptionGadget, sectionName)
                ProcedureReturn #True
            EndIf
        Next
    EndIf
EndProcedure

Procedure.s GetSectionName(PropertyGridGadget, section.i)
    *memory.PropertyGridData = GetGadgetData(PropertyGridGadget)
    If *memory
        ForEach *memory\Items()
            If *memory\Items()\SectionButtonGadget = section
                ProcedureReturn GetGadgetText( *memory\Items()\SectionDescriptionGadget )
            EndIf
        Next
    EndIf
EndProcedure


Procedure.i SetSectionItemDescription(PropertyGridGadget, section.i, gadget.i, description.s)
    *memory.PropertyGridData = GetGadgetData(PropertyGridGadget)
    If *memory
        ForEach *memory\Items()
            If *memory\Items()\SectionButtonGadget = section
                ForEach *memory\Items()\SubItems()
                    If *memory\Items()\SubItems()\ItemGadget = gadget
                        SetGadgetText( *memory\Items()\SubItems()\DescriptionGadget, description)
                        ProcedureReturn #True
                    EndIf
                Next
            EndIf
        Next
    EndIf
EndProcedure

Procedure.s GetSectionItemDescription(PropertyGridGadget, section.i, gadget.i)
    *memory.PropertyGridData = GetGadgetData(PropertyGridGadget)
    If *memory
        ForEach *memory\Items()
            If *memory\Items()\SectionButtonGadget = section
                ForEach *memory\Items()\SubItems()
                    If *memory\Items()\SubItems()\ItemGadget = gadget
                        ProcedureReturn GetGadgetText( *memory\Items()\SubItems()\DescriptionGadget )
                    EndIf
                Next
            EndIf
        Next
    EndIf
EndProcedure
Usage:

Code: Select all

section = AddSection(propertyGrid, "Section Name")
gadget1 = AddButtonGadget(propertyGrid,section,"Description","Button 1")

name$ = GetSectionName(propertyGrid, section)
Debug name$

SetSectionName(propertyGrid, section, "New Section Name")

name$ = GetSectionItemDescription(propertyGrid, section, gadget1)
Debug name$

SetSectionItemDescription(propertyGrid, section, gadget1, "New Description")

Re: Simple PropertyGrid

Posted: Mon Apr 06, 2015 12:00 am
by swan
Great stuff Danilo. Very much appreciated.
Over this weekend I sat down and studied the code and was able to figure out some but you beat me to it. Thanx again ...