2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: WXmString.h /main/4 1996/09/05 17:39:41 cde-hal $
26 * Copyright (c) 1991 HaL Computer Systems, Inc. All rights reserved.
27 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28 * States. Use of a copyright notice is precautionary only and does not
29 * imply publication or disclosure.
31 * This software contains confidential information and trade secrets of HaL
32 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
33 * without the prior express written permission of HaL Computer Systems, Inc.
35 * RESTRICTED RIGHTS LEGEND
36 * Use, duplication, or disclosure by the Government is subject to
37 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38 * Technical Data and Computer Software clause at DFARS 252.227-7013.
39 * HaL Computer Systems, Inc.
40 * 1315 Dell Avenue, Campbell, CA 95008
47 extern Boolean XmStringUngenerate(XmString, XmStringCharSet, char**);
57 enum { NO_COPY = False, COPY = True };
61 inline WXmString () { string = 0; }
62 inline WXmString (XmString s,
65 string = XmStringCopy(s);
69 inline WXmString (const WXmString& w) { string = w.Copy(); }
72 inline WXmString (const char* t, char *tag=XmFONTLIST_DEFAULT_TAG)
74 if (tag == XmFONTLIST_DEFAULT_TAG)
75 string = XmStringCreateLocalized((char *) t);
77 string = XmStringCreate ((char *) t, tag);
80 inline WXmString (char* t,
81 XmStringCharSet charset=XmSTRING_DEFAULT_CHARSET) {
82 string = XmStringCreateLtoR (t, charset);
85 inline WXmString (XmStringDirection d) {
86 string = XmStringDirectionCreate (d);
91 inline ~WXmString () {
92 if (string) XmStringFree (string);
97 inline WXmString& operator= (const WXmString& w) {
98 if (string) XmStringFree (string);
99 string = XmStringCopy(w.string);
102 inline WXmString& operator= (const XmString s) {
103 if (string) XmStringFree (string);
104 string = XmStringCopy(s);
107 inline WXmString& operator= (char *cs) {
108 if (string) XmStringFree (string);
109 #if XmVersion >= 1002
110 string = XmStringCreateLocalized (cs);
112 string = XmStringCreateLtoR (cs, XmSTRING_DEFAULT_CHARSET);
117 inline operator XmString () const { return string; }
118 inline operator XtArgVal () const { return (XtArgVal) string; }
119 inline operator char* () const {
121 #if XmVersion >= 1002
122 XmStringUngenerate(string, XmFONTLIST_DEFAULT_TAG, &ret);
124 XmStringGetLtoR (string, XmSTRING_DEFAULT_CHARSET, &ret);
128 inline Boolean operator== (XmString s) const {
129 return ByteCompare (s);
131 inline WXmString& operator<< (const WXmString& s) {
132 XmString n = Concat(s.string);
133 XmStringFree(string);
137 // Beware that this operator modifies the first string!!
138 inline WXmString& operator + (const WXmString& s) {
139 XmString n = Concat(s.string);
140 XmStringFree(string);
147 inline void Free () {
148 if (string) XmStringFree (string);
151 inline Dimension Baseline (XmFontList fl) const {
152 return XmStringBaseline (fl, string);
154 inline Boolean ByteCompare (XmString s) const {
155 return XmStringByteCompare (string, s);
157 inline Boolean Compare (XmString s) const {
158 return XmStringCompare (string, s);
160 // Caller responsible for deleting return value!!
161 inline XmString Concat (XmString s) const {
162 return XmStringConcat (string, s);
164 inline XmString Copy () const { return XmStringCopy (string); }
165 inline Boolean Empty () const { return XmStringEmpty (string); }
166 inline void Extent (XmFontList fl, Dimension* w, Dimension* h)
168 XmStringExtent (fl, string, w, h);
170 #if XmVersion >= 1002
171 inline Boolean GetLtoR (char** text, char *tag=XmFONTLIST_DEFAULT_TAG)
173 return XmStringUngenerate(string, tag, text);
176 inline Boolean GetLtoR (char** text,
177 XmStringCharSet cs=XmSTRING_DEFAULT_CHARSET)
179 return XmStringGetLtoR (string, cs, text);
182 inline Dimension Height (XmFontList fl) const {
183 return XmStringHeight (fl, string);
185 inline int LineCount () const {
186 return XmStringLineCount (string);
188 inline void NConcat (XmString s, int n) {
189 XmStringNConcat (string, s, n);
191 inline Dimension Width (XmFontList fl) const {
192 return XmStringWidth (fl, string);
194 inline void Zero () { string = 0; }
195 inline XmString disown() { XmString s = string; string = NULL; return s; }
197 WXmString CopyUsingFont( char* newtag );