Page 4 of 6

Re: Simple PropertyGrid

Posted: Mon Dec 03, 2012 12:21 am
by Guimauve
Hello Andre,

The [+/-] button is a tiny ImageGadget() and generate Event when clicked. It's possible to create a procedure to get the handle of this ImageGadget() and/or return it when the section is created. But sorry I can't do it tonight because I have just drink my 3rd glass of home made wine with something like 29% of alcohol in it and it's impossible to concentrate on programming. Maybe tomorrow I will update my code once again.

And maybe next week-end I will add a html help file to present the lib because it become more and more complicated and I'm almost lost my self (and I have created it) so I imagine for other it can be difficult to use it.

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Thu Dec 06, 2012 2:34 am
by Guimauve
Hello everyone,

OK a little update

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
; Change for V1.1.3 :
;
; Enhancement : The Use of "EnableExplicit" is now supported
; Modified : AddPropertyGridSection() now return the Open/Close button handle
; Added : GetPropertyGridSectionOpenCloseHandle() to get the Open/Close button handle
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
http://pages.videotron.com/gsaumure/fil ... Gadget.zip

And sorry for the delay, a real life issue took me all of my free time in the past few days.

Next time I will add the ImageGadget() and few more command.

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Sun Dec 09, 2012 7:15 pm
by Andre
Thanks again, Guimauve, for this latest update!

I was able now to include the PropertyGrid properly into my project source, and I'm able to handle the open/close button myself :D

Some minor issues I found:

- creating a listicon gadget with AddPropertyGridListIconGadget() will get the 'TitleWidth' as parameter, which should be used for setting the width of the listicon itself and the width of the first column => it would be nice, if the column width is set around 20 pixel smaller than listicon width, to avoid a not needed scrollbar

- if one or several property sections is/are opened, there should be some space between them for a better look => could be standard I think, or at least make it optionally

And another feature request:

- Would it be possible to make the AddPropertyGridTextGadget() make auto-adjust its height according to the gadget content (means give it a greater height, if there is a longer text to display)? Or at least add an optional parameter to be able to set the gadget height by the programmer (plus a Setxxxx() procedure to set/change the height later)?

- Even better would be, if the AddPropertyGridSection() would recognize the needed space (height of the included TextGadget), if the is a longer text to display. Or again, add at least an (optional) parameter to be able to set the height....

Here is a screenshot of my application, which shows the above issues:

Image

I know, these are very specific wishes, probably too much for a more general solution thought especially for using it in preferences windows, etc.... But if it would be possible, I will be very happy... :-)

Thank you!

Re: Simple PropertyGrid

Posted: Mon Dec 10, 2012 3:55 am
by Guimauve
Hello Andre,

I glad to help you by upgrading my code but due to real life issue, I have to reduce PureBasic programming time from 7 days a week to only 1 or 2 days (mostly the week-end) every week.
It's not possible to auto-adjust the TextGadget() height when the line is to long and split on two line (The TexteGadget does not support this either). But it's possible to set the height manually to compensate for the extra height needed. Can you replace the previous AddPropertyGridTextGadget() by this one and tell me if it work.

Code: Select all

Procedure AddPropertyGridTextGadget(PropertyGridID, SectionNo, Description.s = "", Flags = 0, P_ItemGadgetHeight = #PropertyGrid_DefaultItemHeight)
  
  Protected *PropertyGridDataA.PropertyGridData = GetGadgetData(PropertyGridID)
  
  If *PropertyGridDataA <> #Null
    
    If SectionNo >= 0 And SectionNo <= ListPropertyGridDataItemsSize(*PropertyGridDataA) - 1
      
      If SelectPropertyGridDataItemsElement(*PropertyGridDataA, SectionNo)
        
        AddPropertyGridItemSubItemsElement(GetPropertyGridDataItems(*PropertyGridDataA))
        
        OpenGadgetList(PropertyGridID)
          SetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), TextGadget(#PB_Any, 0, 0, 0, 0, Description, Flags))
          SetPropertyGridSubItemDescriptionGadgetHeight(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), P_ItemGadgetHeight)
          SetPropertyGridSubItemItemGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), -1)
          SetPropertyGridSubItemItemGadgetHeight(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)), P_ItemGadgetHeight)
        CloseGadgetList()
        
        Private_Update_PropertyGrid(PropertyGridID)
        
        ProcedureReturn GetPropertyGridSubItemDescriptionGadget(GetPropertyGridItemSubItems(GetPropertyGridDataItems(*PropertyGridDataA)))
        
      EndIf
      
    EndIf    
    
  EndIf
  
EndProcedure
About the ListIcon I will see what I can do, I hope tomorrow.

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Tue Dec 11, 2012 12:52 am
by Andre
Thanks Guimauve, for this extended procedures! It works just fine and is useful for my needs :-)

Two more suggestion / feature requests from me:

