Revision: 1764
          http://svn.sourceforge.net/vexi/?rev=1764&view=rev
Author:   clrg
Date:     2007-03-29 11:19:48 -0700 (Thu, 29 Mar 2007)

Log Message:
-----------
Large text commit
- Remove win2k.text directory and contents
- Fix bug with partial highlighting when nothing should be highlighted
- Fix bug where applying new settings to a text area is not propogated to 
contents
- Make highlight color/fill modifiable

Modified Paths:
--------------
    widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/block.t
    widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/edit.t
    widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/word.t
    widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/combo.t
    widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/label.t
    widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/textarea.t
    widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/textfield.t
    widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/tooltip.t

Added Paths:
-----------
    widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/default.t

Removed Paths:
-------------
    widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/text/

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/block.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/block.t        
2007-03-29 15:38:11 UTC (rev 1763)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/block.t        
2007-03-29 18:19:48 UTC (rev 1764)
@@ -35,9 +35,12 @@
         
         // assign static trap functions
         thisbox.font      ++= static.fontFunc;
+        thisbox.font      ++= static.propogateFunc;
         thisbox.fontsize  ++= static.fontFunc;
+        thisbox.fontsize  ++= static.propogateFunc;
         thisbox.getword   ++= static.wordFunc;
         thisbox.multiline ++= static.multilineFunc;
+        thisbox.parent    ++= static.propogateFunc;
         thisbox.textalign ++= static.textalignFunc;
         thisbox.text      ++= static.textReadFunc;
         thisbox.text      ++= static.textWriteFunc;
@@ -223,6 +226,14 @@
         trapee.fontheight = vexi.ui.font.height(trapee.font, trapee.fontsize, 
"dy");
     }
     
