2005-09-26 10:32:10 -07:00
|
|
|
/*
|
2006-01-06 23:20:58 -08:00
|
|
|
* Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors
|
|
|
|
* Copyright (C) 2004-2006 Kim Woelders
|
2005-09-26 10:32:10 -07:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#ifndef _TCLASS_H
|
|
|
|
#define _TCLASS_H
|
|
|
|
|
2006-04-06 14:20:16 -07:00
|
|
|
#include "etypes.h"
|
2005-09-26 10:32:10 -07:00
|
|
|
#include "xwin.h"
|
|
|
|
|
2006-10-18 11:19:14 -07:00
|
|
|
#define MODE_VERBATIM 0
|
|
|
|
#define MODE_WRAP_CHAR 1
|
|
|
|
#define MODE_WRAP_WORD 2
|
2005-09-26 10:32:10 -07:00
|
|
|
|
2006-10-18 11:19:14 -07:00
|
|
|
#define FONT_TO_RIGHT 0
|
|
|
|
#define FONT_TO_DOWN 1
|
|
|
|
#define FONT_TO_UP 2
|
|
|
|
#define FONT_TO_LEFT 3
|
2005-09-26 10:32:10 -07:00
|
|
|
|
2006-10-18 11:19:14 -07:00
|
|
|
#define FONT_TYPE_UNKNOWN 0
|
|
|
|
#define FONT_TYPE_IFT 1 /* Imlib2/FreeType */
|
2006-10-22 07:09:50 -07:00
|
|
|
#define FONT_TYPE_XFT 2 /* Xft */
|
|
|
|
#define FONT_TYPE_XFS 3 /* XFontSet */
|
2006-10-20 08:38:48 -07:00
|
|
|
#define FONT_TYPE_XFONT 0 /* XFontStruct */
|
2006-10-18 11:19:14 -07:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2006-10-22 07:09:50 -07:00
|
|
|
int (*Load) (TextState * ts, int fallback);
|
2006-10-18 11:19:14 -07:00
|
|
|
void (*Destroy) (TextState * ts);
|
|
|
|
void (*TextSize) (TextState * ts, const char *text, int len,
|
|
|
|
int *width, int *height, int *ascent);
|
2006-10-20 13:41:13 -07:00
|
|
|
void (*TextFit) (TextState * ts, char **ptext,
|
|
|
|
int *pwidth, int textwidth_limit);
|
2006-10-21 09:41:20 -07:00
|
|
|
void (*TextDraw) (TextState * ts, int x, int y,
|
|
|
|
const char *text, int len);
|
|
|
|
int (*FdcInit) (TextState * ts, Win win, Drawable draw);
|
|
|
|
void (*FdcFini) (TextState * ts);
|
|
|
|
void (*FdcSetDrawable) (TextState * ts, unsigned long draw);
|
|
|
|
void (*FdcSetColor) (TextState * ts, XColor * xc);
|
2006-10-18 11:19:14 -07:00
|
|
|
} FontOps;
|
2005-11-27 05:11:06 -08:00
|
|
|
|
2005-09-26 10:32:10 -07:00
|
|
|
struct _textstate
|
|
|
|
{
|
|
|
|
char *fontname;
|
2006-10-18 11:19:14 -07:00
|
|
|
char type;
|
|
|
|
char need_utf8;
|
2005-09-26 10:32:10 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
char mode;
|
|
|
|
char orientation;
|
2006-10-18 11:19:14 -07:00
|
|
|
char effect;
|
2005-09-26 10:32:10 -07:00
|
|
|
} style;
|
|
|
|
XColor fg_col;
|
|
|
|
XColor bg_col;
|
2006-10-21 09:41:20 -07:00
|
|
|
void *fdc;
|
2006-10-18 11:19:14 -07:00
|
|
|
const FontOps *ops;
|
2005-09-26 10:32:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _textclass
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
TextState *normal;
|
|
|
|
TextState *hilited;
|
|
|
|
TextState *clicked;
|
|
|
|
TextState *disabled;
|
|
|
|
}
|
|
|
|
norm , active, sticky, sticky_active;
|
|
|
|
int justification;
|
|
|
|
unsigned int ref_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* tclass.c */
|
|
|
|
int TextclassConfigLoad(FILE * fs);
|
|
|
|
void TextclassIncRefcount(TextClass * tc);
|
|
|
|
void TextclassDecRefcount(TextClass * tc);
|
|
|
|
int TextclassGetJustification(TextClass * tc);
|
2005-10-15 05:14:00 -07:00
|
|
|
void TextclassSetJustification(TextClass * tc, int just);
|
2005-09-26 10:32:10 -07:00
|
|
|
TextClass *TextclassFind(const char *name, int fallback);
|
|
|
|
|
|
|
|
/* text.c */
|
|
|
|
TextState *TextclassGetTextState(TextClass * tclass, int state,
|
|
|
|
int active, int sticky);
|
2006-11-11 16:39:19 -08:00
|
|
|
void TextstateTextFit(TextState * ts, char **ptext, int *pw,
|
|
|
|
int textwidth_limit);
|
2006-10-20 13:41:13 -07:00
|
|
|
void TextstateTextDraw(TextState * ts, Win win, Drawable draw,
|
2005-09-26 10:32:10 -07:00
|
|
|
const char *text, int x, int y, int w,
|
2006-05-24 17:18:10 -07:00
|
|
|
int h, const EImageBorder * pad,
|
|
|
|
int fsize, int justification);
|
2005-09-26 10:32:10 -07:00
|
|
|
void TextSize(TextClass * tclass, int active, int sticky,
|
|
|
|
int state, const char *text, int *width,
|
|
|
|
int *height, int fsize);
|
2006-05-08 09:26:22 -07:00
|
|
|
void TextDraw(TextClass * tclass, Win win, Drawable draw,
|
|
|
|
int active, int sticky, int state,
|
|
|
|
const char *text, int x, int y, int w, int h,
|
|
|
|
int fsize, int justification);
|
2005-09-26 10:32:10 -07:00
|
|
|
|
|
|
|
#endif /* _TCLASS_H */
|