Spelling out the license - some geometry handlers

David Bovill david at openpartnership.net
Mon Nov 21 14:27:42 EST 2005


Agreed

On 21 Nov 2005, at 19:50, Richard Gaskin wrote:
The license is the best place to start.  The MC IDE license spells  
out its own terms, and points to the Rev license which governs the  
engine.

As an example:

Some recent code I have been working on trying to formalise the exact  
issues going on with the various wonderful "formatted" sizes you can  
get Rev to return (see below):

License
This work is licensed under the Creative Commons Attribution- 
NonCommercial-ShareAlike 2.5 License. To view a copy of this license,  
visit http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a  
letter to Creative Commons, 543 Howard Street, 5th Floor, San  
Francisco, California, 94105, USA.

Comment
This means that you can use it without asking for non-commercial  
reasons - education or for your own use for example. It also means  
that you may freely distribute to others, but should you charge or  
sell the product commercially then you need to get back to me and  
negotiate. Lastly if you modify it and redistribute, then you under  
the license you are required to notify me of the content of your  
modifications so that I can benefit.

Now of course for a small piece of code like this - well may as well  
be given away public domain (which is dubious legally in many  
countries). But this is an example.

The problem with much of the freely available code, content, icons,  
whatever in this community is that pooled they make a fabulous  
resource - but not a legal one. That is you really have to go to each  
and every contributor and clear the license for every submission (if  
you can get hold of them and if you can't you are stuck).

Without doing this, we all loose as we cannot scale the community  
contributions. A well thought out open source strategy would open  
some of the RunRev content - say the documentation, and create a  
policy (say on this list or at another location) which defaults to  
all submissions of code and creative content posted to use a given  
license.

--> Groups and formatted sizes
-
function rect_GetVisibleRect groupRect, someGroup
     put the margins of someGroup into someMargin
     margin_Normalise someMargin, left_Margin, top_Margin,  
right_Margin, bottom_Margin
     if the showBorder of someGroup is true then
         put the borderWidth of someGroup into someBorder
         if the showName of someGroup is true then
             put the effective textHeight of someGroup - someBorder -  
1 into someBit
             add someBit to item 2 of someMargin
         end if
         put subtractMargin(someBorder, groupRect) into groupRect
     end if
     put subtractMargin(someMargin, groupRect) into myInner_Rect
     return myInner_Rect
end rect_GetVisibleRect

on rect_SetVisibleRect myGroupRect, showInvisible
     put the long id of me into containerGroup

     -- object dependent

     put rect_GetVisibleRect(myGroupRect, containerGroup) into  
myInner_Rect
     -- testRect myInner_Rect, "Inner Rect"

     put the toplevel_GroupIDs of containerGroup into topGroupIDs
     put myInner_Rect into innerGroup_Rect
     repeat for each line someID in topGroupIDs
         if the visible of control id someID is false then
             if showInvisible is true then
                 set the visible of control id someID to true
             else
                 next repeat
             end if
         end if

         put the height of control id someID into groupHeight
         put item 2 of innerGroup_Rect + groupHeight into group_Bottom
         put group_Bottom into item 4 of innerGroup_Rect

         set the group_Rect of control id someID to innerGroup_Rect
         put group_Bottom into item 2 of innerGroup_Rect
     end repeat
end rect_SetVisibleRect

function group_InnerRect someGroupObject, groupMargins
   put the rect of someGroupObject into groupRect
   if myMargins is empty then put the margins of someGroupObject into  
groupMargins
   put subtractMargin(groupMargins, groupRect) into myRect
   return myRect
end group_InnerRect

function width_MaxIndexGroupContainerWidth containingGroup
     put empty into widthList
     put the number of groups of containingGroup into maxNum
     repeat with groupNum = 1 to maxNum
         -- maybe can use formatted width of group?
         put the long id of group groupNum of containingGroup into  
indexGroup
         put the long id of fld 1 of indexGroup into someField
         put width_RealFormatted(someField) & "," after widthList
     end repeat
     return max(widthList)
end width_MaxIndexGroupContainerWidth

function formattedWidth_GetField someText, someField, someTextStyle
     lock screen
     put the htmlText of someField into oHtmlText
     set the text of someField to someText
     if someTextStyle is not empty then
         set the textStyle of char 1 to -1 of someField to someTextStyle
     end if
     put the formattedWidth of someField into someWidth
     set the htmlText of someField to oHtmlText
     unlock screen
     return someWidth
end formattedWidth_GetField

function width_RealFormatted someObject
     put the formattedWidth of someObject into someWidth
     if the showBorder of someObject is true then
         add (2 * the borderWidth of someObject) to someWidth
     end if
     return someWidth
end width_RealFormatted

function height_RealFormatted someObject
     put the formattedHeight of someObject into someHeight
     if the showBorder of someObject is true then
         add (2 * the borderHeight of someObject) to someHeight
     end if
     return someHeight
end height_RealFormatted


--> Margins
-
function addMargin someMargins, someRect
     margin_Normalise someMargin, left_Margin, top_Margin,  
right_Margin, bottom_Margin
     subtract left_Margin from item 1 of someRect
     subtract top_Margin from item 2 of someRect
     add right_Margin to item 3 of someRect
     add bottom_Margin to item 4 of someRect
     return someRect
end addMargin

function subtractMargin someMargin, someRect
     margin_Normalise someMargin, left_Margin, top_Margin,  
right_Margin, bottom_Margin
     add left_Margin to item 1 of someRect
     add top_Margin to item 2 of someRect
     subtract right_Margin from item 3 of someRect
     subtract bottom_Margin from item 4 of someRect
     return someRect
end subtractMargin

on margin_Normalise @someMargin, @left_Margin, @top_Margin,  
@right_Margin, @bottom_Margin
     if the number of items of someMargin = 1 then
         put someMargin into left_Margin
         put someMargin into top_Margin
         put someMargin into right_Margin
         put someMargin into bottom_Margin
     else
         put item 1 of someMargin into left_Margin
         put item 2 of someMargin into top_Margin
         put item 3 of someMargin into right_Margin
         put item 4 of someMargin into bottom_Margin
     end if
     put left_Margin,top_Margin,right_Margin,bottom_Margin into  
someMargin
end margin_Normalise



More information about the use-livecode mailing list