void WEXPORT WRect::fitInside( const WRect& r ) { /***********************************************/ if( _x >= r.w() ) _x = (WOrdinal)(r.w() - 2); if( _y >= r.h() ) _y = (WOrdinal)(r.h() - 2); if( _x+_w >= r.w() ) _w = (WOrdinal)(r.w() - _x - 1); if( _y+_h >= r.h() ) _h = (WOrdinal)(r.h() - _y - 1); }
void WDialog::doDialog( WWindow *parent ) { /*****************************************/ WRect r; gui_create_info create_info; autoPosition( r ); gui_window *hparent = NULL; if( parent != NULL ) { hparent = parent->handle(); } const char *ctext = _text; create_info.text = (char *)ctext; create_info.rect.x = r.x(); create_info.rect.y = r.y(); create_info.rect.width = r.w(); create_info.rect.height = r.h(); create_info.scroll = GUI_NOSCROLL; create_info.style = GUI_NONE; create_info.parent = hparent; create_info.num_menus = 0; create_info.menu = NULL; create_info.num_attrs = 0; create_info.colours = NULL; create_info.call_back = DlgProc; create_info.extra = this; create_info.icon = NULL; GUICreateDialog( &create_info, 0, NULL ); }
void WEXPORT WSystemMetrics::screenSize( WRect& r ) { /***************************************************/ r.x( 0 ); r.y( 0 ); r.w( _screen.width ); r.h( _screen.height ); }
void TreeNode::paint( OutputDevice *dev, TreeRect *r ) //---------------------------------------------------- { /* first make sure that this node needs to be drawn: * it must be visible, and it must be inside the * invalid rectangle */ if( _flags.enabled == Hidden ) return; if( ( r->x() + r->w() < _bounding.x() ) || (r->x() > _bounding.x() + _bounding.w() ) ) return; if( ( r->y() + r->h() < _bounding.y() ) || ( r->y() > _bounding.y() + _bounding.h() ) ) return; WPoint start; WRect virtBnd; TreeCoord xOff = _parent->getXOff(); TreeCoord yOff = _parent->getYOff(); Color back; Color fore; PaintInfo * pinf; PaintInfo * oldPinf; //---------- border ---------// virtBnd.x( (int) _bounding.x() - xOff ); virtBnd.y( (int) _bounding.y() - yOff ); virtBnd.w( (int) _bounding.w() ); virtBnd.h( (int) _bounding.h() ); pinf = getPaintInfo(); oldPinf = dev->getPaintInfo(); dev->setPaintInfo( pinf ); dev->rectangle( virtBnd ); delete pinf; dev->setPaintInfo( oldPinf ); //---------- text -----------// if( _flags.selected ) { back = CUSTOM_RGB(0,0,128); fore = ColorWhite; } else { back = ColorLiteGray; fore = ColorBlack; } start.x( virtBnd.x() + NodeBuffer ); start.y( virtBnd.y() + NodeBuffer ); dev->drawText( start, name(), fore, back ); }
static bool ClipToRect( long & x1, long & y1, long & x2, long & y2, const WRect & clip ) //----------------------------------------------------------------- // Cohen-Sutherland Clipping Algorithm from _Fundamentals of Interactive // Computer Graphics_, page 148. { PointCode point1( x1, y1, CL_Inside ); PointCode point2( x2, y2, CL_Inside ); PointCode * p1; PointCode * p2; PointCode * tmp; long top = clip.y(); long left = clip.x(); long bottom = clip.y() + clip.h(); long right = clip.x() + clip.w(); p1 = & point1; p2 = & point2; while( 1 ) { CalcOut( *p1, top, left, bottom, right ); CalcOut( *p2, top, left, bottom, right ); if( p1->code == CL_Inside && p2->code == CL_Inside ) { return TRUE; // trivial acceptance } if( (p1->code & p2->code) != 0 ) { return FALSE; // trivial rejection } if( p1->code == 0 ) { // p1 inside -- swap so p1 outside tmp = p1; p1 = p2; p2 = tmp; } // perform a subdivision; move p1 to the intersection point. // use the formula y = y1 + slope * (x - x1), // x = x1 + (y - y1) / slope. if( p1->code & CL_Above ) { // divide at top p1->x += ((p2->x - p1->x) * (top - p1->y)) / (p2->y - p1->y); p1->y = top; } else if( p1->code & CL_Below ) { // divide at bottom of p1->x += ((p2->x - p1->x) * (bottom - p1->y)) / (p2->y - p1->y); p1->y = bottom; } else if( p1->code & CL_Right ) { // divide at right p1->y += ((p2->y - p1->y) * (right - p1->x)) / (p2->x - p1->x); p1->x = right; } else if( p1->code & CL_Left ) { // divide at left p1->y += ((p2->y - p1->y) * (left - p1->x)) / (p2->x - p1->x); p1->x = left; } } }
void WEXPORT WStatDialog::getCtrlRect( WControlId id, WRect & r ) { /*****************************************************************/ gui_rect rr; GUIGetControlRect( handle(), id, &rr ); r.x( rr.x ); r.y( rr.y ); r.w( rr.width ); r.h( rr.height ); }
bool WHotSpotList::paint() //----------------------- { int offset; int maxRows = numDirtyRows() + _topIndex + firstDirtyRow(); int numElem = count(); int extent; WRect r; getClientRect( r ); for( int i = _topIndex + firstDirtyRow(); i < maxRows && i < numElem; i += 1 ) { const char * str = getString( i ); int hotSpot; if( i == _hotPressIdx && _inHotZone ) { hotSpot = getHotSpot( i, TRUE ); } else { hotSpot = getHotSpot( i, FALSE ); } if( _hs != NULL ) { WPoint hotSize; _hs->hotSpotSize( hotSpot, hotSize ); offset = getHotOffset( i ) + hotSize.x(); drawHotSpot( hotSpot, i - _topIndex, getHotOffset( i ) ); } else { offset = 0; } extent = r.w(); if( width() > extent ) extent = width(); if( i == _selected ) { drawTextExtent( i - _topIndex, offset, str, WPaintAttrMenuActive, extent ); } else { drawTextExtent( i - _topIndex, offset, str, WPaintAttrControlBackground, extent ); } } return TRUE; }
bool VpeMain::reallyClose() { WRect rect; show( WWinStateShowNormal ); if( _quitAnyways || okToQuit() ) { startWait(); clearProject(); stopWait(); // write out .INI file stuff char buff[_MAX_PATH]; _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR, (char*)_editor.gets() ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_ISDLL, _editorIsDll ? "1" : "0" ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_PARMS, _editorParms.gets() ); for( int i=0; i<_oldProjects.count(); i++ ) { itoa( i+1, buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, buff, (const char*)*((WFileName*)_oldProjects[i]) ); } _ini.write( IDE_INI_IDENTIFIER, IDE_INI_TOOLBAR, _toolBarActive ? "1" : "0" ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_STATWND, (_statusBar != NULL) ? "1" : "0" ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_AUTOREFRESH, _autoRefresh ? "1" : "0" ); getRectangle( rect ); itoa( rect.w(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_WIDTH, buff ); itoa( rect.h(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_HEIGHT, buff ); itoa( rect.x(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_X, buff ); itoa( rect.y(), buff, 10 ); _ini.write( IDE_INI_IDENTIFIER, IDE_INI_Y, buff ); if( _otherhelp != NULL ) { delete _otherhelp; _otherhelp = NULL; } delete _help; _help = NULL; return( true ); } return( false ); }
void VpeMain::readIdeInit() { char buff[FILENAME_MAX]; int width, height, x, y; _ini.read( IDE_INI_IDENTIFIER, IDE_INI_TOOLBAR, "1", buff, sizeof( buff ) ); if( buff[0] == '0' ) { delete clearToolBar(); _toolBarActive = false; } _ini.read( IDE_INI_IDENTIFIER, IDE_INI_STATWND, "1", buff, sizeof( buff ) ); if( buff[0] == '0' ) { deleteStatusBar(); } _ini.read( IDE_INI_IDENTIFIER,IDE_INI_AUTOREFRESH, "1", buff, sizeof( buff ) ); if( buff[0] == '0' ) { _autoRefresh = false; } else { _autoRefresh = true; } _ini.read( IDE_INI_IDENTIFIER, IDE_INI_EDITOR, (const char*)_config->editor(), buff, sizeof( buff ) ); _editor = buff; _ini.read( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_ISDLL, _config->editorIsDLL() ? "1" : "0", buff, sizeof( buff ) ); if( buff[0] == '0' ) { _editorIsDll = false; } else { _editorIsDll = true; } _ini.read( IDE_INI_IDENTIFIER, IDE_INI_EDITOR_PARMS, "%f", buff, sizeof( buff ) ); _editorParms = buff; for( int i=0; i < MAXOLDPROJECTS; i++ ) { itoa( i+1, buff, 10 ); _ini.read( IDE_INI_IDENTIFIER, buff, "*", buff, sizeof( buff ) ); // if we get "*", doesn't exist if( buff[0] != '*' ) { _oldProjects.add( new WFileName( buff ) ); } } _ini.read( IDE_INI_IDENTIFIER, IDE_INI_HEIGHT, "0", buff, sizeof( buff ) ); height = atoi( buff ); _ini.read( IDE_INI_IDENTIFIER, IDE_INI_WIDTH, "0", buff, sizeof( buff ) ); width = atoi( buff ); _ini.read( IDE_INI_IDENTIFIER, IDE_INI_X, "0", buff, sizeof( buff ) ); x = atoi( buff ); _ini.read( IDE_INI_IDENTIFIER, IDE_INI_Y, "0", buff, sizeof( buff ) ); y = atoi( buff ); WRect sc; WSystemMetrics::screenCoordinates( sc ); if( width == 0 ) width = sc.w() * 3/4; if( height == 0 ) height = sc.h() * 9/10; sc.w( width ); sc.h( height ); sc.x( x ); sc.y( y ); move( sc ); }