comparison mac/dw.m @ 1551:cf897886ceeb

Fixed disabling word wrap in the MLE on Mac. Also implemented autosizing of the MLE.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 14 Jan 2012 01:50:39 +0000
parents ca6be9c48fff
children f00f91d15cbf
comparison
equal deleted inserted replaced
1550:78a2e6a51285 1551:cf897886ceeb
3530 3530
3531 thiswidth = size.width; 3531 thiswidth = size.width;
3532 thisheight = size.height; 3532 thisheight = size.height;
3533 } 3533 }
3534 } 3534 }
3535 /* Container */ 3535 /* MLE and Container */
3536 else if([ object isMemberOfClass:[DWContainer class] ]) 3536 else if([ object isMemberOfClass:[DWMLE class] ] ||
3537 { 3537 [ object isMemberOfClass:[DWContainer class] ])
3538 NSRect rect = [object frame]; 3538 {
3539 NSSize size;
3539 3540
3540 thiswidth = rect.size.width; 3541 if([ object isMemberOfClass:[DWMLE class] ])
3541 thisheight = rect.size.height; 3542 {
3543 NSScrollView *sv = [object scrollview];
3544 NSSize frame = [sv frame].size;
3545 BOOL hscroll = [sv hasHorizontalScroller];
3546
3547 if(!hscroll)
3548 {
3549 [[object textContainer] setWidthTracksTextView:NO];
3550 [[object textContainer] setContainerSize:[object maxSize]];
3551 [object setHorizontallyResizable:YES];
3552 [sv setHasHorizontalScroller:YES];
3553 }
3554 [object sizeToFit];
3555 size = [object bounds].size;
3556 if(!hscroll)
3557 {
3558 [[object textContainer] setWidthTracksTextView:YES];
3559 [sv setHasHorizontalScroller:NO];
3560 }
3561 if(size.width > _DW_SCROLLED_MAX_WIDTH)
3562 {
3563 NSSize max = [object maxSize];
3564
3565 [object setMaxSize:NSMakeSize(_DW_SCROLLED_MAX_WIDTH, max.height)];
3566 [object sizeToFit];
3567 size = [object bounds].size;
3568 [object setMaxSize:max];
3569 }
3570 [sv setFrameSize:frame];
3571 }
3572 else
3573 size = [object frame].size;
3574
3575 thiswidth = size.width;
3576 thisheight = size.height;
3542 3577
3543 if(thiswidth < _DW_SCROLLED_MIN_WIDTH) 3578 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
3544 thiswidth = _DW_SCROLLED_MIN_WIDTH; 3579 thiswidth = _DW_SCROLLED_MIN_WIDTH;
3545 if(thiswidth > _DW_SCROLLED_MAX_WIDTH) 3580 if(thiswidth > _DW_SCROLLED_MAX_WIDTH)
3546 thiswidth = _DW_SCROLLED_MAX_WIDTH; 3581 thiswidth = _DW_SCROLLED_MAX_WIDTH;
3547 if(thisheight < _DW_SCROLLED_MIN_HEIGHT) 3582 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
3548 thisheight = _DW_SCROLLED_MIN_HEIGHT; 3583 thisheight = _DW_SCROLLED_MIN_HEIGHT;
3549 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) 3584 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
3550 thisheight = _DW_SCROLLED_MAX_HEIGHT; 3585 thisheight = _DW_SCROLLED_MAX_HEIGHT;
3551 } 3586 }
3552 /* MLE and Tree */ 3587 /* Tree */
3553 else if([ object isMemberOfClass:[DWMLE class] ] || 3588 else if([ object isMemberOfClass:[DWTree class] ])
3554 [ object isMemberOfClass:[DWTree class] ])
3555 { 3589 {
3556 thiswidth = _DW_SCROLLED_MAX_WIDTH; 3590 thiswidth = _DW_SCROLLED_MAX_WIDTH;
3557 thisheight = _DW_SCROLLED_MAX_HEIGHT; 3591 thisheight = _DW_SCROLLED_MAX_HEIGHT;
3558 } 3592 }
3559 /* Any other control type */ 3593 /* Any other control type */
4675 */ 4709 */
4676 HWND API dw_mle_new(ULONG cid) 4710 HWND API dw_mle_new(ULONG cid)
4677 { 4711 {
4678 DWMLE *mle = [[DWMLE alloc] init]; 4712 DWMLE *mle = [[DWMLE alloc] init];
4679 NSScrollView *scrollview = [[NSScrollView alloc] init]; 4713 NSScrollView *scrollview = [[NSScrollView alloc] init];
4680 4714 NSSize size = [mle maxSize];
4715
4716 size.width = size.height;
4717 [mle setMaxSize:size];
4681 [scrollview setBorderType:NSBezelBorder]; 4718 [scrollview setBorderType:NSBezelBorder];
4682 [scrollview setHasVerticalScroller:YES]; 4719 [scrollview setHasVerticalScroller:YES];
4683 [scrollview setAutohidesScrollers:YES]; 4720 [scrollview setAutohidesScrollers:YES];
4684 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; 4721 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
4685 [scrollview setDocumentView:mle]; 4722 [scrollview setDocumentView:mle];
4686 [mle setAutoresizingMask:NSViewWidthSizable]; 4723 [mle setVerticallyResizable:YES];
4724 [mle setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
4687 [mle setScrollview:scrollview]; 4725 [mle setScrollview:scrollview];
4688 /* [mle setTag:cid]; Why doesn't this work? */ 4726 /* [mle setTag:cid]; Why doesn't this work? */
4689 [mle autorelease]; 4727 [mle autorelease];
4690 return mle; 4728 return mle;
4691 } 4729 }
4857 * state: TRUE if it wraps, FALSE if it doesn't. 4895 * state: TRUE if it wraps, FALSE if it doesn't.
4858 */ 4896 */
4859 void API dw_mle_set_word_wrap(HWND handle, int state) 4897 void API dw_mle_set_word_wrap(HWND handle, int state)
4860 { 4898 {
4861 DWMLE *mle = handle; 4899 DWMLE *mle = handle;
4900 NSScrollView *sv = [mle scrollview];
4901
4862 if(state) 4902 if(state)
4863 { 4903 {
4864 [mle setHorizontallyResizable:NO]; 4904 [[mle textContainer] setWidthTracksTextView:YES];
4905 [sv setHasHorizontalScroller:NO];
4865 } 4906 }
4866 else 4907 else
4867 { 4908 {
4909 [[mle textContainer] setWidthTracksTextView:NO];
4910 [[mle textContainer] setContainerSize:[mle maxSize]];
4868 [mle setHorizontallyResizable:YES]; 4911 [mle setHorizontallyResizable:YES];
4912 [sv setHasHorizontalScroller:YES];
4869 } 4913 }
4870 } 4914 }
4871 4915
4872 /* 4916 /*
4873 * Sets the current cursor position of an MLE box. 4917 * Sets the current cursor position of an MLE box.