Mercurial > dwindows
comparison mac/dw.m @ 2814:1b33d03568c4
Mac: Fix object/memory leaks... retain objects created with *_new()
Then once added to a box with dw_box_pack_*() release and autorelease.
So when the window is closed the objects should all get released.
This is how it was originally designed, but it was never enabled.
Similar changes coming to iOS soon.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 01 Aug 2022 16:55:06 +0000 |
parents | 9c9b680f7772 |
children | 1efe0ed76629 |
comparison
equal
deleted
inserted
replaced
2813:9c9b680f7772 | 2814:1b33d03568c4 |
---|---|
2279 @implementation DWMLE | 2279 @implementation DWMLE |
2280 -(void *)userdata { return userdata; } | 2280 -(void *)userdata { return userdata; } |
2281 -(void)setUserdata:(void *)input { userdata = input; } | 2281 -(void)setUserdata:(void *)input { userdata = input; } |
2282 -(id)scrollview { return scrollview; } | 2282 -(id)scrollview { return scrollview; } |
2283 -(void)setScrollview:(id)input { scrollview = input; } | 2283 -(void)setScrollview:(id)input { scrollview = input; } |
2284 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } | 2284 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [scrollview release]; [super dealloc]; } |
2285 @end | 2285 @end |
2286 | 2286 |
2287 #ifndef DW_USE_NSVIEW | 2287 #ifndef DW_USE_NSVIEW |
2288 /* Subclass NSTextFieldCell for displaying image and text */ | 2288 /* Subclass NSTextFieldCell for displaying image and text */ |
2289 @interface DWImageAndTextCell : NSTextFieldCell | 2289 @interface DWImageAndTextCell : NSTextFieldCell |
3106 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; | 3106 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; |
3107 [super keyDown:theEvent]; | 3107 [super keyDown:theEvent]; |
3108 } | 3108 } |
3109 -(void)insertTab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectNextKeyView:self]; } | 3109 -(void)insertTab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectNextKeyView:self]; } |
3110 -(void)insertBacktab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectPreviousKeyView:self]; } | 3110 -(void)insertBacktab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectPreviousKeyView:self]; } |
3111 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } | 3111 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [scrollview release]; [super dealloc]; } |
3112 @end | 3112 @end |
3113 | 3113 |
3114 /* Dive into the tree freeing all desired child nodes */ | 3114 /* Dive into the tree freeing all desired child nodes */ |
3115 void _dw_free_tree_recurse(NSMutableArray *node, NSMutableArray *item) | 3115 void _dw_free_tree_recurse(NSMutableArray *node, NSMutableArray *item) |
3116 { | 3116 { |
4683 DW_FUNCTION_ADD_PARAM2(type, pad) | 4683 DW_FUNCTION_ADD_PARAM2(type, pad) |
4684 DW_FUNCTION_RETURN(dw_box_new, HWND) | 4684 DW_FUNCTION_RETURN(dw_box_new, HWND) |
4685 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int) | 4685 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int) |
4686 { | 4686 { |
4687 DW_FUNCTION_INIT; | 4687 DW_FUNCTION_INIT; |
4688 DWBox *view = [[DWBox alloc] init]; | 4688 DWBox *view = [[[DWBox alloc] init] retain]; |
4689 Box *newbox = [view box]; | 4689 Box *newbox = [view box]; |
4690 memset(newbox, 0, sizeof(Box)); | 4690 memset(newbox, 0, sizeof(Box)); |
4691 newbox->pad = pad; | 4691 newbox->pad = pad; |
4692 newbox->type = type; | 4692 newbox->type = type; |
4693 DW_FUNCTION_RETURN_THIS(view); | 4693 DW_FUNCTION_RETURN_THIS(view); |
4700 * pad: Number of pixels to pad around the box. | 4700 * pad: Number of pixels to pad around the box. |
4701 * title: Text to be displayined in the group outline. | 4701 * title: Text to be displayined in the group outline. |
4702 */ | 4702 */ |
4703 HWND API dw_groupbox_new(int type, int pad, const char *title) | 4703 HWND API dw_groupbox_new(int type, int pad, const char *title) |
4704 { | 4704 { |
4705 NSBox *groupbox = [[DWGroupBox alloc] init]; | 4705 NSBox *groupbox = [[[DWGroupBox alloc] init] retain]; |
4706 DWBox *thisbox = dw_box_new(type, pad); | 4706 DWBox *thisbox = dw_box_new(type, pad); |
4707 Box *box = [thisbox box]; | 4707 Box *box = [thisbox box]; |
4708 | 4708 |
4709 #ifndef BUILDING_FOR_CATALINA | 4709 #ifndef BUILDING_FOR_CATALINA |
4710 [groupbox setBorderType:NSBezelBorder]; | 4710 [groupbox setBorderType:NSBezelBorder]; |
4711 #endif | 4711 #endif |
4712 [groupbox setTitle:[NSString stringWithUTF8String:title]]; | 4712 [groupbox setTitle:[NSString stringWithUTF8String:title]]; |
4713 box->grouphwnd = groupbox; | 4713 box->grouphwnd = groupbox; |
4714 [groupbox setContentView:thisbox]; | 4714 [groupbox setContentView:thisbox]; |
4715 [thisbox release]; | |
4715 [thisbox autorelease]; | 4716 [thisbox autorelease]; |
4716 return groupbox; | 4717 return groupbox; |
4717 } | 4718 } |
4718 | 4719 |
4719 /* | 4720 /* |
4722 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). | 4723 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
4723 * pad: Number of pixels to pad around the box. | 4724 * pad: Number of pixels to pad around the box. |
4724 */ | 4725 */ |
4725 HWND API dw_scrollbox_new( int type, int pad ) | 4726 HWND API dw_scrollbox_new( int type, int pad ) |
4726 { | 4727 { |
4727 DWScrollBox *scrollbox = [[DWScrollBox alloc] init]; | 4728 DWScrollBox *scrollbox = [[[DWScrollBox alloc] init] retain]; |
4728 DWBox *box = dw_box_new(type, pad); | 4729 DWBox *box = dw_box_new(type, pad); |
4729 DWBox *tmpbox = dw_box_new(DW_VERT, 0); | 4730 DWBox *tmpbox = dw_box_new(DW_VERT, 0); |
4730 dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0); | 4731 dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0); |
4731 [scrollbox setHasVerticalScroller:YES]; | 4732 [scrollbox setHasVerticalScroller:YES]; |
4732 [scrollbox setHasHorizontalScroller:YES]; | 4733 [scrollbox setHasHorizontalScroller:YES]; |
4733 [scrollbox setBorderType:NSNoBorder]; | 4734 [scrollbox setBorderType:NSNoBorder]; |
4734 [scrollbox setDrawsBackground:NO]; | 4735 [scrollbox setDrawsBackground:NO]; |
4735 [scrollbox setBox:box]; | 4736 [scrollbox setBox:box]; |
4736 [scrollbox setDocumentView:tmpbox]; | 4737 [scrollbox setDocumentView:tmpbox]; |
4738 [tmpbox release]; | |
4737 [tmpbox autorelease]; | 4739 [tmpbox autorelease]; |
4738 return scrollbox; | 4740 return scrollbox; |
4739 } | 4741 } |
4740 | 4742 |
4741 /* | 4743 /* |
5159 /* Update the item count */ | 5161 /* Update the item count */ |
5160 thisbox->count++; | 5162 thisbox->count++; |
5161 | 5163 |
5162 /* Add the item to the box */ | 5164 /* Add the item to the box */ |
5163 [view addSubview:this]; | 5165 [view addSubview:this]; |
5166 [this release]; | |
5164 /* Enable autorelease on the item... | 5167 /* Enable autorelease on the item... |
5165 * so it will get destroyed when the parent is. | 5168 * so it will get destroyed when the parent is. |
5166 */ | 5169 */ |
5167 [this autorelease]; | 5170 [this autorelease]; |
5168 /* If we are packing a button... */ | 5171 /* If we are packing a button... */ |
5388 } | 5391 } |
5389 | 5392 |
5390 /* Internal function to create a basic button, used by all button types */ | 5393 /* Internal function to create a basic button, used by all button types */ |
5391 HWND _dw_button_new(const char *text, ULONG cid) | 5394 HWND _dw_button_new(const char *text, ULONG cid) |
5392 { | 5395 { |
5393 DWButton *button = [[DWButton alloc] init]; | 5396 DWButton *button = [[[DWButton alloc] init] retain]; |
5394 if(text) | 5397 if(text) |
5395 { | 5398 { |
5396 [button setTitle:[ NSString stringWithUTF8String:text ]]; | 5399 [button setTitle:[ NSString stringWithUTF8String:text ]]; |
5397 } | 5400 } |
5398 [button setTarget:button]; | 5401 [button setTarget:button]; |
5432 * text: The default text to be in the entryfield widget. | 5435 * text: The default text to be in the entryfield widget. |
5433 * id: An ID to be used with dw_window_from_id() or 0L. | 5436 * id: An ID to be used with dw_window_from_id() or 0L. |
5434 */ | 5437 */ |
5435 HWND API dw_entryfield_new(const char *text, ULONG cid) | 5438 HWND API dw_entryfield_new(const char *text, ULONG cid) |
5436 { | 5439 { |
5437 DWEntryField *entry = [[DWEntryField alloc] init]; | 5440 DWEntryField *entry = [[[DWEntryField alloc] init] retain]; |
5438 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; | 5441 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
5439 [entry setTag:cid]; | 5442 [entry setTag:cid]; |
5440 [[entry cell] setScrollable:YES]; | 5443 [[entry cell] setScrollable:YES]; |
5441 [[entry cell] setWraps:NO]; | 5444 [[entry cell] setWraps:NO]; |
5442 return entry; | 5445 return entry; |
5448 * text: The default text to be in the entryfield widget. | 5451 * text: The default text to be in the entryfield widget. |
5449 * id: An ID to be used with dw_window_from_id() or 0L. | 5452 * id: An ID to be used with dw_window_from_id() or 0L. |
5450 */ | 5453 */ |
5451 HWND API dw_entryfield_password_new(const char *text, ULONG cid) | 5454 HWND API dw_entryfield_password_new(const char *text, ULONG cid) |
5452 { | 5455 { |
5453 DWEntryFieldPassword *entry = [[DWEntryFieldPassword alloc] init]; | 5456 DWEntryFieldPassword *entry = [[[DWEntryFieldPassword alloc] init] retain]; |
5454 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; | 5457 [entry setStringValue:[ NSString stringWithUTF8String:text ]]; |
5455 [entry setTag:cid]; | 5458 [entry setTag:cid]; |
5456 [[entry cell] setScrollable:YES]; | 5459 [[entry cell] setScrollable:YES]; |
5457 [[entry cell] setWraps:NO]; | 5460 [[entry cell] setWraps:NO]; |
5458 return entry; | 5461 return entry; |
5558 * text: The text to be display by the static text widget. | 5561 * text: The text to be display by the static text widget. |
5559 * id: An ID to be used with dw_window_from_id() or 0L. | 5562 * id: An ID to be used with dw_window_from_id() or 0L. |
5560 */ | 5563 */ |
5561 HWND API dw_spinbutton_new(const char *text, ULONG cid) | 5564 HWND API dw_spinbutton_new(const char *text, ULONG cid) |
5562 { | 5565 { |
5563 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; | 5566 DWSpinButton *spinbutton = [[[DWSpinButton alloc] init] retain]; |
5564 NSStepper *stepper = [spinbutton stepper]; | 5567 NSStepper *stepper = [spinbutton stepper]; |
5565 NSTextField *textfield = [spinbutton textfield]; | 5568 NSTextField *textfield = [spinbutton textfield]; |
5566 [stepper setIncrement:1]; | 5569 [stepper setIncrement:1]; |
5567 [stepper setTag:cid]; | 5570 [stepper setTag:cid]; |
5568 [stepper setMinValue:-65536]; | 5571 [stepper setMinValue:-65536]; |
5634 * increments: Number of increments available. | 5637 * increments: Number of increments available. |
5635 * id: An ID to be used with dw_window_from_id() or 0L. | 5638 * id: An ID to be used with dw_window_from_id() or 0L. |
5636 */ | 5639 */ |
5637 HWND API dw_slider_new(int vertical, int increments, ULONG cid) | 5640 HWND API dw_slider_new(int vertical, int increments, ULONG cid) |
5638 { | 5641 { |
5639 DWSlider *slider = [[DWSlider alloc] init]; | 5642 DWSlider *slider = [[[DWSlider alloc] init] retain]; |
5640 [slider setMaxValue:(double)increments]; | 5643 [slider setMaxValue:(double)increments]; |
5641 [slider setMinValue:0]; | 5644 [slider setMinValue:0]; |
5642 [slider setContinuous:YES]; | 5645 [slider setContinuous:YES]; |
5643 [slider setTarget:slider]; | 5646 [slider setTarget:slider]; |
5644 [slider setAction:@selector(sliderChanged:)]; | 5647 [slider setAction:@selector(sliderChanged:)]; |
5680 HWND API dw_scrollbar_new(int vertical, ULONG cid) | 5683 HWND API dw_scrollbar_new(int vertical, ULONG cid) |
5681 { | 5684 { |
5682 DWScrollbar *scrollbar; | 5685 DWScrollbar *scrollbar; |
5683 if(vertical) | 5686 if(vertical) |
5684 { | 5687 { |
5685 scrollbar = [[DWScrollbar alloc] init]; | 5688 scrollbar = [[[DWScrollbar alloc] init] retain]; |
5686 [scrollbar setVertical:YES]; | 5689 [scrollbar setVertical:YES]; |
5687 } | 5690 } |
5688 else | 5691 else |
5689 { | 5692 { |
5690 scrollbar = [[DWScrollbar alloc] initWithFrame:NSMakeRect(0,0,100,5)]; | 5693 scrollbar = [[[DWScrollbar alloc] initWithFrame:NSMakeRect(0,0,100,5)] retain]; |
5691 } | 5694 } |
5692 #ifndef BUILDING_FOR_YOSEMITE | 5695 #ifndef BUILDING_FOR_YOSEMITE |
5693 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting]; | 5696 [scrollbar setArrowsPosition:NSScrollerArrowsDefaultSetting]; |
5694 #endif | 5697 #endif |
5695 [scrollbar setRange:0.0 andVisible:0.0]; | 5698 [scrollbar setRange:0.0 andVisible:0.0]; |
5749 * Parameters: | 5752 * Parameters: |
5750 * id: An ID to be used with dw_window_from_id() or 0L. | 5753 * id: An ID to be used with dw_window_from_id() or 0L. |
5751 */ | 5754 */ |
5752 HWND API dw_percent_new(ULONG cid) | 5755 HWND API dw_percent_new(ULONG cid) |
5753 { | 5756 { |
5754 DWPercent *percent = [[DWPercent alloc] init]; | 5757 DWPercent *percent = [[[DWPercent alloc] init] retain]; |
5755 [percent setStyle:DWProgressIndicatorStyleBar]; | 5758 [percent setStyle:DWProgressIndicatorStyleBar]; |
5756 [percent setBezeled:YES]; | 5759 [percent setBezeled:YES]; |
5757 [percent setMaxValue:100]; | 5760 [percent setMaxValue:100]; |
5758 [percent setMinValue:0]; | 5761 [percent setMinValue:0]; |
5759 [percent incrementBy:1]; | 5762 [percent incrementBy:1]; |
5846 } | 5849 } |
5847 | 5850 |
5848 /* Internal common function to create containers and listboxes */ | 5851 /* Internal common function to create containers and listboxes */ |
5849 HWND _dw_cont_new(ULONG cid, int multi) | 5852 HWND _dw_cont_new(ULONG cid, int multi) |
5850 { | 5853 { |
5851 DWFocusRingScrollView *scrollview = [[DWFocusRingScrollView alloc] init]; | 5854 DWFocusRingScrollView *scrollview = [[[DWFocusRingScrollView alloc] init] retain]; |
5852 DWContainer *cont = [[DWContainer alloc] init]; | 5855 DWContainer *cont = [[[DWContainer alloc] init] retain]; |
5853 | 5856 |
5854 [cont setScrollview:scrollview]; | 5857 [cont setScrollview:scrollview]; |
5855 [scrollview setBorderType:NSBezelBorder]; | 5858 [scrollview setBorderType:NSBezelBorder]; |
5856 [scrollview setHasVerticalScroller:YES]; | 5859 [scrollview setHasVerticalScroller:YES]; |
5857 [scrollview setAutohidesScrollers:YES]; | 5860 [scrollview setAutohidesScrollers:YES]; |
6340 DW_FUNCTION_ADD_PARAM2(text, cid) | 6343 DW_FUNCTION_ADD_PARAM2(text, cid) |
6341 DW_FUNCTION_RETURN(dw_combobox_new, HWND) | 6344 DW_FUNCTION_RETURN(dw_combobox_new, HWND) |
6342 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG) | 6345 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG) |
6343 { | 6346 { |
6344 DW_FUNCTION_INIT; | 6347 DW_FUNCTION_INIT; |
6345 DWComboBox *combo = [[DWComboBox alloc] init]; | 6348 DWComboBox *combo = [[[DWComboBox alloc] init] retain]; |
6346 [combo setStringValue:[NSString stringWithUTF8String:text]]; | 6349 [combo setStringValue:[NSString stringWithUTF8String:text]]; |
6347 [combo setDelegate:combo]; | 6350 [combo setDelegate:combo]; |
6348 [combo setTag:cid]; | 6351 [combo setTag:cid]; |
6349 DW_FUNCTION_RETURN_THIS(combo); | 6352 DW_FUNCTION_RETURN_THIS(combo); |
6350 } | 6353 } |
6354 * Parameters: | 6357 * Parameters: |
6355 * id: An ID to be used with dw_window_from_id() or 0L. | 6358 * id: An ID to be used with dw_window_from_id() or 0L. |
6356 */ | 6359 */ |
6357 HWND API dw_mle_new(ULONG cid) | 6360 HWND API dw_mle_new(ULONG cid) |
6358 { | 6361 { |
6359 DWMLE *mle = [[DWMLE alloc] init]; | 6362 DWMLE *mle = [[[DWMLE alloc] init] retain]; |
6360 NSScrollView *scrollview = [[NSScrollView alloc] init]; | 6363 NSScrollView *scrollview = [[[NSScrollView alloc] init] retain]; |
6361 NSSize size = [mle maxSize]; | 6364 NSSize size = [mle maxSize]; |
6362 | 6365 |
6363 size.width = size.height; | 6366 size.width = size.height; |
6364 [mle setMaxSize:size]; | 6367 [mle setMaxSize:size]; |
6365 [scrollview setBorderType:NSBezelBorder]; | 6368 [scrollview setBorderType:NSBezelBorder]; |
6687 * text: The text to be display by the static text widget. | 6690 * text: The text to be display by the static text widget. |
6688 * id: An ID to be used with dw_window_from_id() or 0L. | 6691 * id: An ID to be used with dw_window_from_id() or 0L. |
6689 */ | 6692 */ |
6690 HWND API dw_status_text_new(const char *text, ULONG cid) | 6693 HWND API dw_status_text_new(const char *text, ULONG cid) |
6691 { | 6694 { |
6692 NSBox *border = [[NSBox alloc] init]; | 6695 NSBox *border = [[[NSBox alloc] init] retain]; |
6693 NSTextField *textfield = dw_text_new(text, cid); | 6696 NSTextField *textfield = dw_text_new(text, cid); |
6694 | 6697 |
6695 #ifndef BUILDING_FOR_CATALINA | 6698 #ifndef BUILDING_FOR_CATALINA |
6696 [border setBorderType:NSGrooveBorder]; | 6699 [border setBorderType:NSGrooveBorder]; |
6697 #endif | 6700 #endif |
6698 [border setTitlePosition:NSNoTitle]; | 6701 [border setTitlePosition:NSNoTitle]; |
6699 [border setContentView:textfield]; | 6702 [border setContentView:textfield]; |
6703 [textfield release]; | |
6700 [border setContentViewMargins:NSMakeSize(1.5,1.5)]; | 6704 [border setContentViewMargins:NSMakeSize(1.5,1.5)]; |
6701 [textfield autorelease]; | 6705 [textfield autorelease]; |
6702 [textfield setBackgroundColor:[NSColor clearColor]]; | 6706 [textfield setBackgroundColor:[NSColor clearColor]]; |
6703 [[textfield cell] setVCenter:YES]; | 6707 [[textfield cell] setVCenter:YES]; |
6704 return border; | 6708 return border; |
6710 * text: The text to be display by the static text widget. | 6714 * text: The text to be display by the static text widget. |
6711 * id: An ID to be used with dw_window_from_id() or 0L. | 6715 * id: An ID to be used with dw_window_from_id() or 0L. |
6712 */ | 6716 */ |
6713 HWND API dw_text_new(const char *text, ULONG cid) | 6717 HWND API dw_text_new(const char *text, ULONG cid) |
6714 { | 6718 { |
6715 DWText *textfield = [[DWText alloc] init]; | 6719 DWText *textfield = [[[DWText alloc] init] retain]; |
6716 [textfield setEditable:NO]; | 6720 [textfield setEditable:NO]; |
6717 [textfield setSelectable:NO]; | 6721 [textfield setSelectable:NO]; |
6718 [textfield setBordered:NO]; | 6722 [textfield setBordered:NO]; |
6719 [textfield setDrawsBackground:NO]; | 6723 [textfield setDrawsBackground:NO]; |
6720 [textfield setStringValue:[ NSString stringWithUTF8String:text ]]; | 6724 [textfield setStringValue:[ NSString stringWithUTF8String:text ]]; |
6734 * Returns: | 6738 * Returns: |
6735 * A handle to the widget or NULL on failure. | 6739 * A handle to the widget or NULL on failure. |
6736 */ | 6740 */ |
6737 HWND API dw_render_new(unsigned long cid) | 6741 HWND API dw_render_new(unsigned long cid) |
6738 { | 6742 { |
6739 DWRender *render = [[DWRender alloc] init]; | 6743 DWRender *render = [[[DWRender alloc] init] retain]; |
6740 [render setTag:cid]; | 6744 [render setTag:cid]; |
6741 return render; | 6745 return render; |
6742 } | 6746 } |
6743 | 6747 |
6744 /* | 6748 /* |
7398 DW_FUNCTION_ADD_PARAM1(cid) | 7402 DW_FUNCTION_ADD_PARAM1(cid) |
7399 DW_FUNCTION_RETURN(dw_tree_new, HWND) | 7403 DW_FUNCTION_RETURN(dw_tree_new, HWND) |
7400 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG) | 7404 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG) |
7401 { | 7405 { |
7402 DW_FUNCTION_INIT; | 7406 DW_FUNCTION_INIT; |
7403 NSScrollView *scrollview = [[NSScrollView alloc] init]; | 7407 NSScrollView *scrollview = [[[NSScrollView alloc] init] retain]; |
7404 DWTree *tree = [[DWTree alloc] init]; | 7408 DWTree *tree = [[DWTree alloc] init]; |
7405 | 7409 |
7406 [tree setScrollview:scrollview]; | 7410 [tree setScrollview:scrollview]; |
7407 [scrollview setBorderType:NSBezelBorder]; | 7411 [scrollview setBorderType:NSBezelBorder]; |
7408 [scrollview setHasVerticalScroller:YES]; | 7412 [scrollview setHasVerticalScroller:YES]; |
8669 /* There isn't anything like quite like MDI on MacOS... | 8673 /* There isn't anything like quite like MDI on MacOS... |
8670 * However we will make floating windows that hide | 8674 * However we will make floating windows that hide |
8671 * when the application is deactivated to simulate | 8675 * when the application is deactivated to simulate |
8672 * similar behavior. | 8676 * similar behavior. |
8673 */ | 8677 */ |
8674 DWMDI *mdi = [[DWMDI alloc] init]; | 8678 DWMDI *mdi = [[[DWMDI alloc] init] retain]; |
8675 /* [mdi setTag:cid]; Why doesn't this work? */ | 8679 /* [mdi setTag:cid]; Why doesn't this work? */ |
8676 return mdi; | 8680 return mdi; |
8677 } | 8681 } |
8678 | 8682 |
8679 /* | 8683 /* |
8690 DW_FUNCTION_RETURN(dw_splitbar_new, HWND) | 8694 DW_FUNCTION_RETURN(dw_splitbar_new, HWND) |
8691 DW_FUNCTION_RESTORE_PARAM4(type, int, topleft, HWND, bottomright, HWND, cid, unsigned long) | 8695 DW_FUNCTION_RESTORE_PARAM4(type, int, topleft, HWND, bottomright, HWND, cid, unsigned long) |
8692 { | 8696 { |
8693 DW_FUNCTION_INIT; | 8697 DW_FUNCTION_INIT; |
8694 id tmpbox = dw_box_new(DW_VERT, 0); | 8698 id tmpbox = dw_box_new(DW_VERT, 0); |
8695 DWSplitBar *split = [[DWSplitBar alloc] init]; | 8699 DWSplitBar *split = [[[DWSplitBar alloc] init] retain]; |
8696 [split setDelegate:split]; | 8700 [split setDelegate:split]; |
8697 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); | 8701 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); |
8698 [split addSubview:tmpbox]; | 8702 [split addSubview:tmpbox]; |
8703 [tmpbox release]; | |
8699 [tmpbox autorelease]; | 8704 [tmpbox autorelease]; |
8700 tmpbox = dw_box_new(DW_VERT, 0); | 8705 tmpbox = dw_box_new(DW_VERT, 0); |
8701 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); | 8706 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); |
8702 [split addSubview:tmpbox]; | 8707 [split addSubview:tmpbox]; |
8708 [tmpbox release]; | |
8703 [tmpbox autorelease]; | 8709 [tmpbox autorelease]; |
8704 if(type == DW_VERT) | 8710 if(type == DW_VERT) |
8705 { | 8711 { |
8706 [split setVertical:NO]; | 8712 [split setVertical:NO]; |
8707 } | 8713 } |
8822 DW_FUNCTION_ADD_PARAM1(cid) | 8828 DW_FUNCTION_ADD_PARAM1(cid) |
8823 DW_FUNCTION_RETURN(dw_bitmap_new, HWND) | 8829 DW_FUNCTION_RETURN(dw_bitmap_new, HWND) |
8824 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG) | 8830 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG) |
8825 { | 8831 { |
8826 DW_FUNCTION_INIT; | 8832 DW_FUNCTION_INIT; |
8827 NSImageView *bitmap = [[NSImageView alloc] init]; | 8833 NSImageView *bitmap = [[[NSImageView alloc] init] retain]; |
8828 [bitmap setImageFrameStyle:NSImageFrameNone]; | 8834 [bitmap setImageFrameStyle:NSImageFrameNone]; |
8829 [bitmap setImageScaling:NSImageScaleNone]; | 8835 [bitmap setImageScaling:NSImageScaleNone]; |
8830 [bitmap setEditable:NO]; | 8836 [bitmap setEditable:NO]; |
8831 [bitmap setTag:cid]; | 8837 [bitmap setTag:cid]; |
8832 DW_FUNCTION_RETURN_THIS(bitmap); | 8838 DW_FUNCTION_RETURN_THIS(bitmap); |
9195 * text: The text to be display by the static text widget. | 9201 * text: The text to be display by the static text widget. |
9196 * id: An ID to be used with dw_window_from_id() or 0L. | 9202 * id: An ID to be used with dw_window_from_id() or 0L. |
9197 */ | 9203 */ |
9198 HWND API dw_calendar_new(ULONG cid) | 9204 HWND API dw_calendar_new(ULONG cid) |
9199 { | 9205 { |
9200 DWCalendar *calendar = [[DWCalendar alloc] init]; | 9206 DWCalendar *calendar = [[[DWCalendar alloc] init] retain]; |
9201 [calendar setDatePickerMode:DWDatePickerModeSingle]; | 9207 [calendar setDatePickerMode:DWDatePickerModeSingle]; |
9202 [calendar setDatePickerStyle:DWDatePickerStyleClockAndCalendar]; | 9208 [calendar setDatePickerStyle:DWDatePickerStyleClockAndCalendar]; |
9203 [calendar setDatePickerElements:DWDatePickerElementFlagYearMonthDay]; | 9209 [calendar setDatePickerElements:DWDatePickerElementFlagYearMonthDay]; |
9204 [calendar setTag:cid]; | 9210 [calendar setTag:cid]; |
9205 [calendar setDateValue:[NSDate date]]; | 9211 [calendar setDateValue:[NSDate date]]; |
9363 DW_FUNCTION_ADD_PARAM1(cid) | 9369 DW_FUNCTION_ADD_PARAM1(cid) |
9364 DW_FUNCTION_RETURN(dw_html_new, HWND) | 9370 DW_FUNCTION_RETURN(dw_html_new, HWND) |
9365 DW_FUNCTION_RESTORE_PARAM1(DW_UNUSED(cid), ULONG) | 9371 DW_FUNCTION_RESTORE_PARAM1(DW_UNUSED(cid), ULONG) |
9366 { | 9372 { |
9367 DW_FUNCTION_INIT; | 9373 DW_FUNCTION_INIT; |
9368 DWWebView *web = [[DWWebView alloc] init]; | 9374 DWWebView *web = [[[DWWebView alloc] init] retain]; |
9369 #if WK_API_ENABLED | 9375 #if WK_API_ENABLED |
9370 web.navigationDelegate = web; | 9376 web.navigationDelegate = web; |
9371 #else | 9377 #else |
9372 web.frameLoadDelegate = (id)web; | 9378 web.frameLoadDelegate = (id)web; |
9373 #endif | 9379 #endif |
9695 * id: An ID to be used for getting the resource from the | 9701 * id: An ID to be used for getting the resource from the |
9696 * resource file. | 9702 * resource file. |
9697 */ | 9703 */ |
9698 HWND API dw_notebook_new(ULONG cid, int top) | 9704 HWND API dw_notebook_new(ULONG cid, int top) |
9699 { | 9705 { |
9700 DWNotebook *notebook = [[DWNotebook alloc] init]; | 9706 DWNotebook *notebook = [[[DWNotebook alloc] init] retain]; |
9701 [notebook setDelegate:notebook]; | 9707 [notebook setDelegate:notebook]; |
9702 /* [notebook setTag:cid]; Why doesn't this work? */ | 9708 /* [notebook setTag:cid]; Why doesn't this work? */ |
9703 return notebook; | 9709 return notebook; |
9704 } | 9710 } |
9705 | 9711 |
9824 HWND tmpbox = dw_box_new(DW_VERT, 0); | 9830 HWND tmpbox = dw_box_new(DW_VERT, 0); |
9825 DWBox *box = tmpbox; | 9831 DWBox *box = tmpbox; |
9826 | 9832 |
9827 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); | 9833 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); |
9828 [notepage setView:box]; | 9834 [notepage setView:box]; |
9835 [box release]; | |
9829 [box autorelease]; | 9836 [box autorelease]; |
9830 } | 9837 } |
9831 } | 9838 } |
9832 | 9839 |
9833 #ifndef NSWindowCollectionBehaviorFullScreenPrimary | 9840 #ifndef NSWindowCollectionBehaviorFullScreenPrimary |