ObjGUI  Diff

Differences From Artifact [8cefd08417]:

To Artifact [8a22986e9e]:


1
2

3
4
5
6
7
8
9
/*
 * Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>

 *
 * https://webkeks.org/hg/objgui/
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice is present in all copies.
 *


>







1
2
3
4
5
6
7
8
9
10
/*
 * Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
 * Copyright (c) 2012, Jonathan Schleifer <js@webkeks.org>
 *
 * https://webkeks.org/hg/objgui/
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice is present in all copies.
 *
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
         fill: (BOOL)fill
      padding: (float)padding
{
  RECT rc;
  SetParent(child->widget, widget);
  GetWindowRect(child->widget, &rc);
  
  OGBoxChild *newChild   = (OGBoxChild *)malloc(sizeof(OGBoxChild));
  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
  {
    OGBoxChild *curr = firstBorn;
    while(curr->next != NULL) curr = curr->next;
    curr->next = newChild;
  }
  
  [self resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)prependChild: (OGWidget*)child
        expand: (BOOL)expand
    fill: (BOOL)fill
       padding: (float)padding
{
  RECT rc;
  SetParent(child->widget, widget);
  GetWindowRect(child->widget, &rc);
  
  OGBoxChild *newChild   = (OGBoxChild *)malloc(sizeof(OGBoxChild));
  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 resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)resizeChildren
{
  RECT rc;
  OGBoxChild *curr;
  
  //get our available size
  GetClientRect(widget, &rc);
  int width  = rc.right;
  int height = rc.bottom;
  
  //get total of childrens' heights







|












|




|











|











|


|


|







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
         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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    while(curr != NULL)
    {
      curr->currentSize = curr->originalSize;
      curr = curr->next;
    }
    if(extra < 0)
    {
      //this will generate a WM_SIZE message, and we'll come back to resizeChildren
      SetWindowPos(widget, NULL, 0, 0, width, childOriginal, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
      return;
    }
  }
  else
  {
    int sharers = 0;







|







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
    while(curr != NULL)
    {
      curr->currentSize = curr->originalSize;
      curr = curr->next;
    }
    if(extra < 0)
    {
      //this will generate a WM_SIZE message, and we'll come back to OG_resizeChildren
      SetWindowPos(widget, NULL, 0, 0, width, childOriginal, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
      return;
    }
  }
  else
  {
    int sharers = 0;
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
}
//----------------------------------------------------------------------------------------------------------------------------------
- (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam
{
  switch(msg)
  {
    case WM_SIZE:
      [self resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;
    
    case WM_SIZING:
      [self resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;
  }
  return [(id)super MessageReceived : hwnd : msg : wparam : lparam];
}
//----------------------------------------------------------------------------------------------------------------------------------
@end
//==================================================================================================================================







|




|








168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
}
//----------------------------------------------------------------------------------------------------------------------------------
- (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam
{
  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
//==================================================================================================================================