ObjGUI  Diff

Differences From Artifact [8a22986e9e]:

To Artifact [615b173fac]:


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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
       expand: (BOOL)expand
         fill: (BOOL)fill
      padding: (float)padding
{
  RECT rc;
  SetParent(child->widget, widget);
  GetWindowRect(child->widget, &rc);
  
  og_box_child_t *newChild   = malloc(sizeof(og_box_child_t));
  newChild->hwnd         = child->widget;
  newChild->expand       = expand;
  newChild->fill         = fill;
  newChild->padding      = (int)padding;
  newChild->originalSize = (rc.bottom - rc.top);
  newChild->currentSize  = (float)(newChild->originalSize + (newChild->padding << 1));
  newChild->next         = NULL;
  
  if(firstBorn == NULL)
    firstBorn = newChild;
  else
  {
    og_box_child_t *curr = firstBorn;
    while(curr->next != NULL) curr = curr->next;
    curr->next = newChild;
  }
  
  [self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)prependChild: (OGWidget*)child
        expand: (BOOL)expand
    fill: (BOOL)fill
       padding: (float)padding
{
  RECT rc;
  SetParent(child->widget, widget);
  GetWindowRect(child->widget, &rc);
  
  og_box_child_t *newChild   = malloc(sizeof(og_box_child_t));
  newChild->hwnd         = child->widget;
  newChild->expand       = expand;
  newChild->fill         = fill;
  newChild->padding      = (int)padding;
  newChild->originalSize = (rc.bottom - rc.top);
  newChild->currentSize  = (float)(newChild->originalSize + (newChild->padding << 1));
  newChild->next         = firstBorn;
  
  firstBorn = newChild;
  
  SetParent(child->widget, widget);
  [self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)OG_resizeChildren
{
  RECT rc;
  og_box_child_t *curr;
  
  //get our available size
  GetClientRect(widget, &rc);
  int width  = rc.right;
  int height = rc.bottom;
  
  //get total of childrens' heights
  int childOriginal = 0;
  curr = firstBorn;
  while(curr != NULL)
  {
    childOriginal += (curr->originalSize + (curr->padding << 1));
    curr = curr->next;
  }
  
  //how to divide our extra space
  int extra = height - childOriginal;
  float evenShare = 0.0f;
  
  if(extra <= 0)
  {
    curr = firstBorn;
    while(curr != NULL)
    {
      curr->currentSize = curr->originalSize;
      curr = curr->next;







|








|








|











|








|

|








|




|








|



|







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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
       expand: (BOOL)expand
         fill: (BOOL)fill
      padding: (float)padding
{
  RECT rc;
  SetParent(child->widget, widget);
  GetWindowRect(child->widget, &rc);

  og_box_child_t *newChild   = malloc(sizeof(og_box_child_t));
  newChild->hwnd         = child->widget;
  newChild->expand       = expand;
  newChild->fill         = fill;
  newChild->padding      = (int)padding;
  newChild->originalSize = (rc.bottom - rc.top);
  newChild->currentSize  = (float)(newChild->originalSize + (newChild->padding << 1));
  newChild->next         = NULL;

  if(firstBorn == NULL)
    firstBorn = newChild;
  else
  {
    og_box_child_t *curr = firstBorn;
    while(curr->next != NULL) curr = curr->next;
    curr->next = newChild;
  }

  [self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)prependChild: (OGWidget*)child
        expand: (BOOL)expand
    fill: (BOOL)fill
       padding: (float)padding
{
  RECT rc;
  SetParent(child->widget, widget);
  GetWindowRect(child->widget, &rc);

  og_box_child_t *newChild   = malloc(sizeof(og_box_child_t));
  newChild->hwnd         = child->widget;
  newChild->expand       = expand;
  newChild->fill         = fill;
  newChild->padding      = (int)padding;
  newChild->originalSize = (rc.bottom - rc.top);
  newChild->currentSize  = (float)(newChild->originalSize + (newChild->padding << 1));
  newChild->next         = firstBorn;

  firstBorn = newChild;

  SetParent(child->widget, widget);
  [self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)OG_resizeChildren
{
  RECT rc;
  og_box_child_t *curr;

  //get our available size
  GetClientRect(widget, &rc);
  int width  = rc.right;
  int height = rc.bottom;

  //get total of childrens' heights
  int childOriginal = 0;
  curr = firstBorn;
  while(curr != NULL)
  {
    childOriginal += (curr->originalSize + (curr->padding << 1));
    curr = curr->next;
  }

  //how to divide our extra space
  int extra = height - childOriginal;
  float evenShare = 0.0f;

  if(extra <= 0)
  {
    curr = firstBorn;
    while(curr != NULL)
    {
      curr->currentSize = curr->originalSize;
      curr = curr->next;
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
        if(curr->expand == YES)
          if(curr->fill == YES)
            curr->currentSize = (float)curr->originalSize + evenShare;
        curr = curr->next;
      }
    }
  }
  
  //assign new positions/heights
  float y = 0;
  curr = firstBorn;
  while(curr != NULL)
  {
    y += (float)curr->padding;
    SetWindowPos(curr->hwnd, NULL, 0, (int)y, width, curr->currentSize, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);







|







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
        if(curr->expand == YES)
          if(curr->fill == YES)
            curr->currentSize = (float)curr->originalSize + evenShare;
        curr = curr->next;
      }
    }
  }

  //assign new positions/heights
  float y = 0;
  curr = firstBorn;
  while(curr != NULL)
  {
    y += (float)curr->padding;
    SetWindowPos(curr->hwnd, NULL, 0, (int)y, width, curr->currentSize, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
{
  switch(msg)
  {
    case WM_SIZE:
      [self OG_resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;
    
    case WM_SIZING:
      [self OG_resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;
  }
  return [(id)super MessageReceived : hwnd : msg : wparam : lparam];
}
//----------------------------------------------------------------------------------------------------------------------------------
@end
//==================================================================================================================================







|










171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
{
  switch(msg)
  {
    case WM_SIZE:
      [self OG_resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;

    case WM_SIZING:
      [self OG_resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;
  }
  return [(id)super MessageReceived : hwnd : msg : wparam : lparam];
}
//----------------------------------------------------------------------------------------------------------------------------------
@end
//==================================================================================================================================