TextSrc.c File Reference

#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xutil.h>
#include <X11/Xaw3d/XawInit.h>
#include <X11/Xaw3d/TextSrcP.h>
#include <X11/Xmu/Atoms.h>
#include <X11/Xmu/CharSet.h>
#include "XawI18n.h"
#include <stdio.h>
#include <ctype.h>

Include dependency graph for TextSrc.c:

Go to the source code of this file.

Defines

#define offset(field)   XtOffsetOf(TextSrcRec, textSrc.field)
#define SuperClass   (&objectClassRec)

Functions

static void ClassInitialize ()
static void ClassPartInitialize ()
static void SetSelection ()
static void CvtStringToEditMode ()
static Boolean ConvertSelection ()
static XawTextPosition Search ()
static XawTextPosition Scan ()
static XawTextPosition Read ()
static int Replace ()
static void ClassPartInitialize (WidgetClass wc)
static XawTextPosition Read (Widget w, XawTextPosition pos, XawTextBlock *text, int length)
static int Replace (Widget w, XawTextPosition startPos, XawTextPosition endPos, XawTextBlock *text)
static XawTextPosition Scan (Widget w, XawTextPosition position, XawTextScanType type, XawTextScanDirection dir, int count, Boolean include)
static XawTextPosition Search (Widget w, XawTextPosition position, XawTextScanDirection dir, XawTextBlock *text)
static Boolean ConvertSelection (Widget w, Atom *selection, Atom *target, Atom *type, XtPointer *value, unsigned long *length, int *format)
static void SetSelection (Widget w, XawTextPosition left, XawTextPosition right, Atom selection)
static void CvtStringToEditMode (XrmValuePtr args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal)
XawTextPosition XawTextSourceRead (Widget w, XawTextPosition pos, XawTextBlock *text, int length)
int XawTextSourceReplace (Widget w, XawTextPosition startPos, XawTextPosition endPos, XawTextBlock *text)
XawTextPosition XawTextSourceScan (Widget w, XawTextPosition position, XawTextScanType type, XawTextScanDirection dir, int count, Boolean include)
XawTextPosition XawTextSourceSearch (Widget w, XawTextPosition position, XawTextScanDirection dir, XawTextBlock *text)
Boolean XawTextSourceConvertSelection (Widget w, Atom *selection, Atom *target, Atom *type, XtPointer *value, unsigned long *length, int *format)
void XawTextSourceSetSelection (Widget w, XawTextPosition left, XawTextPosition right, Atom selection)
XrmQuark _XawTextFormat (TextWidget tw)
char * _XawTextWCToMB (Display *d, wchar_t *wstr, int *len_in_out)
wchar_t * _XawTextMBToWC (Display *d, char *str, int *len_in_out)

Variables

static XtResource resources []
TextSrcClassRec textSrcClassRec
WidgetClass textSrcObjectClass = (WidgetClass)&textSrcClassRec


Define Documentation

#define offset ( field   )     XtOffsetOf(TextSrcRec, textSrc.field)

Definition at line 58 of file TextSrc.c.

#define SuperClass   (&objectClassRec)

Definition at line 70 of file TextSrc.c.


Function Documentation

XrmQuark _XawTextFormat ( TextWidget  tw  ) 

Definition at line 579 of file TextSrc.c.

00582 {
00583   return (((TextSrcObject)(tw->text.source))->textSrc.text_format);
00584 }

wchar_t* _XawTextMBToWC ( Display *  d,
char *  str,
int len_in_out 
)

Definition at line 628 of file TextSrc.c.

References buf, and NULL.

