*** empty log message ***
[m17n/m17n-lib.git] / src / internal-gui.h
index c50d936..0ea3d04 100644 (file)
@@ -1,5 +1,5 @@
 /* internal-gui.h -- common header file for the internal GUI API.
-   Copyright (C) 2003, 2004
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    02111-1307, USA.  */
 
 #ifndef _M_INTERNAL_GUI_H
 #define _M_INTERNAL_GUI_H
 
-typedef struct MWDevice MWDevice;
-
-extern MSymbol Mfont;
+enum MDeviceType
+  {
+    MDEVICE_SUPPORT_OUTPUT = 1,
+    MDEVICE_SUPPORT_INPUT = 2
+  };
 
 typedef struct MRealizedFont MRealizedFont;
 typedef struct MRealizedFace MRealizedFace;
 typedef struct MRealizedFontset MRealizedFontset;
+typedef struct MDeviceDriver MDeviceDriver;
 
 /** Information about a frame.  */
 
@@ -37,9 +40,9 @@ struct MFrame
 {
   M17NObject control;
 
-  /** Pointer to a window-system dependent device object associated
-      with the frame.  */
-  MWDevice *device;
+  MSymbol foreground, background, videomode;
+
+  MFont *font;
 
   /** The default face of the frame.  */
   MFace *face;
@@ -51,11 +54,34 @@ struct MFrame
       character of the default face.  */
   int space_width;
 
+  int average_width;
+
   /** The default ascent and descent of a line.  It is ascent and
       descent of ASCII font of the default face.  */
   int ascent, descent;
 
-  /** The following three members are set by mwin__open_device ().  */
+  /** Initialized to 0 and incremented on each modification of a face
+      on which one of the realized faces is based.  */
+  unsigned tick;
+
+  /** Pointer to device dependent information associated with the
+      frame.  */
+  void *device;
+
+  /** The following members are set by "device_open" function of a
+      device dependent library.  */
+
+  /** Logical OR of enum MDeviceType.  */
+  int device_type;
+
+  /** Resolution (dots per inch) of the device.  */
+  int dpi;
+
+  /** Correction of functions to manipulate the device.  */
+  MDeviceDriver *driver;
+
+  /** List of font drivers.  */
+  MPlist *font_driver_list;
 
   /** List of realized fonts.  */
   MPlist *realized_font_list;
@@ -67,6 +93,18 @@ struct MFrame
   MPlist *realized_fontset_list;
 };
 
+#define M_CHECK_WRITABLE(frame, err, ret)                      \
+  do {                                                         \
+    if (! ((frame)->device_type & MDEVICE_SUPPORT_OUTPUT))     \
+      MERROR ((err), (ret));                                   \
+  } while (0)
+
+#define M_CHECK_READABLE(frame, err, ret)                      \
+  do {                                                         \
+    if (! ((frame)->device_type & MDEVICE_SUPPORT_INPUT))      \
+      MERROR ((err), (ret));                                   \
+  } while (0)
+
 enum glyph_type
   {
     GLYPH_CHAR,
@@ -77,46 +115,46 @@ enum glyph_type
     GLYPH_TYPE_MAX
   };
 
-struct MGlyph
+enum glyph_category
+  {
+    GLYPH_CATEGORY_NORMAL,
+    GLYPH_CATEGORY_MODIFIER,
+    GLYPH_CATEGORY_FORMATTER
+  };
+
+typedef struct
 {
-  int pos, to;
-  int c;
-  unsigned code;
-  MSymbol category;
+  MFLTGlyph g;
   MRealizedFace *rface;
-  short width, ascent, descent, lbearing, rbearing;
-  short xoff, yoff;
-  unsigned enabled : 1;
   unsigned left_padding : 1;
   unsigned right_padding : 1;
-  unsigned otf_encoded : 1;
+  unsigned enabled : 1;
   unsigned bidi_level : 6;
-  enum glyph_type type : 3;
-  int combining_code;
-};
-
-typedef struct MGlyph MGlyph;
+  unsigned category : 2;
+  unsigned type : 3;
+} MGlyph;
 
 struct MGlyphString
 {
   M17NObject head;
 
+  MFrame *frame;
+  int tick;
+
   int size, inc, used;
   MGlyph *glyphs;
-  MText *mt;
   int from, to;
   short width, height, ascent, descent;
   short physical_ascent, physical_descent, lbearing, rbearing;
   short text_ascent, text_descent, line_ascent, line_descent;
   int indent, width_limit;
 
-  /* Members to keep temporary data while layouting.  */
-  short sub_width, sub_lbearing, sub_rbearing;
+  /* Copied for <control>.anti_alias but never set if the frame's
+     depth is less than 8.  */
+  unsigned anti_alias : 1;
 
   MDrawControl control;
 
-  MDrawRegion region;
-
   struct MGlyphString *next, *top;
 };
 
