View Issue Details

IDProjectCategoryView StatusLast Update
0025328LazarusWidgetsetpublic2013-11-19 01:43
ReporteraccSoneAssigned ToPaul Ishenin 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformdarwin x86_64OSOSXOS Version10.6.8
Product Version1.3 (SVN)Product Build 
Target VersionFixed in Version1.2.0 
Summary0025328: TMemo doesn't work with Cocoa widgetset
DescriptionTMemo is only visible as white rectangle. No text or scrollbars visible.
Steps To ReproducePut TMemo on a Form, compile with 64bit / cocoa. No text visible
Additional InformationI fixed the issue. See patch.
TagsNo tags attached.
Fixed in Revision43461
LazTarget-
WidgetsetCocoa
Attached Files
  • fix_0025328.patch (4,040 bytes)
    Index: /Developer/lazarus_trunc/lcl/interfaces/cocoa/cocoawsstdctrls.pp
    ===================================================================
    --- /Developer/lazarus_trunc/lcl/interfaces/cocoa/cocoawsstdctrls.pp	(revision 43444)
    +++ /Developer/lazarus_trunc/lcl/interfaces/cocoa/cocoawsstdctrls.pp	(working copy)
    @@ -132,9 +132,8 @@
         class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override;
     
         class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override;
    -    {class procedure SetAlignment(const ACustomMemo: TCustomMemo; const AAlignment: TAlignment); override;
         class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); override;
    -    class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;}
    +    class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;
         class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
     
         class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
    @@ -211,6 +210,37 @@
     
     implementation
     
    +const
    +VerticalScrollerVisible: array[TScrollStyle] of boolean = (
    +  false, // ssNone
    +  false, // ssHorizontal
    +  true, // ssVertical
    +  true, // ssBoth
    +  false, // ssAutoHorizontal
    +  true,  // ssAutoVertical
    +  true //  ssAutoBoth
    +  );
    +
    +HorizontalScrollerVisible: array[TScrollStyle] of boolean = (
    +  false, // ssNone
    +  true, // ssHorizontal
    +  false, // ssVertical
    +  true, // ssBoth
    +  true, // ssAutoHorizontal
    +  false,  // ssAutoVertical
    +  true //  ssAutoBoth
    +  );
    +
    +ScrollerAutoHide: array[TScrollStyle] of boolean = (
    +  false, // ssNone
    +  false, // ssHorizontal
    +  false, // ssVertical
    +  false, // ssBoth
    +  true, // ssAutoHorizontal
    +  true,  // ssAutoVertical
    +  true //  ssAutoBoth
    +  );
    +
     function AllocButton(const ATarget: TWinControl; const ACallBackClass: TLCLButtonCallBackClass; const AParams: TCreateParams; btnBezel: NSBezelStyle; btnType: NSButtonType): NSButton;
     var
       cap: NSString;
    @@ -613,13 +643,34 @@
       txt: TCocoaTextView;
       ns: NSString;
       scr: TCocoaScrollView;
    +  nr:NSRect;
    +  r:TRect;
    +
    +
     begin
    -  txt := TCocoaTextView(NSView(TCocoaTextView.alloc).lclInitWithCreateParams(AParams));
    +
    +  scr := TCocoaScrollView(NSView(TCocoaScrollView.alloc).lclInitWithCreateParams(AParams));
    +
    +  nr.origin.x:=0;
    +  nr.origin.x:=0;
    +  nr.size.height:=0;
    +  nr.size.width:=AParams.Width;
    +
    +  txt := TCocoaTextView.alloc.initwithframe(nr);
    +  scr.setDocumentView(txt);
    +
    +  scr.setHasVerticalScroller(VerticalScrollerVisible[TMemo(AWinControl).ScrollBars]);
    +  scr.setHasHorizontalScroller(HorizontalScrollerVisible[TMemo(AWinControl).ScrollBars]);
    +  scr.setAutohidesScrollers(ScrollerAutoHide[TMemo(AWinControl).ScrollBars]);
    +
    +  nr:=scr.documentVisibleRect;
    +  txt.setFrame(nr);
    +
       txt.callback := TLCLCommonCallback.Create(txt, AWinControl);
       ns := NSStringUtf8(AParams.Caption);
       txt.setString(ns);
       ns.release;
    -  scr := EmbedInScrollView(txt);
    +
       scr.callback := txt.callback;
       Result := TLCLIntfHandle(scr);
     end;
    @@ -651,6 +702,21 @@
         txt.setEditable(not NewReadOnly);
     end;
     
    +
    +class procedure TCocoaWSCustomMemo.SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle);
    +begin
    +  TCocoaScrollView(ACustomMemo.Handle).setHasVerticalScroller(VerticalScrollerVisible[NewScrollbars]);
    +  TCocoaScrollView(ACustomMemo.Handle).setHasHorizontalScroller(HorizontalScrollerVisible[NewScrollbars]);
    +  TCocoaScrollView(ACustomMemo.Handle).setAutohidesScrollers(ScrollerAutoHide[NewScrollbars]);
    +
    +end;
    +
    +class procedure  TCocoaWSCustomMemo.SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean);
    +begin
    +  //todo:
    +end;
    +
    +
     class procedure TCocoaWSCustomMemo.SetText(const AWinControl:TWinControl;const AText:String);
     var
       txt: TCocoaTextView;
    
    fix_0025328.patch (4,040 bytes)

Activities

accSone

2013-11-18 15:45

developer  

fix_0025328.patch (4,040 bytes)
Index: /Developer/lazarus_trunc/lcl/interfaces/cocoa/cocoawsstdctrls.pp
===================================================================
--- /Developer/lazarus_trunc/lcl/interfaces/cocoa/cocoawsstdctrls.pp	(revision 43444)
+++ /Developer/lazarus_trunc/lcl/interfaces/cocoa/cocoawsstdctrls.pp	(working copy)
@@ -132,9 +132,8 @@
     class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override;
 
     class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override;
-    {class procedure SetAlignment(const ACustomMemo: TCustomMemo; const AAlignment: TAlignment); override;
     class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); override;
-    class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;}
+    class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;
     class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
 
     class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
@@ -211,6 +210,37 @@
 
 implementation
 
+const
+VerticalScrollerVisible: array[TScrollStyle] of boolean = (
+  false, // ssNone
+  false, // ssHorizontal
+  true, // ssVertical
+  true, // ssBoth
+  false, // ssAutoHorizontal
+  true,  // ssAutoVertical
+  true //  ssAutoBoth
+  );
+
+HorizontalScrollerVisible: array[TScrollStyle] of boolean = (
+  false, // ssNone
+  true, // ssHorizontal
+  false, // ssVertical
+  true, // ssBoth
+  true, // ssAutoHorizontal
+  false,  // ssAutoVertical
+  true //  ssAutoBoth
+  );
+
+ScrollerAutoHide: array[TScrollStyle] of boolean = (
+  false, // ssNone
+  false, // ssHorizontal
+  false, // ssVertical
+  false, // ssBoth
+  true, // ssAutoHorizontal
+  true,  // ssAutoVertical
+  true //  ssAutoBoth
+  );
+
 function AllocButton(const ATarget: TWinControl; const ACallBackClass: TLCLButtonCallBackClass; const AParams: TCreateParams; btnBezel: NSBezelStyle; btnType: NSButtonType): NSButton;
 var
   cap: NSString;
@@ -613,13 +643,34 @@
   txt: TCocoaTextView;
   ns: NSString;
   scr: TCocoaScrollView;
+  nr:NSRect;
+  r:TRect;
+
+
 begin
-  txt := TCocoaTextView(NSView(TCocoaTextView.alloc).lclInitWithCreateParams(AParams));
+
+  scr := TCocoaScrollView(NSView(TCocoaScrollView.alloc).lclInitWithCreateParams(AParams));
+
+  nr.origin.x:=0;
+  nr.origin.x:=0;
+  nr.size.height:=0;
+  nr.size.width:=AParams.Width;
+
+  txt := TCocoaTextView.alloc.initwithframe(nr);
+  scr.setDocumentView(txt);
+
+  scr.setHasVerticalScroller(VerticalScrollerVisible[TMemo(AWinControl).ScrollBars]);
+  scr.setHasHorizontalScroller(HorizontalScrollerVisible[TMemo(AWinControl).ScrollBars]);
+  scr.setAutohidesScrollers(ScrollerAutoHide[TMemo(AWinControl).ScrollBars]);
+
+  nr:=scr.documentVisibleRect;
+  txt.setFrame(nr);
+
   txt.callback := TLCLCommonCallback.Create(txt, AWinControl);
   ns := NSStringUtf8(AParams.Caption);
   txt.setString(ns);
   ns.release;
-  scr := EmbedInScrollView(txt);
+
   scr.callback := txt.callback;
   Result := TLCLIntfHandle(scr);
 end;
@@ -651,6 +702,21 @@
     txt.setEditable(not NewReadOnly);
 end;
 
+
+class procedure TCocoaWSCustomMemo.SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle);
+begin
+  TCocoaScrollView(ACustomMemo.Handle).setHasVerticalScroller(VerticalScrollerVisible[NewScrollbars]);
+  TCocoaScrollView(ACustomMemo.Handle).setHasHorizontalScroller(HorizontalScrollerVisible[NewScrollbars]);
+  TCocoaScrollView(ACustomMemo.Handle).setAutohidesScrollers(ScrollerAutoHide[NewScrollbars]);
+
+end;
+
+class procedure  TCocoaWSCustomMemo.SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean);
+begin
+  //todo:
+end;
+
+
 class procedure TCocoaWSCustomMemo.SetText(const AWinControl:TWinControl;const AText:String);
 var
   txt: TCocoaTextView;
fix_0025328.patch (4,040 bytes)

Paul Ishenin

2013-11-19 01:43

manager   ~0071386

Thanks, applied with minor formatting changes.

Issue History

Date Modified Username Field Change
2013-11-18 15:44 accSone New Issue
2013-11-18 15:45 accSone File Added: fix_0025328.patch
2013-11-18 23:39 Paul Ishenin Assigned To => Paul Ishenin
2013-11-18 23:39 Paul Ishenin Status new => assigned
2013-11-19 01:43 Paul Ishenin Fixed in Revision => 43461
2013-11-19 01:43 Paul Ishenin LazTarget => -
2013-11-19 01:43 Paul Ishenin Note Added: 0071386
2013-11-19 01:43 Paul Ishenin Status assigned => resolved
2013-11-19 01:43 Paul Ishenin Fixed in Version => 1.2.0
2013-11-19 01:43 Paul Ishenin Resolution open => fixed