ObjGUI  Check-in [ab5fc3316f]

Overview
Comment:Clean up headers a little.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ab5fc3316f74961fc1cf1e3b3befac8f92ab52912981763e4687f4c5840adf92
User & Date: js on 2012-01-05 15:08:37
Other Links: manifest | tags
Context
2012-01-05
15:13
Clean up win32 Makefile. check-in: d73b4f5e50 user: js tags: trunk
15:08
Clean up headers a little. check-in: ab5fc3316f user: js tags: trunk
14:50
Rename OG_W32 to OG_WIN32. check-in: f711c6f48c user: js tags: trunk
Changes

Modified headers/OGBox.h from [1a3aaad4f9] to [df4280417a].

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
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







-
+

-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+




+
-
+
-
+

+









+
+
+
+

 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "OGWidget.h"

#ifdef OG_WIN32
typedef struct s_OGBoxChild
typedef struct og_box_child_t
{
	HWND  hwnd;
	BOOL  expand;
	BOOL  fill;
	int   padding;
	int   originalSize;
	float currentSize;
	struct s_OGBoxChild *next;
} OGBoxChild;
	HWND   hwnd;
	BOOL   expand;
	BOOL   fill;
	int    padding;
	int    originalSize;
	float  currentSize;
	struct og_box_child_t *next;
} og_box_child_t;
#endif

@interface OGBox: OGWidget
#ifdef OG_WIN32
{
{ OGBoxChild *firstBorn; }
	og_child_box_t *firstBorn;
- (void)resizeChildren;
}
#endif

+ box;
- (void)appendChild: (OGWidget*)child
	     expand: (BOOL)expand
	       fill: (BOOL)fill
	    padding: (float)padding;
- (void)prependChild: (OGWidget*)child
	      expand: (BOOL)expand
		fill: (BOOL)fill
	     padding: (float)padding;

#ifdef OG_WIN32
- (void)OG_resizeChildren;
#endif
@end

Modified headers/OGComboBox.h from [b4c169f6cb] to [d91ccea8e4].

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55










56
39
40
41
42
43
44
45






46
47
48
49
50
51
52
53
54
55
56
57
58
59
60







-
-
-
-
-
-




+
+
+
+
+
+
+
+
+
+


@interface OGComboBox: OGWidget
{
	id <OGComboBoxDelegate> delegate;
	id <OGComboBoxDataSource> dataSource;
}

#ifdef OG_WIN32
//unfortunately, the built-in Win32 ListBox stores a pointer to it's parent (for sending selection changed notifications) during CreateWindow().
//it does not update it after a SetParent()... unless we implement a custom ListBox control i don't see a way around this...
- initWithParent : (OGWidget *)parent;
#endif

@property (assign) id <OGComboBoxDelegate> delegate;
@property (assign) id <OGComboBoxDataSource> dataSource;

+ comboBox;

#ifdef OG_WIN32
/*
 * Unfortunately, the built-in Win32 ListBox stores a pointer to it's parent
 * (for sending selection changed notifications) during CreateWindow(). It does
 * not update it after a SetParent() unless we implement a custom ListBox
 * control, so there seems to be no way around this.
 */
- initWithParent: (OGWidget*)parent;
#endif
@end

Modified win32/OGBox.m from [80155f33e8] to [8a087b8b0e].

1
2

3
4
5
6
7
8
9
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.
 *
21
22
23
24
25
26
27



28

29
30
31
32
33
34
35
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40







+
+
+

+







 */
 
//==================================================================================================================================
// OGBox.m
//==================================================================================================================================
#include <malloc.h>
#include <windows.h>

#import <ObjFW/OFNotImplementedException.h>

#import "OGBox.h"

//==================================================================================================================================
@implementation OGBox
//----------------------------------------------------------------------------------------------------------------------------------
+ box
{
  return [[[self alloc] init] autorelease];
}
63
64
65
66
67
68
69
70

71


72
73
74
75
76
77
78
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
84
85







-
+

+
+







- (void)prependChild: (OGWidget*)child
        expand: (BOOL)expand
    fill: (BOOL)fill
       padding: (float)padding
{
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)resizeChildren
- (void)OG_resizeChildren
{
  @throw [OFNotImplementedException exceptionWithClass: isa
                                              selector: _cmd];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam
{
  HWND parent;
  
  switch(msg)

Modified win32/OGHBox.m from [e2f8c4d7bd] to [99145ff743].

1
2

3
4
5
6
7
8
9
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
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));
  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.right - rc.left);
  newChild->currentSize  = (float)(newChild->originalSize + (newChild->padding << 1));
  newChild->next         = NULL;
  
  if(firstBorn == NULL)
    firstBorn = newChild;
  else
  {
    OGBoxChild *curr = firstBorn;
    og_box_child_t *curr = firstBorn;
    while(curr->next != NULL) curr = curr->next;
    curr->next = newChild;
  }
  
  [self resizeChildren];
  [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);
  
  OGBoxChild *newChild   = (OGBoxChild *)malloc(sizeof(OGBoxChild));
  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.right - rc.left);
  newChild->currentSize  = (float)(newChild->originalSize + (newChild->padding << 1));
  newChild->next         = firstBorn;
  
  firstBorn = newChild;
  
  [self resizeChildren];
  [self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)resizeChildren
- (void)OG_resizeChildren
{
  RECT rc;
  OGBoxChild *curr;
  og_box_child_t *curr;
  
  //get our available size
  GetClientRect(widget, &rc);
  int width  = rc.right;
  int height = rc.bottom;
  
  //get total of childrens' widths
117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
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
      //this will generate a WM_SIZE message, and we'll come back to OG_resizeChildren
      SetWindowPos(widget, NULL, 0, 0, childOriginal, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
      return;
    }
  }
  else
  {
    int sharers = 0;
166
167
168
169
170
171
172
173

174
175
176
177
178

179
180
181
182
183
184
185
186
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];
      [self OG_resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;
    
    case WM_SIZING:
      [self resizeChildren];
      [self OG_resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;
  }
  return [(id)super MessageReceived : hwnd : msg : wparam : lparam];
}
//----------------------------------------------------------------------------------------------------------------------------------
@end
//==================================================================================================================================

Modified win32/OGVBox.m from [8cefd08417] to [8a22986e9e].

1
2

3
4
5
6
7
8
9
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
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);
  
  OGBoxChild *newChild   = (OGBoxChild *)malloc(sizeof(OGBoxChild));
  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
  {
    OGBoxChild *curr = firstBorn;
    og_box_child_t *curr = firstBorn;
    while(curr->next != NULL) curr = curr->next;
    curr->next = newChild;
  }
  
  [self resizeChildren];
  [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);
  
  OGBoxChild *newChild   = (OGBoxChild *)malloc(sizeof(OGBoxChild));
  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 resizeChildren];
  [self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)resizeChildren
- (void)OG_resizeChildren
{
  RECT rc;
  OGBoxChild *curr;
  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
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 resizeChildren
      //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
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 resizeChildren];
      [self OG_resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;
    
    case WM_SIZING:
      [self resizeChildren];
      [self OG_resizeChildren];
      return DefWindowProc(hwnd, msg, wparam, lparam);
    break;
  }
  return [(id)super MessageReceived : hwnd : msg : wparam : lparam];
}
//----------------------------------------------------------------------------------------------------------------------------------
@end
//==================================================================================================================================