@@ -157,30 +195,61 @@ struct MGlyphString
     (gstring)->used -= newlen;                                           \
   } while (0)
 
-#define MAKE_COMBINING_CODE(base_y, base_x, add_y, add_x, off_y, off_x)        \
-  (((off_y) << 16)                                                     \
-   | ((off_x) << 8)                                                    \
-   | ((base_x) << 6)                                                   \
-   | ((base_y) << 4)                                                   \
-   | ((add_x) << 2)                                                    \
-   | (add_y))
-
-#define COMBINING_CODE_OFF_Y(code) (((code) >> 16) & 0xFF)
-#define COMBINING_CODE_OFF_X(code) (((code) >> 8) & 0xFF)
-#define COMBINING_CODE_BASE_X(code) (((code) >> 6) & 0x3)
-#define COMBINING_CODE_BASE_Y(code) (((code) >> 4) & 0x3)
-#define COMBINING_CODE_ADD_X(code) (((code) >> 2) & 0x3)
-#define COMBINING_CODE_ADD_Y(code) ((code) & 0x3)
-
-#define MAKE_COMBINING_CODE_BY_CLASS(class) (0x1000000 | class)
+typedef struct MGlyphString MGlyphString;
 
-#define COMBINING_BY_CLASS_P(code) ((code) & 0x1000000)
+typedef struct
+{
+  short x, y;
+} MDrawPoint;
 
-#define COMBINING_CODE_CLASS(code) ((code) & 0xFFFFFF)
+struct MDeviceDriver
+{
+  void (*close) (MFrame *frame);
+  void *(*get_prop) (MFrame *frame, MSymbol key);
+  void (*realize_face) (MRealizedFace *rface);
+  void (*free_realized_face) (MRealizedFace *rface);
+  void (*fill_space) (MFrame *frame, MDrawWindow win,
+                     MRealizedFace *rface, int reverse,
+                     int x, int y, int width, int height,
+                     MDrawRegion region);
+  void (*draw_empty_boxes) (MDrawWindow win, int x, int y,
+                           MGlyphString *gstring,
+                           MGlyph *from, MGlyph *to,
+                           int reverse, MDrawRegion region);
+  void (*draw_hline) (MFrame *frame, MDrawWindow win,
+                     MGlyphString *gstring,
+                     MRealizedFace *rface, int reverse,
+                     int x, int y, int width, MDrawRegion region);
+  void (*draw_box) (MFrame *frame, MDrawWindow win,
+                   MGlyphString *gstring,
+                   MGlyph *g, int x, int y, int width,
+                   MDrawRegion region);
+
+  void (*draw_points) (MFrame *frame, MDrawWindow win,
+                      MRealizedFace *rface,
+                      int intensity, MDrawPoint *points, int num,
+                      MDrawRegion region);
+  MDrawRegion (*region_from_rect) (MDrawMetric *rect);
+  void (*union_rect_with_region) (MDrawRegion region, MDrawMetric *rect);
+  void (*intersect_region) (MDrawRegion region1, MDrawRegion region2);
+  void (*region_add_rect) (MDrawRegion region, MDrawMetric *rect);
+  void (*region_to_rect) (MDrawRegion region, MDrawMetric *rect);
+  void (*free_region) (MDrawRegion region);
+  void (*dump_region) (MDrawRegion region);
+  MDrawWindow (*create_window) (MFrame *frame, MDrawWindow parent);
+  void (*destroy_window) (MFrame *frame, MDrawWindow win);
+  void (*map_window) (MFrame *frame, MDrawWindow win);
+  void (*unmap_window) (MFrame *frame, MDrawWindow win);
+  void (*window_geometry) (MFrame *frame, MDrawWindow win,
+                          MDrawWindow parent, MDrawMetric *geometry);
+  void (*adjust_window) (MFrame *frame, MDrawWindow win,
+                        MDrawMetric *current, MDrawMetric *new);
+  MSymbol (*parse_event) (MFrame *frame, void *arg, int *modifiers);
+};
 
