void Button::OnChangeStyles() { GC gc( this ); gc.Set( GetFont() ); cpoint p = text.GetTextExtents(gc); if ( icon.ptr() ) { if ( p.y < 12 ) { p.y = 12; } p.x += ICONX_RIGHTSPACE + icon->Width(); if ( icon->Width() > p.y + 4 ) { p.y = icon->Width() - 4; } } p.x += LEFTSPACE + RIGHTSPACE; p.x += 8; p.y += 8; SetLSize( LSize( p ) ); }
static void mac_groweventlog(WindowPtr window, EventRecord *event) { Session *s = mac_windowsession(window); Rect limits; long grow_result; #if TARGET_API_MAC_CARBON Rect rect; Point cellsize; #else GrafPtr saveport; #endif SetRect(&limits, 15, 0, SHRT_MAX, SHRT_MAX); grow_result = GrowWindow(window, event->where, &limits); if (grow_result == 0) return; SizeWindow(window, LoWord(grow_result), HiWord(grow_result), TRUE); LSize(LoWord(grow_result) - 15, HiWord(grow_result), s->eventlog); mac_adjusteventlogscrollbar(s); /* We would use SetListCellSize in Carbon, but it's missing. */ (*s->eventlog)->cellSize.h = LoWord(grow_result) - 15; #if TARGET_API_MAC_CARBON cellsize.h = LoWord(grow_result) - 15; GetListViewBounds(s->eventlog, &rect); InvalWindowRect(window, &rect); #else GetPort(&saveport); SetPort(window); InvalRect(&(*s->eventlog)->rView); SetPort(saveport); #endif }
NCNumberWin( Win* parent, int width = 10 ) : Win( Win::WT_CHILD, 0, parent, 0 ), _num( 0 ) { wal::GC gc( this ); cpoint size = GetStaticTextExtent( gc, ABCString, GetFont() ); size.x = size.x / ABCStringLen * width; SetLSize( LSize( size ) ); }
StaticLine::StaticLine(int nId, Win *parent, const unicode_t *txt, crect *rect) : Win(Win::WT_CHILD, 0, parent, rect, nId), text(new_unicode_str(txt)) { if (!rect) { GC gc(this); SetLSize(LSize(GetStaticTextExtent(gc,txt,GetFont()))); } }
StaticLabel::StaticLabel(int nId, Win* parent, const unicode_t* txt, Win* _master, crect* rect) : Win(Win::WT_CHILD, 0, parent, rect, nId), text(txt), master(_master) { if (!rect) { GC gc(this); SetLSize(LSize(text.GetTextExtents(gc, GetFont()))); } }
OperFileNameWin::OperFileNameWin( Win* parent, int ccount ) : Win( Win::WT_CHILD, 0, parent, 0 ) , _ccount( ccount ) { wal::GC gc( this ); cpoint size = GetStaticTextExtent( gc, ABCString, GetFont() ); size.x = size.x / ABCStringLen * ccount; if ( size.x > 500 ) { size.x = 550; } SetLSize( LSize( size ) ); }
extern pascal void LSizeWhite(SInt16 listWidth, SInt16 listHeight, ListHandle lHandle) { OSStatus err; MoreThemeDrawingState state; err = MoreGetThemeDrawingState(&state); if (err == noErr) { err = MoreNormalizeThemeDrawingState(); assert(err == noErr); LSize(listWidth, listHeight, lHandle); err = MoreSetThemeDrawingState(state, true); } assert(err == noErr); }
static int message_ListWin(int message, long param) { Cell cell; Rect rect; switch(message){ case MW_GROW: rect=win.ref->portRect; LSize(rect.right-14, rect.bottom-14, gPlaylist); return 0; case MW_LIST_SELECT: LDeselectAll(gPlaylist); cell.h=0; cell.v=param; LSetSelect(true, cell, gPlaylist); LAutoScroll(gPlaylist); return 0; } return -1; //not supported }
SButton::SButton( int nId, Win* parent, unicode_t* txt, int _group, bool _isSet, crect* rect ) : Win( Win::WT_CHILD, Win::WH_TABFOCUS | WH_CLICKFOCUS, parent, rect, nId ), isSet( _isSet ), text( txt ), group( _group ) { if ( !rect ) { GC gc( this ); gc.Set( GetFont() ); cpoint p = gc.GetTextExtents( txt ); if ( p.y < 16 ) { p.y = 16; } p.x += 17 + 4; p.y += 2; SetLSize( LSize( p ) ); } Change( isSet ); }
clSelectDriveDlgMenu::clSelectDriveDlgMenu( Win* parent, clMenuData* data ) : Win( Win::WT_CHILD, Win::WH_TABFOCUS | Win::WH_CLICKFOCUS, parent ) , _data( data ) , _current( 0 ) , _itemH( 16 ) , _width( 50 ) , _nameW( 10 ) , _comment1W( 0 ) , _comment2W( 0 ) , _splitterH( 5 ) , _splitterW( 1 ) { wal::GC gc( this ); gc.Set( GetFont() ); int w = 0; int height = 0; static unicode_t A[] = {'A', 'B', 'C'}; cpoint p = gc.GetTextExtents( A, 3 ); _itemH = p.y; if ( _itemH < 16 ) { _itemH = 16; } _splitterH = _itemH / 4; if ( _splitterH < 3 ) { _splitterH = 3; } for ( int i = 0 ; i < _data->Count(); i++ ) { unicode_t* name = _data->list[i].name.data(); if ( _data->list[i].cmd != 0 ) { if ( name ) { cpoint p = gc.GetTextExtents( name ); if ( _nameW < p.x ) { _nameW = p.x; } } unicode_t* comment1 = _data->list[i].comment1.data(); unicode_t* comment2 = _data->list[i].comment2.data(); if ( comment1 ) { cpoint p = gc.GetTextExtents( comment1 ); if ( _comment1W < p.x ) { _comment1W = p.x; } } if ( comment2 ) { cpoint p = gc.GetTextExtents( comment2 ); if ( _comment2W < p.x ) { _comment2W = p.x; } } height += _itemH; } else { height += _splitterH; } } w = 16 + 5 + _nameW + 5 + _comment1W + 30 + _comment2W; if ( _width < w ) { _width = w; } SetLSize( LSize( cpoint( _width, height ) ) ); }
// -------------------------------------------------------------------------------------- void AdjustControls(WindowRef prefsWindow) { Rect contentRect, listViewRect; ControlRef rootControl, userPane; SInt16 userPaneWidth, userPaneHeight; UInt16 panelIndex; ListHandle iconList; short oldListHeight, newListHeight; GetWindowBounds(prefsWindow, kWindowContentRgn, &contentRect); userPaneWidth = (contentRect.right - contentRect.left) - (gWindowEdgeSpacing + kListWidth + kScrollBarWidth + kControlSpacing) - (kSizeBoxWidth + gMinimumSpacing); userPaneHeight = (contentRect.bottom - contentRect.top) - gWindowEdgeSpacing - (kSizeBoxWidth + gMinimumSpacing); GetRootControl(prefsWindow, &rootControl); for (panelIndex = 1; panelIndex <= kNumberOfRows; panelIndex++) { GetIndexedSubControl(rootControl, panelIndex, &userPane); SizeControl(userPane, userPaneWidth, userPaneHeight); } GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, &iconList); GetListViewBounds(iconList, &listViewRect); oldListHeight = listViewRect.bottom - listViewRect.top; newListHeight = (contentRect.bottom - contentRect.top) - gWindowEdgeSpacing - gWindowEdgeSpacing; newListHeight -= newListHeight % kCellHeight; // make the list height a multiple if (newListHeight > kMaxListHeight) // of the cell height and don't make newListHeight = kMaxListHeight; // it bigger than we have cells for if (newListHeight != oldListHeight) { Rect invalRect; listViewRect.right += kScrollBarWidth; // we will need to redraw the scroll bar as well // we need to invalidate the area where a cell will be drawn or erased if (newListHeight > oldListHeight) SetRect(&invalRect, listViewRect.left - 5, listViewRect.bottom - 5, listViewRect.right + 5, contentRect.bottom); // the extra 5 pixels are // to cause the bottom of the list box frame to get erased else SetRect(&invalRect, listViewRect.left - 5, gWindowEdgeSpacing + newListHeight - 5, listViewRect.right + 5, contentRect.bottom); // the drawing section is as far down as possible to avoid any screen flickering DrawThemeFocusRect(&listViewRect, false); // erase the focus rectangle LSize(kListWidth, newListHeight, iconList); // resize the List drawFrameAndFocus(iconList, true, prefsWindow); // draw the focus rectangle back InvalWindowRect(prefsWindow, &invalRect); } #if TARGET_API_MAC_OS8 CalculateBalloonHelpRects(prefsWindow); #endif } // AdjustControls