123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /******************************************************************************
- *******************************************************************************
- *
- * (c) Copyright 1992 HEWLETT-PACKARD COMPANY
- * ALL RIGHTS RESERVED
- *
- *******************************************************************************
- ******************************************************************************/
- #include <stdio.h>
- #include <X11/cursorfont.h>
- #include "ButtonP.h"
- #include <Xm/ManagerP.h>
- #include <Xm/DrawP.h>
- #include <Dt/Control.h>
- #include <Dt/MacrosP.h>
- #include <Dt/DtStrDefs.h>
- #include "DtSvcInternal.h" /* _DtGetMask */
- #include <Xm/XmPrivate.h> /* _XmFocusInGadget, _XmFocusOutGadget, _XmSocorro */
- #define DELAY_DEFAULT 100
- static void Initialize(
- Widget request_w,
- Widget new_w) ;
- static void GetGCs(
- Widget w) ;
- static void UpdateGCs(
- Widget w) ;
- static void Redisplay(
- Widget w,
- XEvent *event,
- Region region) ;
- static Boolean SetValues(
- Widget current_w,
- Widget request_w,
- Widget new_w) ;
- static void Arm(
- Widget w,
- XEvent *event,
- String *params,
- Cardinal *num_params) ;
- static void Disarm(
- Widget w,
- XEvent *event,
- String *params,
- Cardinal *num_params) ;
- static void Activate(
- Widget w,
- XEvent *event,
- String *params,
- Cardinal *num_params) ;
- static void ArmAndActivate(
- Widget w,
- XEvent *event,
- String *params,
- Cardinal *num_params) ;
- static void InputDispatch(
- Widget w,
- XButtonEvent *event,
- Mask event_mask) ;
- static Boolean VisualChange(
- Widget w,
- Widget current_w,
- Widget new_w) ;
- static void ArmTimeout(
- Widget w,
- XtIntervalId *id) ;
- static void Enter(
- Widget wid,
- XEvent *event,
- String *params,
- Cardinal *num_params) ;
- static void Leave(
- Widget wid,
- XEvent *event,
- String *params,
- Cardinal *num_params) ;
- static void CallCallback(
- DtButtonGadget g,
- XtCallbackList cb,
- int reason,
- XEvent *event) ;
- static void DefaultSelectColor(
- Widget widget,
- int offset,
- XrmValue *value) ;
- /* Resource list for button */
- #define R_Offset(field) \
- XtOffset (DtButtonGadget, button.field)
- static XtResource resources[] =
- {
- {
- XmNcursorFont,
- XmCCursorFont, XmRInt, sizeof (int),
- R_Offset (cursor_font),
- XmRImmediate, (XtPointer) 1
- },
- {
- XmNarmColor,
- XmCArmColor, XmRPixel, sizeof (Pixel),
- R_Offset (arm_color),
- XmRCallProc, (XtPointer) DefaultSelectColor
- },
- {
- XmNsubpanel,
- XmCSubpanel, XmRWidget, sizeof (Widget),
- R_Offset (subpanel),
- XmRImmediate, (XtPointer) NULL
- },
- {
- XmNpushFunction,
- XmCPushFunction, XmRFunction, sizeof (XtPointer),
- R_Offset (push_function),
- XmRImmediate, (XtPointer) NULL
- },
- {
- XmNpushArgument,
- XmCPushArgument, XmRPointer, sizeof (XtPointer),
- R_Offset (push_argument),
- XmRImmediate, (XtPointer) NULL
- },
- {
- XmNimageName,
- XmCString, XmRString, sizeof (String),
- R_Offset (image_name),
- XmRImmediate, (XtPointer) ""
- },
- {
- XmNcallback,
- XmCCallback, XmRCallback, sizeof(XtCallbackList),
- R_Offset (callback),
- XmRImmediate, (caddr_t) NULL
- },
- {
- XmNmultiClick,
- XmCMultiClick, XmRMultiClick, sizeof (unsigned char),
- R_Offset (multiClick),
- XmRImmediate, (XtPointer) XmMULTICLICK_KEEP
- }
- };
- /* The button class record definition */
- externaldef (dtbuttongadgetclassrec)
- DtButtonGadgetClassRec dtButtonGadgetClassRec=
- {
- {
- (WidgetClass) &xmGadgetClassRec, /* superclass */
- "DtButton", /* class_name */
- sizeof(DtButtonGadgetRec), /* widget_size */
- NULL, /* class_initialize */
- NULL, /* class_part_initialize */
- FALSE, /* class_inited */
- (XtInitProc) Initialize, /* initialize */
- NULL, /* initialize_hook */
- NULL, /* realize */
- NULL, /* actions */
- 0, /* num_actions */
- resources, /* resources */
- XtNumber(resources), /* num_resources */
- NULLQUARK, /* xrm_class */
- TRUE, /* compress_motion */
- XtExposeCompressMaximal, /* compress_exposure */
- TRUE, /* compress_enterleave */
- FALSE, /* visible_interest */
- NULL, /* destroy */
- NULL, /* resize */
- (XtExposeProc) Redisplay, /* expose */
- (XtSetValuesFunc) SetValues, /* set_values */
- NULL, /* set_values_hook */
- XtInheritSetValuesAlmost, /* set_values_almost */
- NULL, /* get_values_hook */
- NULL, /* accept_focus */
- XtVersion, /* version */
- NULL, /* callback private */
- NULL, /* tm_table */
- NULL, /* query_geometry */
- NULL, /* display_accelerator */
- NULL, /* extension */
- },
- /* XmGadget Part */
- {
- (XtWidgetProc) _XtInherit, /* Gadget border_highlight */
- (XtWidgetProc) _XtInherit, /* Gadget border_unhighlight */
- ArmAndActivate, /* arm_and_activate */
- (XmWidgetDispatchProc)InputDispatch, /* input_dispatch */
- VisualChange, /* visual_change */
- NULL, /* get resources */
- 0, /* num get_resources */
- NULL, /* class_cache_part */
- NULL, /* extension */
- }
- };
- externaldef(dtbuttonwidgetclass) WidgetClass dtButtonGadgetClass =
- (WidgetClass) &dtButtonGadgetClassRec;
- /************************************************************************
- *
- * Initialize
- * The main widget instance initialization routine.
- *
- ************************************************************************/
- static void
- Initialize(
- Widget request_w,
- Widget new_w )
- {
- DtButtonGadget request = (DtButtonGadget) request_w ;
- DtButtonGadget new_g = (DtButtonGadget) new_w ;
- XmManagerWidget mw = (XmManagerWidget) XtParent(new_w) ;
- new_g->button.timer = 0;
- new_g->button.click_count = 0;
- new_g->button.armTimeStamp = 0;
- new_g->button.activateTimeStamp = 0;
- B_Armed (new_g) = False;
- /* Set the input mask for events handled by Manager.
- */
- G_EventMask (new_g) = (XmARM_EVENT | XmACTIVATE_EVENT |
- XmMULTI_ARM_EVENT | XmMULTI_ACTIVATE_EVENT |
- XmHELP_EVENT | XmFOCUS_IN_EVENT |
- XmFOCUS_OUT_EVENT | XmENTER_EVENT | XmLEAVE_EVENT);
- /* Get pixmap and mask, get pixmap geometry, get gcs.
- */
- if (B_ImageName (new_g) != NULL)
- {
- String str = B_ImageName (new_g);
- B_ImageName (new_g) = XtMalloc (strlen (str) + 1);
- strcpy (B_ImageName (new_g), str);
- B_Pixmap (new_g) =
- XmGetPixmap (XtScreen (new_g), B_ImageName (new_g),
- M_BottomShadowColor (mw),
- M_TopShadowColor (mw));
- B_Mask (new_g) =
- _DtGetMask (XtScreen (new_g), B_ImageName (new_g));
- if (B_Pixmap (new_g) != XmUNSPECIFIED_PIXMAP)
- {
- Window root;
- int int_x = 0, int_y = 0;
- unsigned int int_w = 0, int_h = 0,
- int_bw, depth;
- XGetGeometry (XtDisplay (new_g), B_Pixmap (new_g),
- &root, &int_x, &int_y, &int_w, &int_h,
- &int_bw, &depth);
- B_PixmapWidth (new_g) = (Dimension) int_w;
- B_PixmapHeight (new_g) = (Dimension) int_h;
- }
- else
- {
- B_PixmapWidth (new_g) = 0;
- B_PixmapHeight (new_g) = 0;
- }
- }
- else
- {
- B_Pixmap (new_g) = XmUNSPECIFIED_PIXMAP;
- B_Mask (new_g) = XmUNSPECIFIED_PIXMAP;
- B_PixmapWidth (new_g) = 0;
- B_PixmapHeight (new_g) = 0;
- }
- GetGCs (new_w);
- /* Set widget geometry.
- */
- new_g -> gadget.shadow_thickness = 1;
- new_g -> gadget.highlight_thickness = 1;
- if (G_Width(request) == 0)
- {
- if (B_PixmapWidth (new_g) > 0)
- G_Width(new_g) = B_PixmapWidth (new_g) + 4;
- else
- G_Width(new_g) = 10;
- }
- if (G_Height(request) == 0)
- {
- if (B_PixmapHeight (new_g) > 0)
- G_Height(new_g) = B_PixmapHeight (new_g) + 4;
- else
- G_Height(new_g) = 10;
- }
- }
- /************************************************************************
- *
- * GetGCs
- * Get the graphics context used for drawing the button.
- *
- ************************************************************************/
- static void
- GetGCs(
- Widget w )
- {
- DtButtonGadget bg = (DtButtonGadget) w ;
- XmManagerWidget mw = (XmManagerWidget) XtParent(w) ;
- XGCValues values;
- XtGCMask valueMask;
- valueMask = GCForeground | GCBackground;
- values.foreground = M_Foreground(mw);
- values.background = M_Background(mw);
- bg -> button.gc_normal = XtGetGC ((Widget) mw, valueMask, &values);
- values.foreground = B_ArmColor (bg);
- bg -> button.gc_armed_bg = XtGetGC ((Widget) mw, valueMask, &values);
- values.foreground = M_Background(mw);
- values.background = M_Foreground(mw);
- bg -> button.gc_background = XtGetGC ((Widget) mw, valueMask, &values);
- /* Get Clip GC
- */
- if (B_Mask(bg) != XmUNSPECIFIED_PIXMAP)
- {
- valueMask = GCForeground | GCBackground | GCClipMask;
- values.clip_mask = B_Mask(bg);
- values.foreground = M_Foreground (mw);
- values.background = M_Background (mw);
- bg->button.gc_clip = XtGetGC ((Widget) mw, valueMask, &values);
- }
- else
- bg->button.gc_clip = NULL;
- }
- static void
- UpdateGCs(
- Widget w )
- {
- DtButtonGadget bg = (DtButtonGadget) w ;
- XmManagerWidget mw = (XmManagerWidget) XtParent(w) ;
- XtReleaseGC ((Widget) mw, bg->button.gc_normal);
- XtReleaseGC ((Widget) mw, bg->button.gc_background);
- XtReleaseGC ((Widget) mw, bg->button.gc_armed_bg);
- if (bg->button.gc_clip != NULL)
- XtReleaseGC ((Widget) mw, bg->button.gc_clip);
- GetGCs (w);
- }
- /************************************************************************
- *
- * Redisplay
- * General redisplay function called on exposure events.
- *
- ************************************************************************/
- /* ARGSUSED */
- static void
- Redisplay(
- Widget w,
- XEvent *event,
- Region region )
- {
- DtButtonGadget bg = (DtButtonGadget) w;
- Dimension s_t = bg -> gadget.shadow_thickness;
- Dimension h_t = bg -> gadget.highlight_thickness;
- Position x;
- Pixmap pix;
- GC gc;
- gc = (B_Armed (bg)) ? bg -> button.gc_armed_bg : bg -> button.gc_background;
- XFillRectangle (XtDisplay (bg), XtWindow (bg),
- gc, G_X(bg) +s_t + h_t, G_Y(bg) + s_t + h_t,
- G_Width(bg) - 2 * (s_t + h_t),
- G_Height(bg) - 2 * (s_t + h_t));
- if (s_t > 0)
- {
- GC gc1, gc2;
- if (B_Armed (bg))
- {
- gc1 = XmParentBottomShadowGC(w);
- gc2 = XmParentTopShadowGC(w);
- }
- else
- {
- gc1 = bg -> button.gc_background;
- gc2 = bg -> button.gc_background;
- }
- XmeDrawShadows (XtDisplay(bg), XtWindow (bg), gc1, gc2,
- G_X(bg) + h_t, G_Y(bg) + h_t,
- G_Width(bg) - 2 * h_t, G_Height(bg) - 2 * h_t,
- s_t,XmSHADOW_OUT);
- }
- x = G_X(bg) + ((Position)(G_Width(bg) - B_PixmapWidth (bg))/2);
- if (x % 2 == 1)
- x++;
- if (B_Mask (bg) != XmUNSPECIFIED_PIXMAP)
- {
- gc = bg->button.gc_clip;
- XSetClipMask (XtDisplay(bg), gc, B_Mask (bg));
- XSetClipOrigin (XtDisplay(bg), gc,
- x, G_Y(bg) + (Position)(G_Height(bg) - B_PixmapHeight (bg))/2);
- }
- else
- gc = bg->button.gc_normal;
- pix = B_Pixmap (bg);
- if ((gc != NULL) && (pix != XmUNSPECIFIED_PIXMAP))
- {
- XCopyArea (XtDisplay ((Widget) bg), pix, XtWindow ((Widget) bg), gc, 0, 0,
- B_PixmapWidth (bg), B_PixmapHeight (bg),
- x, G_Y(bg) + (Position)(G_Height(bg) - B_PixmapHeight (bg))/2);
- }
- if (bg -> gadget.highlighted)
- (*(xmGadgetClassRec.gadget_class.border_highlight))((Widget) bg);
- }
- /************************************************************************
- *
- * Destroy
- * Clean up allocated resources when the widget is destroyed.
- *
- ************************************************************************/
- #if 0
- static void
- Destroy(
- Widget w )
- {
- DtButtonGadget bg = (DtButtonGadget) w ;
- if (bg->button.timer)
- XtRemoveTimeOut (bg->button.timer);
- XtReleaseGC (w, bg -> button.gc_normal);
- XtReleaseGC (w, bg -> button.gc_background);
- XtReleaseGC (w, bg -> button.gc_armed_bg);
- if (bg -> button.gc_clip != NULL)
- XtReleaseGC (w, bg -> button.gc_clip);
- XtRemoveAllCallbacks (w, "callback");
- }
- #endif /* 0 */
- /************************************************************************
- *
- * SetValues
- * Note: The only implementation within this function is to
- * support the resetting of the image, cursor, and functions
- * as needed by the front panel.
- *
- ************************************************************************/
- /* ARGSUSED */
- static Boolean
- SetValues(
- Widget current_w,
- Widget request_w,
- Widget new_w )
- {
- DtButtonGadget current = (DtButtonGadget) current_w;
- DtButtonGadget new_g = (DtButtonGadget) new_w;
- XmManagerWidget mw = (XmManagerWidget) XtParent(new_w);
- Boolean returnFlag = FALSE;
- G_EventMask (new_g) = (XmARM_EVENT | XmACTIVATE_EVENT |
- XmMULTI_ARM_EVENT | XmMULTI_ACTIVATE_EVENT |
- XmHELP_EVENT | XmFOCUS_IN_EVENT |
- XmFOCUS_OUT_EVENT | XmENTER_EVENT | XmLEAVE_EVENT);
- /* Change the image */
- if (strcmp (B_ImageName (current), B_ImageName (new_g)) != 0)
- {
- String str = B_ImageName (new_g);
- XtFree (B_ImageName (current));
- B_ImageName (new_g) = XtMalloc (strlen (str) + 1);
- strcpy (B_ImageName (new_g), str);
- B_Pixmap (new_g) =
- XmGetPixmap (XtScreen (new_g), B_ImageName (new_g),
- M_BottomShadowColor (mw),
- M_TopShadowColor (mw));
- B_Mask (new_g) =
- _DtGetMask (XtScreen (new_g), B_ImageName (new_g));
- if (B_Pixmap (new_g) != XmUNSPECIFIED_PIXMAP)
- {
- Window root;
- int int_x = 0, int_y = 0;
- unsigned int int_w = 0, int_h = 0,
- int_bw, depth;
- XGetGeometry (XtDisplay (new_g), B_Pixmap (new_g),
- &root, &int_x, &int_y, &int_w, &int_h, &int_bw, &depth);
- B_PixmapWidth (new_g) = (Dimension) int_w;
- B_PixmapHeight (new_g) = (Dimension) int_h;
- }
- else
- {
- B_PixmapWidth (new_g) = 0;
- B_PixmapHeight (new_g) = 0;
- }
- UpdateGCs(new_w);
- returnFlag = TRUE;
- }
- else
- {
- if (B_ImageName (new_g) != B_ImageName (current))
- {
- String str = B_ImageName (new_g);
- XtFree (B_ImageName (current));
- B_ImageName (new_g) = XtMalloc (strlen (str) + 1);
- strcpy (B_ImageName (new_g), str);
- }
- }
- return (returnFlag);
- }
- /************************************************************************
- *
- * arm
- * This function processes button 1 down occurring on the button.
- *
- ************************************************************************/
- static void
- Arm(
- Widget w,
- XEvent *event,
- String *params,
- Cardinal *num_params )
- {
- DtButtonGadget bg = (DtButtonGadget) w ;
- (void) XmProcessTraversal((Widget) bg, XmTRAVERSE_CURRENT);
- B_Armed (bg) = True;
- if ((event->xbutton.time - bg->button.armTimeStamp) >
- XtGetMultiClickTime(XtDisplay(bg)))
- {
- bg -> button.armTimeStamp = event->xbutton.time;
- B_Expose ( w, event, NULL);
- }
- }
- /************************************************************************
- *
- * disarm
- * This function processes button 1 up occurring on the button.
- *
- ************************************************************************/
- static void
- Disarm(
- Widget w,
- XEvent *event,
- String *params,
- Cardinal *num_params )
- {
- DtButtonGadget bg = (DtButtonGadget) w ;
- B_Armed (bg) = False;
- B_Expose (w, event, NULL);
- }
- /************************************************************************
- *
- * activate
- * This function processes button 1 up occurring on the button.
- * If the button 1 up occurred inside the button the activate
- * callbacks are called.
- *
- ************************************************************************/
- static void
- Activate(
- Widget w,
- XEvent *event,
- String *params,
- Cardinal *num_params )
- {
- DtButtonGadget bg = (DtButtonGadget) w ;
- DtButtonCallbackStruct call_value;
- if (!B_Armed (bg))
- return;
- if ((event->xbutton.time - bg->button.activateTimeStamp) >
- XtGetMultiClickTime(XtDisplay(bg)))
- {
- bg -> button.activateTimeStamp = event->xbutton.time;
- bg->button.click_count = 1;
- }
- else
- bg->button.click_count++;
- B_Armed (bg) = False;
- if (bg->button.callback)
- {
- call_value.reason = XmCR_ACTIVATE;
- call_value.event = event;
- call_value.click_count = bg->button.click_count;
- if ((bg->button.multiClick == XmMULTICLICK_DISCARD) &&
- (call_value.click_count > 1)) {
- return;
- }
- XFlush(XtDisplay(bg));
- CallCallback (bg, B_Callback (bg), XmCR_ACTIVATE, event);
- }
- }
- /************************************************************************
- *
- * ArmAndActivate
- *
- ************************************************************************/
- static void
- ArmAndActivate(
- Widget w,
- XEvent *event,
- String *params,
- Cardinal *num_params )
- {
- DtButtonCallbackStruct call_value;
- DtButtonGadget bg = (DtButtonGadget) w ;
- B_Armed (bg) = True;
- Redisplay ( w, event, FALSE);
- XFlush (XtDisplay (bg));
- call_value.reason = XmCR_ACTIVATE;
- call_value.event = event;
- call_value.click_count = 1; /* always 1 in kselect */
- if (bg->button.callback)
- {
- XFlush (XtDisplay (bg));
- CallCallback (bg, B_Callback (bg), XmCR_ACTIVATE, event);
- }
- B_Armed (bg) = False;
- /* If the button is still around, show it released, after a short delay */
- if (bg->object.being_destroyed == False)
- {
- bg->button.timer = XtAppAddTimeOut(
- XtWidgetToApplicationContext((Widget)bg),
- (unsigned long) DELAY_DEFAULT,
- (XtTimerCallbackProc)ArmTimeout,
- (caddr_t)bg);
- }
- }
- /* ARGSUSED */
- static void
- ArmTimeout(
- Widget w,
- XtIntervalId *id )
- {
- DtButtonGadget bg = (DtButtonGadget) w ;
- bg -> button.timer = 0;
- if (XtIsRealized ((Widget)bg) && XtIsManaged ((Widget)bg)) {
- Redisplay ( w, NULL, FALSE);
- XFlush (XtDisplay (bg));
- }
- return;
- }
- /*-------------------------------------------------------------
- ** InputDispatch
- ** Process event dispatched from parent or event handler.
- */
- static void
- InputDispatch(
- Widget w,
- XButtonEvent *event,
- Mask event_mask )
- {
- DtButtonGadget bg = (DtButtonGadget) w ;
- if (event_mask & XmARM_EVENT ||
- event_mask & XmMULTI_ARM_EVENT)
- {
- if (event->button == Button1)
- Arm (w, (XEvent*) event, (String *)NULL, (Cardinal*)NULL);
- }
- else if (event_mask & XmACTIVATE_EVENT ||
- event_mask & XmMULTI_ACTIVATE_EVENT)
- {
- if (event->button == Button1)
- {
- if (event->x >= G_X (bg) &&
- event->x <= (Position)(G_X (bg) + G_Width (bg)) &&
- event->y >= G_Y (bg) &&
- event->y <= (Position)(G_Y (bg) + G_Height (bg)))
- {
- Activate (w, (XEvent*) event,
- (String *)NULL, (Cardinal*)NULL);
- Disarm (w, (XEvent*) event,
- (String *)NULL, (Cardinal*)NULL);
- }
- else
- Disarm (w, (XEvent*) event,
- (String *)NULL, (Cardinal*)NULL);
- }
- }
- else if (event_mask & XmHELP_EVENT)
- _XmSocorro (w, (XEvent *)event,
- (String *)NULL,(Cardinal*)NULL);
- else if (event_mask & XmENTER_EVENT)
- Enter (w, (XEvent *)event, (String *)NULL,(Cardinal*)NULL);
- else if (event_mask & XmLEAVE_EVENT)
- Leave (w, (XEvent *)event, (String *)NULL,(Cardinal*)NULL);
- else if (event_mask & XmFOCUS_IN_EVENT)
- _XmFocusInGadget (w, (XEvent *)event,
- (String *)NULL,(Cardinal*)NULL);
- else if (event_mask & XmFOCUS_OUT_EVENT)
- _XmFocusOutGadget (w, (XEvent *)event,
- (String *)NULL,(Cardinal*)NULL);
- }
- /*-------------------------------------------------------------
- ** VisualChange
- ** Update GCs when parent visuals change.
- */
- static Boolean
- VisualChange(
- Widget w,
- Widget current_w,
- Widget new_w )
- {
- XmManagerWidget current = (XmManagerWidget) current_w;
- XmManagerWidget new_m = (XmManagerWidget) new_w;
- DtButtonGadget bg = (DtButtonGadget) w ;
- Boolean update = False;
- /* If the parent foreground or background has changed,
- * then update gcs and pixmap.
- */
- if (M_Foreground (current) != M_Foreground (new_m) ||
- M_Background (current) != M_Background (new_m))
- {
- UpdateGCs(w);
- update = True;
- }
- if (update)
- {
- if (B_ImageName (bg) != NULL)
- {
- if (B_Mask(bg) != XmUNSPECIFIED_PIXMAP)
- XmDestroyPixmap (XtScreen(bg), B_Mask(bg));
- if (B_Pixmap(bg) != XmUNSPECIFIED_PIXMAP)
- XmDestroyPixmap (XtScreen(w), B_Pixmap (bg));
- B_Pixmap (bg) = XmGetPixmap (XtScreen (bg), B_ImageName (bg),
- M_TopShadowColor (new_m),
- M_BottomShadowColor (new_m));
- if (B_Pixmap (bg) != XmUNSPECIFIED_PIXMAP)
- B_Mask(bg) = (Pixmap)_DtGetMask(XtScreen(bg), B_ImageName(bg));
- return (True);
- }
- else
- return (False);
- }
- return (False);
- }
- /************************************************************************
- *
- * Enter
- *
- ************************************************************************/
- static void
- Enter(
- Widget wid,
- XEvent *event,
- String *params,
- Cardinal *num_params )
- {
- DtButtonGadget bg = (DtButtonGadget) wid ;
- _XmEnterGadget (wid, (XEvent *)event, (String *)NULL,(Cardinal *)NULL);
- if (B_Armed (bg))
- B_Expose (wid, event, NULL);
- }
- /************************************************************************
- *
- * Leave
- *
- ************************************************************************/
- static void
- Leave(
- Widget wid,
- XEvent *event,
- String *params,
- Cardinal *num_params )
- {
- DtButtonGadget bg = (DtButtonGadget) wid ;
- _XmLeaveGadget (wid, (XEvent *)event, (String *)NULL, (Cardinal *)0);
- if (B_Armed (bg))
- {
- B_Armed (bg) = False;
- B_Expose (wid, event, NULL);
- B_Armed (bg) = True;
- }
- }
- /*-------------------------------------------------------------
- ** CallCallback
- ** Call callback, if any, with reason and event.
- */
- static void
- CallCallback(
- DtButtonGadget w,
- XtCallbackList cb,
- int reason,
- XEvent *event )
- {
- DtControlCallbackStruct cb_data;
- if (cb != NULL)
- {
- cb_data.reason = reason;
- cb_data.event = event;
- cb_data.control_type = XmCONTROL_BUTTON;
- cb_data.set = False;
- cb_data.subpanel = B_Subpanel (w);
- cb_data.push_function = B_PushFunction (w);
- cb_data.push_argument = B_PushArgument (w);
- cb_data.file_size = 0;
- XtCallCallbackList ((Widget) w, cb, &cb_data);
- }
- }
- /*-------------------------------------------------------------
- ** DefaultSelectColor
- ** Resource proc. to determine the default select color.
- ** (Formerly _XmSelectColorDefault).
- */
- static void
- DefaultSelectColor(
- Widget widget,
- int offset,
- XrmValue *value )
- {
- XmeGetDefaultPixel (widget, XmSELECT, offset, value);
- }
- /************************************************************************
- *
- * DtCreateButtonGadget
- * Create an instance of an button and return the widget id.
- *
- ************************************************************************/
- Widget
- DtCreateButtonGadget(
- Widget parent,
- char *name,
- ArgList arglist,
- Cardinal argcount )
- {
- return (XtCreateWidget (name, dtButtonGadgetClass,
- parent, arglist, argcount));
- }
|