1 /* # skkinput (Simple Kana-Kanji Input)
2  *
3  * This file is part of skkinput.
4  * Copyright (C) 2002
5  * Takashi SAKAMOTO (PXG01715@nifty.ne.jp)
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with skkinput; see the file COPYING.  If not, write to
19  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 #if !defined (TConvAttr_h)
22 #define	TConvAttr_h
23 
24 #include "TFontSet.h"
25 
26 enum {
27 	CONVERSION_EVENTSELECT_INPUTONLY,
28 	CONVERSION_EVENTSELECT_FOCUS,
29 	CONVERSION_EVENTSELECT_NONE,
30 } ;
31 
32 enum {
33 	CONVERSION_INPUTSTYLE_ROOTWINDOW,
34 	CONVERSION_INPUTSTYLE_OFFTHESPOT,
35 	CONVERSION_INPUTSTYLE_OVERTHESPOT,
36 	CONVERSION_INPUTSTYLE_ONTHESPOT,
37 } ;
38 
39 enum {
40 	CAEventSelectBit		= 0,
41 	CAInputStyleBit			= 1,
42 	CAFocusWindowBit		= 2,
43 	CAPreeditMaskBit		= 3,
44 	CAStatusMaskBit			= 4,
45 } ;
46 
47 enum {
48 	CASpotLocationBit		= 0,
49 	CAClientAreaBit			= 1,
50 	/* font �� linespacing �ˤϽ����¸�����롣
51 	 *	CAFontBit < CALineSpacingBit �Ǥ��뤳�ȡ�
52 	 */
53 	CAFontBit				= 2,
54 	CALineSpacingBit		= 3,
55 	CAColormapBit			= 4,
56 	CAForegroundPixelBit	= 5,
57 	CABackgroundPixelBit	= 6,
58 	CABackgroundPixmapBit	= 7,
59 	CACursorBit				= 8,
60 	CAClientAreaNeededBit	= 9,
61 } ;
62 
63 #define	CAEventSelect		((unsigned long)1L << CAEventSelectBit)
64 #define	CAInputStyle		((unsigned long)1L << CAInputStyleBit)
65 #define	CAFocusWindow		((unsigned long)1L << CAFocusWindowBit)
66 #define	CAPreeditMask		((unsigned long)1L << CAPreeditMaskBit)
67 #define	CAStatusMask		((unsigned long)1L << CAStatusMaskBit)
68 
69 #define	CASpotLocation		((unsigned long)1L << CASpotLocationBit)
70 #define	CAClientArea		((unsigned long)1L << CAClientAreaBit)
71 #define	CAFont				((unsigned long)1L << CAFontBit)
72 #define	CALineSpacing		((unsigned long)1L << CALineSpacingBit)
73 #define	CAColormap			((unsigned long)1L << CAColormapBit)
74 #define	CAForegroundPixel	((unsigned long)1L << CAForegroundPixelBit)
75 #define	CABackgroundPixel	((unsigned long)1L << CABackgroundPixelBit)
76 #define	CABackgroundPixmap	((unsigned long)1L << CABackgroundPixmapBit)
77 #define	CACursor			((unsigned long)1L << CACursorBit)
78 #define	CAClientAreaNeeded	((unsigned long)1L << CAClientAreaNeededBit)
79 
80 typedef struct {
81 	unsigned int		m_uMask ;
82 	Pixel				m_foreground ;
83 	Pixel				m_background ;
84 	XPoint				m_spot ;
85 	XRectangle			m_area ;
86 	XRectangle			m_areaNeeded ;
87 	Colormap			m_colormap ;
88 	int					m_nLineSpacing ;
89 	TFontSet			m_FontSet ;
90 	Pixmap				m_pixBackground ;
91 	Cursor				m_cursor ;
92 }	PreeditAttribute ;
93 
94 typedef struct {
95 	unsigned int		m_uMask ;
96 	Pixel				m_foreground ;
97 	Pixel				m_background ;
98 	XRectangle			m_area ;
99 	XRectangle			m_areaNeeded ;
100 	int					m_nLineSpacing ;
101 	Colormap			m_colormap ;
102 	TFontSet			m_FontSet ;
103 	Pixmap				m_pixBackground ;
104 	Cursor				m_cursor ;
105 }	StatusAttribute ;
106 
107 struct tagTConversionAttribute {
108 	unsigned int		m_uMask ;
109 	int					m_nEventSelect ;
110 	int					m_nInputStyle ;
111 	Window				m_wndFocus ;
112 	PreeditAttribute	m_Preedit ;
113 	StatusAttribute		m_Status ;
114 } ;
115 
116 typedef struct tagTConversionAttribute	TConversionAttribute ;
117 
118 #define	IS_CONVATTR_MASK(ca,mask)			(((ca).m_uMask) & (mask))
119 #define	IS_CONVATTR_PREEDIT_MASK(ca,mask)	(((ca).m_Preedit.m_uMask) & (mask))
120 #define	IS_CONVATTR_STATUS_MASK(ca,mask)	(((ca).m_Status.m_uMask) & (mask))
121 #define	SET_CONVATTR_MASK(ca,mask)			{((ca).m_uMask) |= (mask) ;}
122 #define	SET_CONVATTR_PREEDIT_MASK(ca,mask)	{((ca).m_Preedit.m_uMask) |= (mask) ;}
123 #define	SET_CONVATTR_STATUS_MASK(ca,mask)	{((ca).m_Status.m_uMask) |= (mask) ;}
124 #define	UNSET_CONVATTR_MASK(ca,mask)			{((ca).m_uMask) &= ~(mask) ;}
125 #define	UNSET_CONVATTR_PREEDIT_MASK(ca,mask)	{((ca).m_Preedit.m_uMask) &= ~(mask) ;}
126 #define	UNSET_CONVATTR_STATUS_MASK(ca,mask)	{((ca).m_Status.m_uMask) &= ~(mask) ;}
127 #define	CLR_CONVATTR_MASK(ca)				{((ca).m_uMask) = 0 ;}
128 #define	CLR_CONVATTR_PREEDIT_MASK(ca)		{((ca).m_Preedit.m_uMask) = 0 ;}
129 #define	CLR_CONVATTR_STATUS_MASK(ca)		{((ca).m_Status.m_uMask) = 0 ;}
130 
131 #define	CONVATTR_FOCUSWINDOW(ca)			((ca).m_wndFocus)
132 #define	CONVATTR_PREEDIT_SPOT(ca)			((ca).m_Preedit.m_spot)
133 #define	CONVATTR_PREEDIT_CLIENTAREA(ca)		((ca).m_Preedit.m_area)
134 #define	CONVATTR_PREEDIT_FOREGROUND(ca)		((ca).m_Preedit.m_foreground)
135 #define	CONVATTR_PREEDIT_BACKGROUND(ca)		((ca).m_Preedit.m_background)
136 #define	CONVATTR_PREEDIT_FONTSET(ca)		((ca).m_Preedit.m_FontSet)
137 #define	CONVATTR_PREEDIT_COLORMAP(ca)		((ca).m_Preedit.m_colormap)
138 #define	CONVATTR_STATUS_FOREGROUND(ca)		((ca).m_Status.m_foreground)
139 #define	CONVATTR_STATUS_BACKGROUND(ca)		((ca).m_Status.m_background)
140 #define	CONVATTR_STATUS_CLIENTAREA(ca)		((ca).m_Status.m_area)
141 #define	CONVATTR_STATUS_FONTSET(ca)			((ca).m_Status.m_FontSet)
142 #define	CONVATTR_STATUS_COLORMAP(ca)		((ca).m_Status.m_colormap)
143 
144 #define	IS_AREA_EQUAL(area1,area2)			((area1).x == (area2).x && (area1).y == (area2).y && (area1).width == (area2).width && (area1).height == (area2).height)
145 
146 #define	TConvAttr_Initialize(pConvAttr)	\
147 {	\
148 	register TConversionAttribute*	ptr	= (pConvAttr) ;	\
149 	ptr->m_uMask	= ptr->m_Preedit.m_uMask	= ptr->m_Status.m_uMask	= 0 ;	\
150 	TFontSet_Initialize (&ptr->m_Preedit.m_FontSet) ;	\
151 	TFontSet_Initialize (&ptr->m_Status.m_FontSet) ;	\
152 }
153 
154 #define	TConvAttr_Uninitialize(pConvAttr)	\
155 {	\
156 	register TConversionAttribute*	ptr	= (pConvAttr) ;	\
157 	TFontSet_Destroy (&ptr->m_Preedit.m_FontSet) ;	\
158 	TFontSet_Destroy (&ptr->m_Status.m_FontSet) ;	\
159 }
160 
161 #define	TConvAttr_Copy(pDestOrg,pSrcOrg)	\
162 {	\
163 	register TConversionAttribute*	pDest	= (pDestOrg) ;	\
164 	register TConversionAttribute*	pSrc	= (pSrcOrg) ;	\
165 	if ((pSrc->m_uMask & CAPreeditMask) && (pSrc->m_Preedit.m_uMask & CAFont))	\
166 		TFontSet_Copy (&pDest->m_Preedit.m_FontSet, &pSrc->m_Preedit.m_FontSet) ;	\
167 	if ((pSrc->m_uMask & CAStatusMask)  && (pSrc->m_Status.m_uMask & CAFont))	\
168 		TFontSet_Copy (&pDest->m_Status.m_FontSet, &pSrc->m_Status.m_FontSet) ;	\
169 	memcpy (pDest, pSrc, sizeof (TConversionAttribute)) ;	\
170 }
171 
172 #endif
173 
174