+    /** propogate a property to child words */
+    static.propogateFunc = function(v)
+    {
+        cascade = v;
+        for (var i=0; trapee.numchildren>i; i++)
+            trapee[i][trapname] = v;
+    }
+    
     /** trap: set whether this is a flowing (multiline) text block or not 
(singleline) */
     static.multilineFunc = function(v) 
     {
@@ -322,12 +333,13 @@
     /** read trap for getting new words relevant to a block */
     static.wordFunc = function()
     {
-        var ret = vexi..org.vexi.lib.text.word(vexi.box);
-        ret.font = trapee.font;
-        ret.fontsize = trapee.fontsize;
-        ret.textcolor = trapee.textcolor;
-        ret.packed = false;
-        return ret;
+        var r = vexi..org.vexi.lib.text.word(vexi.box);
+        r.packed = false;
+        r.font = trapee.font;
+        r.fontsize = trapee.fontsize;
+        r.parent = trapee.parent;
+        r.textcolor = trapee.textcolor;
+        return r;
     }
     
     /** reset block dimensions if wrapwidth is unset */

Added: widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/default.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/default.t              
                (rev 0)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/default.t      
2007-03-29 18:19:48 UTC (rev 1764)
@@ -0,0 +1,95 @@
+<!-- Copyright 2006 - see COPYING for details [LGPL] -->
+
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="org.vexi.lib">
+    <meta:doc>
+        <author>Charles Goodwin</author>
+        <desc>A sane fallback text implementation</desc>
+    </meta:doc>
+    
+    <ui:box>
+        <role.repeatable id="cursor" align="topleft" display="false" 
interval="300" packed="false" width="1">
+            
+            var counter = 0;        // counter used to implement blinking
+            thisbox.moved = false;  // used to track recent cursor movement
+            
+            /** the repeating action, makes the cursor blink */
+            thisbox.action ++= function(v)
+            {
+                // blink counter
+                counter = (++counter)%3;
+                if (moved)
+                {
+                    // reset counter / blink
+                    counter = 1;
+                    display = true;
+                }
+                // blink
+                else display = (counter != 0);
+                // reset moved;
+                moved = false;
+                cascade = v;
+            }
+            
+            /** display cursor if it's activated */
+            thisbox.repeat ++= function(v) { cascade = v; display = repeat; }
+            
+        </role.repeatable>
+        
+        thisbox.th_cursor = $cursor;
+        
+        /** syncCursor function called by edit.t */
+        thisbox.syncCursor = function(v)
+        {
+            var cBlock = getCBlock();
+            var cWord = getCWord();
+            var cPos = getCPos();
+            // calculate cursor pos according to cWord
+            if (cWord)
+            {
+                // invalid cWord/cBlock combo
+                // FIXME: this is a bandaid - need to investigate why this 
happens
+                //if (cBlock.indexof(cWord) == -1) return;
+                
+                $cursor.height = vexi.ui.font.height(cWord.font, 
cWord.fontsize, "dy");
+                var d = thisbox.distanceto(cWord);
+                if (cWord.whitespace and cWord.width == 0 and 
cBlock.indexof(cWord) == cBlock.numchildren-1)
+                {
+                    $cursor.x = 0;
+                    $cursor.y = d.y + cWord.height;
+                }
+                else
+                {
+                    $cursor.x = d.x + (cPos == 0 ? 0 :
+                        vexi.ui.font.width(cWord.font, cWord.fontsize, 
cWord.text.substring(0, cPos)));
+                    $cursor.y = d.y;
+                }
+            }
+            // place cursor at start of cBlock
+            else if (cBlock == null)
+                vexi.log.warn("Error - cBlock should never be null");
+            else
+            {
+                var d = thisbox.distanceto(cBlock);
+                $cursor.x = d.x;
+                $cursor.y = d.y;
+                $cursor.height = vexi.ui.font.height(cBlock.font, 
cBlock.fontsize, "dy");
+            }
+            
+            // temporarily delays the cursor flashing
+            $cursor.moved = true;
+        }
+        
+        /** activate cursor when focused */
+        thisbox.focused ++= function(v) { cascade = v; $cursor.repeat = 
focused; }
+        
+        thisbox.cursorcolor ++= function(v) { $cursor.fill = v; }
+        
+        // set sane defaults
+        thisbox.cursorcolor = "black";
+        thisbox.highlightcolor = "white";
+        thisbox.highlightfill = "darkblue";
+        // other text properties default to Vexi defaults
+        
+    </ui:box>
+    <text.edit />
+</vexi>

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/edit.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/edit.t 2007-03-29 
15:38:11 UTC (rev 1763)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/edit.t 2007-03-29 
18:19:48 UTC (rev 1764)
@@ -1815,6 +1815,7 @@
         var r = vexi..org.vexi.lib.text.block..newBlock(trapee.multiline, 
trapee.wrapwidth);
         r.font = trapee.font;
         r.fontsize = trapee.fontsize;
+        r.parent = trapee;
         r.textalign = trapee.textalign;
         r.textcolor = trapee.textcolor;
         return r;

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/word.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/word.t 2007-03-29 
15:38:11 UTC (rev 1763)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/lib/text/word.t 2007-03-29 
18:19:48 UTC (rev 1764)
@@ -28,6 +28,7 @@
         textcolor   ++= static.textcolorFunc;
         text        ++= static.textReadFunc;
         text        ++= static.textWriteFunc;
+        parent      ++= static.parentFunc;
         
         /** do a partial highlight
          *  - c1 - start character
@@ -50,6 +51,7 @@
             // more specific highlight required
             if (c1 == null) c1 = 0;
             if (c2 == null) c2 = $t.text.length;
+            if (c1 == c2) { $o.display = false; return; }
             $o.text = $t.text.substring(c1, c2);
             $o.x = c1==0?0:vexi.ui.font.width(font, fontsize, 
$t.text.substring(0, c1));
             
@@ -87,8 +89,8 @@
     {
         cascade = null;
         trapee[0][0].display = false;
-        trapee[0].fill = v ? "darkblue" : null;
-        trapee[0].textcolor = v ? "white" : trapee.textcolor;
+        trapee[0].fill = v ? trapee.parent.highlightfill : null;
+        trapee[0].textcolor = v ? trapee.parent.highlightcolor : 
trapee.textcolor;
     }
     
     /** write font information to internal text-box and highlight-box */
@@ -100,6 +102,14 @@
         trapee[0][trapname] = v; trapee[0][0][trapname] = v;
     }
     
+    /** change certain things when moved to a new edit */
+    static.parentFunc = function(v)
+    {
+        cascade = v;
+        trapee[0][0].fill = v.highlightfill;
+        trapee[0][0].color = v.highlightcolor;
+    }
+    
     /** return textual content from internal text-box */
     static.textReadFunc = function() { return trapee[0].text; }
     

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/combo.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/combo.t     
2007-03-29 15:38:11 UTC (rev 1763)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/combo.t     
2007-03-29 18:19:48 UTC (rev 1764)
@@ -1,15 +1,15 @@
 <!-- Copyright 2006 - see COPYING for details [LGPL] -->
 
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.theme.win2k" xmlns:lib="org.vexi.lib.widget" 
xmlns:util="vexi.util"> 
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.theme.win2k" xmlns:lib="org.vexi.lib"> 
     <meta:doc>
         <author>Charles Goodwin</author>
     </meta:doc>
     
