Fresco/Berlin/modules/Text TextKitImpl.cc,1.38,1.39 TextKitImpl.hh,1.28,1.29

Stefan Seefeld <[email protected]>
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/Fresco/Berlin/modules/Text
In directory purcel:/tmp/cvs-serv31700/Berlin/modules/Text

Modified Files:
	TextKitImpl.cc TextKitImpl.hh 
Log Message:
a somewhat lengthy fix for http://issues.fresco.org/bug92

Index: TextKitImpl.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Text/TextKitImpl.cc,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- TextKitImpl.cc	25 Jan 2003 22:37:03 -0000	1.38
+++ TextKitImpl.cc	18 Feb 2003 07:26:35 -0000	1.39
@@ -46,16 +46,18 @@
 using namespace Berlin::TextKit;
 
 TextKitImpl::TextKitImpl(const std::string &id,
-			 const Fresco::Kit::PropertySeq &p)
-    : KitImpl(id, p),  _strut(0),
-      _lineCompositor(new LRCompositor()), 
-      _pageCompositor(new TBCompositor())
+			 const Fresco::Kit::PropertySeq &p,
+			 ServerContextImpl *c)
+  : KitImpl(id, p, c),
+    my_strut(0),
+    my_lineCompositor(new LRCompositor()), 
+    my_pageCompositor(new TBCompositor())
 { }
 
 TextKitImpl::~TextKitImpl()
 {
-  delete _lineCompositor;
-  delete _pageCompositor;
+  delete my_lineCompositor;
+  delete my_pageCompositor;
 }
 
 void TextKitImpl::bind(ServerContext_ptr sc)
@@ -63,12 +65,11 @@
   KitImpl::bind(sc);
   Fresco::Kit::PropertySeq props;
   props.length(0);
-  _canonicalDK =
-      DrawingKit::_narrow(sc->
-			  get_singleton("IDL:fresco.org/Fresco/DrawingKit:1.0"));
-  _layout = resolve_kit<LayoutKit>(sc,
-				   "IDL:fresco.org/Fresco/LayoutKit:1.0",
-				   props);
+  my_canonicalDK =
+    DrawingKit::_narrow(sc->get_singleton("IDL:fresco.org/Fresco/DrawingKit:1.0"));
+  my_layout = resolve_kit<LayoutKit>(sc,
+				     "IDL:fresco.org/Fresco/LayoutKit:1.0",
+				     props);
 }
 
 // chunks are flyweights
@@ -90,59 +91,59 @@
   if (len == 1) return glyph(u[0]);
   else 
   {
-      Graphic_var hbox = _layout->hbox();
-      hbox->append_graphic(Graphic_var(strut()));
-      Babylon::String tmp(Unicode::to_internal(u));
-      // for (unsigned int i = 0; i < len; ++i)
-      for(Babylon::vis_iterator i(tmp.begin(), tmp.end());
-	  i != tmp.end();
-	  ++i)
-	  hbox->append_graphic(Graphic_var(glyph(Unicode::to_CORBA(*i))));
-      return hbox._retn();
+    Graphic_var hbox = my_layout->hbox();
+    hbox->append_graphic(Graphic_var(strut()));
+    Babylon::String tmp(Unicode::to_internal(u));
+    // for (unsigned int i = 0; i < len; ++i)
+    for(Babylon::vis_iterator i(tmp.begin(), tmp.end());
+	i != tmp.end();
+	++i)
+      hbox->append_graphic(Graphic_var(glyph(Unicode::to_CORBA(*i))));
+    return hbox._retn();
   }
 }
 
 Graphic_ptr TextKitImpl::glyph(Unichar ch)
 {
-  Prague::Guard<Mutex> guard(_mutex);
-  if (_cache.find(ch) == _cache.end())
+  Prague::Guard<Mutex> guard(my_mutex);
+  if (my_cache.find(ch) == my_cache.end())
   {
-      Graphic::Requisition r;
-      GraphicImpl::init_requisition(r);
-      _canonicalDK->allocate_char(ch, r);
-      TextChunk *chunk = new TextChunk(ch, r);
-      activate(chunk);
-      _cache[ch] = chunk->_this();
+    Graphic::Requisition r;
+    GraphicImpl::init_requisition(r);
+    my_canonicalDK->allocate_char(ch, r);
+    TextChunk *chunk = new TextChunk(ch, r);
+    activate(chunk);
+    my_cache[ch] = chunk->_this();
   }
-  return Graphic::_duplicate(_cache[ch]);
+  return Graphic::_duplicate(my_cache[ch]);
 }
 
 Graphic_ptr TextKitImpl::strut()
 {
-  Prague::Guard<Mutex> guard(_mutex);
-  if (!_strut)
+  Prague::Guard<Mutex> guard(my_mutex);
+  if (!my_strut)
   {
-      DrawingKit::FontMetrics metrics = _canonicalDK->font_metrics();
-      Graphic::Requisition r;
-      GraphicImpl::init_requisition(r);
-      r.y.natural = r.y.minimum = r.y.maximum =
-	  static_cast<Coord>(metrics.height >> 6) /
-	  _canonicalDK->resolution(yaxis);
-      r.y.defined = true;
-      r.y.align = metrics.height == 0 ? 0.0 :
-	  static_cast<double>(metrics.ascender) / metrics.height; 
-      _strut = new Strut(r);
-      activate(_strut);
+    DrawingKit::FontMetrics metrics = my_canonicalDK->font_metrics();
+    Graphic::Requisition r;
+    GraphicImpl::init_requisition(r);
+    r.y.natural = r.y.minimum = r.y.maximum =
+      static_cast<Coord>(metrics.height >> 6) /
+      my_canonicalDK->resolution(yaxis);
+    r.y.defined = true;
+    r.y.align = metrics.height == 0 ? 0.0 :
+      static_cast<double>(metrics.ascender) / metrics.height; 
+    my_strut = new Strut(r);
+    activate(my_strut);
   }
-  return _strut->_this();
+  return my_strut->_this();
 }
 
 Graphic_ptr TextKitImpl::simple_viewer(TextBuffer_ptr buf)
 {
   Graphic_var tv = create<Graphic>(new TextViewer(buf,
 						  TextKit_var(_this()),
-						  _canonicalDK,
-						  _lineCompositor));
+						  my_canonicalDK,
+						  my_lineCompositor));
   buf->attach(Observer_ptr(Graphic_ptr(tv)));
   return tv;
 }
