logo       
Google Custom Search
    AddThis Social Bookmark Button

Fresco/Berlin/modules/Layout LayoutKitImpl.cc,1.29,1.30: msg#00134

Subject: Fresco/Berlin/modules/Layout LayoutKitImpl.cc,1.29,1.30
Update of /cvs/fresco/Fresco/Berlin/modules/Layout
In directory purcel:/tmp/cvs-serv9995/Berlin/modules/Layout

Modified Files:
        LayoutKitImpl.cc 
Log Message:
Cleanup the cleanup.

A new template create_and_set_body added to KitImpl. That gets us around the
need to define a temporary in most places, shortening the code even further.


Index: LayoutKitImpl.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Layout/LayoutKitImpl.cc,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- LayoutKitImpl.cc    23 Jan 2003 22:31:04 -0000      1.29
+++ LayoutKitImpl.cc    25 Jan 2003 22:37:02 -0000      1.30
@@ -93,10 +93,7 @@
 
 Viewport_ptr LayoutKitImpl::scrollable(Graphic_ptr g)
 {
-    Viewport_ptr res =
-       create<Viewport>(new ViewportImpl);
-    res->body(g);
-    return res;
+    return create_and_set_body<Viewport>(new ViewportImpl, g);
 }
 
 // Layout::Splitter_ptr LayoutKitImpl::splitter(Graphic_ptr g, Graphic_ptr p, 
Axis a)
@@ -288,20 +285,17 @@
 
 Graphic_ptr LayoutKitImpl::align(Graphic_ptr g, Alignment x, Alignment y)
 {
-    Graphic_ptr res = create<Graphic>(new Placement(
-                                         new LayoutSuperpose(
-                                             new LayoutCenter(xaxis, x),
-                                             new LayoutCenter(yaxis, y))));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(new Placement(
+                                           new LayoutSuperpose(
+                                               new LayoutCenter(xaxis, x),
+                                               new LayoutCenter(yaxis, y))),
+                                       g);
 }
 
 Graphic_ptr LayoutKitImpl::align_axis(Graphic_ptr g, Axis a, Alignment align)
 {
-    Graphic_ptr res = create<Graphic>(new Placement(
-                                         new LayoutCenter(a, align)));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(new Placement(
+                                           new LayoutCenter(a, align)), g);
 }
  
 Graphic_ptr LayoutKitImpl::halign(Graphic_ptr g, Alignment x)
@@ -316,20 +310,17 @@
 
 Graphic_ptr LayoutKitImpl::fixed_size(Graphic_ptr g, Coord x, Coord y)
 {
-    Graphic_ptr res = create<Graphic>(new Placement(
-                                         new LayoutSuperpose(
-                                             new LayoutFixed(xaxis, x),
-                                             new LayoutFixed(yaxis, y))));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(new Placement(
+                                           new LayoutSuperpose(
+                                               new LayoutFixed(xaxis, x),
+                                               new LayoutFixed(yaxis, y))),
+                                       g);
 }
 
 Graphic_ptr LayoutKitImpl::fixed_axis(Graphic_ptr g, Axis a, Coord size)
 {
-    Graphic_ptr res = create<Graphic>(new Placement(
-                                         new LayoutFixed(a, size)));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(new Placement(
+                                           new LayoutFixed(a, size)), g);
 }
 
 Graphic_ptr LayoutKitImpl::hfixed(Graphic_ptr g, Coord x)
@@ -345,16 +336,12 @@
 Graphic_ptr
 LayoutKitImpl::flexible(Graphic_ptr g, Coord stretch, Coord shrink)
 {
-    Graphic_ptr res =
-       create<Graphic>(new Placement(new LayoutSuperpose(
-                                         new LayoutVariable(xaxis,
-                                                            stretch,
-                                                            shrink),
-                                         new LayoutVariable(yaxis,
-                                                            stretch,
-                                                            shrink))));
-    res->body(g);
-    return res;
+    return
+       create_and_set_body<Graphic>(
+           new Placement(new LayoutSuperpose(
+                             new LayoutVariable(xaxis, stretch, shrink),
+                             new LayoutVariable(yaxis, stretch, shrink))),
+           g);
 }
 
 Graphic_ptr LayoutKitImpl::flexible_fill(Graphic_ptr g)