00632 {
00633   if (*len_in_out == 0) {
00634     return(NULL);
00635   } else {
00636     XTextProperty textprop;
00637     char *buf;
00638     wchar_t **wlist, *wstr;
00639     int count;
00640     buf = XtMalloc(*len_in_out + 1);
00641     if (!buf) {
00642         XtErrorMsg("convertError", "multiSourceCreate", "XawError",
00643                  "No Memory", NULL, NULL);
00644         *len_in_out = 0;
00645         return (NULL);   /* The above function doesn't really return. */
00646     }
00647     strncpy(buf, str, *len_in_out);
00648     *(buf + *len_in_out) = '\0';
00649     if (XmbTextListToTextProperty(d, &buf, 1, XTextStyle, &textprop)
00650                         != Success) {
00651         XtWarningMsg("convertError", "textSource", "XawError",
00652                  "No Memory, or Locale not supported.", NULL, NULL);
00653         XtFree(buf);
00654         *len_in_out = 0;
00655         return (NULL);
00656     }
00657     XtFree(buf);
00658     if (XwcTextPropertyToTextList(d, &textprop,
00659                         (wchar_t***)&wlist, &count) != Success) {
00660         XtWarningMsg("convertError", "multiSourceCreate", "XawError",
00661                  "Non-character code(s) in source.", NULL, NULL);
00662         *len_in_out = 0;
00663         return (NULL);
00664     }
00665     wstr = wlist[0];
00666     *len_in_out = wcslen(wstr);
00667     XFree((char**)wlist); /* this is evil */
00668     return(wstr);
00669   }
00670 }

char* _XawTextWCToMB ( Display*  d,
wchar_t*  wstr,
int len_in_out 
)

Definition at line 599 of file TextSrc.c.

References NULL.

00604 {
00605     XTextProperty textprop;
00606     if (XwcTextListToTextProperty(d, (wchar_t**)&wstr, 1,
00607       XTextStyle, &textprop) < Success) {
00608       XtWarningMsg("convertError", "textSource", "XawError",
00609                  "Non-character code(s) in buffer.", NULL, NULL);
00610       *len_in_out = 0;
00611       return( NULL );
00612     }
00613     *len_in_out = textprop.nitems;
00614     return((char *)textprop.value);
00615 }

static void ClassInitialize (  )  [static]

static void ClassPartInitialize ( WidgetClass  wc  )  [static]

Definition at line 129 of file TextSrc.c.

References _TextSrcClassPart::ConvertSelection, _TextSrcClassRec::object_class, _TextSrcClassPart::Read, _TextSrcClassPart::Replace, _TextSrcClassPart::Scan, _TextSrcClassPart::Search, _TextSrcClassPart::SetSelection, _TextSrcClassRec::textSrc_class, XtInheritConvertSelection, XtInheritRead, XtInheritReplace, XtInheritScan, XtInheritSearch, and XtInheritSetSelection.

00131 {
00132   TextSrcObjectClass t_src, superC;
00133 
00134   t_src = (TextSrcObjectClass) wc;
00135   superC = (TextSrcObjectClass) t_src->object_class.superclass;
00136 
00137 /* 
00138  * We don't need to check for null super since we'll get to TextSrc
00139  * eventually.
00140  */
00141     if (t_src->textSrc_class.Read == XtInheritRead) 
00142       t_src->textSrc_class.Read = superC->textSrc_class.Read;
00143 
00144     if (t_src->textSrc_class.Replace == XtInheritReplace) 
00145       t_src->textSrc_class.Replace = superC->textSrc_class.Replace;
00146 
00147     if (t_src->textSrc_class.Scan == XtInheritScan) 
00148       t_src->textSrc_class.Scan = superC->textSrc_class.Scan;
00149 
00150     if (t_src->textSrc_class.Search == XtInheritSearch) 
00151       t_src->textSrc_class.Search = superC->textSrc_class.Search;
00152 
00153     if (t_src->textSrc_class.SetSelection == XtInheritSetSelection) 
00154       t_src->textSrc_class.SetSelection = superC->textSrc_class.SetSelection;
00155 
00156     if (t_src->textSrc_class.ConvertSelection == XtInheritConvertSelection) 
00157       t_src->textSrc_class.ConvertSelection =
00158                                        superC->textSrc_class.ConvertSelection;
00159 }

static void ClassPartInitialize (  ) 

static Boolean ConvertSelection ( Widget  w,
Atom *  selection,
Atom *  target,
Atom *  type,
XtPointer *  value,
unsigned long length,
int format 
) [static]

Definition at line 273 of file TextSrc.c.

References FALSE.

00279 {
00280   return(FALSE);
00281 }

static Boolean ConvertSelection (  )  [static]

