[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
|
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
2699.0. "Mixing fonts inside Compound String Text Widgets ?" by SCOTMN::WOOD (El Vaquero) Wed May 02 1990 09:13
Hi,
Does anybody know if it is possible to mix fonts in DwtCSText
widget, if so, how ?
I have a customer who is creating two compound strings, concatenating
them and then adding the resultant string to the DwtCSText widget.
The problem is when using DwtGetNextSegment, only one segment is
returned with the concatenated string inside it.
What particularly perplexes me is the meaning of the 'char set'
argument in calls to DwtCSString and DwtCreateFontList.
Any information gratefully received
Richard
P.S. Here is the code to demonstrate the problem.
********************************************************************************
#include <decw$include:dwtappl.h>
#define newfont "-Adobe-Helvetica-Medium-R-Normal--18-*-*-*-*-*-ISO8859-1"
#define newfont1 "-Adobe-Courier-Bold-R-Normal--18-*-*-*-*-*-ISO8859-1"
static DwtCallback callback_arg[2];
static Widget toplevel,db,pb1,pb2,st;
static void set_text();
static void get_text();
static void no_font();
main(argc, argv)
int argc;
char **argv;
{
Arg args[4];
Display *dpy;
Font fid;
XFontStruct *font_struct;
DwtFontList font_list,new_font_list;
toplevel = XtInitialize(
"Pen",
"PenningtonClass",
NULL,
0,
&argc,
argv);
XtSetArg (args[0], DwtNwidth, 200 );
XtSetArg (args[1], DwtNheight, 200 );
db = DwtDialogBoxCreate ( toplevel,
"PenDialog",
args,
2);
callback_arg[0].proc = set_text;
callback_arg[0].tag = 0;
callback_arg[1].proc = NULL;
XtSetArg (args[0], DwtNx, 100 );
XtSetArg (args[1], DwtNy, 60 );
XtSetArg(args[2], DwtNactivateCallback, callback_arg );
pb1 = DwtPushButtonCreate ( db,
"PenPush1",
args,
3 );
callback_arg[0].proc = get_text;
callback_arg[0].tag = 0;
callback_arg[1].proc = NULL;
XtSetArg (args[0], DwtNx, 100 );
XtSetArg (args[1], DwtNy, 100 );
XtSetArg(args[2], DwtNactivateCallback, callback_arg );
pb2 = DwtPushButtonCreate ( db,
"PenPush2",
args,
3 );
dpy = XtDisplay(toplevel);
font_struct = XLoadQueryFont (dpy, newfont );
font_list = DwtCreateFontList (font_struct, 2);
font_struct = XLoadQueryFont (dpy, newfont1 );
new_font_list = DwtAddFontList (font_list, font_struct, 6);
XtManageChild(db);
XtManageChild(pb1);
XtManageChild(pb2);
XtRealizeWidget( toplevel );
callback_arg[0].proc = no_font;
callback_arg[0].tag = 0;
callback_arg[1].proc = NULL;
XtSetArg (args[0], DwtNx, 20 );
XtSetArg (args[1], DwtNy, 20 );
XtSetArg(args[2], DwtNnoFontCallback, callback_arg );
XtSetArg(args[3], DwtNfont, new_font_list );
st = DwtCSTextCreate (db,
"CSTEXT",
args,
4);
XtManageChild(st);
XtMainLoop();
} /* End Main */
static void set_text ( widget, tag, callback_data )
Widget widget;
char *tag;
DwtAnyCallbackStruct *callback_data;
{
DwtCompString s1,s2,test_str;
long lang,stat,direction,chr_set;
DwtRendMask rend;
DwtCompStringContext temp_ctxt;
char *txt_ptr;
printf("\nST>");
s1 = DwtCSString ("first part ",
1,
0,
lang,
rend);
s2 = DwtCSString ("second part",
6,
0,
lang,
rend);
test_str = DwtCStrcat(s1,s2);
DwtCSTextSetString (st,test_str);
stat = DwtInitGetSegment (&temp_ctxt, test_str);
if (stat == DwtSuccess)
{
stat = DwtGetNextSegment(&temp_ctxt,
&txt_ptr,
&chr_set,
&direction,
&lang,
&rend );
while (stat == DwtSuccess)
{
printf("\ntext ptr = %s",txt_ptr);
printf("\nchr set = %d", chr_set);
stat = DwtGetNextSegment(&temp_ctxt,
&txt_ptr,
&chr_set,
&direction,
&lang,
&rend );
}
}
else
printf("failed to get context\n");
}
static void get_text ( widget, tag, callback_data )
Widget widget;
char *tag;
DwtAnyCallbackStruct *callback_data;
{
DwtCompString s1,s2,test_str;
long lang,stat,direction,chr_set;
DwtRendMask rend;
DwtCompStringContext temp_ctxt;
char *txt_ptr;
printf("\nGT>");
test_str = DwtCSTextGetString(st);
stat = DwtInitGetSegment (&temp_ctxt, test_str);
if (stat == DwtSuccess)
{
stat = DwtGetNextSegment(&temp_ctxt,
&txt_ptr,
&chr_set,
&direction,
&lang,
&rend );
while (stat == DwtSuccess)
{
printf("\nGT>text ptr = %s",txt_ptr);
printf("\nGT>chr set = %d", chr_set);
stat = DwtGetNextSegment(&temp_ctxt,
&txt_ptr,
&chr_set,
&direction,
&lang,
&rend );
}
}
else
printf("GT>failed to get context\n");
}
static void no_font ( widget, tag, callback_data )
Widget widget;
char *tag;
DwtAnyCallbackStruct *callback_data;
{
printf("\nNo Font");
}
T.R | Title | User | Personal Name | Date | Lines |
---|
2699.1 | Don't know about SText, but... | DECWIN::KLEIN | | Wed May 02 1990 15:50 | 10 |
| If they are only interested in displaying the multi-font string (no editing,
no select-by-character), you might want to check out the VList widget.
It supports segmented strings, with different fonts, colors and stippling
per-segment. All the fonts should have the same character height, however,
for it to work right.
Send me mail if you'd like to try it out.
-steve-
|
2699.2 | Clarification please - CSText vs SText | SCOTMN::WOOD | El Vaquero | Fri May 04 1990 10:37 | 14 |
|
Hi again,
Can somebody please clarify what the difference is between
is between a Compound String Text Widget and a Simple Text Widget.
On the face of it the main difference is that the former can cope
with Compound Strings (with multiple segments), but this does not
seem to be the case; I have not been able to successfully insert
a Compound String with more than one segment into the CSText widget
data structure. Does anybody have any ideas.
Any info appreciated
Richard
|
2699.3 | Some Clarifications | ALEXWS::ALEX | Bugs are coming in triplets ... | Tue May 08 1990 06:28 | 32 |
| Richard!
The CStext Widget does handle multi-segment, multi-character-set compound
string with full I/O capability. It can handle segments with different directions
(this is the primary reason for making CStext).
There is a distinction between CHARACTER_SET and FONTS. CStext tries to match
CHARACTER_SET data of each segment against FontList. The FIRST font of the same
character set in the FontList is then used to display the character string in
the segment.
That means that different fonts MUST be specified for different character
sets, but all the segments with same character_set will be displayed in a SINGLE
font.
The ability to display different segments of same character set in different
font is the feature that is not supported by current implementation of CStext,
and as far as I know there are no plans to it. Most probably that the widget
that will be able to do this should be called MultiFontCStext.
What you see in your example is caused by the following feature of CStext:
In order to optimize the drawing of strings (remember that different segments
may be of different direction) CStext tries to combine all the segments of the
CString with same character set (i.e. pack the CString). In addition to this
all the text that is displayable in the first font in FontList (primary font) is
translated into segments with character_set of this font. This means, that the
font for character set that is most frequently used in CString should be the
first font of FontList.
Hope this helps,
Alex
|