T.R | Title | User | Personal Name | Date | Lines |
---|
966.1 | Not easy | SX4GTO::ROSE | | Fri Jun 16 1989 13:39 | 17 |
| A compound string is made up of a bunch of segments, each potentially
in a different character set. You need to use DwtGetNextSegment to
retrieve each segment as a sequence of bytes, and then (based on the
character set) translate that sequence of bytes to ascii. The latter
part is quite tricky...
Suppose the compound string segment is in Cyrillic. You have various
choices for how to express it in ascii. For example the Cyrillic letter
that looks like an x can be transcribed h or kh. You can ignore the
soft sign or represent it as ', etc.
If the compound string segment is in kanji, then you're in for more
fun. Not only do you have to choose a romanization system, let's say
Hepburn with the macrons omitted, but you also have to figure out from
context what the right reading is for each character. (Lots and lots of
characters have three or four or more...)
|
966.2 | here's an example | NEURON::NICHOLSON | A belly as big as an oil spill | Fri Jun 16 1989 18:16 | 38 |
| In the simple case where your compound string is a single segment
and your character set is Latin1, you can use a routine similar to
the following (which I hacked together from some code of Dave
Burleigh's).
#include <stdio.h>
#include <decw$include:DwtAppl.h>
char *ascii_from_cmp ( DwtCompString value )
{
DwtCompStringContext context;
char *ascii_string;
/* First get the compound string context */
if ( DwtInitGetSegment ( &context, value ) == DwtSuccess )
{
int charset, direction, language, rendition;
/* Then get the next (first) text segment */
if ( DwtGetNextSegment ( &context, &ascii_string, &charset,
&direction, &language, &rendition ) == DwtSuccess )
return ascii_string;
else
{
fprintf ( stderr, "Can't get next segment\n" );
return NULL;
}
}
else
{
fprintf ( stderr, "Can't create string context\n" );
return NULL;
}
}
|
966.3 | make sure you free the string when you're finished | NEURON::NICHOLSON | A belly as big as an oil spill | Sun Jun 18 1989 18:10 | 5 |
| I might add that the storage for the string returned by
DwtGetNextSegment is allocated in that routine (if you use the C
format) so you should XtFree the string my routine returns to you
when you are finished with it.
|
966.4 | How to get multiple segments from a list box | ASIMOV::KENYON | The Foundation of Science (fiction) | Wed Jul 26 1989 10:40 | 14 |
| I am working with a CMP who needs to get the text from the selections
made in a list box. If one selection is made his routine works fine
(as in .2), but if more than one entry is selected only the first is
returned.
How can he get an unknown number of selected entries returned as text?
The reason he would like to do this is he needs to use the text(s) as
input to other processing the application does.
thanks for any assistance,
-jeff
|
966.5 | only last selected item per callback | CB750C::BOLGATZ | | Wed Jul 26 1989 12:52 | 13 |
| listbox only returns in the last selected item in its callback.
In other words, your application will get a callback every time
an item is selected. The reason field - single or extend - will
indicate whether other items are selected as well. Therefore,
its fairly easy to track the selected items yourself. (see pp. 8 - 82-84
in the V1 VMS DECwindows Toolkit Routines Ref Manual).
You can also obtain the entire list of selected items using GetValues on
DwtNselectedItems and DwtNselectedItemsCount. SelectedItems points to an
array of cs strings comprising the current selected item list...
Jay
|
966.6 | | QUARK::LIONEL | Free advice is worth every cent | Wed Jul 26 1989 13:04 | 7 |
| Just make sure you use something like DwtCStrcpy to copy the string
value from the callback structure and not just save away the value
from the structure. I fixed DECBURGER so it wouldn't make this mistake
when I noticed it no longer worked in DW V2.
Steve
|