[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: StdProp overhaul, take 2



Le lun, aoû 13, 2001, à 10:23:45 -0500, Lars Clausen a écrit:
> 
> Cyrille, with the StdProp overhaul, how difficult would it be to add units
> to the various inputs.  I'm thinking we could add two properties (kind of
> sub-properties of PROP_TYPE_INT), one for general units, one for font
> units.  The widgets for these could show the unit, the actual unit should
> be settable in the diagram properties.  How does that sound?

It depends. If the difference between property types is strictly cosmetic,
it's really trivial: have a look at the differences between
PROP_TYPE_STRING and MULTISTRING in lib/prop_text.c (basically, 
fooprop_get_widget() is the only difference). If you need more fancy stuff
(like unit conversion to the right format), then upgrade the difficulty from
"trivial" to "easy": you need to override fooprop_reset_widget() and
fooprop_set_from_widget(), like the difference between _STRING and _FILE
(same place). Remember that the _STRING property is currently polluted by
the UTF-8 transition garbage, so the code is actually much more trivial. 

Don't forget to register the new property type (using prop_type_register)
(I'm sorry, but I've pushed the ELF linker a bit too far, and couldn't avoid
this. Good news is that MSVC shouldn't complain).

Where to place these new property types ? If it's of general use, next to
the derived property: everything stays static. If it's more specific,
declare the derived property's methods extern, and do it in the specific
object library (in your case I think it's going to be general, so that'll go 
in either lib/prop_inttypes.c or lib/prop_geomtypes.c, but this post'll
serve as an excuse for documentation for the time being)

Isn't the font size a float currently ? You may want to do these
widgets-with-unit-specification PROP_TYPE_REAL derivatives instead... It
would be nice if the unit spec was persistent, so you'll also want to
override fooprop_load() and fooprop_save(), and fooprop_{set|get}_from_offsets() 
(maybe using the offset2 field). [Of course, all of these must be made clever
enough about their defaults to support upgrading an object which used plain
PROP_TYPE_REAL]
Hmmm... That doesn't leave much in common with  the original _REAL property... 
No problem, you just have seen property mitosis :-) 

	-- Cyrille

-- 
Grumpf.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK