00001 #ifndef __DW_FLTKPLATFORM_HH__
00002 #define __DW_FLTKPLATFORM_HH__
00003
00004 #ifndef __INCLUDED_FROM_DW_FLTK_CORE_HH__
00005 # error Do not include this file directly, use "fltkcore.hh" instead.
00006 #endif
00007
00008 namespace dw {
00009
00013 namespace fltk {
00014
00015 class FltkFont: public core::style::Font
00016 {
00017 class FontFamily: public lout::object::Object {
00018 Fl_Font font[4];
00019 public:
00020 FontFamily (Fl_Font fontNormal, Fl_Font fontBold,
00021 Fl_Font fontItalic, Fl_Font fontBoldItalic);
00022 void set (Fl_Font, int attrs);
00023 Fl_Font get (int attrs);
00024 };
00025
00026 static FontFamily standardFontFamily;
00027
00028 static lout::container::typed::HashTable <lout::object::ConstString,
00029 FontFamily> *systemFonts;
00030 static lout::container::typed::HashTable <dw::core::style::FontAttrs,
00031 FltkFont> *fontsTable;
00032
00033 FltkFont (core::style::FontAttrs *attrs);
00034 ~FltkFont ();
00035
00036 static void initSystemFonts ();
00037
00038 public:
00039 Fl_Font font;
00040
00041 static FltkFont *create (core::style::FontAttrs *attrs);
00042 static bool fontExists (const char *name);
00043 static Fl_Font get (const char *name, int attrs);
00044 };
00045
00046
00047 class FltkColor: public core::style::Color
00048 {
00049 static lout::container::typed::HashTable <dw::core::style::ColorAttrs,
00050 FltkColor> *colorsTable;
00051
00052 FltkColor (int color);
00053 ~FltkColor ();
00054
00055 public:
00056 int colors[SHADING_NUM];
00057
00058 static FltkColor *create(int color);
00059 };
00060
00061 class FltkTooltip: public core::style::Tooltip
00062 {
00063 private:
00064 FltkTooltip (const char *text);
00065 ~FltkTooltip ();
00066 public:
00067 static FltkTooltip *create(const char *text);
00068 static void cancel();
00069 void onEnter();
00070 void onLeave();
00071 void onMotion();
00072 };
00073
00074
00078 class FltkView: public core::View
00079 {
00080 public:
00081 virtual bool usesFltkWidgets () = 0;
00082
00083 virtual void addFltkWidget (Fl_Widget *widget,
00084 core::Allocation *allocation);
00085 virtual void removeFltkWidget (Fl_Widget *widget);
00086 virtual void allocateFltkWidget (Fl_Widget *widget,
00087 core::Allocation *allocation);
00088 virtual void drawFltkWidget (Fl_Widget *widget, core::Rectangle *area);
00089 };
00090
00091
00092 class FltkPlatform: public core::Platform
00093 {
00094 private:
00095 class FltkResourceFactory: public core::ui::ResourceFactory
00096 {
00097 private:
00098 FltkPlatform *platform;
00099
00100 public:
00101 inline void setPlatform (FltkPlatform *platform) {
00102 this->platform = platform; }
00103
00104 core::ui::LabelButtonResource *createLabelButtonResource (const char
00105 *label);
00106 core::ui::ComplexButtonResource *
00107 createComplexButtonResource (core::Widget *widget, bool relief);
00108 core::ui::ListResource *
00109 createListResource (core::ui::ListResource::SelectionMode selectionMode,
00110 int rows);
00111 core::ui::OptionMenuResource *createOptionMenuResource ();
00112 core::ui::EntryResource *createEntryResource (int maxLength,
00113 bool password,
00114 const char *label);
00115 core::ui::MultiLineTextResource *createMultiLineTextResource (int cols,
00116 int rows);
00117 core::ui::CheckButtonResource *createCheckButtonResource (bool
00118 activated);
00119 core::ui::RadioButtonResource *
00120 createRadioButtonResource (core::ui::RadioButtonResource
00121 *groupedWith, bool activated);
00122 };
00123
00124 FltkResourceFactory resourceFactory;
00125
00126 class IdleFunc: public lout::object::Object
00127 {
00128 public:
00129 int id;
00130 void (core::Layout::*func) ();
00131 };
00132
00133 core::Layout *layout;
00134
00135 lout::container::typed::List <IdleFunc> *idleQueue;
00136 bool idleFuncRunning;
00137 int idleFuncId;
00138
00139 static void generalStaticIdle(void *data);
00140 void generalIdle();
00141
00142 FltkView *view;
00143 lout::container::typed::List <ui::FltkResource> *resources;
00144
00145 public:
00146 FltkPlatform ();
00147 ~FltkPlatform ();
00148
00149 void setLayout (core::Layout *layout);
00150
00151 void attachView (core::View *view);
00152
00153 void detachView (core::View *view);
00154
00155 int textWidth (core::style::Font *font, const char *text, int len);
00156 int nextGlyph (const char *text, int idx);
00157 int prevGlyph (const char *text, int idx);
00158 float dpiX ();
00159 float dpiY ();
00160
00161 int addIdle (void (core::Layout::*func) ());
00162 void removeIdle (int idleId);
00163
00164 core::style::Font *createFont (core::style::FontAttrs *attrs,
00165 bool tryEverything);
00166 bool fontExists (const char *name);
00167 core::style::Color *createColor (int color);
00168 core::style::Tooltip *createTooltip (const char *text);
00169 void cancelTooltip();
00170
00171 core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height);
00172
00173 void copySelection(const char *text);
00174
00175 core::ui::ResourceFactory *getResourceFactory ();
00176
00177 void attachResource (ui::FltkResource *resource);
00178 void detachResource (ui::FltkResource *resource);
00179 };
00180
00181 }
00182 }
00183
00184 #endif // __DW_FLTKPLATFORM_HH__