static void CvtStringToEditMode ( XrmValuePtr  args,
Cardinal *  num_args,
XrmValuePtr  fromVal,
XrmValuePtr  toVal 
) [static]

Definition at line 304 of file TextSrc.c.

References editType, FALSE, NULL, TRUE, XawtextAppend, XawtextEdit, XawtextRead, and XmuCopyISOLatin1Lowered().

00309 {
00310   static XawTextEditType editType;
00311   static  XrmQuark  QRead, QAppend, QEdit;
00312   XrmQuark    q;
00313   char        lowerName[40];
00314   static Boolean inited = FALSE;
00315     
00316   if ( !inited ) {
00317     QRead   = XrmPermStringToQuark(XtEtextRead);
00318     QAppend = XrmPermStringToQuark(XtEtextAppend);
00319     QEdit   = XrmPermStringToQuark(XtEtextEdit);
00320     inited = TRUE;
00321   }
00322 
00323   if (strlen ((char*) fromVal->addr) < sizeof lowerName) {
00324     XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr);
00325     q = XrmStringToQuark(lowerName);
00326 
00327     if      (q == QRead)   editType = XawtextRead;
00328     else if (q == QAppend) editType = XawtextAppend;
00329     else if (q == QEdit)   editType = XawtextEdit;
00330     else {
00331       toVal->size = 0;
00332       toVal->addr = NULL;
00333       return;
00334     }
00335     toVal->size = sizeof editType;
00336     toVal->addr = (XPointer) &editType;
00337     return;
00338   }
00339   toVal->size = 0;
00340   toVal->addr = NULL;
00341 }

Here is the call graph for this function:

static void CvtStringToEditMode (  )  [static]

static XawTextPosition Read ( Widget  w,
XawTextPosition  pos,
XawTextBlock text,
int  length 
) [static]

Definition at line 178 of file TextSrc.c.

00183 {
00184   XtAppError(XtWidgetToApplicationContext(w), 
00185              "TextSrc Object: No read function is defined.");
00186 
00187   return( (XawTextPosition) 0 ); /* for gcc -Wall and lint */
00188 }

static XawTextPosition Read (  ) 

static int Replace ( Widget  w,
XawTextPosition  startPos,
XawTextPosition  endPos,
XawTextBlock text 
) [static]

Definition at line 200 of file TextSrc.c.

References XawEditError.

00204 {
00205   return(XawEditError);
00206 }

static int Replace (  )  [static]

static XawTextPosition Scan ( Widget  w,
XawTextPosition  position,
XawTextScanType  type,
XawTextScanDirection  dir,
int  count,
Boolean  include 
) [static]

Definition at line 225 of file TextSrc.c.

00232 {
00233   XtAppError(XtWidgetToApplicationContext(w), 
00234              "TextSrc Object: No SCAN function is defined.");
00235 
00236   return( (XawTextPosition) 0 ); /* for gcc -Wall and lint */
00237 }

static XawTextPosition Scan (  ) 

static XawTextPosition Search ( Widget  w,
XawTextPosition  position,
XawTextScanDirection  dir,
XawTextBlock text 
) [static]

Definition at line 250 of file TextSrc.c.

References XawTextSearchError.

00255 {
00256   return(XawTextSearchError);
00257 }

static XawTextPosition Search (  )  [static]

static void SetSelection ( Widget  w,
XawTextPosition  left,
XawTextPosition  right,
Atom  selection 
) [static]

Definition at line 293 of file TextSrc.c.

00297 {
00298   /* This space intentionally left blank. */
00299 }

static void SetSelection (  ) 

Boolean XawTextSourceConvertSelection ( Widget  w,
Atom *  selection,
Atom *  target,
Atom *  type,
XtPointer *  value,
unsigned long length,
int format 
)

Definition at line 515 of file TextSrc.c.

References NULL, textSrcObjectClass, and w.

00523 {
00524   TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
00525 
00526   if ( !XtIsSubclass( w, textSrcObjectClass ) )
00527       XtErrorMsg("bad argument", "textSource", "XawError",
00528                 "XawTextSourceConvertSelectionXawTextSourceConvertSelection's 1st parameter must be subclass of asciiSrc.",
00529                    NULL, NULL);
00530 
00531   return((*class->textSrc_class.ConvertSelection)(w, selection, target, type,
00532                                                   value, length, format));
00533 }

