wxPGProperty SetAttribute...
BlitzMax Forums/Brucey's Modules/wxPGProperty SetAttribute...
| ||
I'm using SetAttributeString, SetAttributeBool, SetAttributeInt etc.. inside a type extended from wxPGProperty, doing 'SetAttribute...()' does nothing: And the main usage of the SetValue method: Method UpdateProps() 'Local pnames:String[], pprops:wxPGProperty[] 'PropertiesToNames(pnames, pprops) 'RefreshDimensions() For Local prop:wxPGProperty = EachIn Gadget_Props 'Local i:Int = 0 To pnames.Length ' Local Name:String = pnames[i], prop:wxPGProperty = pprops[i] If wxIntPropertyField(prop) wxIntPropertyField(prop).SetValue(CurrentGadget) ElseIf wxFloatPropertyField(prop) wxFloatPropertyField(prop).SetValue(CurrentGadget) ElseIf wxStringPropertyField(prop) wxStringPropertyField(prop).SetValue(CurrentGadget) ElseIf wxColourPropertyField(prop) Local sprop:wxColourPropertyField = wxColourPropertyField(prop), wxc:wxColour Local fld:TField = sprop.m_PropertyField.m_Field, flddat:Object = fld.Get(CurrentGadget), .. fldtype:TTypeId = fld.TypeId() Local r:Int = Int(String(fldtype.GetArrayElement(flddat, 0))), .. g:Int = Int(String(fldtype.GetArrayElement(flddat, 1))), .. b:Int = Int(String(fldtype.GetArrayElement(flddat, 2))) wxc = wxColour.CreateColour(r, g, b) SetPropertyValueColour(sprop, wxc) 'cant do this from within a wxColourProperty object, report to Brucey ElseIf wxBoolPropertyField(prop) wxBoolPropertyField(prop).SetValue(CurrentGadget) EndIf Next End Method Also neither wxColourProperty.SetPropertyValueColour() nor wxColourProperty.GetValueAsColour() exist; but their type counterparts (Boolean, String, Integer, Double/Float) do exist. Simple problem, just not implemented? If you want to see it in action (or rather, not in action ;) run guitest.exe, click 'New Project' (from the menu or the toolbar), and select a gadget or panel. Notice how only the color, in the property grid, changes according to the gadget/panel you select, that is because I am setting the value in the property grid (because wxColourProperty.GetValueAsColour() does not exist; if it did I would have a SetValue method for wxColourPropertyField), see above: Method UpdateProps() http://files.filefront.com/wxdesigner+7+9+08+pre+azip/;10996491;/fileinfo.html EDIT: Oh ya, I have a workaround for wxColourProperty.GetValueAsColour(); the second line in wxColourPropertyField.SetFieldValue: If Value = Null Then Value = GetGrid().GetPropertyValueAsColour(Self) EDIT: It wxPropertyGrid.Disable() and .Enable() work, but do not gray-out the area where the propertygrid is.. is that the correct behavior? |
| ||
Simple problem, just not implemented? Very possible. I implemented a core set of the code, then have been adding to it on request for most of the rest of the time - driven largely by Gabriel. It's just a very large API, and I can only sit and go through a given amount of it in one session as it starts to drive you mad after a while ;-) (Disclaimer - it starts to drive me mad after a while... prolly why I like to mingle large modules with smaller ones as I go, to keep myself at least 5% sane). I'll look into the ones you are having trouble with. As for Grid Disable/Enable, it sounds like that is library specific. But I'll check it over anyway. :o) |
| ||
All wxPGProperty 'GetValueAs...' (string, bool double.. etc) are blank functions. wxPGProperty is also blank: Method GetGrid:wxPropertyGrid() End Method So I cannot do my workaround (used for getting the value of a wxColourProperty) for all types of properties. Halp? P.S 'SetAttribute...' functions (in wxPGProperty) are actually calling things, but not changing anything. |
| ||
Ok. I'll push it up to the top of my list... :-) |
| ||
Hey ho... I've implemented GetValueAsColour(). Taking me a while to get my head back into this module properly. It's very large and complicated, and uses techniques I'm not used to.... so much trial and error before I get some things right... wxColour c; c << prop->GetValue(); Getting there :-) |
| ||
btw, are you sure SetAttributeXXX doesn't work? Don't you need to fill in the "name" part, for the name/value pair? I thought it was meant to work like a hash map/associative array. |
| ||
I thought about that, but you would need to implement GetName() as well for it to be tested.. EDIT: But there is such a method in wxPropGrid that doesn't need the name of the property (just the property, as it should be in wxPGProperty).. wxPropGrid.SetPropertyValueColour(prop, colour) |
| ||
I meant this :SetAttributeInt("", m_PropertyField.m_Field.GetInt(Gadget)) Shouldn't you provide an attribute name? |
| ||
I also need to sync up with the latest version of the (wxPropgrid) source - which is usually a pain in the ..... Again, living with a constantly changing target makes things a bit more interesting, wrapper wise :-p |
| ||
Shouldn't you provide an attribute name? Yeah, shouldn't it be given its current name?I create a prop: Local prop:wxIntProperty = New wxIntProperty.Create("X", wxPG_LABEL, 5) To set it's value: prop.SetAttributeInt("", 10) Why should I need to fill the attribute name (or, why is there even a name parameter)? the object should already know its own name. Nonsense. That method should only be for setting the value, not the name as well. I just don't understand why it requires a name.. EDIT: I think my assumption earlier on was: SetAttributexxx was just a combination of setname and setvalue, and if I just wanted to set the value I was supposed to keep the name parameter blank. |
| ||
Ah... SetAttribute has nothing to do with the value of the property :-p Property attributes are a bit like having a Type with a TMap field attached. You SetAttributeXXX("someName", someValue) and that is stored in the Property object, for retrieval later via GetAttributeXXX("someName"). They are mostly used for holding settings that are useful to different kinds of Properties, like for instance, the starting directory of a File Property. But they are also available to use yourself : prop1.SetAttributeInt("abcd", 432) DebugLog prop1.GetAttributeAsInt("abcd", 100) ... DebugLog:432 If you want to set the value, you use SetValueXXXX() or SetPropertyValueXXXX(property, ...) :-) Before you say what I know you're going to say... I know... I'm working on that right now :-p |
| ||
Okay... I've added wxPGProperty SetValueXXX and GetValueXXX methods.. which should make it a bit easier to work with... Still another 300+ methods to implement, I expect... but we'll get there one day... |
| ||
I've updated to the latest wxPropgrid source, which apparently fixes lots of bugs etc. The sample appears to be running fine using this new code (on MacOS Intel), so I've committed it. Please let me know if you have any problems with it. :-) |
| ||
Great! Except for the values not always updating on the propgrid: When a value is changed using wxPGProperty.SetValueXXX() you have to click around in the property grid to get it to show (I assume that means the grid just needs to be updated). However, when a value is changed using wxPropertyGrid.SetPropertyValueXXX() the changes are instantly visible (in my current project there is still no wxColourProperty.SetValueColour() so I use the work-around: wxPropertyGrid.SetPropertyValueColour(prop, colour) - the changes for colour properties are instant, while others are not). Any Ideas? (I've tried wxPropertyGrid.Update() and it did nothing) EDIT: I just found wxPropertyGrid.UpdateProps() - but it seems to hang my code. It does not go to show debug information, it just hangs indefinitely. EDIT2: wxPropertyGrid.Refresh() is doing the trick! (leaves doubts about the UpdateProps() method though..) Thanks. |
| ||
Notes from the docs... On SetValueXXX - Call this to set value of the property. Unlike methods in wxPropertyGrid, this does not automatically update the display. Like what you've found. I suppose in that way, you can set as many as you like *before* being forced to redraw the properties. I'll take a look at UpdateProps... <EDIT> ... which doesn't appear to exist in my code? |
| ||
I'll take a look at UpdateProps... Huh.. same here, I have no idea how it was able to compile (using UpdateProps()), but Refresh() is working flawlessly!<EDIT> ... which doesn't appear to exist in my code? EDIT: UpdateProps() was a method I implemented in my extended type. (this is even stupider) I was calling UpdateProps() in UpdateProps(), so it was stuck in an infinite loop. Whoops. |