00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
#ifndef _MB_EXP_H_
00030
#define _MB_EXP_H_
00031
00032
#include "libmb/mbconfig.h"
00033
#include "mbpixbuf.h"
00034
#include "mbdotdesktop.h"
00035
00036
#ifdef USE_XFT
00037
#include <X11/Xft/Xft.h>
00038
#include <locale.h>
00039
#include <langinfo.h>
00040
#endif
00041
00042
#ifdef USE_PANGO
00043
#include <pango/pango.h>
00044
#include <pango/pangoxft.h>
00045
#endif
00046
00047
#ifdef __cplusplus
00048
extern "C" {
00049
#endif
00050
00068
typedef struct MBColor
00069 {
00070
MBPixbuf *pb;
00071
00072
unsigned char r;
00073
unsigned char g;
00074
unsigned char b;
00075
unsigned char a;
00076
00077 XColor xcol;
00078
#if defined (USE_XFT) || defined (USE_PANGO)
00079
XftColor xftcol;
00080
#endif
00081
int ref_cnt;
00082
00083 }
MBColor;
00084
00092
typedef struct MBFont
00093 {
00094 Display *dpy;
00095
unsigned char *family;
00096
int weight;
00097
int slant;
00098
int pt_size;
00099 Bool have_shadow;
00100
00101
MBColor *col;
00102
00103
#ifdef USE_PANGO
00104
PangoContext *pgo_context;
00105 PangoFontMap *pgo_fontmap;
00106 PangoFontDescription *fontdes;
00107 PangoFont *font;
00108 PangoFontMetrics *metrics;
00109
#elif defined (USE_XFT)
00110
XftFont *font;
00111
#else
00112
GC gc;
00113 XFontStruct *font;
00114
#endif
00115
00116 Bool _have_fresh_font_object;
00117
int ref_cnt;
00118
00119 }
MBFont;
00120
00126 typedef enum {
00127
00128 MB_ENCODING_LATIN,
00129 MB_ENCODING_UTF8
00130
00131 }
MBEncoding;
00132
00138 typedef enum {
00139
00140 MB_NORMAL = 0,
00141 MB_LIGHT,
00142 MB_MEDIUM,
00143 MB_DEMIBOLD,
00144 MB_BOLD,
00145 MB_BLACK,
00146 MB_N_WEIGHTS
00147
00148 }
MBFontWeight;
00149
00155 typedef enum {
00156
00157 MB_ROMAN = 0,
00158 MB_ITALIC,
00159 MB_OBLIQUE,
00160
00161 MB_N_SLANTS
00162
00163 }
MBFontSlant;
00164
00170 typedef enum {
00171
00172 MB_FONT_RENDER_OPTS_NONE = 0,
00173 MB_FONT_RENDER_OPTS_CLIP_TRAIL = (1<<1),
00174 MB_FONT_RENDER_ALIGN_CENTER = (1<<2),
00175 MB_FONT_RENDER_ALIGN_RIGHT = (1<<3),
00176 MB_FONT_RENDER_EFFECT_SHADOW = (1<<4),
00177 MB_FONT_RENDER_VALIGN_MIDDLE = (1<<5)
00178
00179 }
MBFontRenderOpts;
00180
00189
typedef struct MBDrawable
00190 {
00191
MBPixbuf *pb;
00192 Pixmap xpixmap;
00193 Bool have_ext_pxm;
00194
#if defined (USE_XFT) || defined (USE_PANGO)
00195
XftDraw *xftdraw;
00196
#endif
00197
00198
int width, height;
00199 }
MBDrawable;
00200
00208
typedef struct MBLayout
00209 {
00210
int x;
00211
int y;
00212
int width;
00213
int height;
00214
int line_spacing;
00215
00216
unsigned char *txt;
00217
MBEncoding txt_encoding;
00218
MBFont *font;
00219
00220 Bool _have_autocalc_size;
00221
00222 }
MBLayout;
00223
00224
00225
00236
MBColor*
00237
mb_col_new_from_spec (MBPixbuf *pb,
char *spec);
00238
00239
00250 Bool
00251
mb_col_set (MBColor *col,
char *spec);
00252
00263
void
00264
mb_col_set_rgba (MBColor *col,
00265
unsigned char red,
00266
unsigned char green,
00267
unsigned char blue,
00268
unsigned char alpha);
00269
00280
void
00281
mb_col_get_rgba (MBColor *col,
00282
unsigned char *red,
00283
unsigned char *green,
00284
unsigned char *blue,
00285
unsigned char *alpha);
00286
00287
00288
#define mb_col_red(col) (col)->r
00289
#define mb_col_green(col) (col)->g
00290
#define mb_col_blue(col) (col)->b
00291
#define mb_col_alpha(col) (col)->a
00292
#define mb_col_xpixel(col) (col)->xcol.pixel
00293
00294
00295
00296
00302
void
00303
mb_col_unref (MBColor *col);
00304
00305
00306
00314
MBFont*
00315
mb_font_new (Display *dpy,
00316
char *family);
00317
00323
void
00324
mb_font_ref(MBFont* font);
00325
00331
void
00332
mb_font_unref(MBFont* font);
00333
00342
MBFont*
00343
mb_font_new_from_string(Display *dpy,
char *spec) ;
00344
00353
MBFont*
00354
mb_font_set_from_string(MBFont *font,
char *spec) ;
00355
00362
void
00363
mb_font_set_family (MBFont *font,
const char *family);
00364
00371
char*
00372
mb_font_get_family (MBFont *font);
00373
00374
00375
char*
00376 mb_font_get (MBFont *font);
00377
00384
void
00385
mb_font_set_weight (MBFont *font, MBFontWeight weight);
00386
00393
MBFontWeight
00394
mb_font_get_weight (MBFont *font);
00395
00402
void
00403
mb_font_set_slant (MBFont *font, MBFontSlant slant);
00404
00405
00406
00407
00414
void
00415
mb_font_set_point_size (MBFont *font,
int points);
00416
00423
int
00424
mb_font_get_point_size (MBFont *font);
00425
00434
int
00435
mb_font_set_size_to_pixels (MBFont *font,
int max_pixels,
int *points_to_try);
00436
00445
void
00446
mb_font_set_color (MBFont *font, MBColor *col);
00447
00454
MBColor *
00455
mb_font_get_color (MBFont *font);
00456
00457
00458
int
00459 mb_font_get_txt_width (MBFont *font,
00460
unsigned char *txt,
00461
int byte_len,
00462
int encoding);
00463
00470
int
00471
mb_font_get_height (MBFont *font);
00472
00479
int
00480
mb_font_get_ascent(MBFont *font);
00481
00488
int
00489
mb_font_get_descent(MBFont *font);
00490
00491
00505
int
00506
mb_font_render_simple (MBFont *font,
00507 MBDrawable *drw,
00508
int x,
00509
int y,
00510
int width,
00511
unsigned char *text,
00512
int encoding,
00513 MBFontRenderOpts opts);
00514
00515
00516
00517
00518
00519
00520
00521
00522
MBLayout *
00523 mb_layout_new (
void);
00524
00525
void
00526 mb_layout_unref (MBLayout *layout);
00527
00528
void
00529 mb_layout_set_font(MBLayout *layout, MBFont *font);
00530
00531
00532
00533
void
00534 mb_layout_set_geometry(MBLayout *layout,
00535
int width,
int height);
00536
00537
void
00538 mb_layout_get_geometry(MBLayout *layout,
00539
int *width,
int *height);
00540
00541
00542
void
00543 mb_layout_set_text(MBLayout *layout,
00544
unsigned char *text,
00545 MBEncoding encoding);
00546
00547
void
00548 mb_layout_destroy (MBLayout *layout);
00549
00550
void
00551 mb_layout_set_multiline (MBLayout *layout, Bool want_multiline);
00552
00553
void
00554 mb_layout_set_align (MBLayout *layout,
int horizontal,
int vertical);
00555
00556
void
00557 mb_layout_set_clip_style (MBLayout *layout,
int clip_stype);
00558
00559
void
00560 mb_layout_render (MBLayout *layout,
00561 MBDrawable *drw,
00562
int x,
00563
int y,
00564 MBFontRenderOpts opts);
00565
00566
#define mb_layout_width(l) (l)->width
00567
#define mb_layout_height(l) (l)->height
00568
00569
00570
00571
00581
MBDrawable*
00582
mb_drawable_new (MBPixbuf *pixbuf,
int width,
int height);
00583
00593
MBDrawable*
00594
mb_drawable_new_from_pixmap (MBPixbuf *pixbuf, Pixmap pxm);
00595
00602
void
00603
mb_drawable_unref (MBDrawable* drw);
00604
00610 #define mb_drawable_pixmap(drw) (drw)->xpixmap
00611
00612
00613
int
00614 mb_util_next_utf8_char (
unsigned char **string);
00615
00618
#ifdef __cplusplus
00619
}
00620
#endif
00621
00622
#endif