@@ -151,9 +152,9 @@
 {
   Graphic_var tv = create<Graphic>(new TerminalView(buf,
 						    TextKit_var(_this()),
-						    _canonicalDK,
-						    _lineCompositor,
-						    _pageCompositor));
+						    my_canonicalDK,
+						    my_lineCompositor,
+						    my_pageCompositor));
   buf->attach(Observer_ptr(Graphic_ptr(tv)));
   return tv;
 }
@@ -237,5 +238,5 @@
 extern "C" KitImpl *load()
 {
   static std::string properties[] = {"implementation", "TextKitImpl", "locale", "latin"};
-  return create_kit<TextKitImpl>("IDL:fresco.org/Fresco/TextKit:1.0", properties, 4);
+  return create_prototype<TextKitImpl>("IDL:fresco.org/Fresco/TextKit:1.0", properties, 4);
 } 

Index: TextKitImpl.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Text/TextKitImpl.hh,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- TextKitImpl.hh	5 Jan 2003 16:21:34 -0000	1.28
+++ TextKitImpl.hh	18 Feb 2003 07:26:35 -0000	1.29
@@ -34,8 +34,10 @@
 #include "TextChunk.hh"                // for our chunks
 #include <map>                         // for the cache
 
-namespace Berlin {
-namespace TextKit {
+namespace Berlin 
+{
+namespace TextKit 
+{
 
 class Compositor;
 class Strut;
@@ -45,9 +47,12 @@
 {
   typedef std::map<Fresco::Unichar, Fresco::Graphic_var> cache_t;
  public:
-  TextKitImpl(const std::string &, const Fresco::Kit::PropertySeq &);
+  TextKitImpl(const std::string &,
+	      const Fresco::Kit::PropertySeq &,
+	      ServerContextImpl *);
   virtual ~TextKitImpl();
-  virtual KitImpl *clone(const Fresco::Kit::PropertySeq &p) { return new TextKitImpl(repo_id(), p);}
+  virtual KitImpl *clone(const Fresco::Kit::PropertySeq &p, ServerContextImpl *c)
+  { return new TextKitImpl(repo_id(), p, c);}
   virtual void bind(Fresco::ServerContext_ptr);
 
   Fresco::Graphic_ptr chunk(const Fresco::Unistring &u);
@@ -63,14 +68,14 @@
   Fresco::Graphic_ptr style(Fresco::Graphic_ptr, const Fresco::Unistring &);
   Fresco::Graphic_ptr font_attribute(Fresco::Graphic_ptr, const Fresco::NVPair &);
  private:
-  cache_t                _cache;
-  Fresco::DrawingKit_var _canonicalDK;
+  cache_t                my_cache;
+  Fresco::DrawingKit_var my_canonicalDK;
 
-  RefCount_var<Fresco::LayoutKit> _layout;
-  Impl_var<Strut>       _strut;
-  Prague::Mutex         _mutex;
-  Compositor           *_lineCompositor;
-  Compositor           *_pageCompositor;
+  RefCount_var<Fresco::LayoutKit> my_layout;
+  Impl_var<Strut>       my_strut;
+  Prague::Mutex         my_mutex;
+  Compositor           *my_lineCompositor;
+  Compositor           *my_pageCompositor;
 };
 
 } // namespace
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.