1) It would be nice to have a DeletePropertyGridGadget(GadgetID) or similar named function, with which I could delete a specific gadget from inside a PropertyGadgetSection. Currently it seems I need to clear the complete section and build all gadgets (without the not needed) again...

2) As I'm using also the PropertyGridSections for displaying informations, there are probably no more gadgets inside the section. Then the possibility to open/close the section is useless and should be avoided. Here would be a third option beside the [+] and [-] images a nice addition, e.g. [o] => means there is nothing more to display and the PropertyGridSection is closed and could also not be opened by the user by clicking on this image...

Re: Simple PropertyGrid

Posted: Wed Dec 12, 2012 3:24 am
by Guimauve
Hello Andre,

I'm sorry to announce another delay about my next upgrade. I know it is not pleasant to have to wait for someone else to finish is work to
complete our. Unfortunately, I have many real life issue to deal with and I don't have the time to program properly. Maybe next week-end ...

Again I'm very sorry about the extra delay.

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Mon Dec 17, 2012 4:03 am
by Guimauve
Hello everyone,

Good news, 4 new commands, Bad news few element requested by Andre are not implemented yet (the 3rd state for the Open/Close button, ListIcon column width adjustment).
For the moment I run out of idea about how I can do it efficiently so I prefer to spend more time solve all remaining issues.

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

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Mon Dec 17, 2012 5:14 am
by jassing
Nice work -- glad to see it's development moving on.

Re: Simple PropertyGrid

Posted: Mon Dec 17, 2012 10:28 pm
by Andre
Hi Guimauve,

thanks again, not tested yet. I need some more sleep today after the interview "late-night session" yesterday... :wink:

About the "third possibility" I could imagine, that the "easiest" solution could be the following:
- include a 3rd image type, maybe [o] or [/], or just use the existing [-]
- create each new GridSection with this 3rd image type as standard and save a GridSection "state" like "#GridSectionContent = #False" (empty) for each GridSection, which will cause it to not react on mouse-clicks
- change the image automatically to [+] and the GridSection state to "#GridSectionContent = #True", as soon there is added at least one item gadget to the GridSection, and then react on mouse-clicks on [+] and [-]

Re: Simple PropertyGrid

Posted: Fri Dec 28, 2012 12:20 am
by Guimauve
Hello everyone,

Sorry for the long delay but it's the first day I have nothing to do except programming. OK this the V1.1.5 with the triple state Open/Close button, I think the empty section handling is OK but not bulletproof for the moment. Feel free to test and report back.

@Andre : About the ListIconGadget() column width correction, I think I got it, but on Linux with the previous version example I don't have any horizontal scroll bar for this gadget, I think it's a Mac OS issue. Can you try and report back please.

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

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Sat Dec 29, 2012 12:07 am
by Andre
Hi Guimauve,

no problem with the delay - thanks a lot for your further improvements!

The following screenshot is showing the new "triple state" and the reduced listicon width in action (on MacOS, I've not tested it on Windows). All seems to work very well! :D
Image

Some minor issues remaining - for my wishlist ;-):
- a cosmetic one: before each 2nd, 3rd, etc. PropertyGridSection should be some space (ca. 10 pixel?), just like between section title and first gadget inside
- if there is any possibility: let me adjust the height of the section title (TextGadget), so that I'm able to display a multi-line text as title string
- provide a function able to expand PropertyGridSections (specific section as well all at once)
- provide a function able to collapse PropertyGridSections (specific section as well all -opened- at once)

Thanks again for your effort!

Re: Simple PropertyGrid

Posted: Sat Dec 29, 2012 3:30 am
by Guimauve
Andre wrote:Some minor issues remaining - for my wishlist ;-):
- a cosmetic one: before each 2nd, 3rd, etc. PropertyGridSection should be some space (ca. 10 pixel?), just like between section title and first gadget inside
To fix this problem we will have to proceed by trial and error. On Linux the PropertyGrid look like :

Image

Can you replace the Private_RelocatePropertyGridSubItem() procedure by this one :

Code: Select all

Procedure Private_RelocatePropertyGridSubItem(*PropertyGridSubItemA.PropertyGridSubItem, Index, Width, Height)
  
  CompilerSelect #PB_Compiler_OS
      
    CompilerCase #PB_OS_Windows 
      
      If GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA) <> -1
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index,  width >> 1 - 40, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
      Else
        
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index,  width - 42, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width - 62, 0)
        EndIf
        
      EndIf
      
      If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
        
        ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index, width >> 1 - 4, GetPropertyGridSubItemItemGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width >> 1 - 39, 0)
        EndIf
        
      EndIf
      
    CompilerCase #PB_OS_Linux
      
      If GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA) <> -1
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 12, width >> 1 - 40, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
      Else
        
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 12, width - 42, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width - 62, 0)
        EndIf
        
      EndIf  
      
      If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
        
        ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index - 12, width >> 1 - 4, GetPropertyGridSubItemItemGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width >> 1 - 39, 0)
        EndIf
        
      EndIf
      
    CompilerCase #PB_OS_MacOS
      
      If GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA) <> -1
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 12, width >> 1 - 40, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
      Else
        
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 12, width - 40, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width - 62, 0)
        EndIf
        
      EndIf
      
      If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
        
        ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index - 12, width >> 1 - 4, GetPropertyGridSubItemItemGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width >> 1 - 39, 0)
        EndIf
        
      EndIf
      
  CompilerEndSelect
  
