Change to the linux kernel coding style
[wmaker-crm.git] / WINGs / wsplitview.c
Commit [+]AuthorDateLineData
9d2e6ef9 scottc1998-09-29 22:36:29 +00001
9d2e6ef9 scottc1998-09-29 22:36:29 +00002#include "WINGsP.h"
3
94f4483d kojima1999-10-27 22:32:12 +00004/*
6830b057 dan2004-10-12 21:28:27 +00005 char *WMSplitViewDidResizeSubviewsNotification
6 = "WMSplitViewDidResizeSubviewsNotification";
7 char *WMSplitViewWillResizeSubviewsNotification
8 = "WMSplitViewWillResizeSubviewsNotification";
9 */
94f4483d kojima1999-10-27 22:32:12 +000010
046403db dan2001-04-15 01:22:56 +000011typedef struct W_SplitViewSubview {
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020012 WMView *view;
13 int minSize;
14 int maxSize;
15 int size;
16 int pos;
046403db dan2001-04-15 01:22:56 +000017} W_SplitViewSubview;
9d2e6ef9 scottc1998-09-29 22:36:29 +000018
9d2e6ef9 scottc1998-09-29 22:36:29 +000019typedef struct W_SplitView {
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020020 W_Class widgetClass;
21 W_View *view;
6830b057 dan2004-10-12 21:28:27 +000022
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020023 WMArray *subviews;
6830b057 dan2004-10-12 21:28:27 +000024
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020025 WMSplitViewConstrainProc *constrainProc;
6830b057 dan2004-10-12 21:28:27 +000026
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020027 struct {
28 unsigned int vertical:1;
29 unsigned int adjustOnPaint:1;
30 unsigned int subviewsWereManuallyMoved:1;
31 } flags;
94f4483d kojima1999-10-27 22:32:12 +000032
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020033 /* WMSplitViewResizeSubviewsProc *resizeSubviewsProc; */
94f4483d kojima1999-10-27 22:32:12 +000034
046403db dan2001-04-15 01:22:56 +000035} W_SplitView;
9d2e6ef9 scottc1998-09-29 22:36:29 +000036
94f4483d kojima1999-10-27 22:32:12 +000037#define DIVIDER_THICKNESS 8
38#define MIN_SUBVIEW_SIZE 4
39#define MAX_SUBVIEW_SIZE -1
40
046403db dan2001-04-15 01:22:56 +000041/* TODO: rewrite --Dan */
42#define _GetSubviewsCount() WMGetArrayItemCount(sPtr->subviews)
94f4483d kojima1999-10-27 22:32:12 +000043
38807b65 dan1999-11-07 21:40:22 +000044#define _AddPSubviewStruct(P) \
6830b057 dan2004-10-12 21:28:27 +000045 (WMAddToArray(sPtr->subviews,((void*)P)))
94f4483d kojima1999-10-27 22:32:12 +000046
38807b65 dan1999-11-07 21:40:22 +000047#define _GetPSubviewStructAt(i) \
6830b057 dan2004-10-12 21:28:27 +000048 ((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))
94f4483d kojima1999-10-27 22:32:12 +000049
38807b65 dan1999-11-07 21:40:22 +000050#define _GetSubviewAt(i) \
6830b057 dan2004-10-12 21:28:27 +000051 (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->view)
94f4483d kojima1999-10-27 22:32:12 +000052
53#define _GetMinSizeAt(i) \
6830b057 dan2004-10-12 21:28:27 +000054 (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->minSize)
94f4483d kojima1999-10-27 22:32:12 +000055
56#define _GetMaxSizeAt(i) \
6830b057 dan2004-10-12 21:28:27 +000057 (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->maxSize)
9d2e6ef9 scottc1998-09-29 22:36:29 +000058
94f4483d kojima1999-10-27 22:32:12 +000059#define _GetSizeAt(i) \
6830b057 dan2004-10-12 21:28:27 +000060 (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->size)
9d2e6ef9 scottc1998-09-29 22:36:29 +000061
94f4483d kojima1999-10-27 22:32:12 +000062#define _GetPosAt(i) \
6830b057 dan2004-10-12 21:28:27 +000063 (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->pos)
94f4483d kojima1999-10-27 22:32:12 +000064
65#define _GetSplitViewSize() \
6830b057 dan2004-10-12 21:28:27 +000066 ((sPtr->flags.vertical) ? sPtr->view->size.width : sPtr->view->size.height)
9d2e6ef9 scottc1998-09-29 22:36:29 +000067
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020068static void destroySplitView(WMSplitView * sPtr);
69static void paintSplitView(WMSplitView * sPtr);
9d2e6ef9 scottc1998-09-29 22:36:29 +000070
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020071static void handleEvents(XEvent * event, void *data);
72static void handleActionEvents(XEvent * event, void *data);
9d2e6ef9 scottc1998-09-29 22:36:29 +000073
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020074static void getConstraints(WMSplitView * sPtr, int index, int *minSize, int *maxSize)
9d2e6ef9 scottc1998-09-29 22:36:29 +000075{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020076 *minSize = MIN_SUBVIEW_SIZE;
77 *maxSize = MAX_SUBVIEW_SIZE;
94f4483d kojima1999-10-27 22:32:12 +000078
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020079 if (sPtr->constrainProc)
80 (*sPtr->constrainProc) (sPtr, index, minSize, maxSize);
94f4483d kojima1999-10-27 22:32:12 +000081
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020082 if (*minSize < MIN_SUBVIEW_SIZE)
83 *minSize = MIN_SUBVIEW_SIZE;
94f4483d kojima1999-10-27 22:32:12 +000084
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020085 if (*maxSize < MIN_SUBVIEW_SIZE)
86 *maxSize = MAX_SUBVIEW_SIZE;
87 else if (*maxSize < *minSize)
88 *maxSize = *minSize;
9d2e6ef9 scottc1998-09-29 22:36:29 +000089}
90
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020091static void updateConstraints(WMSplitView * sPtr)
9d2e6ef9 scottc1998-09-29 22:36:29 +000092{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020093 W_SplitViewSubview *p;
94 int i, count;
9d2e6ef9 scottc1998-09-29 22:36:29 +000095
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020096 count = _GetSubviewsCount();
97 for (i = 0; i < count; i++) {
98 p = _GetPSubviewStructAt(i);
99 getConstraints(sPtr, i, &(p->minSize), &(p->maxSize));
100 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000101}
102
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200103static void resizeView(WMSplitView * sPtr, WMView * view, int size)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000104{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200105 int width, height;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000106
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200107 if (sPtr->flags.vertical) {
108 width = size;
109 height = sPtr->view->size.height;
110 } else {
111 width = sPtr->view->size.width;
112 height = size;
113 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000114
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200115 if (view->self)
116 WMResizeWidget(view->self, width, height);
117 else
118 W_ResizeView(view, width, height);
94f4483d kojima1999-10-27 22:32:12 +0000119}
9d2e6ef9 scottc1998-09-29 22:36:29 +0000120
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200121static void reparentView(WMSplitView * sPtr, WMView * view, int pos)
94f4483d kojima1999-10-27 22:32:12 +0000122{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200123 int x, y;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000124
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200125 if (sPtr->flags.vertical) {
126 x = pos;
127 y = 0;
128 } else {
129 x = 0;
130 y = pos;
131 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000132
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200133 W_ReparentView(view, sPtr->view, x, y);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000134}
135
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200136static void moveView(WMSplitView * sPtr, WMView * view, int pos)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000137{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200138 int x, y;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000139
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200140 if (sPtr->flags.vertical) {
141 x = pos;
142 y = 0;
143 } else {
144 x = 0;
145 y = pos;
146 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000147
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200148 if (view->self)
149 WMMoveWidget(view->self, x, y);
150 else
151 W_MoveView(view, x, y);
94f4483d kojima1999-10-27 22:32:12 +0000152}
153
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200154static int checkSizes(WMSplitView * sPtr)
94f4483d kojima1999-10-27 22:32:12 +0000155{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200156 int i, count, offset;
157 W_SplitViewSubview *p;
94f4483d kojima1999-10-27 22:32:12 +0000158
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200159 count = _GetSubviewsCount();
160 offset = 0;
161 for (i = 0; i < count; i++) {
162 p = _GetPSubviewStructAt(i);
163 if (p->size < p->minSize) {
164 offset += p->minSize - p->size;
165 p->size = p->minSize;
166 } else if (p->maxSize != MAX_SUBVIEW_SIZE && p->size > p->maxSize) {
167 offset += p->maxSize - p->size;
168 p->size = p->maxSize;
169 }
170 }
6830b057 dan2004-10-12 21:28:27 +0000171
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200172 return (offset);
94f4483d kojima1999-10-27 22:32:12 +0000173}
174
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200175static void checkPositions(WMSplitView * sPtr)
94f4483d kojima1999-10-27 22:32:12 +0000176{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200177 int i, count, pos;
178 W_SplitViewSubview *p;
94f4483d kojima1999-10-27 22:32:12 +0000179
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200180 count = _GetSubviewsCount();
181 pos = 0;
182 for (i = 0; i < count; i++) {
183 p = _GetPSubviewStructAt(i);
184 p->pos = pos;
185 pos += p->size + DIVIDER_THICKNESS;
186 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000187}
188
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200189static void updateSubviewsGeom(WMSplitView * sPtr)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000190{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200191 int i, count;
192 W_SplitViewSubview *p;
94f4483d kojima1999-10-27 22:32:12 +0000193
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200194 count = _GetSubviewsCount();
195 for (i = 0; i < count; i++) {
196 p = _GetPSubviewStructAt(i);
197 resizeView(sPtr, p->view, p->size);
198 moveView(sPtr, p->view, p->pos);
199 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000200}
201
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200202static int getTotalSize(WMSplitView * sPtr)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000203{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200204 int i, count, totSize;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000205
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200206 count = _GetSubviewsCount();
207 if (!count)
208 return (0);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000209
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200210 totSize = 0;
211 for (i = 0; i < count; i++)
212 totSize += _GetSizeAt(i) + DIVIDER_THICKNESS;
6830b057 dan2004-10-12 21:28:27 +0000213
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200214 return (totSize - DIVIDER_THICKNESS);
94f4483d kojima1999-10-27 22:32:12 +0000215}
216
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200217static Bool distributeOffsetEqually(WMSplitView * sPtr, int offset)
94f4483d kojima1999-10-27 22:32:12 +0000218{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200219 W_SplitViewSubview *p;
220 int i, count, sizeChanged, forced;
94f4483d kojima1999-10-27 22:32:12 +0000221
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200222 if ((count = _GetSubviewsCount()) < 1)
223 return (True);
94f4483d kojima1999-10-27 22:32:12 +0000224
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200225 forced = False;
226 while (offset != 0) {
227 sizeChanged = 0;
228 for (i = 0; i < count && offset != 0; i++) {
229 p = _GetPSubviewStructAt(i);
230 if (offset < 0) {
231 if (p->size > p->minSize) {
232 offset++;
233 p->size--;
234 sizeChanged = 1;
235 }
236 } else if (p->maxSize == MAX_SUBVIEW_SIZE || p->size < p->maxSize) {
237 offset--;
238 p->size++;
239 sizeChanged = 1;
240 }
241 }
242 if (offset != 0 && !sizeChanged) {
243 p = _GetPSubviewStructAt(count - 1);
244 if (offset > 0) {
245 p->size += offset;
246 p->maxSize = MAX_SUBVIEW_SIZE;
247 }
248 offset = 0;
249 forced = True;
250 }
251 }
6830b057 dan2004-10-12 21:28:27 +0000252
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200253 return (forced);
94f4483d kojima1999-10-27 22:32:12 +0000254}
255
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200256static Bool distributeOffsetFormEnd(WMSplitView * sPtr, int offset)
94f4483d kojima1999-10-27 22:32:12 +0000257{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200258 W_SplitViewSubview *p;
259 int i, count, sizeTmp;
94f4483d kojima1999-10-27 22:32:12 +0000260
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200261 if ((count = _GetSubviewsCount()) < 1)
262 return (True);
94f4483d kojima1999-10-27 22:32:12 +0000263
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200264 for (i = count - 1; i >= 0 && offset != 0; i--) {
265 p = _GetPSubviewStructAt(i);
266 sizeTmp = p->size;
267 if (offset > 0) {
268 if (p->maxSize == MAX_SUBVIEW_SIZE || p->size + offset < p->maxSize)
269 p->size += offset;
270 else
271 p->size = p->maxSize;
272 } else {
273 if (p->size + offset >= p->minSize)
274 p->size += offset;
275 else
276 p->size = p->minSize;
277 }
278 offset -= p->size - sizeTmp;
279 }
94f4483d kojima1999-10-27 22:32:12 +0000280
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200281 return (offset == 0);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000282}
283
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200284static void adjustSplitViewSubviews(WMSplitView * sPtr)
94f4483d kojima1999-10-27 22:32:12 +0000285{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200286 W_SplitViewSubview *p;
287 int i, count, adjSize, adjPad;
94f4483d kojima1999-10-27 22:32:12 +0000288
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200289 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000290
9d2e6ef9 scottc1998-09-29 22:36:29 +0000291#if 0
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200292 printf("---- (adjustSplitViewSubviews - 1) ----\n");
293 dumpSubviews(sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000294#endif
295
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200296 if ((count = _GetSubviewsCount()) < 1)
297 return;
94f4483d kojima1999-10-27 22:32:12 +0000298
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200299 adjSize = (_GetSplitViewSize() - ((count - 1) * DIVIDER_THICKNESS)) / count;
300 adjPad = (_GetSplitViewSize() - ((count - 1) * DIVIDER_THICKNESS)) % count;
301 for (i = 0; i < count; i++) {
302 p = _GetPSubviewStructAt(i);
303 p->size = adjSize;
304 }
6830b057 dan2004-10-12 21:28:27 +0000305
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200306 distributeOffsetEqually(sPtr, adjPad - checkSizes(sPtr));
6830b057 dan2004-10-12 21:28:27 +0000307
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200308 checkPositions(sPtr);
309 updateSubviewsGeom(sPtr);
6830b057 dan2004-10-12 21:28:27 +0000310
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200311 sPtr->flags.subviewsWereManuallyMoved = 0;
94f4483d kojima1999-10-27 22:32:12 +0000312
6830b057 dan2004-10-12 21:28:27 +0000313#if 0
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200314 printf("---- (adjustSplitViewSubviews - 2) ----\n");
315 dumpSubviews(sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000316#endif
317}
318
319#if 0
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200320static void handleSubviewResized(void *self, WMNotification * notif)
321{
322 WMSplitView *sPtr = (WMSplitView *) self;
323
324 CHECK_CLASS(sPtr, WC_SplitView);
325
326 if (WMGetNotificationName(notif) == WMViewSizeDidChangeNotification) {
327 W_SplitViewSubview *p;
328 int i, count, done;
329 WMView *view = WMGetNotificationObject(notif);
330
331 count = _GetSubviewsCount();
332 done = 0;
333 for (i = 0; i < count; i++) {
334 p = _GetPSubviewStructAt(i);
335 if (p->view == view) {
336 done = 1;
337 break;
338 }
339 }
340
341 if (done) {
342 /* TODO !!! */
343 resizeView(sPtr, p->view, p->size);
344 moveView(sPtr, p->view, p->pos);
345 }
346 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000347}
348#endif
349
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200350static void handleViewResized(void *self, WMNotification * notification)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000351{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200352 WMSplitView *sPtr = (WMSplitView *) self;
94f4483d kojima1999-10-27 22:32:12 +0000353
354#if 0
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200355 printf("---- (handleViewResized - 1) ----\n");
356 dumpSubviews(sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000357#endif
358
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200359 updateConstraints(sPtr);
360 checkSizes(sPtr);
6830b057 dan2004-10-12 21:28:27 +0000361
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200362 if (sPtr->constrainProc || sPtr->flags.subviewsWereManuallyMoved) {
363 distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr));
364 checkPositions(sPtr);
365 updateSubviewsGeom(sPtr);
366 } else
367 adjustSplitViewSubviews(sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000368
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200369 assert(checkSizes(sPtr) == 0);
94f4483d kojima1999-10-27 22:32:12 +0000370
371#if 0
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200372 printf("---- (handleViewResized - 2) ----\n");
373 dumpSubviews(sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000374#endif
9d2e6ef9 scottc1998-09-29 22:36:29 +0000375}
376
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200377static void paintSplitView(WMSplitView * sPtr)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000378{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200379 W_SplitViewSubview *p;
380 W_Screen *scr = sPtr->view->screen;
381 int x, y, i, count;
382 WMPixmap *dimple = scr->scrollerDimple;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000383
94f4483d kojima1999-10-27 22:32:12 +0000384#if 0
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200385 printf("---- (paintSplitView - 1) ----\n");
386 dumpSubviews(sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000387#endif
6830b057 dan2004-10-12 21:28:27 +0000388
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200389 if (!sPtr->view->flags.mapped || !sPtr->view->flags.realized)
390 return;
94f4483d kojima1999-10-27 22:32:12 +0000391
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200392 XClearWindow(scr->display, sPtr->view->window);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000393
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200394 count = _GetSubviewsCount();
395 if (count == 0)
396 return;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000397
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200398 if (sPtr->flags.adjustOnPaint) {
399 handleViewResized(sPtr, NULL);
400 sPtr->flags.adjustOnPaint = 0;
401 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000402
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200403 XSetClipMask(scr->display, scr->clipGC, dimple->mask);
94f4483d kojima1999-10-27 22:32:12 +0000404
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200405 if (sPtr->flags.vertical) {
406 x = ((DIVIDER_THICKNESS - dimple->width) / 2);
407 y = (sPtr->view->size.height - dimple->height) / 2;
408 } else {
409 x = (sPtr->view->size.width - dimple->width) / 2;
410 y = ((DIVIDER_THICKNESS - dimple->height) / 2);
411 }
94f4483d kojima1999-10-27 22:32:12 +0000412
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200413 for (i = 0; i < count - 1; i++) {
414 p = _GetPSubviewStructAt(i);
6830b057 dan2004-10-12 21:28:27 +0000415
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200416 if (sPtr->flags.vertical)
417 x += p->size;
418 else
419 y += p->size;
6830b057 dan2004-10-12 21:28:27 +0000420
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200421 XSetClipOrigin(scr->display, scr->clipGC, x, y);
422 XCopyArea(scr->display, dimple->pixmap, sPtr->view->window,
423 scr->clipGC, 0, 0, dimple->width, dimple->height, x, y);
6830b057 dan2004-10-12 21:28:27 +0000424
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200425 if (sPtr->flags.vertical)
426 x += DIVIDER_THICKNESS;
427 else
428 y += DIVIDER_THICKNESS;
429 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000430
94f4483d kojima1999-10-27 22:32:12 +0000431#if 0
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200432 printf("---- (paintSplitView - 2) ----\n");
433 dumpSubviews(sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000434#endif
435}
9d2e6ef9 scottc1998-09-29 22:36:29 +0000436
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200437static void drawDragingRectangle(WMSplitView * sPtr, int pos)
438{
439 int x, y, w, h;
440
441 if (sPtr->flags.vertical) {
442 x = pos;
443 y = 0;
444 w = DIVIDER_THICKNESS;
445 h = sPtr->view->size.height;
446 } else {
447 x = 0;
448 y = pos;
449 w = sPtr->view->size.width;
450 h = DIVIDER_THICKNESS;
451 }
452
453 XFillRectangle(sPtr->view->screen->display, sPtr->view->window, sPtr->view->screen->ixorGC, x, y, w, h);
454}
455
456static void getMinMaxDividerCoord(WMSplitView * sPtr, int divider, int *minC, int *maxC)
457{
458 int relMinC, relMaxC;
459 int totSize = _GetSizeAt(divider) + _GetSizeAt(divider + 1);
460
461 relMinC = _GetMinSizeAt(divider);
462 if (_GetMaxSizeAt(divider + 1) != MAX_SUBVIEW_SIZE && relMinC < totSize - _GetMaxSizeAt(divider + 1))
463 relMinC = totSize - _GetMaxSizeAt(divider + 1);
464
465 relMaxC = totSize - _GetMinSizeAt(divider + 1);
466 if (_GetMaxSizeAt(divider) != MAX_SUBVIEW_SIZE && relMaxC > _GetMaxSizeAt(divider))
467 relMaxC = _GetMaxSizeAt(divider);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000468
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200469 *minC = _GetPosAt(divider) + relMinC;
470 *maxC = _GetPosAt(divider) + relMaxC;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000471}
472
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200473static void dragDivider(WMSplitView * sPtr, int clickX, int clickY)
474{
475 int divider, pos, ofs, done, dragging;
476 int i, count;
477 XEvent ev;
478 WMScreen *scr;
479 int minCoord, maxCoord, coord;
480
481 if (sPtr->constrainProc) {
482 updateConstraints(sPtr);
483 checkSizes(sPtr);
484 distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr));
485 checkPositions(sPtr);
486 updateSubviewsGeom(sPtr);
487 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000488
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200489 scr = sPtr->view->screen;
490 divider = ofs = pos = done = 0;
491 coord = (sPtr->flags.vertical) ? clickX : clickY;
492 count = _GetSubviewsCount();
493 if (count < 2)
494 return;
94f4483d kojima1999-10-27 22:32:12 +0000495
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200496 for (i = 0; i < count - 1; i++) {
497 pos += _GetSizeAt(i) + DIVIDER_THICKNESS;
498 if (coord < pos) {
499 ofs = coord - pos + DIVIDER_THICKNESS;
500 done = 1;
501 break;
502 }
503 divider++;
504 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000505
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200506 if (!done)
507 return;
94f4483d kojima1999-10-27 22:32:12 +0000508
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200509 getMinMaxDividerCoord(sPtr, divider, &minCoord, &maxCoord);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000510
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200511 done = 0;
512 dragging = 0;
513 while (!done) {
514 WMMaskEvent(scr->display, ButtonMotionMask | ButtonReleaseMask | ExposureMask, &ev);
6830b057 dan2004-10-12 21:28:27 +0000515
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200516 coord = (sPtr->flags.vertical) ? ev.xmotion.x : ev.xmotion.y;
6830b057 dan2004-10-12 21:28:27 +0000517
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200518 switch (ev.type) {
519 case ButtonRelease:
520 done = 1;
521 if (dragging)
522 drawDragingRectangle(sPtr, pos);
523 break;
6830b057 dan2004-10-12 21:28:27 +0000524
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200525 case MotionNotify:
526 if (dragging)
527 drawDragingRectangle(sPtr, pos);
528 if (coord - ofs < minCoord)
529 pos = minCoord;
530 else if (coord - ofs > maxCoord)
531 pos = maxCoord;
532 else
533 pos = coord - ofs;
534 drawDragingRectangle(sPtr, pos);
535 dragging = 1;
536 break;
6830b057 dan2004-10-12 21:28:27 +0000537
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200538 default:
539 WMHandleEvent(&ev);
540 break;
541 }
542 }
6830b057 dan2004-10-12 21:28:27 +0000543
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200544 if (dragging) {
545 W_SplitViewSubview *p1, *p2;
546 int totSize;
6830b057 dan2004-10-12 21:28:27 +0000547
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200548 p1 = _GetPSubviewStructAt(divider);
549 p2 = _GetPSubviewStructAt(divider + 1);
6830b057 dan2004-10-12 21:28:27 +0000550
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200551 totSize = p1->size + DIVIDER_THICKNESS + p2->size;
6830b057 dan2004-10-12 21:28:27 +0000552
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200553 p1->size = pos - p1->pos;
554 p2->size = totSize - p1->size - DIVIDER_THICKNESS;
555 p2->pos = p1->pos + p1->size + DIVIDER_THICKNESS;
6830b057 dan2004-10-12 21:28:27 +0000556
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200557 resizeView(sPtr, p1->view, p1->size);
558 moveView(sPtr, p2->view, p2->pos);
559 resizeView(sPtr, p2->view, p2->size);
560 sPtr->flags.subviewsWereManuallyMoved = 1;
561 }
94f4483d kojima1999-10-27 22:32:12 +0000562}
563
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200564static void handleEvents(XEvent * event, void *data)
94f4483d kojima1999-10-27 22:32:12 +0000565{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200566 WMSplitView *sPtr = (WMSplitView *) data;
94f4483d kojima1999-10-27 22:32:12 +0000567
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200568 CHECK_CLASS(data, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000569
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200570 switch (event->type) {
571 case Expose:
572 if (event->xexpose.count != 0)
573 break;
574 paintSplitView(sPtr);
575 break;
6830b057 dan2004-10-12 21:28:27 +0000576
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200577 case DestroyNotify:
578 destroySplitView(sPtr);
579 break;
580 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000581}
582
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200583static void handleActionEvents(XEvent * event, void *data)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000584{
6830b057 dan2004-10-12 21:28:27 +0000585
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200586 CHECK_CLASS(data, WC_SplitView);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000587
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200588 switch (event->type) {
589 case ButtonPress:
590 if (event->xbutton.button == Button1)
591 dragDivider(data, event->xbutton.x, event->xbutton.y);
592 break;
593 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000594}
595
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200596static void destroySplitView(WMSplitView * sPtr)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000597{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200598 WMFreeArray(sPtr->subviews);
94f4483d kojima1999-10-27 22:32:12 +0000599
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200600 WMRemoveNotificationObserver(sPtr);
046403db dan2001-04-15 01:22:56 +0000601
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200602 wfree(sPtr);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000603}
604
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200605WMSplitView *WMCreateSplitView(WMWidget * parent)
94f4483d kojima1999-10-27 22:32:12 +0000606{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200607 WMSplitView *sPtr;
6830b057 dan2004-10-12 21:28:27 +0000608
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200609 sPtr = wmalloc(sizeof(WMSplitView));
610 memset(sPtr, 0, sizeof(WMSplitView));
94f4483d kojima1999-10-27 22:32:12 +0000611
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200612 sPtr->widgetClass = WC_SplitView;
94f4483d kojima1999-10-27 22:32:12 +0000613
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200614 sPtr->view = W_CreateView(W_VIEW(parent));
615 if (!sPtr->view) {
616 wfree(sPtr);
617 return NULL;
618 }
619 sPtr->view->self = sPtr;
94f4483d kojima1999-10-27 22:32:12 +0000620
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200621 WMSetViewNotifySizeChanges(sPtr->view, True);
94f4483d kojima1999-10-27 22:32:12 +0000622
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200623 WMCreateEventHandler(sPtr->view, ExposureMask | StructureNotifyMask
624 | ClientMessageMask, handleEvents, sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000625
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200626 WMCreateEventHandler(sPtr->view, ButtonPressMask | ButtonReleaseMask
627 | EnterWindowMask | LeaveWindowMask, handleActionEvents, sPtr);
046403db dan2001-04-15 01:22:56 +0000628
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200629 WMAddNotificationObserver(handleViewResized, sPtr, WMViewSizeDidChangeNotification, sPtr->view);
046403db dan2001-04-15 01:22:56 +0000630
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200631 sPtr->subviews = WMCreateArrayWithDestructor(8, wfree);
94f4483d kojima1999-10-27 22:32:12 +0000632
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200633 return sPtr;
94f4483d kojima1999-10-27 22:32:12 +0000634}
635
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200636void WMAdjustSplitViewSubviews(WMSplitView * sPtr)
94f4483d kojima1999-10-27 22:32:12 +0000637{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200638 CHECK_CLASS(sPtr, WC_SplitView);
6830b057 dan2004-10-12 21:28:27 +0000639
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200640 checkSizes(sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000641
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200642 adjustSplitViewSubviews(sPtr);
94f4483d kojima1999-10-27 22:32:12 +0000643
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200644 assert(checkSizes(sPtr) == 0);
94f4483d kojima1999-10-27 22:32:12 +0000645}
646
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200647void WMAddSplitViewSubview(WMSplitView * sPtr, WMView * subview)
94f4483d kojima1999-10-27 22:32:12 +0000648{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200649 int wasMapped, count;
650 W_SplitViewSubview *p;
94f4483d kojima1999-10-27 22:32:12 +0000651
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200652 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000653
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200654 if (!(p = (W_SplitViewSubview *) wmalloc(sizeof(W_SplitViewSubview))))
655 return;
94f4483d kojima1999-10-27 22:32:12 +0000656
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200657 wasMapped = subview->flags.mapped;
658 if (wasMapped)
659 W_UnmapView(subview);
94f4483d kojima1999-10-27 22:32:12 +0000660
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200661 count = _GetSubviewsCount();
662 p->view = subview;
663 getConstraints(sPtr, count, &(p->minSize), &(p->maxSize));
664 if (sPtr->flags.vertical)
665 p->size = subview->size.width;
666 else
667 p->size = subview->size.height;
94f4483d kojima1999-10-27 22:32:12 +0000668
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200669 WMAddToArray(sPtr->subviews, p);
670 reparentView(sPtr, subview, 0);
046403db dan2001-04-15 01:22:56 +0000671
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200672 /*
673 We should have something like that...
6830b057 dan2004-10-12 21:28:27 +0000674
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200675 WMSetViewNotifySizeChanges(subview, True);
676 WMAddNotificationObserver(handleSubviewResized, sPtr,
677 WMViewSizeDidChangeNotification,
678 subview);
679 WMSetViewNotifyMoveChanges(subview, True);
680 WMAddNotificationObserver(handleSubviewResized, sPtr,
681 WMViewMoveDidChangeNotification,
682 subview);
683 */
684 if (wasMapped) {
685 W_MapView(subview);
e99511b0 kojima2001-01-02 14:17:26 +0000686
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200687 sPtr->flags.adjustOnPaint = 1;
688 paintSplitView(sPtr);
689 } else {
690 handleViewResized(sPtr, NULL);
691 }
94f4483d kojima1999-10-27 22:32:12 +0000692}
693
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200694WMView *WMGetSplitViewSubviewAt(WMSplitView * sPtr, int index)
94f4483d kojima1999-10-27 22:32:12 +0000695{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200696 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000697
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200698 if (index >= 0 && index < _GetSubviewsCount())
699 return (_GetSubviewAt(index));
700 else
701 return (NULL);
94f4483d kojima1999-10-27 22:32:12 +0000702}
703
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200704void WMRemoveSplitViewSubview(WMSplitView * sPtr, WMView * view)
94f4483d kojima1999-10-27 22:32:12 +0000705{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200706 W_SplitViewSubview *p;
707 int i, count;
94f4483d kojima1999-10-27 22:32:12 +0000708
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200709 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000710
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200711 /* TODO: rewrite this. This code with macros is getting more complex than it worths */
712 count = _GetSubviewsCount();
713 for (i = 0; i < count; i++) {
714 p = _GetPSubviewStructAt(i);
715 if (p->view == view) {
716 WMDeleteFromArray(sPtr->subviews, i);
717 sPtr->flags.adjustOnPaint = 1;
718 paintSplitView(sPtr);
719 break;
720 }
721 }
94f4483d kojima1999-10-27 22:32:12 +0000722}
723
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200724void WMRemoveSplitViewSubviewAt(WMSplitView * sPtr, int index)
94f4483d kojima1999-10-27 22:32:12 +0000725{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200726 W_SplitViewSubview *p;
94f4483d kojima1999-10-27 22:32:12 +0000727
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200728 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000729
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200730 /* TODO: same about rewrite */
731 if (index >= 0 && index < _GetSubviewsCount()) {
732 p = _GetPSubviewStructAt(index);
733 WMDeleteFromArray(sPtr->subviews, index);
734 sPtr->flags.adjustOnPaint = 1;
735 paintSplitView(sPtr);
736 }
94f4483d kojima1999-10-27 22:32:12 +0000737}
738
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200739void WMSetSplitViewConstrainProc(WMSplitView * sPtr, WMSplitViewConstrainProc * proc)
94f4483d kojima1999-10-27 22:32:12 +0000740{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200741 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000742
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200743 sPtr->constrainProc = proc;
94f4483d kojima1999-10-27 22:32:12 +0000744}
745
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200746int WMGetSplitViewSubviewsCount(WMSplitView * sPtr)
94f4483d kojima1999-10-27 22:32:12 +0000747{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200748 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000749
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200750 return (_GetSubviewsCount());
94f4483d kojima1999-10-27 22:32:12 +0000751}
752
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200753Bool WMGetSplitViewVertical(WMSplitView * sPtr)
94f4483d kojima1999-10-27 22:32:12 +0000754{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200755 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000756
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200757 return (sPtr->flags.vertical == 1);
94f4483d kojima1999-10-27 22:32:12 +0000758}
759
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200760void WMSetSplitViewVertical(WMSplitView * sPtr, Bool flag)
94f4483d kojima1999-10-27 22:32:12 +0000761{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200762 int vertical;
6830b057 dan2004-10-12 21:28:27 +0000763
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200764 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000765
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200766 vertical = ((flag == 0) ? 0 : 1);
767 if (sPtr->flags.vertical == vertical)
768 return;
6830b057 dan2004-10-12 21:28:27 +0000769
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200770 sPtr->flags.vertical = vertical;
6830b057 dan2004-10-12 21:28:27 +0000771
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200772 /* if (sPtr->view->flags.mapped && sPtr->view->flags.realized) */
773 handleViewResized(sPtr, NULL);
774 /* else
775 sPtr->flags.adjustOnPaint = 1;
776 */
94f4483d kojima1999-10-27 22:32:12 +0000777}
778
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200779int WMGetSplitViewDividerThickness(WMSplitView * sPtr)
94f4483d kojima1999-10-27 22:32:12 +0000780{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200781 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000782
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200783 return (DIVIDER_THICKNESS);
94f4483d kojima1999-10-27 22:32:12 +0000784}
785
786#if 0
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200787void WMSetSplitViewResizeSubviewsProc(WMSplitView * sPtr, WMSplitViewResizeSubviewsProc * proc)
94f4483d kojima1999-10-27 22:32:12 +0000788{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200789 CHECK_CLASS(sPtr, WC_SplitView);
94f4483d kojima1999-10-27 22:32:12 +0000790
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200791 sPtr->resizeSubviewsProc = proc;
94f4483d kojima1999-10-27 22:32:12 +0000792}
793#endif