Back to index

plt-scheme  4.2.1
xwLabel.c
Go to the documentation of this file.
00001 /* Generated by wbuild
00002  * (generator version 3.2)
00003  */
00004 #include <X11/IntrinsicP.h>
00005 #include <X11/StringDefs.h>
00006 #include <stdio.h>
00007 #include <xwTabString.h>
00008 #include <./xwLabelP.h>
00009 static void _resolve_inheritance(
00010 #if NeedFunctionPrototypes
00011 WidgetClass
00012 #endif
00013 );
00014 static void set_label(
00015 #if NeedFunctionPrototypes
00016 Widget,String 
00017 #endif
00018 );
00019 static Boolean  set_values(
00020 #if NeedFunctionPrototypes
00021 Widget ,Widget ,Widget,ArgList ,Cardinal *
00022 #endif
00023 );
00024 static void initialize(
00025 #if NeedFunctionPrototypes
00026 Widget ,Widget,ArgList ,Cardinal *
00027 #endif
00028 );
00029 static void destroy(
00030 #if NeedFunctionPrototypes
00031 Widget
00032 #endif
00033 );
00034 static void realize(
00035 #if NeedFunctionPrototypes
00036 Widget,XtValueMask *,XSetWindowAttributes *
00037 #endif
00038 );
00039 static void _expose(
00040 #if NeedFunctionPrototypes
00041 Widget,XEvent *,Region 
00042 #endif
00043 );
00044 static void make_gc(
00045 #if NeedFunctionPrototypes
00046 Widget
00047 #endif
00048 );
00049 static void make_graygc(
00050 #if NeedFunctionPrototypes
00051 Widget
00052 #endif
00053 );
00054 static void count_lines(
00055 #if NeedFunctionPrototypes
00056 Widget
00057 #endif
00058 );
00059 /*ARGSUSED*/
00060 #if NeedFunctionPrototypes
00061 static void make_gc(Widget self)
00062 #else
00063 static void make_gc(self)Widget self;
00064 #endif
00065 {
00066     XtGCMask mask, fnt = 0;
00067     XGCValues values;
00068 
00069     if (((XfwfLabelWidget)self)->xfwfLabel.gc != NULL) XtReleaseGC(self, ((XfwfLabelWidget)self)->xfwfLabel.gc);
00070     values.background = ((XfwfLabelWidget)self)->xfwfLabel.text_bg;
00071     if (!((XfwfLabelWidget)self)->xfwfLabel.xfont) {
00072       values.foreground = ((XfwfLabelWidget)self)->xfwfLabel.foreground;
00073       if (((XfwfLabelWidget)self)->xfwfLabel.font) {
00074         values.font = ((XfwfLabelWidget)self)->xfwfLabel.font->fid;
00075         fnt = GCFont;
00076       }
00077     } else {
00078       if (((XfwfLabelWidget)self)->xfwfLabel.pixmap)
00079        values.foreground = ((XfwfLabelWidget)self)->xfwfLabel.foreground;
00080       else
00081        values.foreground = values.background;
00082     }
00083     mask = fnt | GCBackground | GCForeground;
00084     ((XfwfLabelWidget)self)->xfwfLabel.gc = XtGetGC(self, mask, &values);
00085 }
00086 /*ARGSUSED*/
00087 #if NeedFunctionPrototypes
00088 static void make_graygc(Widget self)
00089 #else
00090 static void make_graygc(self)Widget self;
00091 #endif
00092 {
00093     XtGCMask mask;
00094     XGCValues values;
00095 
00096     if (((XfwfLabelWidget)self)->xfwfLabel.graygc != NULL) XtReleaseGC(self, ((XfwfLabelWidget)self)->xfwfLabel.graygc);
00097 
00098     if ((((XfwfLabelWidget)self)->xfwfLabel.pixmap != 0) || !wx_enough_colors(XtScreen(self))) {
00099       /* A GC to draw over bitmaps/text: */
00100       values.foreground = ((XfwfLabelWidget)self)->xfwfLabel.text_bg;
00101       values.stipple = GetGray(self);
00102       values.fill_style = FillStippled;
00103       mask = GCForeground | GCStipple | GCFillStyle;
00104     } else {
00105       /* A GC for drawing gray text: */
00106       static Pixel color;
00107       values.background = ((XfwfLabelWidget)self)->xfwfLabel.text_bg;
00108       ((XfwfLabelWidgetClass)self->core.widget_class)->xfwfCommon_class.darker_color(self, ((XfwfLabelWidget)self)->xfwfLabel.text_bg, &color);
00109       values.foreground = color;
00110       mask = GCBackground | GCForeground;
00111       if (((XfwfLabelWidget)self)->xfwfLabel.font) {
00112        values.font = ((XfwfLabelWidget)self)->xfwfLabel.font->fid;
00113        mask |= GCFont;
00114       }
00115     }
00116  
00117     ((XfwfLabelWidget)self)->xfwfLabel.graygc = XtGetGC(self, mask, &values);
00118 }
00119 /*ARGSUSED*/
00120 #if NeedFunctionPrototypes
00121 static void count_lines(Widget self)
00122 #else
00123 static void count_lines(self)Widget self;
00124 #endif
00125 {
00126     String p, s;
00127     int w;
00128 
00129     ((XfwfLabelWidget)self)->xfwfLabel.nlines = 0;
00130     ((XfwfLabelWidget)self)->xfwfLabel.label_width = 0; ((XfwfLabelWidget)self)->xfwfLabel.label_height = 0; ((XfwfLabelWidget)self)->xfwfLabel.label_depth = 0;
00131     if (((XfwfLabelWidget)self)->xfwfLabel.label) {
00132        for (p = ((XfwfLabelWidget)self)->xfwfLabel.label, ((XfwfLabelWidget)self)->xfwfLabel.nlines = 1, s = ((XfwfLabelWidget)self)->xfwfLabel.label; *s; s++) {
00133            if (*s == '\n') {
00134               ((XfwfLabelWidget)self)->xfwfLabel.nlines++;
00135               w = XfwfTextWidth(XtDisplay(self), ((XfwfLabelWidget)self)->xfwfLabel.font, (wxExtFont)((XfwfLabelWidget)self)->xfwfLabel.xfont, p, s - p, ((XfwfLabelWidget)self)->xfwfLabel.tabs);
00136               p = s + 1;
00137               if (w > ((XfwfLabelWidget)self)->xfwfLabel.label_width) ((XfwfLabelWidget)self)->xfwfLabel.label_width = w;
00138            }
00139        }
00140        w = XfwfTextWidth(XtDisplay(self), ((XfwfLabelWidget)self)->xfwfLabel.font, (wxExtFont)((XfwfLabelWidget)self)->xfwfLabel.xfont, p, s - p, ((XfwfLabelWidget)self)->xfwfLabel.tabs);
00141        if (w > ((XfwfLabelWidget)self)->xfwfLabel.label_width) ((XfwfLabelWidget)self)->xfwfLabel.label_width = w;
00142        ((XfwfLabelWidget)self)->xfwfLabel.label_height = ((XfwfLabelWidget)self)->xfwfLabel.nlines * (wx_ASCENT(((XfwfLabelWidget)self)->xfwfLabel.font, ((wxExtFont)((XfwfLabelWidget)self)->xfwfLabel.xfont)) + wx_DESCENT(((XfwfLabelWidget)self)->xfwfLabel.font, ((wxExtFont)((XfwfLabelWidget)self)->xfwfLabel.xfont)));
00143     } else if (((XfwfLabelWidget)self)->xfwfLabel.pixmap) {
00144        Window        root;
00145        int           x, y;
00146        unsigned int  width, height, bw, depth;
00147        XGetGeometry(XtDisplay(self), ((XfwfLabelWidget)self)->xfwfLabel.pixmap, &root,
00148                     &x, &y, &width, &height, &bw, &depth);
00149        ((XfwfLabelWidget)self)->xfwfLabel.label_width  = (Dimension)width;
00150        ((XfwfLabelWidget)self)->xfwfLabel.label_height = (Dimension)height;
00151        ((XfwfLabelWidget)self)->xfwfLabel.label_depth  = depth;
00152        if (((XfwfLabelWidget)self)->xfwfLabel.maskmap) {
00153          XGetGeometry(XtDisplay(self), ((XfwfLabelWidget)self)->xfwfLabel.maskmap, &root,
00154                      &x, &y, &width, &height, &bw, &depth);
00155          ((XfwfLabelWidget)self)->xfwfLabel.mask_depth  = depth;
00156        }
00157     }
00158     /* add border */
00159     ((XfwfLabelWidget)self)->xfwfLabel.label_width += ((XfwfLabelWidget)self)->xfwfLabel.leftMargin + ((XfwfLabelWidget)self)->xfwfLabel.rightMargin;
00160     ((XfwfLabelWidget)self)->xfwfLabel.label_height += ((XfwfLabelWidget)self)->xfwfLabel.topMargin + ((XfwfLabelWidget)self)->xfwfLabel.bottomMargin;
00161 }
00162 
00163 static XtResource resources[] = {
00164 {XtNlabel,XtCLabel,XtRString,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.label),XtOffsetOf(XfwfLabelRec,xfwfLabel.label),XtRImmediate,(XtPointer)NULL },
00165 {XtNtablist,XtCTablist,XtRString,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.tablist),XtOffsetOf(XfwfLabelRec,xfwfLabel.tablist),XtRImmediate,(XtPointer)NULL },
00166 {XtNfont,XtCFont,XtRFontStruct,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.font),XtOffsetOf(XfwfLabelRec,xfwfLabel.font),XtRString,(XtPointer)XtDefaultFont },
00167 {XtNxfont,XtCXFont,XtRvoid,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.xfont),XtOffsetOf(XfwfLabelRec,xfwfLabel.xfont),XtRPointer,(XtPointer)NULL },
00168 {XtNpixmap,XtCPixmap,XtRPixmap,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.pixmap),XtOffsetOf(XfwfLabelRec,xfwfLabel.pixmap),XtRImmediate,(XtPointer)0 },
00169 {XtNmaskmap,XtCMaskmap,XtRPixmap,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.maskmap),XtOffsetOf(XfwfLabelRec,xfwfLabel.maskmap),XtRImmediate,(XtPointer)0 },
00170 {XtNforeground,XtCForeground,XtRPixel,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.foreground),XtOffsetOf(XfwfLabelRec,xfwfLabel.foreground),XtRString,(XtPointer)XtDefaultForeground },
00171 {XtNtext_bg,XtCText_bg,XtRPixel,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.text_bg),XtOffsetOf(XfwfLabelRec,xfwfLabel.text_bg),XtRPointer,(XtPointer)NULL },
00172 {XtNalignment,XtCAlignment,XtRAlignment,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.alignment),XtOffsetOf(XfwfLabelRec,xfwfLabel.alignment),XtRImmediate,(XtPointer)0 },
00173 {XtNtopMargin,XtCTopMargin,XtRDimension,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.topMargin),XtOffsetOf(XfwfLabelRec,xfwfLabel.topMargin),XtRImmediate,(XtPointer)2 },
00174 {XtNbottomMargin,XtCBottomMargin,XtRDimension,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.bottomMargin),XtOffsetOf(XfwfLabelRec,xfwfLabel.bottomMargin),XtRImmediate,(XtPointer)2 },
00175 {XtNleftMargin,XtCLeftMargin,XtRDimension,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.leftMargin),XtOffsetOf(XfwfLabelRec,xfwfLabel.leftMargin),XtRImmediate,(XtPointer)2 },
00176 {XtNrightMargin,XtCRightMargin,XtRDimension,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.rightMargin),XtOffsetOf(XfwfLabelRec,xfwfLabel.rightMargin),XtRImmediate,(XtPointer)2 },
00177 {XtNshrinkToFit,XtCShrinkToFit,XtRBoolean,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.shrinkToFit),XtOffsetOf(XfwfLabelRec,xfwfLabel.shrinkToFit),XtRImmediate,(XtPointer)False },
00178 {XtNrvStart,XtCRvStart,XtRInt,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.rvStart),XtOffsetOf(XfwfLabelRec,xfwfLabel.rvStart),XtRImmediate,(XtPointer)0 },
00179 {XtNrvLength,XtCRvLength,XtRInt,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.rvLength),XtOffsetOf(XfwfLabelRec,xfwfLabel.rvLength),XtRImmediate,(XtPointer)0 },
00180 {XtNtraversalOn,XtCTraversalOn,XtRBoolean,sizeof(((XfwfLabelRec*)NULL)->xfwfCommon.traversalOn),XtOffsetOf(XfwfLabelRec,xfwfCommon.traversalOn),XtRImmediate,(XtPointer)False },
00181 {XtNdrawgray,XtCDrawgray,XtRBoolean,sizeof(((XfwfLabelRec*)NULL)->xfwfLabel.drawgray),XtOffsetOf(XfwfLabelRec,xfwfLabel.drawgray),XtRImmediate,(XtPointer)FALSE },
00182 };
00183 
00184 XfwfLabelClassRec xfwfLabelClassRec = {
00185 { /* core_class part */
00186 /* superclass        */  (WidgetClass) &xfwfBoardClassRec,
00187 /* class_name        */  "XfwfLabel",
00188 /* widget_size       */  sizeof(XfwfLabelRec),
00189 /* class_initialize  */  NULL,
00190 /* class_part_initialize*/  _resolve_inheritance,
00191 /* class_inited      */  FALSE,
00192 /* initialize        */  initialize,
00193 /* initialize_hook   */  NULL,
00194 /* realize           */  realize,
00195 /* actions           */  NULL,
00196 /* num_actions       */  0,
00197 /* resources         */  resources,
00198 /* num_resources     */  18,
00199 /* xrm_class         */  NULLQUARK,
00200 /* compres_motion    */  True ,
00201 /* compress_exposure        */  XtExposeCompressMaximal ,
00202 /* compress_enterleave      */  True ,
00203 /* visible_interest  */  False ,
00204 /* destroy           */  destroy,
00205 /* resize            */  XtInheritResize,
00206 /* expose            */  XtInheritExpose,
00207 /* set_values        */  set_values,
00208 /* set_values_hook   */  NULL,
00209 /* set_values_almost        */  XtInheritSetValuesAlmost,
00210 /* get_values+hook   */  NULL,
00211 /* accept_focus      */  XtInheritAcceptFocus,
00212 /* version           */  XtVersion,
00213 /* callback_private  */  NULL,
00214 /* tm_table          */  NULL,
00215 /* query_geometry    */  XtInheritQueryGeometry,
00216 /* display_acceleator       */  XtInheritDisplayAccelerator,
00217 /* extension         */  NULL 
00218 },
00219 { /* composite_class part */
00220 XtInheritGeometryManager,
00221 XtInheritChangeManaged,
00222 XtInheritInsertChild,
00223 XtInheritDeleteChild,
00224 NULL
00225 },
00226 { /* XfwfCommon_class part */
00227 XtInherit_compute_inside,
00228 XtInherit_total_frame_width,
00229 _expose,
00230 XtInherit_highlight_border,
00231 XtInherit_unhighlight_border,
00232 XtInherit_hilite_callbacks,
00233 XtInherit_would_accept_focus,
00234 XtInherit_traverse,
00235 XtInherit_lighter_color,
00236 XtInherit_darker_color,
00237 XtInherit_set_color,
00238 /* traversal_trans */  NULL ,
00239 /* traversal_trans_small */  NULL ,
00240 /* travMode */  1 ,
00241 },
00242 { /* XfwfFrame_class part */
00243  /* dummy */  0
00244 },
00245 { /* XfwfBoard_class part */
00246 XtInherit_set_abs_location,
00247 },
00248 { /* XfwfLabel_class part */
00249 set_label,
00250 },
00251 };
00252 WidgetClass xfwfLabelWidgetClass = (WidgetClass) &xfwfLabelClassRec;
00253 static void _resolve_inheritance(class)
00254 WidgetClass class;
00255 {
00256   XfwfLabelWidgetClass c = (XfwfLabelWidgetClass) class;
00257   XfwfLabelWidgetClass super;
00258   static CompositeClassExtensionRec extension_rec = {
00259     NULL, NULLQUARK, XtCompositeExtensionVersion,
00260     sizeof(CompositeClassExtensionRec), True};
00261   CompositeClassExtensionRec *ext;
00262   ext = (XtPointer)XtMalloc(sizeof(*ext));
00263   *ext = extension_rec;
00264   ext->next_extension = c->composite_class.extension;
00265   c->composite_class.extension = ext;
00266   if (class == xfwfLabelWidgetClass) return;
00267   super = (XfwfLabelWidgetClass)class->core_class.superclass;
00268   if (c->xfwfLabel_class.set_label == XtInherit_set_label)
00269     c->xfwfLabel_class.set_label = super->xfwfLabel_class.set_label;
00270 }
00271 /*ARGSUSED*/
00272 #if NeedFunctionPrototypes
00273 static void set_label(Widget self,String  newlabel)
00274 #else
00275 static void set_label(self,newlabel)Widget self;String  newlabel;
00276 #endif
00277 {
00278     Position x, y;
00279     int w, h;
00280 
00281     XtFree(((XfwfLabelWidget)self)->xfwfLabel.label);
00282     ((XfwfLabelWidget)self)->xfwfLabel.label = XtNewString(newlabel);
00283     count_lines(self);
00284     if (XtIsRealized(self)) {
00285        ((XfwfLabelWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
00286        XClearArea(XtDisplay(self), XtWindow(self), x, y, max(w, 0), max(h, 0), True);
00287        /* $_expose($, NULL, NULL); */
00288     }
00289 }
00290 /*ARGSUSED*/
00291 #if NeedFunctionPrototypes
00292 static Boolean  set_values(Widget  old,Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00293 #else
00294 static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00295 #endif
00296 {
00297     Boolean need_redisplay = False, need_count = False;
00298     Position x, y;
00299 
00300     if (((XfwfLabelWidget)self)->core.background_pixel != ((XfwfLabelWidget)old)->core.background_pixel)
00301        if (((XfwfLabelWidget)self)->xfwfLabel.graygc) make_graygc(self);
00302 
00303     if (((XfwfLabelWidget)self)->xfwfLabel.tablist != ((XfwfLabelWidget)old)->xfwfLabel.tablist) {
00304        XtFree((String) ((XfwfLabelWidget)old)->xfwfLabel.tabs);
00305        ((XfwfLabelWidget)self)->xfwfLabel.tabs = XfwfTablist2Tabs(((XfwfLabelWidget)self)->xfwfLabel.tablist);
00306        if (((XfwfLabelWidget)self)->xfwfLabel.label != NULL) need_count = True;
00307     }
00308 
00309     if ((((XfwfLabelWidget)self)->xfwfLabel.font != ((XfwfLabelWidget)old)->xfwfLabel.font)
00310        || (((XfwfLabelWidget)self)->xfwfLabel.xfont != ((XfwfLabelWidget)old)->xfwfLabel.xfont)) {
00311        make_gc(self);
00312        if (((XfwfLabelWidget)self)->xfwfLabel.label != NULL) need_count = True;
00313     }
00314     if (((XfwfLabelWidget)self)->xfwfLabel.foreground != ((XfwfLabelWidget)old)->xfwfLabel.foreground
00315        || ((XfwfLabelWidget)self)->core.background_pixel != ((XfwfLabelWidget)old)->core.background_pixel) {
00316        make_gc(self);
00317        if (((XfwfLabelWidget)self)->xfwfLabel.label != NULL || ((XfwfLabelWidget)self)->xfwfLabel.pixmap != 0) need_redisplay = True;
00318     }
00319     if (((XfwfLabelWidget)self)->xfwfLabel.topMargin != ((XfwfLabelWidget)old)->xfwfLabel.topMargin
00320        || ((XfwfLabelWidget)self)->xfwfLabel.bottomMargin != ((XfwfLabelWidget)old)->xfwfLabel.bottomMargin
00321        || ((XfwfLabelWidget)self)->xfwfLabel.leftMargin != ((XfwfLabelWidget)old)->xfwfLabel.leftMargin
00322        || ((XfwfLabelWidget)self)->xfwfLabel.rightMargin != ((XfwfLabelWidget)old)->xfwfLabel.rightMargin
00323        || ((XfwfLabelWidget)self)->xfwfLabel.alignment != ((XfwfLabelWidget)old)->xfwfLabel.alignment)
00324        need_count = True;
00325 
00326     if ((((XfwfLabelWidget)self)->core.sensitive != ((XfwfLabelWidget)old)->core.sensitive)
00327         || (((XfwfLabelWidget)self)->xfwfLabel.drawgray != ((XfwfLabelWidget)old)->xfwfLabel.drawgray))
00328        if (((XfwfLabelWidget)self)->xfwfLabel.label != NULL || ((XfwfLabelWidget)self)->xfwfLabel.pixmap != 0) need_redisplay = True;
00329 
00330     if (((XfwfLabelWidget)self)->xfwfLabel.label != ((XfwfLabelWidget)old)->xfwfLabel.label || ((XfwfLabelWidget)self)->xfwfLabel.pixmap != ((XfwfLabelWidget)old)->xfwfLabel.pixmap) {
00331        XtFree(((XfwfLabelWidget)old)->xfwfLabel.label);
00332        ((XfwfLabelWidget)self)->xfwfLabel.label = XtNewString(((XfwfLabelWidget)self)->xfwfLabel.label);
00333        need_count = True;
00334     }
00335     if (need_count) {
00336        count_lines(self);
00337        need_redisplay = True;
00338     }
00339     if (need_count && ((XfwfLabelWidget)self)->xfwfLabel.shrinkToFit) {
00340         int w, h, wd, ht;
00341        ((XfwfLabelWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
00342        wd = ((XfwfLabelWidget)self)->xfwfLabel.label_width + ((XfwfLabelWidget)self)->core.width - w;
00343        ht = ((XfwfLabelWidget)self)->xfwfLabel.label_height + ((XfwfLabelWidget)self)->core.height - h;
00344        if (wd != ((XfwfLabelWidget)self)->core.width || ht != ((XfwfLabelWidget)self)->core.height) {
00345            ((XfwfLabelWidgetClass)self->core.widget_class)->xfwfBoard_class.set_abs_location(self, CWWidth | CWHeight, 0, 0, max(1, wd), max(1, ht));
00346            need_redisplay = True;
00347        }
00348     }
00349 
00350     return need_redisplay;
00351 }
00352 /*ARGSUSED*/
00353 #if NeedFunctionPrototypes
00354 static void initialize(Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00355 #else
00356 static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00357 #endif
00358 {
00359     Position x, y;
00360     int w, h, wd, ht;
00361 
00362     if (((XfwfLabelWidget)self)->xfwfLabel.label) ((XfwfLabelWidget)self)->xfwfLabel.label = XtNewString(((XfwfLabelWidget)self)->xfwfLabel.label);
00363     count_lines(self);
00364     ((XfwfLabelWidget)self)->xfwfLabel.gc = NULL;
00365     ((XfwfLabelWidget)self)->xfwfLabel.graygc = NULL;
00366     ((XfwfLabelWidget)self)->xfwfLabel.tabs = XfwfTablist2Tabs(((XfwfLabelWidget)self)->xfwfLabel.tablist);
00367     if (!((XfwfLabelWidget)self)->xfwfLabel.text_bg)
00368       ((XfwfLabelWidget)self)->xfwfLabel.text_bg = ((XfwfLabelWidget)self)->core.background_pixel;
00369     if (((XfwfLabelWidget)self)->xfwfLabel.shrinkToFit) {
00370        ((XfwfLabelWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
00371        wd = ((XfwfLabelWidget)self)->xfwfLabel.label_width + ((XfwfLabelWidget)self)->core.width - w;
00372        ht = ((XfwfLabelWidget)self)->xfwfLabel.label_height + ((XfwfLabelWidget)self)->core.height - h;
00373        ((XfwfLabelWidgetClass)self->core.widget_class)->xfwfBoard_class.set_abs_location(self, CWWidth | CWHeight, 0, 0, max(1, wd), max(1, ht));
00374     }
00375 }
00376 /*ARGSUSED*/
00377 #if NeedFunctionPrototypes
00378 static void destroy(Widget self)
00379 #else
00380 static void destroy(self)Widget self;
00381 #endif
00382 {
00383   if (((XfwfLabelWidget)self)->xfwfLabel.gc) XtReleaseGC(self, ((XfwfLabelWidget)self)->xfwfLabel.gc); ((XfwfLabelWidget)self)->xfwfLabel.gc = NULL;
00384   if (((XfwfLabelWidget)self)->xfwfLabel.graygc) XtReleaseGC(self, ((XfwfLabelWidget)self)->xfwfLabel.graygc); ((XfwfLabelWidget)self)->xfwfLabel.graygc = NULL;
00385 }
00386 /*ARGSUSED*/
00387 #if NeedFunctionPrototypes
00388 static void realize(Widget self,XtValueMask * mask,XSetWindowAttributes * attributes)
00389 #else
00390 static void realize(self,mask,attributes)Widget self;XtValueMask * mask;XSetWindowAttributes * attributes;
00391 #endif
00392 {
00393   xfwfBoardClassRec.core_class.realize(self, mask, attributes);
00394   make_gc(self);
00395   /* make_graygc($); - now on demand */
00396 }
00397 #define draw_line(dpy, win, from, to, reg) do {\
00398        w1 = XfwfTextWidth(dpy, ((XfwfLabelWidget)self)->xfwfLabel.font, (wxExtFont)((XfwfLabelWidget)self)->xfwfLabel.xfont, ((XfwfLabelWidget)self)->xfwfLabel.label + from, to - from, ((XfwfLabelWidget)self)->xfwfLabel.tabs);\
00399        if (((XfwfLabelWidget)self)->xfwfLabel.alignment & XfwfLeft)\
00400            x = rect.x;\
00401        else if (((XfwfLabelWidget)self)->xfwfLabel.alignment & XfwfRight)\
00402            x = rect.x + rect.width - w1;\
00403        else\
00404            x = rect.x + (rect.width - w1)/2;\
00405        if (w1) {\
00406          int grayed;\
00407          grayed = ((!((XfwfLabelWidget)self)->core.sensitive || ((XfwfLabelWidget)self)->xfwfLabel.drawgray) && wx_enough_colors(XtScreen(self)));\
00408          XfwfDrawImageString(dpy, win, \
00409                            (((XfwfLabelWidget)self)->xfwfLabel.xfont\
00410                             ? ((XfwfLabelWidget)self)->xfwfLabel.gc\
00411                             : (grayed\
00412                               ? ((XfwfLabelWidget)self)->xfwfLabel.graygc \
00413                               : ((XfwfLabelWidget)self)->xfwfLabel.gc)), \
00414                            x, y, ((XfwfLabelWidget)self)->xfwfLabel.label + from,\
00415                            to - from, ((XfwfLabelWidget)self)->xfwfLabel.tabs, ((XfwfLabelWidget)self)->xfwfLabel.font,\
00416                            (wxExtFont)((XfwfLabelWidget)self)->xfwfLabel.xfont, !grayed, reg);\
00417        }\
00418     }while (0 )
00419 
00420 
00421 /*ARGSUSED*/
00422 #if NeedFunctionPrototypes
00423 static void _expose(Widget self,XEvent * event,Region  region)
00424 #else
00425 static void _expose(self,event,region)Widget self;XEvent * event;Region  region;
00426 #endif
00427 {
00428     Region reg;
00429     XRectangle rect;
00430     int baseline;
00431     int w1;
00432     int x, y, i, j;
00433 
00434     if (! XtIsRealized(self)) return;
00435 
00436     if (!((XfwfLabelWidget)self)->core.sensitive || ((XfwfLabelWidget)self)->xfwfLabel.drawgray)
00437       if (!((XfwfLabelWidget)self)->xfwfLabel.graygc) make_graygc(self);
00438 
00439     xfwfBoardClassRec.xfwfCommon_class._expose(self, event, region);
00440     reg = NULL;
00441     if (((XfwfLabelWidget)self)->xfwfLabel.label != NULL || ((XfwfLabelWidget)self)->xfwfLabel.pixmap != 0) {
00442        int w, h;
00443        ((XfwfLabelWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &rect.x, &rect.y, &w, &h);
00444        rect.x += ((XfwfLabelWidget)self)->xfwfLabel.leftMargin;  w -= ((XfwfLabelWidget)self)->xfwfLabel.leftMargin + ((XfwfLabelWidget)self)->xfwfLabel.rightMargin;
00445        rect.y += ((XfwfLabelWidget)self)->xfwfLabel.topMargin;  h -= ((XfwfLabelWidget)self)->xfwfLabel.topMargin + ((XfwfLabelWidget)self)->xfwfLabel.bottomMargin;
00446        rect.width = max(0, w);
00447        rect.height = max(0, h);
00448        reg = XCreateRegion();
00449        XUnionRectWithRegion(&rect, reg, reg);
00450        if (region != NULL) XIntersectRegion(region, reg, reg);
00451        XSetRegion(XtDisplay(self), ((XfwfLabelWidget)self)->xfwfLabel.gc, reg);
00452     }
00453     if (((XfwfLabelWidget)self)->xfwfLabel.label != NULL) {
00454         int ascent;
00455        ascent = wx_ASCENT(((XfwfLabelWidget)self)->xfwfLabel.font, ((wxExtFont)((XfwfLabelWidget)self)->xfwfLabel.xfont));
00456        baseline = ascent + wx_DESCENT(((XfwfLabelWidget)self)->xfwfLabel.font, ((wxExtFont)((XfwfLabelWidget)self)->xfwfLabel.xfont));
00457        if (((XfwfLabelWidget)self)->xfwfLabel.alignment & XfwfTop)
00458            y = rect.y + ascent;
00459        else if (((XfwfLabelWidget)self)->xfwfLabel.alignment & XfwfBottom)
00460            y = rect.y + rect.height - ((XfwfLabelWidget)self)->xfwfLabel.nlines * baseline + ascent;
00461        else
00462            y = rect.y + (rect.height - ((XfwfLabelWidget)self)->xfwfLabel.nlines * baseline)/2 + ascent;
00463        for (i = 0, j = 0; ((XfwfLabelWidget)self)->xfwfLabel.label[i]; i++) {
00464            if (((XfwfLabelWidget)self)->xfwfLabel.label[i] == '\n') {
00465               draw_line(XtDisplay(self), XtWindow(self), j, i, reg);
00466               j = i + 1;
00467               y += baseline;
00468            }
00469        }
00470        draw_line(XtDisplay(self), XtWindow(self), j, i, reg);
00471 
00472        /* Gray out if not sensitive */
00473        if (! ((XfwfLabelWidget)self)->core.sensitive || ((XfwfLabelWidget)self)->xfwfLabel.drawgray) {
00474          if (!wx_enough_colors(XtScreen(self))) {
00475            XSetRegion(XtDisplay(self), ((XfwfLabelWidget)self)->xfwfLabel.graygc, reg);
00476            XFillRectangle(XtDisplay(self), XtWindow(self), ((XfwfLabelWidget)self)->xfwfLabel.graygc, rect.x,
00477                         rect.y, rect.width, rect.height);
00478            XSetClipMask(XtDisplay(self), ((XfwfLabelWidget)self)->xfwfLabel.graygc, None);
00479          }
00480        }
00481     } else if (((XfwfLabelWidget)self)->xfwfLabel.pixmap != 0) {
00482        Dimension width = ((XfwfLabelWidget)self)->xfwfLabel.label_width - ((XfwfLabelWidget)self)->xfwfLabel.leftMargin - ((XfwfLabelWidget)self)->xfwfLabel.rightMargin;
00483        Dimension height = ((XfwfLabelWidget)self)->xfwfLabel.label_height - ((XfwfLabelWidget)self)->xfwfLabel.topMargin - ((XfwfLabelWidget)self)->xfwfLabel.bottomMargin;
00484        if (((XfwfLabelWidget)self)->xfwfLabel.alignment & XfwfTop)
00485            y = rect.y;
00486        else if (((XfwfLabelWidget)self)->xfwfLabel.alignment & XfwfBottom)
00487            y = rect.y + rect.height - height;
00488        else
00489            y = rect.y + (rect.height - height)/2;
00490        if (((XfwfLabelWidget)self)->xfwfLabel.alignment & XfwfLeft)
00491            x = rect.x;
00492        else if (((XfwfLabelWidget)self)->xfwfLabel.alignment & XfwfRight)
00493            x = rect.x + rect.width - width;
00494        else
00495            x = rect.x + (rect.width - width)/2;
00496 
00497        wxDrawBitmapLabel(XtDisplay(self), 
00498                        ((XfwfLabelWidget)self)->xfwfLabel.pixmap, ((XfwfLabelWidget)self)->xfwfLabel.maskmap, 
00499                        XtWindow(self), ((XfwfLabelWidget)self)->xfwfLabel.gc,
00500                        x, y, width, height, 
00501                        ((XfwfLabelWidget)self)->xfwfLabel.label_depth, ((XfwfLabelWidget)self)->xfwfLabel.mask_depth,
00502                        reg, 
00503                        (! ((XfwfLabelWidget)self)->core.sensitive || ((XfwfLabelWidget)self)->xfwfLabel.drawgray) ? ((XfwfLabelWidget)self)->xfwfLabel.graygc : 0,
00504                        ((XfwfLabelWidget)self)->core.background_pixel);
00505     }
00506 
00507     if (((XfwfLabelWidget)self)->xfwfLabel.label != NULL || ((XfwfLabelWidget)self)->xfwfLabel.pixmap != 0) {
00508       XSetClipMask(XtDisplay(self), ((XfwfLabelWidget)self)->xfwfLabel.gc, None);
00509     }
00510     if (reg) XDestroyRegion(reg);
00511 }