3 * $Id: SlideC.c,v 1.5 2005/12/01 14:31:43 tringali Exp $
5 * Copyright (C) 1996 Free Software Foundation, Inc.
6 * Copyright © 1999-2001 by the LessTif developers.
8 * This file is part of the GNU LessTif Extension Library.
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the Free
22 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "../config.h"
40 Widget methods, forward declarations
43 static void class_initialize(void);
44 static void class_part_initialize(WidgetClass widget_class
);
45 static void initialize(Widget request
, Widget new_w
, ArgList args
, Cardinal
*num_args
);
46 static void destroy(Widget w
);
47 static Boolean
set_values(Widget old
, Widget request
, Widget new_w
, ArgList args
, Cardinal
*num_args
);
48 static void get_values_hook(Widget w
, ArgList args
, Cardinal
*num_args
);
50 static void _XltSlideProc(Widget w
);
51 static void targetDestroy(Widget target
, Widget w
);
54 Widget default resources
57 #define Offset(field) XtOffsetOf(XltSlideContextRec, slide.field)
58 static XtResource resources
[] =
61 XltNslideFinishCallback
, XtCCallback
, XtRCallback
,
62 sizeof(XtCallbackList
), Offset(slideFinishCallback
),
66 XltNslideMotionCallback
, XtCCallback
, XtRCallback
,
67 sizeof(XtCallbackList
), Offset(slideMotionCallback
),
71 XltNslideWidget
, XltCSlideWidget
, XtRWidget
,
72 sizeof(Widget
), Offset(slide_widget
),
76 XltNslideInterval
, XltCSlideInterval
, XtRInt
,
77 sizeof(int), Offset(interval
),
78 XtRImmediate
, (XtPointer
)5
81 XltNslideDestWidth
, XltCSlideDestWidth
, XtRDimension
,
82 sizeof(Dimension
), Offset(dest_width
),
83 XtRImmediate
, (XtPointer
)XmUNSPECIFIED
86 XltNslideDestHeight
, XltCSlideDestHeight
, XtRDimension
,
87 sizeof(Dimension
), Offset(dest_height
),
88 XtRImmediate
, (XtPointer
)XmUNSPECIFIED
91 XltNslideDestX
, XltCSlideDestX
, XtRPosition
,
92 sizeof(Position
), Offset(dest_x
),
93 XtRImmediate
, (XtPointer
)XmUNSPECIFIED_POSITION
96 XltNslideDestY
, XltCSlideDestY
, XtRPosition
,
97 sizeof(Position
), Offset(dest_y
),
98 XtRImmediate
, (XtPointer
)XmUNSPECIFIED_POSITION
106 XltSlideContextClassRec xltSlideContextClassRec
= {
107 /* Object Class Part */
109 /* pointer to superclass ClassRec WidgetClass */ (WidgetClass
) &objectClassRec
,
110 /* widget resource class name String */ "XltSlideContext",
111 /* size in bytes of widget record Cardinal */ sizeof(XltSlideContextRec
),
112 /* class initialization proc XtProc */ class_initialize
,
113 /* dynamic initialization XtWidgetClassProc */ class_part_initialize
,
114 /* has class been initialized? XtEnum */ False
,
115 /* initialize subclass fields XtInitProc */ initialize
,
116 /* notify that initialize called XtArgsProc */ NULL
,
117 /* NULL XtProc */ NULL
,
118 /* NULL XtPointer */ NULL
,
119 /* NULL Cardinal */ (Cardinal
)NULL
,
120 /* resources for subclass fields XtResourceList */ resources
,
121 /* number of entries in resources Cardinal */ XtNumber(resources
),
122 /* resource class quarkified XrmClass */ NULLQUARK
,
123 /* NULL Boolean */ (Boolean
)NULL
,
124 /* NULL XtEnum */ (XtEnum
)NULL
,
125 /* NULL Boolean */ (Boolean
)NULL
,
126 /* NULL Boolean */ (Boolean
)NULL
,
127 /* free data for subclass pointers XtWidgetProc */ destroy
,
128 /* NULL XtProc */ NULL
,
129 /* NULL XtProc */ NULL
,
130 /* set subclass resource values XtSetValuesFunc */ set_values
,
131 /* notify that set_values called XtArgsFunc */ NULL
,
132 /* NULL XtProc */ NULL
,
133 /* notify that get_values called XtArgsProc */ get_values_hook
,
134 /* NULL XtProc */ NULL
,
135 /* version of intrinsics used XtVersionType */ XtVersion
,
136 /* list of callback offsets XtPointer */ NULL
,
137 /* NULL String */ NULL
,
138 /* NULL XtProc */ NULL
,
139 /* NULL XtProc */ NULL
,
140 /* pointer to extension record XtPointer */ NULL
142 /* SlideContext Class Part */
148 WidgetClass xltSlideContextWidgetClass
= (WidgetClass
)&xltSlideContextClassRec
;
151 class_initialize(void)
156 class_part_initialize(WidgetClass widget_class
)
161 initialize(Widget request
, Widget new_w
, ArgList args
, Cardinal
*num_args
)
164 printf("%s:%s(%d) - %s %li\n", __FILE__, __FUNCTION__, __LINE__,
166 Slide_Interval(new_w));
169 if (Slide_DestWidth(new_w
) == (Dimension
)XmUNSPECIFIED
)
171 Slide_DestWidth(new_w
) = XtWidth(Slide_Widget(new_w
));
173 if (Slide_DestHeight(new_w
) == (Dimension
)XmUNSPECIFIED
)
175 Slide_DestHeight(new_w
) = XtHeight(Slide_Widget(new_w
));
177 if (Slide_DestX(new_w
) == XmUNSPECIFIED_POSITION
)
179 Slide_DestX(new_w
) = XtX(Slide_Widget(new_w
));
181 if (Slide_DestY(new_w
) == XmUNSPECIFIED_POSITION
)
183 Slide_DestY(new_w
) = XtY(Slide_Widget(new_w
));
185 Slide_Id(new_w
) = XtAppAddTimeOut(XtWidgetToApplicationContext(new_w
),
186 Slide_Interval(new_w
),
187 (XtTimerCallbackProc
)_XltSlideProc
,
189 XtAddCallback(Slide_Widget(new_w
), XmNdestroyCallback
, (XtCallbackProc
)targetDestroy
, new_w
);
195 if (Slide_Id(w
) != (XtIntervalId
)NULL
)
197 XtRemoveTimeOut(Slide_Id(w
));
198 Slide_Id(w
) = (XtIntervalId
)NULL
;
200 XtRemoveCallback(Slide_Widget(w
), XmNdestroyCallback
, (XtCallbackProc
)targetDestroy
, w
);
204 set_values(Widget old
, Widget request
, Widget new_w
, ArgList args
, Cardinal
*num_args
)
206 if (Slide_Widget(old
) != Slide_Widget(new_w
))
208 XtRemoveCallback(Slide_Widget(old
), XmNdestroyCallback
, (XtCallbackProc
)targetDestroy
, old
);
209 XtAddCallback(Slide_Widget(new_w
), XmNdestroyCallback
, (XtCallbackProc
)targetDestroy
, new_w
);
215 get_values_hook(Widget w
, ArgList args
, Cardinal
*num_args
)
220 targetDestroy(Widget target
, Widget w
)
226 _XltSlideProc(Widget w
)
228 Dimension width
, height
;
232 printf("%s:%s(%d) - %s %li\n", __FILE__, __FUNCTION__, __LINE__,
237 width
= XtWidth(Slide_Widget(w
));
238 height
= XtHeight(Slide_Widget(w
));
239 x
= XtX(Slide_Widget(w
));
240 y
= XtY(Slide_Widget(w
));
242 height
= height
- (((height
- Slide_DestHeight(w
)) * 10) / 100);
243 if (height
< Slide_DestHeight(w
))
247 if (height
> Slide_DestHeight(w
))
251 width
= width
- (((width
- Slide_DestWidth(w
)) * 10) / 100);
252 if (width
< Slide_DestWidth(w
))
256 if (width
> Slide_DestWidth(w
))
262 y
= y
- ((((y
- Slide_DestY(w
)) * 10) / 100) + 0);
263 if (y
< Slide_DestY(w
))
267 if (y
> Slide_DestY(w
))
271 x
= x
- ((((x
- Slide_DestX(w
)) * 10) / 100) + 0);
272 if (x
< Slide_DestX(w
))
276 if (x
> Slide_DestX(w
))
282 XtCallCallbackList(w, Slide_MotionCallback(w), NULL);
284 XtVaSetValues(Slide_Widget(w
),
290 if (Slide_DestX(w
) == XtX(Slide_Widget(w
)) &&
291 Slide_DestY(w
) == XtY(Slide_Widget(w
)) &&
292 Slide_DestWidth(w
) == XtWidth(Slide_Widget(w
)) &&
293 Slide_DestHeight(w
) == XtHeight(Slide_Widget(w
)))
295 XtCallCallbackList(w
, Slide_FinishCallback(w
), NULL
);
296 XtRemoveCallback(Slide_Widget(w
), XmNdestroyCallback
, (XtCallbackProc
)targetDestroy
, w
);
301 Slide_Id(w
) = XtAppAddTimeOut(XtWidgetToApplicationContext(w
),
303 (XtTimerCallbackProc
)_XltSlideProc
,