-typedef struct MGlyphString MGlyphString;
+extern MSymbol Mlatin;
 
-typedef struct MFontDriver MFontDriver;
+extern MSymbol Mgd;
 
 extern int mfont__init ();
 extern void mfont__fini ();
@@ -197,82 +266,4 @@ extern void mfont__fontset_fini ();
 extern int minput__win_init ();
 extern void minput__win_fini ();
 
-extern int mwin__init ();
-extern void mwin__fini ();
-
-extern MWDevice *mwin__open_device (MFrame *frame, MPlist *plist);
-
-extern void mwin__close_device (MFrame *frame);
-
-extern void *mwin__device_get_prop (MWDevice *device, MSymbol key);
-
-extern int mwin__parse_font_name (char *name, MFont *font);
-
-extern char *mwin__build_font_name (MFont *font);
-
-extern void mwin__realize_face (MRealizedFace *rface);
-
-extern void mwin__free_realized_face (MRealizedFace *rface);
-
-extern void mwin__fill_space (MFrame *frame, MDrawWindow win,
-                             MRealizedFace *rface, int reverse,
-                             int x, int y, int width, int height,
-                             MDrawRegion region);
-
-extern void mwin__draw_hline (MFrame *frame, MDrawWindow win,
-                             MGlyphString *gstring,
-                             MRealizedFace *rface, int reverse,
-                             int x, int y, int width, MDrawRegion region);
-
-extern void mwin__draw_box (MFrame *frame, MDrawWindow win,
-                           MGlyphString *gstring,
-                           MGlyph *g, int x, int y, int width,
-                           MDrawRegion region);
-
-extern void mwin__draw_bitmap (MFrame *frame, MDrawWindow win,
-                              MRealizedFace *rface, int reverse,
-                              int x, int y,
-                              int width, int height, int row_bytes,
-                              unsigned char *bmp,
-                              MDrawRegion region);
-
-extern MDrawRegion mwin__region_from_rect (MDrawMetric *rect);
-
-extern void mwin__union_rect_with_region (MDrawRegion region,
-                                         MDrawMetric *rect);
-
-extern void mwin__intersect_region (MDrawRegion region1, MDrawRegion region2);
-
-extern void mwin__region_add_rect (MDrawRegion region, MDrawMetric *rect);
-
-extern void mwin__region_to_rect (MDrawRegion region, MDrawMetric *rect);
-
-extern void mwin__free_region (MDrawRegion region);
-
-extern void mwin__verify_region (MFrame *frame, MDrawRegion region);
-
-extern void mwin__dump_region (MDrawRegion region);
-
-extern MDrawWindow mwin__create_window (MFrame *frame, MDrawWindow parent);
-
-extern void mwin__destroy_window (MFrame *frame, MDrawWindow win);
-
-#if 0
-extern MDrawWindow mwin__event_window (void *event);
-
-extern void mwin__print_event (void *event, char *win_name);
-#endif
-
-extern void mwin__map_window (MFrame *frame, MDrawWindow win);
-
-extern void mwin__unmap_window (MFrame *frame, MDrawWindow win);
-
-extern void mwin__window_geometry (MFrame *frame, MDrawWindow win,
-                                  MDrawWindow parent, MDrawMetric *geometry);
-
-extern void mwin__adjust_window (MFrame *frame, MDrawWindow win,
-                                MDrawMetric *current, MDrawMetric *new);
-
-extern MSymbol mwin__parse_event (MFrame *frame, void *arg, int *modifiers);
-
 #endif /* _M_INTERNAL_GUI_H */