EndProcedure
Andre wrote:- if there is any possibility: let me adjust the height of the section title (TextGadget), so that I'm able to display a multi-line text as title string
In fact the TextGadget() it's self can't deal the multi-line text automatically. The best I can do is overriding the default gadget height by putting a different value for the fourth parameter of this procedure :

Code: Select all

AddPropertyGridTextGadget(PropertyGridID, SectionNo, Description.s = "", Flags = 0, P_ItemGadgetHeight = #PropertyGrid_DefaultItemHeight)
By default the height value is 20 pixel for Windows, 30 for Linux and 25 for MacOS, but you can put any value to fit your needs, the gadgets will be relocated according to their specified heights. The TextGadget() don't adjust it's height automatically in the multi-line text case. In contrary, the ImageGadget() adjust it's size when the Image size are different of the gadget size. We should ask Fred and/or Freak about this behaviour.
Andre wrote:- provide a function able to expand PropertyGridSections (specific section as well all at once)
- provide a function able to collapse PropertyGridSections (specific section as well all -opened- at once)
It's the next step in the development but it will take a while because will become very busy in the coming days.

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Sat Dec 29, 2012 2:23 pm
by Andre
Hi Guimauve,

the changed code is now setting the space at the bottom of each section, but removes the spaces at top of each section (first gadget immediately is below the section title). See the new screenshot in comparison to the previous one:

Image

About setting a greater height for the section title I can image another optional parameter to the related procedure, like this:

Code: Select all

AddPropertyGridSection(PropertyGridID, SectionName.s, IsOpen.b = #True, SectionTitleHeight = #PropertyGrid_DefaultItemHeight)
Then I could calculate the needed height (of the text to display as "section title") myself before, and (if needed) pass a greater value at creating the section....

Inside the section I already use the AddPropertyGridTextGadget() function with its optional height parameter to adjust the TextGadget to a greater height if needed.

Re: Simple PropertyGrid

Posted: Sat Dec 29, 2012 2:58 pm
by Guimauve
Hello Andre,

Try with this one :

Code: Select all

Procedure Private_RelocatePropertyGridSubItem(*PropertyGridSubItemA.PropertyGridSubItem, Index, Width, Height)
  
  CompilerSelect #PB_Compiler_OS
      
    CompilerCase #PB_OS_Windows 
      
      If GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA) <> -1
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index,  width >> 1 - 40, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
      Else
        
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index,  width - 42, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width - 62, 0)
        EndIf
        
      EndIf
      
      If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
        
        ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index, width >> 1 - 4, GetPropertyGridSubItemItemGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width >> 1 - 39, 0)
        EndIf
        
      EndIf
      
    CompilerCase #PB_OS_Linux
      
      If GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA) <> -1
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 12, width >> 1 - 40, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
      Else
        
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 12, width - 42, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width - 62, 0)
        EndIf
        
      EndIf  
      
      If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
        
        ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index - 12, width >> 1 - 4, GetPropertyGridSubItemItemGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width >> 1 - 39, 0)
        EndIf
        
      EndIf
      
    CompilerCase #PB_OS_MacOS
      
      If GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA) <> -1
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 6, width >> 1 - 40, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
      Else
        
        ResizeGadget(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), 20, Index - 6, width - 40, GetPropertyGridSubItemDescriptionGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemDescriptionGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width - 62, 0)
        EndIf
        
      EndIf
      
      If IsGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA))
        
        ResizeGadget(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), width >> 1 - 19, Index - 6, width >> 1 - 4, GetPropertyGridSubItemItemGadgetHeight(*PropertyGridSubItemA) - 1)
        
        If GetPropertyGridSubItemReduceWidth(*PropertyGridSubItemA) = #True
          SetGadgetItemAttribute(GetPropertyGridSubItemItemGadget(*PropertyGridSubItemA), -1, #PB_ListIcon_ColumnWidth, width >> 1 - 39, 0)
        EndIf
        
      EndIf
      
  CompilerEndSelect
  
EndProcedure
About the TextGadget() used to display the Section name, will see what I can do. Stay in touch !

Best regards
Guimauve

Re: Simple PropertyGrid

Posted: Sat Dec 29, 2012 7:47 pm
by Andre
Thanks Guimauve! :-)

This newest update of the Private_RelocatePropertyGridSubItem() procedure works now like I would: there is some space at top and at bottom of each (opened) section.
Guimauve wrote:About the TextGadget() used to display the Section name, will see what I can do. Stay in touch !
Thanks :D