diff options
author | jcid <devnull@localhost> | 2008-09-24 18:44:40 +0200 |
---|---|---|
committer | jcid <devnull@localhost> | 2008-09-24 18:44:40 +0200 |
commit | c377e06400f138325a9a9d43d91a9272691867a1 (patch) | |
tree | 49f3ca1c46af11a058a68714899d4137ec717618 /dw/platform.hh | |
parent | 642f9b3e747859a7256ea12fab9f9ed50aa9253a (diff) |
- Moved the dw2 tree into dillo2's tree.
Diffstat (limited to 'dw/platform.hh')
-rw-r--r-- | dw/platform.hh | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/dw/platform.hh b/dw/platform.hh new file mode 100644 index 00000000..0ae5d508 --- /dev/null +++ b/dw/platform.hh @@ -0,0 +1,144 @@ +#ifndef __DW_PLATFORM_HH__ +#define __DW_PLATFORM_HH__ + +#ifndef __INCLUDED_FROM_DW_CORE_HH__ +# error Do not include this file directly, use "core.hh" instead. +#endif + +namespace dw { +namespace core { + +/** + * \brief An interface to encapsulate some platform dependencies. + * + * \sa\ref dw-overview + */ +class Platform: public object::Object +{ +public: + /* + * ----------------------------------- + * General + * ----------------------------------- + */ + + /** + * \brief This methods notifies the platform, that it has been attached to + * a layout. + */ + virtual void setLayout (Layout *layout) = 0; + + /* + * ------------------------- + * Operations on views + * ------------------------- + */ + + /** + * \brief This methods notifies the platform, that a view has been attached + * to the related layout. + */ + virtual void attachView (View *view) = 0; + + /** + * \brief This methods notifies the platform, that a view has been detached + * from the related layout. + */ + virtual void detachView (View *view) = 0; + + /* + * ----------------------------------- + * Platform dependant properties + * ----------------------------------- + */ + + /** + * \brief Return the width of a text, with a given length and font. + */ + virtual int textWidth (style::Font *font, const char *text, int len) = 0; + + /** + * \brief Return the index of the next glyph in string text. + */ + virtual int nextGlyph (const char *text, int idx) = 0; + + /** + * \brief Return the index of the previous glyph in string text. + */ + virtual int prevGlyph (const char *text, int idx) = 0; + + /* + * --------------------------------------------------------- + * These are to encapsulate some platform dependencies + * --------------------------------------------------------- + */ + + /** + * \brief Add an idle function. + * + * An idle function is called once, when no other + * tasks are to be done (e.g. there are no events to process), and then + * removed from the queue. The return value is a number, which can be + * used in removeIdle below. + */ + virtual int addIdle (void (Layout::*func) ()) = 0; + + /** + * \brief Remove an idle function, which has not been processed yet. + */ + virtual void removeIdle (int idleId) = 0; + + /* + * --------------------- + * Style Resources + * --------------------- + */ + + /** + * \brief Create a (platform dependant) font. + * + * Typically, within a platform, a sub class of dw::core::style::Font + * is defined, which holds more platform dependant data. + * + * Also, this method must fill the attributes "font" (when needed), + * "ascent", "descent", "spaceSidth" and "xHeight". If "tryEverything" + * is true, several methods should be used to use another font, when + * the requested font is not available. Passing false is typically done, + * if the caller wants to test different variations. + */ + virtual style::Font *createFont (style::FontAttrs *attrs, + bool tryEverything) = 0; + + /** + * \brief Create a simple color resource for a given 0xrrggbb value. + */ + virtual style::Color *createSimpleColor (int color) = 0; + + /** + * \brief Create a shaded color resource for a given 0xrrggbb value. + */ + virtual style::Color *createShadedColor (int color) = 0; + + + /* + * -------------------- + * Image Buffers + * -------------------- + */ + virtual Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height) = 0; + + /** + * \brief Copy selected text (0-terminated). + */ + virtual void copySelection(const char *text) = 0; + + /** + * ... + */ + virtual ui::ResourceFactory *getResourceFactory () = 0; +}; + +} // namespace dw +} // namespace core + +#endif // __DW_PLATFORM_HH__ |