File: layout.c

package info (click to toggle)
vis5d 4.3-5
  • links: PTS
  • area: main
  • in suites: slink
  • size: 16,856 kB
  • ctags: 6,127
  • sloc: ansic: 66,158; fortran: 4,470; makefile: 1,683; tcl: 414; sh: 69
file content (105 lines) | stat: -rw-r--r-- 1,647 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* layout.c */



/*
 * Automatic widget layout helper.
 */


#include "layout.h"

static int LastX, LastY;
static int LastWidth, LastHeight;

static int Gutter = 5;



/*
 * Set gutter (space between widgets) in pixels.
 */
void LUI_LayoutGutter( int g )
{
   Gutter = g;
}


int LUI_LayoutGetGutter( void )
{
   return Gutter;
}



/*
 * Return the value associated with the given layout symbol.
 */
int LUI_LayoutGet( int param )
{
   switch (param) {
      case LUI_NEXT_X:
         return LastX + LastWidth + Gutter;
      case LUI_NEXT_Y:
         return LastY + LastHeight + Gutter;
      case LUI_SAME_X:
         return LastX;
      case LUI_SAME_Y:
         return LastY;
      case LUI_SAME_W:
         return LastWidth;
      case LUI_SAME_H:
         return LastHeight;
      case LUI_LEFT:
         return Gutter;
      case LUI_TOP:
         return Gutter;
      default:
         return 0;
   }
}




/*
 * Check if user position/size arguments specify auto placement.  If so,
 * compute real arguments.
 */
void LUI_LayoutCheck( int *x, int *y, int *width, int *height )
{

   if (*x==LUI_NEXT_X) {
      *x = LastX + LastWidth + Gutter;
   }
   else if (*x==LUI_SAME_X) {
      *x = LastX;
   }
   else if (*x==LUI_LEFT) {
      *x = Gutter;
   }

   if (*y==LUI_NEXT_Y) {
      *y = LastY + LastHeight + Gutter;
   }
   else if (*y==LUI_SAME_Y) {
      *y = LastY;
   }
   else if (*y==LUI_TOP) {
      *y = Gutter;
   }

   if (*width==LUI_SAME_W) {
      *width = LastWidth;
   }

   if (*height==LUI_SAME_H) {
      *height = LastHeight;
   }

   LastX = *x;
   LastY = *y;
   LastWidth = *width;
   LastHeight = *height;

}