XawTextPosition XawTextSourceRead ( Widget  w,
XawTextPosition  pos,
XawTextBlock text,
int  length 
)

Definition at line 365 of file TextSrc.c.

References NULL, textSrcObjectClass, and w.

Referenced by DisplayText(), FindDistance(), and FindPosition().

00371 {
00372   TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
00373 
00374   if ( !XtIsSubclass( w, textSrcObjectClass ) )
00375       XtErrorMsg("bad argument", "textSource", "XawError",
00376                 "XawTextSourceRead's 1st parameter must be subclass of asciiSrc.",
00377                    NULL, NULL);
00378 
00379   return((*class->textSrc_class.Read)(w, pos, text, length));
00380 }

Here is the caller graph for this function:

int XawTextSourceReplace ( Widget  w,
XawTextPosition  startPos,
XawTextPosition  endPos,
XawTextBlock text 
)

Definition at line 396 of file TextSrc.c.

References NULL, textSrcObjectClass, and w.

00401 {
00402   TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
00403 
00404   if ( !XtIsSubclass( w, textSrcObjectClass ) )
00405       XtErrorMsg("bad argument", "textSource", "XawError",
00406                 "XawTextSourceReplace's 1st parameter must be subclass of asciiSrc.",
00407                    NULL, NULL);
00408 
00409   return((*class->textSrc_class.Replace)(w, startPos, endPos, text));
00410 }

XawTextPosition XawTextSourceScan ( Widget  w,
XawTextPosition  position,
XawTextScanType  type,
XawTextScanDirection  dir,
int  count,
Boolean  include 
)

Definition at line 441 of file TextSrc.c.

References NULL, textSrcObjectClass, and w.

Referenced by GetStringRaw().

00449 {
00450   TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
00451 
00452   if ( !XtIsSubclass( w, textSrcObjectClass ) )
00453       XtErrorMsg("bad argument", "textSource", "XawError",
00454                 "XawTextSourceScan's 1st parameter must be subclass of asciiSrc.",
00455                    NULL, NULL);
00456 
00457   return((*class->textSrc_class.Scan)(w, position, type, dir, count, include));
00458 }

Here is the caller graph for this function:

XawTextPosition XawTextSourceSearch ( Widget  w,
XawTextPosition  position,
XawTextScanDirection  dir,
XawTextBlock text 
)

Definition at line 480 of file TextSrc.c.

References NULL, textSrcObjectClass, and w.

00486 {
00487   TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
00488 
00489   if ( !XtIsSubclass( w, textSrcObjectClass ) )
00490       XtErrorMsg("bad argument", "textSource", "XawError",
00491                 "XawTextSourceSearch's 1st parameter must be subclass of asciiSrc.",
00492                    NULL, NULL);
00493 
00494   return((*class->textSrc_class.Search)(w, position, dir, text));
00495 }

void XawTextSourceSetSelection ( Widget  w,
XawTextPosition  left,
XawTextPosition  right,
Atom  selection 
)

Definition at line 548 of file TextSrc.c.

References NULL, textSrcObjectClass, and w.

00553 {
00554   TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
00555 
00556   if ( !XtIsSubclass( w, textSrcObjectClass ) )
00557       XtErrorMsg("bad argument", "textSource", "XawError",
00558                 "'s 1st parameter must be subclass of asciiSrc.",
00559                    NULL, NULL);
00560 
00561   (*class->textSrc_class.SetSelection)(w, left, right, selection);
00562 }


Variable Documentation

XtResource resources[] [static]

Initial value:

 {
    {XtNeditType, XtCEditType, XtREditMode, sizeof(XawTextEditType), 
        offset(edit_mode), XtRString, "read"},
}

Definition at line 59 of file TextSrc.c.

TextSrcClassRec textSrcClassRec

Definition at line 71 of file TextSrc.c.

WidgetClass textSrcObjectClass = (WidgetClass)&textSrcClassRec

Definition at line 118 of file TextSrc.c.


Generated on Sun Mar 4 16:02:50 2007 for Scilab [trunk] by  doxygen 1.5.1