bool FloatRoundedRect::xInterceptsAtY(float y, float& minXIntercept, float& maxXIntercept) const { if (y < rect().y() || y > rect().maxY()) return false; if (!isRounded()) { minXIntercept = rect().x(); maxXIntercept = rect().maxX(); return true; } const FloatRect& topLeftRect = topLeftCorner(); const FloatRect& bottomLeftRect = bottomLeftCorner(); if (!topLeftRect.isEmpty() && y >= topLeftRect.y() && y < topLeftRect.maxY()) minXIntercept = topLeftRect.maxX() - cornerRectIntercept(topLeftRect.maxY() - y, topLeftRect); else if (!bottomLeftRect.isEmpty() && y >= bottomLeftRect.y() && y <= bottomLeftRect.maxY()) minXIntercept = bottomLeftRect.maxX() - cornerRectIntercept(y - bottomLeftRect.y(), bottomLeftRect); else minXIntercept = m_rect.x(); const FloatRect& topRightRect = topRightCorner(); const FloatRect& bottomRightRect = bottomRightCorner(); if (!topRightRect.isEmpty() && y >= topRightRect.y() && y <= topRightRect.maxY()) maxXIntercept = topRightRect.x() + cornerRectIntercept(topRightRect.maxY() - y, topRightRect); else if (!bottomRightRect.isEmpty() && y >= bottomRightRect.y() && y <= bottomRightRect.maxY()) maxXIntercept = bottomRightRect.x() + cornerRectIntercept(y - bottomRightRect.y(), bottomRightRect); else maxXIntercept = m_rect.maxX(); return true; }
inline typename std::enable_if<T_SHAPE_FUNC::DIM!=0>::type computeMappingMatrices( const T_MESH_ELEMENT &ele, const double* natural_pt, const MeshLib::ElementCoordinatesMappingLocal &ele_local_coord, T_SHAPE_MATRICES &shapemat, FieldType<ShapeMatrixType::DNDX>) { computeMappingMatrices<T_MESH_ELEMENT, T_SHAPE_FUNC, T_SHAPE_MATRICES> (ele, natural_pt, ele_local_coord, shapemat, FieldType<ShapeMatrixType::DNDR_J>()); checkJacobianDeterminant(shapemat.detJ, ele); //J^-1, dshape/dx shapemat.invJ.noalias() = shapemat.J.inverse(); auto const nnodes(shapemat.dNdr.cols()); auto const ele_dim(shapemat.dNdr.rows()); assert(shapemat.dNdr.rows()==ele.getDimension()); const unsigned global_dim = ele_local_coord.getGlobalDimension(); if (global_dim==ele_dim) { shapemat.dNdx.topLeftCorner(ele_dim, nnodes).noalias() = shapemat.invJ * shapemat.dNdr; } else { auto const& matR = ele_local_coord.getRotationMatrixToGlobal(); // 3 x 3 auto invJ_dNdr = shapemat.invJ * shapemat.dNdr; auto dshape_global = matR.topLeftCorner(3u, ele_dim) * invJ_dNdr; //3 x nnodes shapemat.dNdx = dshape_global.topLeftCorner(global_dim, nnodes);; } }
template<typename MatrixType> void corners(const MatrixType& m) { typedef typename MatrixType::Index Index; Index rows = m.rows(); Index cols = m.cols(); Index r = internal::random<Index>(1,rows); Index c = internal::random<Index>(1,cols); MatrixType matrix = MatrixType::Random(rows,cols); const MatrixType const_matrix = MatrixType::Random(rows,cols); COMPARE_CORNER(topLeftCorner(r,c), block(0,0,r,c)); COMPARE_CORNER(topRightCorner(r,c), block(0,cols-c,r,c)); COMPARE_CORNER(bottomLeftCorner(r,c), block(rows-r,0,r,c)); COMPARE_CORNER(bottomRightCorner(r,c), block(rows-r,cols-c,r,c)); Index sr = internal::random<Index>(1,rows) - 1; Index nr = internal::random<Index>(1,rows-sr); Index sc = internal::random<Index>(1,cols) - 1; Index nc = internal::random<Index>(1,cols-sc); COMPARE_CORNER(topRows(r), block(0,0,r,cols)); COMPARE_CORNER(middleRows(sr,nr), block(sr,0,nr,cols)); COMPARE_CORNER(bottomRows(r), block(rows-r,0,r,cols)); COMPARE_CORNER(leftCols(c), block(0,0,rows,c)); COMPARE_CORNER(middleCols(sc,nc), block(0,sc,rows,nc)); COMPARE_CORNER(rightCols(c), block(0,cols-c,rows,c)); }
////////////// // TOP LEFT // ////////////// sf::Vector2f Fonction::topLeftCorner(const sf::Sprite& sprite) { return topLeftCorner(sprite.getGlobalBounds()); }
void UIWidget::drawImage(const Rect& screenCoords) { if(!m_imageTexture || !screenCoords.isValid()) return; // cache vertex buffers if(m_imageCachedScreenCoords != screenCoords || m_imageMustRecache) { m_imageCoordsBuffer.clear(); m_imageCachedScreenCoords = screenCoords; m_imageMustRecache = false; Rect drawRect = screenCoords; drawRect.translate(m_imageRect.topLeft()); if(m_imageRect.isValid()) drawRect.resize(m_imageRect.size()); Rect clipRect = m_imageClipRect.isValid() ? m_imageClipRect : Rect(0, 0, m_imageTexture->getSize()); if(!m_imageBordered) { if(m_imageFixedRatio) { Size textureSize = m_imageTexture->getSize(); Size textureClipSize = drawRect.size(); textureClipSize.scale(textureSize, Fw::KeepAspectRatio); Point texCoordsOffset; if(textureSize.height() > textureClipSize.height()) texCoordsOffset.y = (textureSize.height() - textureClipSize.height())/2; else if(textureSize.width() > textureClipSize.width()) texCoordsOffset.x = (textureSize.width() - textureClipSize.width())/2; Rect textureClipRect(texCoordsOffset, textureClipSize); m_imageCoordsBuffer.addRect(drawRect, textureClipRect); } else { if(m_imageRepeated) m_imageCoordsBuffer.addRepeatedRects(drawRect, clipRect); else m_imageCoordsBuffer.addRect(drawRect, clipRect); } } else { int top = m_imageBorder.top; int bottom = m_imageBorder.bottom; int left = m_imageBorder.left; int right = m_imageBorder.right; // calculates border coords const Rect clip = clipRect; Rect leftBorder(clip.left(), clip.top() + top, left, clip.height() - top - bottom); Rect rightBorder(clip.right() - right + 1, clip.top() + top, right, clip.height() - top - bottom); Rect topBorder(clip.left() + left, clip.top(), clip.width() - right - left, top); Rect bottomBorder(clip.left() + left, clip.bottom() - bottom + 1, clip.width() - right - left, bottom); Rect topLeftCorner(clip.left(), clip.top(), left, top); Rect topRightCorner(clip.right() - right + 1, clip.top(), right, top); Rect bottomLeftCorner(clip.left(), clip.bottom() - bottom + 1, left, bottom); Rect bottomRightCorner(clip.right() - right + 1, clip.bottom() - bottom + 1, right, bottom); Rect center(clip.left() + left, clip.top() + top, clip.width() - right - left, clip.height() - top - bottom); Size bordersSize(leftBorder.width() + rightBorder.width(), topBorder.height() + bottomBorder.height()); Size centerSize = drawRect.size() - bordersSize; Rect rectCoords; // first the center if(centerSize.area() > 0) { rectCoords = Rect(drawRect.left() + leftBorder.width(), drawRect.top() + topBorder.height(), centerSize); m_imageCoordsBuffer.addRepeatedRects(rectCoords, center); } // top left corner rectCoords = Rect(drawRect.topLeft(), topLeftCorner.size()); m_imageCoordsBuffer.addRepeatedRects(rectCoords, topLeftCorner); // top rectCoords = Rect(drawRect.left() + topLeftCorner.width(), drawRect.topLeft().y, centerSize.width(), topBorder.height()); m_imageCoordsBuffer.addRepeatedRects(rectCoords, topBorder); // top right corner rectCoords = Rect(drawRect.left() + topLeftCorner.width() + centerSize.width(), drawRect.top(), topRightCorner.size()); m_imageCoordsBuffer.addRepeatedRects(rectCoords, topRightCorner); // left rectCoords = Rect(drawRect.left(), drawRect.top() + topLeftCorner.height(), leftBorder.width(), centerSize.height()); m_imageCoordsBuffer.addRepeatedRects(rectCoords, leftBorder); // right rectCoords = Rect(drawRect.left() + leftBorder.width() + centerSize.width(), drawRect.top() + topRightCorner.height(), rightBorder.width(), centerSize.height()); m_imageCoordsBuffer.addRepeatedRects(rectCoords, rightBorder); // bottom left corner rectCoords = Rect(drawRect.left(), drawRect.top() + topLeftCorner.height() + centerSize.height(), bottomLeftCorner.size()); m_imageCoordsBuffer.addRepeatedRects(rectCoords, bottomLeftCorner); // bottom rectCoords = Rect(drawRect.left() + bottomLeftCorner.width(), drawRect.top() + topBorder.height() + centerSize.height(), centerSize.width(), bottomBorder.height()); m_imageCoordsBuffer.addRepeatedRects(rectCoords, bottomBorder); // bottom right corner rectCoords = Rect(drawRect.left() + bottomLeftCorner.width() + centerSize.width(), drawRect.top() + topRightCorner.height() + centerSize.height(), bottomRightCorner.size()); m_imageCoordsBuffer.addRepeatedRects(rectCoords, bottomRightCorner); } } // smooth is now enabled by default for all textures //m_imageTexture->setSmooth(m_imageSmooth); g_painter->setColor(m_imageColor); g_painter->drawTextureCoords(m_imageCoordsBuffer, m_imageTexture); }
/*! \brief This function creates and updates the BPopUpMenu. * \details The created menu is updated every time the TimeRepresentation * changes. */ void CalendarControl::CreateMenu( void ) { // The whole menu will be created in fixed font. BFont fixedFont(be_fixed_font); BFont plainFont(be_plain_font); BRect rectangle; BPoint topLeftCorner( 0, 0 ); BSize rectSize; BString sb; // Which month shall we represent? map<int, BString> dayNames = fCalModule->GetDayNamesForLocalYearMonth( this->fRepresentedTime.tm_year, this->fRepresentedTime.tm_mon); map<int, DoubleNames> monthNames = fCalModule->GetMonthNamesForLocalYear( this->fRepresentedTime.tm_year); int daysInMonth = dayNames.size(); int daysInWeek = ( int )fCalModule->GetDaysInWeek(); // We need to determine the bounding rectangle for the menu. // For this, we need to obtain the maximum bounding rectangle for a string. font_height fontHeightStruct; fixedFont.GetHeight( &fontHeightStruct ); float fixedFontHeightString = fontHeightStruct.ascent + fontHeightStruct.descent + fontHeightStruct.leading + SPACING; plainFont.GetHeight( &fontHeightStruct ); float plainFontHeightString = fontHeightStruct.ascent + fontHeightStruct.descent + fontHeightStruct.leading + SPACING; // Now fixedFontHeightString is surely big enough to enclose every string in // height. How many lines will we need? One for name of month and year, // one for weekday names, and several more for the dates themselves. At the // bottom, there is an additional line for "Return to today" option. // tempDay is a running date in current month. Each day item will be initialized // from the tempDay. TimeRepresentation tempDay( this->fRepresentedTime ); tempDay.tm_mday = 1; int firstDayOfMonthWD = fCalModule->GetWeekDayForLocalDateAsInt( tempDay ); int firstDayOfWeek = ( int )fFirstDayOfEveryWeek; int firstDayOfMonthInFirstWeek = (firstDayOfMonthWD + daysInWeek - firstDayOfWeek) % daysInWeek; // This is the menu we're adding items to. if ( fDateSelector ) { BMenuItem* item = NULL; while ( fDateSelector->ItemAt( 0 ) ) { item = fDateSelector->RemoveItem( ( int32 )0 ); delete item; } } else { fDateSelector = new BMenu("⇩", B_ITEMS_IN_MATRIX ); } // Sanity check if ( !fDateSelector ) { // Panic! fLastError = B_NO_MEMORY; return; } fDateSelector->SetViewColor( ui_color( B_MENU_BACKGROUND_COLOR ) ); fDateSelector->SetFont( &fixedFont ); topLeftCorner.x = SPACING + 5; topLeftCorner.y = SPACING; // Build the list of months. BPopUpMenu* listOfMonths = CreateMonthsMenu(monthNames); //----------------------------------------------------- // FIRST ROW. //----------------------------------------------------- /*---------------------------------------------------------------------------- * Adding months menu with option to scroll forward and backward *----------------------------------------------------------------------------*/ // Add the item to scroll list of months back BMessage* messageOfItem = new BMessage( kMonthDecreased ); DayItem* itemToAdd = new DayItem("‹", messageOfItem); if ( !itemToAdd ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } itemToAdd->SetServiceItem( true ); itemToAdd->SetFrontColor( fColorForServiceItems ); itemToAdd->SetBackColor( ui_color( B_MENU_BACKGROUND_COLOR ) ); itemToAdd->SetEnabled( true ); rectSize.SetHeight( fixedFontHeightString ); rectSize.SetWidth( 25 ); // rectSize.SetWidth( ( float )fixedFont.StringWidth("‹") + SPACING ); fDateSelector->AddItem( itemToAdd, BRect( topLeftCorner, rectSize ) ); itemToAdd->SetTarget( this ); topLeftCorner.x += rectSize.Width() + SPACING; // Add the list of months BString longestMonth = monthNames[ 1 ].longName; for ( int i = 2; i < ( int )monthNames.size(); i++ ) { if ( ( ( BString )( monthNames[ i ].longName ) ).Length() > longestMonth.Length() ) { longestMonth = monthNames[i].longName; } } rectSize.SetHeight( plainFontHeightString ); rectSize.SetWidth( (float)plainFont.StringWidth( longestMonth.String() ) + 10 + SPACING ); fDateSelector->AddItem( listOfMonths, BRect(topLeftCorner, rectSize) ); topLeftCorner.x += rectSize.Width() + SPACING; // Add the item to scroll list of months forward. messageOfItem = new BMessage( kMonthIncreased ); if ( !messageOfItem ) { // Panic! fLastError = B_NO_MEMORY; return; } itemToAdd = new DayItem( "›", messageOfItem ); if ( !itemToAdd ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } itemToAdd->SetServiceItem(true); itemToAdd->SetFrontColor( fColorForServiceItems ); itemToAdd->SetBackColor( ui_color( B_MENU_BACKGROUND_COLOR ) ); itemToAdd->SetEnabled( true ); rectSize.SetHeight( fixedFontHeightString ); rectSize.SetWidth( 25 ); // rectSize.SetWidth( ( float )fixedFont.StringWidth("›") + SPACING ); fDateSelector->AddItem( itemToAdd, BRect( topLeftCorner, rectSize ) ); itemToAdd->SetTarget( this ); topLeftCorner.x += rectSize.Width() + 10 + SPACING; /*---------------------------------------------------------------------------- * Adding years menu with option to scroll forward and backward *----------------------------------------------------------------------------*/ // Add the item to scroll list of years down. messageOfItem = new BMessage( kYearDecreased ); if ( !messageOfItem ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } itemToAdd = new DayItem( "‒", messageOfItem ); if ( !itemToAdd ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } itemToAdd->SetServiceItem(true); itemToAdd->SetFrontColor( fColorForServiceItems ); itemToAdd->SetBackColor( ui_color( B_MENU_BACKGROUND_COLOR ) ); itemToAdd->SetEnabled( true ); rectSize.SetHeight( fixedFontHeightString ); rectSize.SetWidth( 25 ); // rectSize.SetWidth( ( float )fixedFont.StringWidth("‒") + SPACING ); fDateSelector->AddItem( itemToAdd, BRect( topLeftCorner, rectSize ) ); itemToAdd->SetTarget( this ); topLeftCorner.x += rectSize.Width() + SPACING; // Add year sb.Truncate( 0 ); sb << fRepresentedTime.tm_year; rectSize.SetHeight( plainFontHeightString ); rectSize.SetWidth( ( float )plainFont.StringWidth( sb.String() ) + 10 + SPACING ); BPopUpMenu* listOfYears = CreateYearsMenu(this->fRepresentedTime.tm_year); if ( !listOfYears ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fDateSelector->AddItem( listOfYears, BRect( topLeftCorner, rectSize ) ); topLeftCorner.x += rectSize.Width() + SPACING; // Add item to scroll list of years up. messageOfItem = new BMessage( kYearIncreased ); if ( !messageOfItem ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } itemToAdd = new DayItem( "+", messageOfItem ); if ( !itemToAdd ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } itemToAdd->SetServiceItem(true); itemToAdd->SetFrontColor( fColorForServiceItems ); itemToAdd->SetBackColor( ui_color( B_MENU_BACKGROUND_COLOR ) ); itemToAdd->SetEnabled(true); rectSize.SetHeight( fixedFontHeightString ); rectSize.SetWidth( 25 ); // rectSize.SetWidth( ( float )fixedFont.StringWidth( "+" ) + SPACING ); fDateSelector->AddItem( itemToAdd, BRect( topLeftCorner, rectSize ) ); //----------------------------------------------------- // SECOND ROW. WEEKDAY NAMES //----------------------------------------------------- sb.Truncate( 0 ); rectSize.SetHeight( fixedFontHeightString ); sb << ( int )fCalModule->GetLongestMonthLength(); rectSize.SetWidth( fixedFont.StringWidth( sb.String() ) + SPACING ); float rowHeight = rectSize.Height() + SPACING; float itemWidth = rectSize.Width() + 15 + SPACING; rectSize.SetWidth( itemWidth ); rectSize.SetHeight( rowHeight ); topLeftCorner.x = SPACING; topLeftCorner.y += rowHeight + ( SPACING * 2 ); map<uint32, DoubleNames> weekdayNames = fCalModule->GetWeekdayNames(); uint32 limit = ( uint32 )fCalModule->GetDaysInWeek(); uint32 curDay; for (uint32 i = firstDayOfWeek; i < limit+firstDayOfWeek; ++i) { curDay = ( (i - 1) % limit ) + 1; itemToAdd = new DayItem( weekdayNames[ curDay ].shortName.String(), NULL ); if (!itemToAdd) { /* Panic! */ fLastError = B_NO_MEMORY; return; } itemToAdd->SetServiceItem( true ); // If this is a weekend, we shold display it in another color if ( fWeekends.HasItem( (void*)i ) || fWeekends.HasItem( (void*)( i % daysInWeek ) ) ) { itemToAdd->SetFrontColor( fColorForWeekends ); } else { itemToAdd->SetFrontColor( fColorForServiceItems );; } itemToAdd->SetEnabled(false); itemToAdd->SetBackColor( ui_color( B_MENU_BACKGROUND_COLOR ) ); fDateSelector->AddItem( itemToAdd, BRect( topLeftCorner, rectSize ) ); topLeftCorner.x += itemWidth + SPACING; } topLeftCorner.x = SPACING; topLeftCorner.y += rowHeight + SPACING; //----------------------------------------------------------------------- // THIRD ROW AND DOWN - THE WEEK INDIVIDUAL DAYS. //---------------------------------------------------------------------- uint32 currentWeekday = ( uint32 )firstDayOfMonthInFirstWeek; topLeftCorner.x += ( itemWidth + SPACING ) * firstDayOfMonthInFirstWeek; for (int day = 1; day <= daysInMonth; ++day ) { messageOfItem = new BMessage(kTodayModified); if ( !messageOfItem ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } messageOfItem->AddInt32( "Date", day ); sb.Truncate( 0 ); char padding = ' '; // <-- For proper aligning of the items ( day < 10 ) ? sb << padding << day : sb << day; itemToAdd = new DayItem( sb.String(), messageOfItem ); if ( !itemToAdd ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } itemToAdd->SetEnabled( true ); itemToAdd->SetServiceItem( false ); messageOfItem->AddPointer( "Item", &itemToAdd ); if ( fWeekends.HasItem( ( void* )( ( fFirstDayOfEveryWeek + currentWeekday ) % daysInWeek ) ) || fWeekends.HasItem( ( void* )( ( fFirstDayOfEveryWeek + currentWeekday ) ) ) ) { itemToAdd->SetFrontColor( weekendDateColor ); } else { itemToAdd->SetFrontColor( ui_color( B_MENU_ITEM_TEXT_COLOR ) ); } // Does this item represent today? if ( fRepresentedTime.tm_mday == day ) { itemToAdd->SetToday( true ); itemToAdd->SetBackColor( fColorForServiceItems ); itemToAdd->SetMarked( true ); } fDateSelector->AddItem( itemToAdd, BRect( topLeftCorner, rectSize ) ); itemToAdd->SetTarget( this ); topLeftCorner.x += itemWidth + SPACING; ++currentWeekday; if ( ( currentWeekday % daysInWeek == 0 ) && ( day < daysInMonth ) ) { topLeftCorner.x = SPACING; topLeftCorner.y += rowHeight+SPACING; currentWeekday = 0; } } //----------------------------------------------------------------------- // LAST ROW - The option to return to current date. //---------------------------------------------------------------------- topLeftCorner.y += rowHeight + SPACING; messageOfItem = new BMessage( kReturnToToday ); if ( !messageOfItem ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } sb.Truncate( 0 ); sb << "Go to today"; // Label itemToAdd = new DayItem( sb.String(), messageOfItem ); if ( !itemToAdd ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } // Setting the color to blue itemToAdd->SetServiceItem(true); itemToAdd->SetFrontColor( fColorForServiceItems ); itemToAdd->SetBackColor( ui_color( B_MENU_BACKGROUND_COLOR ) ); itemToAdd->SetEnabled( true ); itemToAdd->SetTarget( this ); // The new v-alignment was already set above. Now it's time to set the // x-alignment. I'd like to align this item to the center of Menu's rec- // tangle, which require some additional calculations. float currentWidth = itemWidth * daysInWeek + ( SPACING * 2 ); float desiredWidth = plainFont.StringWidth( sb.String()) ; topLeftCorner.x = SPACING + 0.5 * ( currentWidth - desiredWidth ); rectSize.SetHeight( plainFontHeightString ); rectSize.SetWidth( desiredWidth + 30 ); fDateSelector->AddItem( itemToAdd, BRect( topLeftCorner, rectSize ) ); fDateSelector->SetTargetForItems( this ); UpdateTargets( fDateSelector ); }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; ZERO_OUT(msg); HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_SCENEVIEWER, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SCENEVIEWER)); SetupBaseUtil setupBase; FileLogUtil fileLog; SetupCoreUtil setupCore; SetupEngineUtil setupEngine; CConsole console(APP_TITLE); console.setTopLeft(0,0); MyApp app; #if 0 vector2d<int> resolution(800,600); vector2d<int> topLeftCorner(800,450); #else //vector2d<int> resolution(1024,768); vector2d<int> resolution(1400,900); vector2d<int> topLeftCorner(0,0); #endif GetMessage(&msg, NULL, 0, 0); { MyAppWindow appWindow( &app, msg.hwnd ); appWindow.bringToFront(); appWindow.setTopLeft( topLeftCorner.x, topLeftCorner.y ); g_pMainWindow = &appWindow; app.PreInit_CreateViewports( &appWindow ); GameTimer timer; UNDONE; if( !app.Initialize(MXC("???")) ) { return -1; } // Main message loop: while( true ) { BOOL bPendingMsg = FALSE; //if( appWindow.isActive() ) { bPendingMsg = ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ); } //else //{ // bPendingMsg = ::GetMessage( &msg, NULL, 0, 0 ); //} if( msg.message == WM_QUIT ) { break; } //if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) //{ // TranslateMessage(&msg); // DispatchMessage(&msg); //} if( bPendingMsg ) { TranslateMessage(&msg); DispatchMessage(&msg); } const F4 deltaSeconds = timer.TickFrame(); appWindow.Tick( deltaSeconds ); appWindow.Draw(); MX_PROFILE_INCREMENT_FRAME_COUNTER; mxSleepMilliseconds(1); } app.Shutdown(); } return (int) msg.wParam; }