50 //static char defaultTranslations[] = "<BtnDown>: mousedown()\n"; |
50 //static char defaultTranslations[] = "<BtnDown>: mousedown()\n"; |
51 static char defaultTranslations[] = "\ |
51 static char defaultTranslations[] = "\ |
52 <EnterWindow>: getfocus()\n\ |
52 <EnterWindow>: getfocus()\n\ |
53 <LeaveWindow>: loosefocus()\n"; |
53 <LeaveWindow>: loosefocus()\n"; |
54 |
54 |
|
55 static XtResource resources[] = |
|
56 { |
|
57 { |
|
58 gridColumnSpacing, |
|
59 gridColumnSpacing, |
|
60 XmRDimension, |
|
61 sizeof (Dimension), |
|
62 XtOffsetOf( GridRec, |
|
63 mywidget.columnspacing), |
|
64 XmRImmediate, |
|
65 (XtPointer) 0 |
|
66 }, |
|
67 { |
|
68 gridRowSpacing, |
|
69 gridRowSpacing, |
|
70 XmRDimension, |
|
71 sizeof (Dimension), |
|
72 XtOffsetOf( GridRec, |
|
73 mywidget.rowspacing), |
|
74 XmRImmediate, |
|
75 (XtPointer) 0 |
|
76 }, |
|
77 { |
|
78 gridMargin, |
|
79 gridMargin, |
|
80 XmRDimension, |
|
81 sizeof (Dimension), |
|
82 XtOffsetOf( GridRec, |
|
83 mywidget.margin), |
|
84 XmRImmediate, |
|
85 (XtPointer) 0 |
|
86 } |
|
87 }; |
55 |
88 |
56 ///* |
89 ///* |
57 static XtResource constraints[] = |
90 static XtResource constraints[] = |
58 { |
91 { |
59 { |
92 { |
177 (XtPointer) 0 |
210 (XtPointer) 0 |
178 } |
211 } |
179 |
212 |
180 }; |
213 }; |
181 //*/ |
214 //*/ |
182 //static XtResource constraints[] = {}; |
|
183 |
215 |
184 GridClassRec gridClassRec = { |
216 GridClassRec gridClassRec = { |
185 // Core Class |
217 // Core Class |
186 { |
218 { |
187 //(WidgetClass)&constraintClassRec, // superclass |
219 //(WidgetClass)&constraintClassRec, // superclass |
188 (WidgetClass)&xmManagerClassRec, |
220 (WidgetClass)&xmManagerClassRec, |
189 "Grid", // class_name |
221 "Grid", // class_name |
190 sizeof(GridRec), // widget_size |
222 sizeof(GridRec), // widget_size |
191 grid_class_initialize, // class_initialize |
223 grid_class_initialize, // class_initialize |
192 NULL, // class_part_initialize |
224 NULL, // class_part_initialize |
193 FALSE, // class_inited |
225 FALSE, // class_inited |
194 (XtInitProc)grid_initialize, // initialize |
226 (XtInitProc)grid_initialize, // initialize |
195 NULL, // initialize_hook |
227 NULL, // initialize_hook |
196 grid_realize, // realize |
228 grid_realize, // realize |
197 actionslist, // actions |
229 actionslist, // actions |
198 XtNumber(actionslist), // num_actions |
230 XtNumber(actionslist), // num_actions |
199 NULL, // resources |
231 resources, // resources |
200 0, // num_resources |
232 XtNumber(resources), // num_resources |
201 NULLQUARK, // xrm_class |
233 NULLQUARK, // xrm_class |
202 True, // compress_motion |
234 True, // compress_motion |
203 True, // compress_exposure |
235 True, // compress_exposure |
204 True, // compress_enterleave |
236 True, // compress_enterleave |
205 False, // visible_interest |
237 False, // visible_interest |
478 } |
510 } |
479 req_height += rows[i].size; |
511 req_height += rows[i].size; |
480 } |
512 } |
481 |
513 |
482 if(req_width > 0 && req_height > 0) { |
514 if(req_width > 0 && req_height > 0) { |
|
515 // add col/row spacing |
|
516 req_width += (ncols-1)*w->mywidget.columnspacing; |
|
517 req_height += (nrows-1)*w->mywidget.rowspacing; |
|
518 |
483 Widget parent = w->core.parent; |
519 Widget parent = w->core.parent; |
484 Dimension rwidth = req_width; |
520 Dimension rwidth = req_width; |
485 Dimension rheight = req_height; |
521 Dimension rheight = req_height; |
486 if(rwidth < w->core.width) { |
522 if(rwidth < w->core.width) { |
487 //rwidth = w->core.width; |
523 //rwidth = w->core.width; |
557 if(constraints->grid.hfill) { |
594 if(constraints->grid.hfill) { |
558 if(constraints->grid.colspan > 1) { |
595 if(constraints->grid.colspan > 1) { |
559 Dimension cwidth = 0; |
596 Dimension cwidth = 0; |
560 for(int j=0;j<constraints->grid.colspan;j++) { |
597 for(int j=0;j<constraints->grid.colspan;j++) { |
561 if(constraints->grid.x+j < ncols) { |
598 if(constraints->grid.x+j < ncols) { |
562 cwidth += cols[constraints->grid.x+j].size; |
599 cwidth += cols[constraints->grid.x+j].size + (j > 0 ? w->mywidget.columnspacing : 0); |
563 } |
600 } |
564 } |
601 } |
565 width = cwidth; |
602 width = cwidth; |
566 } else { |
603 } else { |
567 width = c.size; |
604 width = c.size - w->mywidget.columnspacing; |
568 } |
605 } |
569 } |
606 } |
570 if(constraints->grid.vfill) { |
607 if(constraints->grid.vfill) { |
571 if(constraints->grid.rowspan > 1) { |
608 if(constraints->grid.rowspan > 1) { |
572 Dimension cheight = 0; |
609 Dimension cheight = 0; |
573 for(int j=0;j<constraints->grid.rowspan;j++) { |
610 for(int j=0;j<constraints->grid.rowspan;j++) { |
574 if(constraints->grid.y+j < nrows) { |
611 if(constraints->grid.y+j < nrows) { |
575 cheight += rows[constraints->grid.y+j].size; |
612 cheight += rows[constraints->grid.y+j].size + (j > 0 ? w->mywidget.rowspacing : 0); |
576 } |
613 } |
577 } |
614 } |
578 height = cheight; |
615 height = cheight; |
579 } else { |
616 } else { |
580 height = r.size; |
617 height = r.size - w->mywidget.rowspacing; |
581 } |
618 } |
582 } |
619 } |
583 |
620 |
584 XtConfigureWidget(child, x, y, width, height, child->core.border_width); |
621 XtConfigureWidget(child, x, y, width, height, child->core.border_width); |
585 //printf("child %d %d - %d %d\n", (int)child->core.x, (int)child->core.y, (int)child->core.width, (int)child->core.height); |
622 //printf("child %d %d - %d %d\n", (int)child->core.x, (int)child->core.y, (int)child->core.width, (int)child->core.height); |