-    <lib:combo redirect="$proxy" fill="white" margin="3" maxlistheight="160">
+    <lib:widget.combo redirect="$proxy" fill="white" margin="3" 
maxlistheight="160">
         <bevel form="down">
             <pad id="pad" padding="3">
                 <ui:box id="inset">
-                    <text.edit id="edit" align="left" packed="false" 
vshrink="true" />
+                    <lib:text.default id="edit" align="left" packed="false" 
vshrink="true" />
                 </ui:box>
             </pad>
             <button id="button" width="19" minheight="19">
@@ -28,7 +28,7 @@
         </border>
         
         // redirects
-        util.redirect..addRedirect(thisbox, $pad, "fill");
+        vexi..vexi.util.redirect..addRedirect(thisbox, $pad, "fill");
         
         // assign theme variables
         thisbox.th_arrow    = $arrow;
@@ -73,5 +73,5 @@
         /** move proxy children to $popbox children */
         $proxy.ChildAdded ++= function(v) { $content[$content.numchildren] = 
v; }
         
-    </lib:combo>
+    </lib:widget.combo>
 </vexi>

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/label.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/label.t     
2007-03-29 15:38:11 UTC (rev 1763)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/label.t     
2007-03-29 18:19:48 UTC (rev 1764)
@@ -5,11 +5,11 @@
         <author>Charles Goodwin</author>
     </meta:doc>
     
-    <edit enabled="false" multiline="true">
+    <default enabled="false" multiline="true">
         
         thisbox.syncCursor = static.syncCursor;
         
-    </edit>
+    </default>
     
     static.syncCursor = function() { return true; }
     

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/textarea.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/textarea.t  
2007-03-29 15:38:11 UTC (rev 1763)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/textarea.t  
2007-03-29 18:19:48 UTC (rev 1764)
@@ -1,16 +1,16 @@
 <!-- Copyright 2006 - see COPYING for details [LGPL] -->
 
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.theme.win2k" xmlns:lib="org.vexi.lib.widget">
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.theme.win2k" xmlns:lib="org.vexi.lib">
     <meta:doc>
         <author>Charles Goodwin</author>
         <notes>Win2k-like implementation of a text-area</notes>
     </meta:doc>
     
-    <lib:textarea />
+    <lib:widget.textarea />
     <bevel form="down" margin="3">
         <scrollpane id="scroll" redirect="null" autohidehorizontal="true" 
autohidevertical="true">
             <pad id="pad" fill="white" padding="3">
-                <text.edit id="content" minheight="30" multiline="true" />
+                <lib:text.default id="content" minheight="30" multiline="true" 
/>
             </pad>
         </scrollpane>
         

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/textfield.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/textfield.t 
2007-03-29 15:38:11 UTC (rev 1763)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/textfield.t 
2007-03-29 18:19:48 UTC (rev 1764)
@@ -1,15 +1,15 @@
 <!-- Copyright 2006 - see COPYING for details [LGPL] -->
 
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.theme.win2k" xmlns:lib="org.vexi.lib.widget" 
xmlns:util="vexi.util">
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.theme.win2k" xmlns:lib="org.vexi.lib">
     <meta:doc>
         <author>Charles Goodwin</author>
     </meta:doc>
     
-    <lib:textfield />
+    <lib:widget.textfield />
     <bevel redirect="null" fill="white" form="down" margin="3">
         <pad padding="3">
             <ui:box id="inset">
-                <text.edit id="edit" align="left" packed="false" 
vshrink="true" />
+                <lib:text.default id="edit" align="left" packed="false" 
vshrink="true" />
             </ui:box>
         </pad>
         

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/tooltip.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/tooltip.t   
2007-03-29 15:38:11 UTC (rev 1763)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/theme/win2k/tooltip.t   
2007-03-29 18:19:48 UTC (rev 1764)
@@ -1,13 +1,13 @@
 <!-- Copyright 2006 - see COPYING for details [LGPL] -->
 
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.theme.win2k">
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.theme.win2k" xmlns:text="org.vexi.lib.text">
     <meta:doc>
         <author>Charles Goodwin</author>
     </meta:doc>
     
     <border border="black" depth="1">
         <pad padding="3" fill="#ffffcc">
-               <text.edit id="edit" multiline="true" wrapwidth="250" />
+               <text:default id="edit" multiline="true" wrapwidth="250" />
         </pad>
         
         vexi..vexi.util.redirect..addRedirect(thisbox, $edit, "text");


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to