Rapicorn - Experimental UI Toolkit - Source Code 10.08.1
text-editor.hh
Go to the documentation of this file.
00001 /* Rapicorn
00002  * Copyright (C) 2006 Tim Janik
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * A copy of the GNU Lesser General Public License should ship along
00015  * with this library; if not, see http://www.gnu.org/copyleft/.
00016  */
00017 #ifndef __RAPICORN_TEXT_EDITOR_HH__
00018 #define __RAPICORN_TEXT_EDITOR_HH__
00019 
00020 #include <ui/container.hh>
00021 
00022 namespace Rapicorn {
00023 namespace Text {
00024 
00025 struct ParaState {
00026   AlignType     align;
00027   EllipsizeType ellipsize;
00028   double        line_spacing;
00029   double        indent;
00030   String        font_family;
00031   double        font_size; /* absolute font size */
00032   explicit      ParaState();
00033 };
00034 
00035 struct AttrState {
00036   String   font_family;
00037   double   font_scale; /* relative font size */
00038   bool     bold;
00039   bool     italic;
00040   bool     underline;
00041   bool     small_caps;
00042   bool     strike_through;
00043   Color    foreground;
00044   Color    background;
00045   explicit AttrState();
00046 };
00047 
00048 class Editor : public virtual ContainerImpl {
00049 protected:
00050   virtual const PropertyList& list_properties();
00051 public:
00052   /* Text::Editor::Client */
00053   class Client {
00054   protected:
00055     const PropertyList& client_list_properties();
00056     virtual String      save_markup  () const = 0;
00057     virtual void        load_markup  (const String    &markup) = 0;
00058   public:
00059     virtual            ~Client ();
00060     virtual const char* peek_text    (int *byte_length) = 0;
00061     virtual ParaState   para_state   () const = 0;
00062     virtual void        para_state   (const ParaState &pstate) = 0;
00063     virtual AttrState   attr_state   () const = 0;
00064     virtual void        attr_state   (const AttrState &astate) = 0;
00065     /* properties */
00066     virtual String      markup_text  () const;
00067     virtual void        markup_text  (const String &markup);
00068     virtual TextMode    text_mode    () const = 0;
00069     virtual void        text_mode    (TextMode      text_mode) = 0;
00070     /* size negotiation */
00071     virtual double      text_requisition (uint          n_chars,
00072                                           uint          n_digits) = 0;
00073     /* mark handling */
00074     virtual int         mark            () const = 0; /* byte_index */
00075     virtual void        mark            (int              byte_index) = 0;
00076     virtual bool        mark_at_end     () const = 0;
00077     virtual bool        mark_to_coord   (double x, double y) = 0;
00078     virtual void        step_mark       (int              visual_direction) = 0;
00079     virtual void        mark2cursor     () = 0;
00080     virtual void        hide_cursor     () = 0;
00081     virtual void        mark_delete     (uint             n_utf8_chars) = 0;
00082     virtual void        mark_insert     (String           utf8string,
00083                                          const AttrState *astate = NULL) = 0;
00084   };
00085 public:
00086   /* Text::Editor */
00087   virtual void          text           (const String &text) = 0;
00088   virtual String        text           () const = 0;
00089   virtual TextMode      text_mode      () const = 0;
00090   virtual void          text_mode      (TextMode      text_mode) = 0;
00091   virtual String        markup_text    () const = 0;
00092   virtual void          markup_text    (const String &markup) = 0;
00093   virtual uint          request_chars  () const = 0;
00094   virtual void          request_chars  (uint nc) = 0;
00095   virtual uint          request_digits () const = 0;
00096   virtual void          request_digits (uint nd) = 0;
00097 };
00098 
00099 } // Text
00100 } // Rapicorn
00101 
00102 #endif  /* __RAPICORN_TEXT_EDITOR_HH__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines