changeset 807:f7016a38bedd

Fix for dw_window_set_text() on buttons not working. Implemented dw_mle_get_size() returning the line count.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 24 Mar 2011 15:42:50 +0000
parents 16964b141964
children c0641a6d4258
files mac/dw.m
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Thu Mar 24 06:35:41 2011 +0000
+++ b/mac/dw.m	Thu Mar 24 15:42:50 2011 +0000
@@ -3679,9 +3679,13 @@
     DWMLE *mle = [sv documentView];
     NSTextStorage *ts = [mle textStorage];
     NSMutableString *ms = [ts mutableString];
-
-    *bytes = [ms length];
-    *lines = 0; /* TODO: Line count */
+    NSUInteger numberOfLines, index, stringLength = [ms length];
+    
+    for(index=0, numberOfLines=0; index < stringLength; numberOfLines++)
+        index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]);
+
+    *bytes = stringLength;
+    *lines = numberOfLines;
 }
 
 /*
@@ -6413,16 +6417,16 @@
     DW_MUTEX_LOCK;
     NSObject *object = handle;
 
-    if([ object isKindOfClass:[ NSControl class ] ])
+    if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ])
+    {
+        id window = handle;
+        [window setTitle:[ NSString stringWithUTF8String:text ]];
+    }
+    else if([ object isKindOfClass:[ NSControl class ] ])
     {
         NSControl *control = handle;
         [control setStringValue:[ NSString stringWithUTF8String:text ]];
     }
-    else if([ object isKindOfClass:[ NSWindow class ] ])
-    {
-        NSWindow *window = handle;
-        [window setTitle:[ NSString stringWithUTF8String:text ]];
-    }
     DW_MUTEX_UNLOCK;
 }