"Fossies" - the Fresh Open Source Software Archive

Member "google-gadgets-for-linux-0.11.2/ggadget/edit_element_base.h" (2 Nov 2009, 6428 Bytes) of package /linux/misc/old/google-gadgets-for-linux-0.11.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2   Copyright 2008 Google Inc.
    3 
    4   Licensed under the Apache License, Version 2.0 (the "License");
    5   you may not use this file except in compliance with the License.
    6   You may obtain a copy of the License at
    7 
    8        http://www.apache.org/licenses/LICENSE-2.0
    9 
   10   Unless required by applicable law or agreed to in writing, software
   11   distributed under the License is distributed on an "AS IS" BASIS,
   12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13   See the License for the specific language governing permissions and
   14   limitations under the License.
   15 */
   16 
   17 #ifndef GGADGET_EDIT_ELEMENT_BASE_H__
   18 #define GGADGET_EDIT_ELEMENT_BASE_H__
   19 
   20 #include <string>
   21 #include <ggadget/canvas_interface.h>
   22 #include <ggadget/basic_element.h>
   23 #include <ggadget/scrolling_element.h>
   24 
   25 namespace ggadget {
   26 
   27 /**
   28  * @ingroup Elements
   29  * Base class of <a href=
   30  * "http://code.google.com/apis/desktop/docs/gadget_apiref.html#edit">
   31  * edit element</a>.
   32  *
   33  * Real EditElement implementation shall inherit
   34  * this class and implement its pure virtual functions.
   35  *
   36  * All scriptable properties will be registered in EditElementBase class,
   37  * derived class does not need to care about them.
   38  */
   39 class EditElementBase : public ScrollingElement {
   40  public:
   41   DEFINE_CLASS_ID(0x6C5D2E793806428F, ScrollingElement);
   42 
   43   EditElementBase(View *view, const char *name);
   44   virtual ~EditElementBase();
   45 
   46  protected:
   47   virtual void DoClassRegister();
   48 
   49  public:
   50   virtual bool IsTabStopDefault() const;
   51   virtual void Layout();
   52 
   53   /**
   54    * Connects a specified slot to onchange event signal.
   55    * The signal will be fired when FireOnChangeEvent() method is called by
   56    * derived class.
   57    */
   58   Connection *ConnectOnChangeEvent(Slot0<void> *slot);
   59 
   60  public:
   61   /** Gets the background color or texture of the text */
   62   virtual Variant GetBackground() const = 0;
   63   /** Sets the background color or texture of the text */
   64   virtual void SetBackground(const Variant &background) = 0;
   65 
   66   /** Gets whether the text is bold. */
   67   virtual bool IsBold() const = 0;
   68   /** Sets whether the text is bold. */
   69   virtual void SetBold(bool bold) = 0;
   70 
   71   /** Gets the text color of the text. */
   72   virtual std::string GetColor() const = 0;
   73   /** Sets the text color of the text. */
   74   virtual void SetColor(const char *color) = 0;
   75 
   76   /** Gets the text font. */
   77   virtual std::string GetFont() const = 0;
   78   /** Sets the text font. */
   79   virtual void SetFont(const char *font) = 0;
   80 
   81   /** Gets whether the text is italicized. */
   82   virtual bool IsItalic() const = 0;
   83   /** Sets whether the text is italicized. */
   84   virtual void SetItalic(bool italic) = 0;
   85 
   86   /** Gets whether the edit can display multiple lines of text. */
   87   virtual bool IsMultiline() const = 0;
   88   /**
   89    * Sets whether the edit can display multiple lines of text.
   90    * If @c false, incoming "\n"s are ignored, as are presses of the Enter key.
   91    */
   92   virtual void SetMultiline(bool multiline) = 0;
   93 
   94   /**
   95    * Gets the character that should be displayed each time the user
   96    * enters a character.
   97    */
   98   virtual std::string GetPasswordChar() const = 0;
   99   /**
  100    * Sets the character that should be displayed each time the user
  101    * enters a character. By default, the value is @c "\0", which means that the
  102    * typed character is displayed as-is.
  103    */
  104   virtual void SetPasswordChar(const char *passwordChar) = 0;
  105 
  106   /** Gets the text size in points. */
  107   double GetSize() const;
  108   /**
  109    * Sets the text size in points. Setting size to -1 will reset the
  110    * font size to default. The gadget host may allow the user to change the
  111    * default font size.
  112    * Subclasses should implement @c DoGetSize() and @c GetSize().
  113    */
  114   void SetSize(double size);
  115 
  116   /**
  117    * Same as GetSize(), except that if size is default, GetCurrentSize()
  118    * returns the current default point size instead of -1.
  119    */
  120   double GetCurrentSize() const;
  121 
  122   /** Gets whether the text is struke-out. */
  123   virtual bool IsStrikeout() const = 0;
  124   /** Sets whether the text is struke-out. */
  125   virtual void SetStrikeout(bool strikeout) = 0;
  126 
  127   /** Gets whether the text is underlined. */
  128   virtual bool IsUnderline() const = 0;
  129   /** Sets whether the text is underlined. */
  130   virtual void SetUnderline(bool underline) = 0;
  131 
  132   /** Gets the value of the element. */
  133   virtual std::string GetValue() const = 0;
  134   /** Sets the value of the element. */
  135   virtual void SetValue(const char *value) = 0;
  136 
  137   /** Gets whether to wrap the text when it's too large to display. */
  138   virtual bool IsWordWrap() const = 0;
  139   /** Sets whether to wrap the text when it's too large to display. */
  140   virtual void SetWordWrap(bool wrap) = 0;
  141 
  142   /** Gets whether the edit element is readonly */
  143   virtual bool IsReadOnly() const = 0;
  144   /** Sets whether the edit element is readonly */
  145   virtual void SetReadOnly(bool readonly) = 0;
  146 
  147   /** Gets detectUrls property, introduced in 5.8 */
  148   virtual bool IsDetectUrls() const = 0;
  149   /** Sets detectUrls property, introduced in 5.8 */
  150   virtual void SetDetectUrls(bool detect_urls) = 0;
  151 
  152   /** Gets the ideal bounding rect for the edit element which is large enough
  153    * for displaying the content without scrolling. */
  154   virtual void GetIdealBoundingRect(int *width, int *height) = 0;
  155 
  156   /**
  157    * Selects the specified characters in the edit box. The first character has
  158    * index 0. Use -1 to indicate the last character.
  159    *
  160    * Added in 5.5 out-of-beta
  161    */
  162   virtual void Select(int start, int end) = 0;
  163 
  164   /**
  165    * Selects all characters in the edit box.
  166    *
  167    * Added in 5.5 out-of-beta
  168    */
  169   virtual void SelectAll() = 0;
  170 
  171   /** Gets the text horizontal alignment setting. */
  172   virtual CanvasInterface::Alignment GetAlign() const = 0;
  173 
  174   /** Sets the text horizontal alignment setting. */
  175   virtual void SetAlign(CanvasInterface::Alignment align) = 0;
  176 
  177   /** Gets the text vertical alignment setting. */
  178   virtual CanvasInterface::VAlignment GetVAlign() const = 0;
  179 
  180   /** Sets the text vertical alignment setting. */
  181   virtual void SetVAlign(CanvasInterface::VAlignment valign) = 0;
  182 
  183  public:
  184   /**
  185    * Derived class shall call this method if the value is changed.
  186    */
  187   void FireOnChangeEvent() const;
  188 
  189  protected:
  190   /** Informs the derived class that the font size has changed. */
  191   virtual void OnFontSizeChange() = 0;
  192 
  193  private:
  194   DISALLOW_EVIL_CONSTRUCTORS(EditElementBase);
  195 
  196   class Impl;
  197   Impl *impl_;
  198 };
  199 
  200 } // namespace ggadget
  201 
  202 #endif // GGADGET_EDIT_ELEMENT_BASE_H__