@@ -366,12 +353,10 @@
 LayoutKitImpl::flexible_axis(Graphic_ptr g, Axis a,
                             Coord stretch, Coord shrink)
 {
-    Graphic_ptr res = create<Graphic>(new Placement(
-                                         new LayoutVariable(a,
-                                                            stretch,
-                                                            shrink)));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(new Placement(
+                                           new LayoutVariable(a,
+                                                              stretch,
+                                                              shrink)), g);
 }
 
 Graphic_ptr
@@ -388,20 +373,17 @@
 
 Graphic_ptr LayoutKitImpl::natural(Graphic_ptr g, Coord x, Coord y)
 {
-    Graphic_ptr res = create<Graphic>(new Placement(
-                                         new LayoutSuperpose(
-                                             new LayoutNatural(xaxis, x),
-                                             new LayoutNatural(yaxis, y))));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(new Placement(
+                                           new LayoutSuperpose(
+                                               new LayoutNatural(xaxis, x),
+                                               new LayoutNatural(yaxis, y))),
+                                       g);
 }
 
 Graphic_ptr LayoutKitImpl::natural_axis(Graphic_ptr g, Axis a, Coord size)
 {
-    Graphic_ptr res = create<Graphic>(new Placement(
-                                         new LayoutNatural(a, size)));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(new Placement(
+                                           new LayoutNatural(a, size)), g);
 }
 
 Graphic_ptr LayoutKitImpl::hnatural(Graphic_ptr g, Coord x)
@@ -416,24 +398,20 @@
 
 Graphic_ptr LayoutKitImpl::margin(Graphic_ptr g, Coord all)
 {
-    Graphic_ptr res = create<Graphic>(new Placement(
-                                         new LayoutMargin(all)));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(new Placement(
+                                           new LayoutMargin(all)), g);
 }
 
 Graphic_ptr
 LayoutKitImpl::margin_flexible(Graphic_ptr g,
                               Coord margin, Coord stretch, Coord shrink)
 {
-    Graphic_ptr res =
-       create<Graphic>(new Placement(
-                           new LayoutMargin(margin, stretch, shrink,
-                                            margin, stretch, shrink,
-                                            margin, stretch, shrink,
-                                            margin, stretch, shrink)));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(
+       new Placement(
+           new LayoutMargin(margin, stretch, shrink,
+                            margin, stretch, shrink,
+                            margin, stretch, shrink,
+                            margin, stretch, shrink)), g);
 }
 
 Graphic_ptr
@@ -441,12 +419,9 @@
                           Coord lmargin, Coord rmargin,
                           Coord bmargin, Coord tmargin)
 {
-    Graphic_ptr res =
-       create<Graphic>(new Placement(
-                           new LayoutMargin(lmargin, rmargin,
-                                            bmargin, tmargin)));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(
+       new Placement(new LayoutMargin(lmargin, rmargin,
+                                      bmargin, tmargin)), g);
 }
 
 Graphic_ptr
@@ -460,14 +435,11 @@
                                    Coord bmargin, Coord bstretch,
                                    Coord bshrink)
 {
-    Graphic_ptr res =
-       create<Graphic>(new Placement(
-                           new LayoutMargin(lmargin, lstretch, lshrink,
-                                            rmargin, rstretch, rshrink,
-                                            tmargin, tstretch, tshrink,
-                                            bmargin, bstretch, bshrink)));
-    res->body(g);
-    return res;
+    return create_and_set_body<Graphic>(
+       new Placement(new LayoutMargin(lmargin, lstretch, lshrink,
+                                      rmargin, rstretch, rshrink,
+                                      tmargin, tstretch, tshrink,
+                                      bmargin, bstretch, bshrink)), g);
 }
 
 Graphic_ptr LayoutKitImpl::hmargin(Graphic_ptr g, Coord both)



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>