2013년 7월 21일 일요일

NSView의 사이징 이벤트 windowDidResize



1. 노티피케이션 센터에 옵저버를 추가한다.

- (void)viewDidMoveToWindow
{
    
    [[NSNotificationCenter defaultCenteraddObserver:self
                                             selector:@selector(windowDidResize:)
                                                 name:NSWindowDidResizeNotification
                                               object:nil];
}

2. 사용이 끝난 옵저버는 제거해줘야 한다.

- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
    
    delete m_pImage;
    
    [super dealloc];
}

3. 다음 메소드를 재정의한다. [self bounds]가 클라이언트 영역의 크기이다.

- (void)windowDidResize:(NSNotification *)notification
{
    NSRect bounds = [self bounds];
    CRect rectClient(0., 0., bounds.size.width, bounds.size.height);
    m_pImage->OnSizeWindow(rectClient);
}

서브 뷰를 리사이즈 할 경우에는 아래와 같이 한다.


    [dicomImage setFrame:bounds];




댓글 없음:

댓글 쓰기