sf::Vector2f ScreenSpaceDrawable::CalcFakePos () { sf::Vector2f fakePos; switch (mAlignH) { case LEFT: fakePos.x = GetScreenSize().x / 2 + basePos.x * windowFakeScale; break; case CENTER: fakePos.x = Game->GetRenderWindow()->GetWidth() / 2 + basePos.x * windowFakeScale; break; case RIGHT: fakePos.x = Game->GetRenderWindow()->GetWidth() - GetScreenSize().x / 2 + basePos.x * windowFakeScale; break; } switch (mAlignV) { case TOP: fakePos.y = GetScreenSize().y / 2 + basePos.y * windowFakeScale; break; case MIDDLE: fakePos.y = Game->GetRenderWindow()->GetHeight() / 2 + basePos.y * windowFakeScale; break; case BOTTOM: fakePos.y = Game->GetRenderWindow()->GetHeight() - GetScreenSize().y / 2 + basePos.y * windowFakeScale; break; } return fakePos; }
void CFWL_ToolTipImp::RefreshToolTipPos() { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { CFX_RectF rtPopup; CFX_RectF rtWidget(m_pProperties->m_rtWidget); CFX_RectF rtAnchor(m_rtAnchor); rtPopup.Set(0, 0, 0, 0); FX_FLOAT fx = rtAnchor.Center().x + 20; FX_FLOAT fy = rtAnchor.Center().y + 20; rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height()); FX_FLOAT fScreenWidth = 0; FX_FLOAT fScreenHeight = 0; GetScreenSize(fScreenWidth, fScreenHeight); if (rtPopup.bottom() > fScreenHeight) { rtPopup.Offset(0, fScreenHeight - rtPopup.bottom()); } if (rtPopup.right() > fScreenWidth) { rtPopup.Offset(fScreenWidth - rtPopup.right(), 0); } if (rtPopup.left < 0) { rtPopup.Offset(0 - rtPopup.left, 0); } if (rtPopup.top < 0) { rtPopup.Offset(0, 0 - rtPopup.top); } SetWidgetRect(rtPopup); Update(); } }
void Console::Draw(void) { // update the hooks to their necessary values static DWORD count = 0; if(!IsReady()) Initialize(); if(IsVisible()) { if(count % 15 == 0 && IsEnabled()) cursor->SetIsVisible(!cursor->GetIsVisible()); // TODO: make this respect wrapping char* t = const_cast<char*>(text->GetText()); uint width = GetScreenSize().x; POINT textlen = CalculateTextLen(t, 0); int newsize = textlen.x + text->GetX(); cursor->SetX(newsize); cursor->SetX2(newsize); if(box->GetXSize() != width) { // screen resolution reset, time to adjust all coordinates as necessary // TODO: fix up the lines when the screen resizes box->SetXSize(width); } } count++; }
static void GetCenterRect( CRect &rc ) { CSize scr = GetScreenSize( ); int left = ( scr.cx - rc.Width() ) / 2; int top = ( scr.cy - rc.Height() ) / 2; rc.OffsetRect( left, top ); }
void TopWindow::Open(HWND hwnd) { GuiLock __; if(dokeys && (!GUI_AKD_Conservative() || GetAccessKeysDeep() <= 1)) DistributeAccessKeys(); UsrLogT(3, "OPEN " + Desc(this)); LLOG("TopWindow::Open, owner HWND = " << FormatIntHex((int)hwnd, 8) << ", Active = " << FormatIntHex((int)::GetActiveWindow(), 8)); IgnoreMouseUp(); SyncCaption(); #ifdef PLATFORM_WINCE if(!GetRect().IsEmpty()) #endif if(fullscreen) { SetRect(GetScreenSize()); Create(hwnd, WS_POPUP, 0, false, SW_SHOWMAXIMIZED, false); } else { CenterRect(hwnd, hwnd && hwnd == GetTrayHWND__() ? center ? 2 : 0 : center); Create(hwnd, style, exstyle, false, state == OVERLAPPED ? SW_SHOWNORMAL : state == MINIMIZED ? SW_MINIMIZE : SW_MAXIMIZE, false); } PlaceFocus(); SyncCaption(); FixIcons(); }
/** * Initializes the rendering using the appropriate rendering method. */ bool InitializeRendering() { DestroyWaveMesh(); DeinitRendering(); D3DPRESENT_PARAMETERS params; memset(¶ms, 0, sizeof(D3DPRESENT_PARAMETERS)); params.Windowed = !gFullscreen; params.SwapEffect = D3DSWAPEFFECT_DISCARD; params.hDeviceWindow = gWindowHandle; params.BackBufferCount = 2; if (gFullscreen) { GetScreenSize(gWindowWidth, gWindowHeight); params.BackBufferFormat = D3DFMT_A8R8G8B8; params.BackBufferWidth = gWindowWidth; params.BackBufferHeight = gWindowHeight; } else { gWindowWidth = 1280; gWindowHeight = 1024; unsigned int width, height; DetermineWindowSize(width, height); SetWindowPos(gWindowHandle, HWND_TOP, 0, 0, width, height, SWP_NOMOVE); } HRESULT hr = gGraphicsDevice->Reset(¶ms); if (FAILED(hr)) { ReportError("Failed to initialize device"); return false; } InitRendering(gWindowWidth, gWindowHeight, gBroadcastWidth, gBroadcastHeight); // Set the viewport D3DVIEWPORT9 vp; vp.X = 0; vp.Y = 0; vp.MinZ = 0.0f; vp.MaxZ = 1.0f; vp.Width = gWindowWidth; vp.Height = gWindowHeight; gGraphicsDevice->SetViewport(&vp); // Setup the projection matrix D3DXMatrixPerspectiveFovLH(&gProjectionMatrix, D3DXToRadian(60), (FLOAT)gWindowWidth/(FLOAT)gWindowHeight, 1, 1000); // Create the mesh that will be rendered CreateWaveMesh(64, 20); InitializeChatRenderer(gWindowWidth, gWindowHeight); return true; }
bool GLVideo::SaveScreenshot( const str_type::char_t* name, const Texture::BITMAP_FORMAT fmt, math::Rect2D rect) { str_type::string fileName = name, ext; const int type = GetSOILTexType(fmt, ext); if (!Platform::IsExtensionRight(fileName, ext)) fileName.append(ext); if (rect.size.x <= 0 || rect.size.y <= 0) { rect.pos = math::Vector2i(0,0); rect.size = GetScreenSize(); } const bool r = (SOIL_save_screenshot( fileName.c_str(), type, rect.pos.x, rect.pos.y, rect.size.x, rect.size.y)); if (!r) { ShowMessage(str_type::string("Couldn't save screen shot ") + fileName, GSMT_ERROR); } return r; }
EXPORT_C TInt RConsoleProxy::GetScreenSize(TSize& aSize) const { TRequestStatus stat; TPckg<TSize> size(aSize); GetScreenSize(size, stat); User::WaitForRequest(stat); return stat.Int(); }
void DisplayMessageWindow (MessageWindow *messageWindow) { FcitxLightUI* lightui = messageWindow->owner; Display *dpy = lightui->dpy; int dwidth, dheight; GetScreenSize(lightui, &dwidth, &dheight); XMapRaised (dpy, messageWindow->window); XMoveWindow (dpy, messageWindow->window, (dwidth - messageWindow->width) / 2, (dheight - messageWindow->height) / 2); }
int __stdcall start(int state) { int p; int i; int scrnsize; int scrnbpp; int scrnpitch; if( !test_mmx()) return FALSE; if( (scrnbpp = GetScreenBpp()) != 32) return FALSE; scrnsize = GetScreenSize(); scrnpitch = GetScreenPitch(); scrn_clip.xmin = 0; scrn_clip.ymin = 0; scrn_clip.xmax = (scrnsize >> 16) - 1; scrn_clip.ymax = (scrnsize & 0xFFFF) - 1; scrn_pixmap.width = scrnsize >> 16; scrn_pixmap.height = scrnsize & 0xFFFF; scrn_pixmap.format = PICT_a8r8g8b8; scrn_pixmap.flags = PX_MEM_LOCAL; scrn_pixmap.pitch = scrnpitch; scrn_pixmap.mapped = (void*)LFB_BASE; br_slab.available = 256; br_slab.start = brushes; br_slab.nextavail = brushes; for (i = 0, p = (int)br_slab.start; i < 256; i++) { *(int *)p = p+sizeof(brush_t); p = p+sizeof(brush_t); }; px_slab.available = 64; px_slab.start = pixmaps; px_slab.nextavail = pixmaps; for (i = 0, p = (int)px_slab.start; i < 64; i++) { *(int *)p = p+sizeof(pixmap_t); p = p+sizeof(pixmap_t); }; srv_hw2d = get_service("HDRAW"); if(srv_hw2d == 0) srv_hw2d = load_service("/rd/1/drivers/ati2d.drv"); return TRUE; };
void Console::Draw(void) { static DWORD count = GetTickCount(); EnterCriticalSection(&Vars.cConsoleSection); if (IsVisible()) { POINT size = GetScreenSize(); int xsize = size.x; int ysize = size.y; size = CalculateTextLen("@", Vars.dwConsoleFont); int charwidth = size.x; int charheight = max(12, size.y / 2 + 2); // the default console height is 30% of the screen size int height = ((int)(((double)ysize) * .3) / charheight) * charheight + charheight; lineWidth = xsize - (2 * charwidth); lineCount = height / charheight; int cmdsize = 0; int cmdlines = 0; std::list<std::wstring> cmdsplit; if (IsEnabled()) { std::wstring cmdstr = cmd.str(); if (cmdstr.length() > 0) { SplitLines(cmdstr, Console::MaxWidth(), L' ', cmdsplit); cmdsize = CalculateTextLen(cmdsplit.back().c_str(), Vars.dwConsoleFont).x; cmdlines += cmdsplit.size() - 1; } } Console::height = height + (cmdlines * charheight) + 6; // draw the box large enough to hold the whole thing D2GFX_DrawRectangle(0, 0, xsize, Console::height, 0xdf, 0); std::deque<std::wstring>::reverse_iterator it = lines.rbegin(); if (scrollIndex == 0 && lines.size() == lineCount && IsEnabled()) // handle index 0, top of console it++; for (int i = lineCount - (int)IsEnabled(); i > 0 && it != lines.rend(); i--, it++) myDrawText(it->c_str(), charwidth, 4 + (i * charheight), 0, Vars.dwConsoleFont); if (IsEnabled()) { if (cmdsplit.size() > 0) { int dy = height + 3; for (std::list<std::wstring>::iterator it2 = cmdsplit.begin(); it2 != cmdsplit.end(); it2++, dy += charheight) myDrawText(it2->c_str(), charwidth, dy, 0, Vars.dwConsoleFont); } myDrawText(L">", 1, Console::height - 3, 0, Vars.dwConsoleFont); DWORD tick = GetTickCount(); if ((tick - count) < 600) { int lx = cmdsize + charwidth, ly = Console::height - (charheight / 3); D2GFX_DrawRectangle(lx, ly, lx + ((charwidth * 2) / 3), ly + 2, 0xFF, 0x07); } else if ((tick - count) > 1100) count = tick; } } LeaveCriticalSection(&Vars.cConsoleSection); }
void _NonAppStop() { uint16_t row, col; GetScreenSize(&row, &col); gotorowcol(row-1, 0); /* pressanykey(); */ printf("<Press any key to close screen> "); getcharacter(); }
bool GLVideo::EndSpriteScene() { m_rendering = false; const GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { ResetVideoMode(static_cast<unsigned int>(GetScreenSize().x), static_cast<unsigned int>(GetScreenSize().y), Texture::PF_DEFAULT); } return true; }
void FillScreen(gfxScreen_t screen, u8 bg_r, u8 bg_g, u8 bg_b) { Rect screen_size = GetScreenSize(screen); u8* fb_addr = gfxGetFramebuffer(screen, GFX_LEFT, nullptr, nullptr); for (int i = 0; i < screen_size.w * screen_size.h * 3; i += 3) { fb_addr[i] = bg_b; fb_addr[i+1] = bg_g; fb_addr[i+2] = bg_r; } }
void XlibMenuMoveWindow(FcitxXlibWindow* window) { XlibMenu* menu = (XlibMenu*) window; FcitxClassicUI* classicui = window->owner; int sheight; GetScreenSize(classicui, NULL, &sheight); if (menu->anchor == MA_MainWindow) { menu->iPosX = classicui->iMainWindowOffsetX; menu->iPosY = classicui->iMainWindowOffsetY + classicui->mainWindow->parent.height; if ((menu->iPosY + window->height) > sheight) { menu->iPosY = classicui->iMainWindowOffsetY - 5 - window->height; } } else if (menu->anchor == MA_Menu) { int dwidth, dheight; XlibMenu* parent = menu->anchorMenu; GetScreenSize(classicui, &dwidth, &dheight); menu->iPosX = parent->iPosX + parent->parent.contentX + parent->parent.contentWidth - 4; menu->iPosY = parent->iPosY + menu->offseth - window->contentY; if (menu->iPosX + window->width > dwidth) { menu->iPosX = parent->iPosX - window->width + parent->parent.contentX + 4; } if (menu->iPosY + window->height > dheight) { menu->iPosY = dheight - window->height; } } else if (menu->anchor == MA_Tray) { CalMenuWindowPosition(menu, menu->trayX, menu->trayY, classicui->trayWindow->size); } menu->anchor = MA_None; XMoveWindow(classicui->dpy, window->wId, menu->iPosX, menu->iPosY); }
void MoveSubMenu(XlibMenu *sub, XlibMenu *parent, int offseth) { int dwidth, dheight; GetScreenSize(parent->owner, &dwidth, &dheight); UpdateMenuShell(sub->menushell); GetMenuSize(sub); sub->iPosX=parent->iPosX + parent->width - MenuMarginRight - 4; sub->iPosY=parent->iPosY + offseth - MenuMarginTop; if ( sub->iPosX + sub->width > dwidth) sub->iPosX=parent->iPosX - sub->width + MenuMarginLeft + 4; if ( sub->iPosY + sub->height > dheight) sub->iPosY = dheight - sub->height; XMoveWindow(parent->owner->dpy, sub->menuWindow, sub->iPosX, sub->iPosY); }
void UnitSymbol::Draw(Canvas &canvas, PixelScalar x, PixelScalar y, Color bg_color, Color text_color) const { assert(IsDefined()); const PixelSize size = GetSize(); const PixelSize screen_size = GetScreenSize(); canvas.StretchMono(x, y, screen_size.cx, screen_size.cy, #if defined(USE_GDI) || defined(ENABLE_OPENGL) bitmap, #else buffer, #endif 0, 0, size.cx, size.cy, text_color, bg_color); }
void CGameWindow::OpenWindow() { int iScreenWidth, iScreenHeight; GetScreenSize(iScreenWidth, iScreenHeight); #ifdef _DEBUG BaseClass::OpenWindow(iScreenWidth*2/3, iScreenHeight*2/3, false, false); #else BaseClass::OpenWindow(iScreenWidth*2/3, iScreenHeight*2/3, false, false); #endif RenderLoading(); m_pGameServer = new CGameServer(); m_pRenderer = CreateRenderer(); m_pRenderer->Initialize(); }
void MoveSubMenu(XlibMenu *sub, XlibMenu *parent, int offseth) { int dwidth, dheight; FcitxSkin *sc = &parent->owner->skin; GetScreenSize(parent->owner, &dwidth, &dheight); FcitxMenuUpdate(sub->menushell); GetMenuSize(sub); sub->iPosX = parent->iPosX + parent->width - sc->skinMenu.marginRight - 4; sub->iPosY = parent->iPosY + offseth - sc->skinMenu.marginTop; if (sub->iPosX + sub->width > dwidth) sub->iPosX = parent->iPosX - sub->width + sc->skinMenu.marginLeft + 4; if (sub->iPosY + sub->height > dheight) sub->iPosY = dheight - sub->height; XMoveWindow(parent->owner->dpy, sub->menuWindow, sub->iPosX, sub->iPosY); }
static void FilterScreenSizeX(GenericConfig* config, ConfigGroup *group, ConfigOption *option, void *value, ConfigSync sync, void *filterArg) { int* X = (int*) value; FcitxLightUI *lightui = (FcitxLightUI*) config; int width, height; GetScreenSize(lightui, &width, &height); switch (sync) { case Raw2Value: if (*X >= width) *X = width - 10; if (*X < 0) *X = 0; break; case Value2Raw: break; } }
void VideoDecoder::DecodeFrame(bool synchronous) { UpdateVideoFilter(); if(_hdFilterEnabled) { ((HdVideoFilter*)_videoFilter.get())->SetHdScreenTiles(_hdScreenInfo); } _videoFilter->SendFrame(_ppuOutputBuffer, _isOddFrame); uint32_t* outputBuffer = (uint32_t*)_videoFilter->GetOutputBuffer(); FrameInfo frameInfo = _videoFilter->GetFrameInfo(); if(_rotateFilter) { outputBuffer = _rotateFilter->ApplyFilter(outputBuffer, frameInfo.Width, frameInfo.Height); frameInfo = _rotateFilter->GetFrameInfo(frameInfo); } if(_scaleFilter) { outputBuffer = _scaleFilter->ApplyFilter(outputBuffer, frameInfo.Width, frameInfo.Height); frameInfo = _scaleFilter->GetFrameInfo(frameInfo); } if(_hud) { _hud->DrawHud((uint8_t*)outputBuffer, frameInfo, _videoFilter->GetOverscan()); } ScreenSize screenSize; GetScreenSize(screenSize, true); if(_previousScale != EmulationSettings::GetVideoScale() || screenSize.Height != _previousScreenSize.Height || screenSize.Width != _previousScreenSize.Width) { MessageManager::SendNotification(ConsoleNotificationType::ResolutionChanged); } _previousScale = EmulationSettings::GetVideoScale(); _previousScreenSize = screenSize; _lastFrameInfo = frameInfo; _frameChanged = false; //Rewind manager will take care of sending the correct frame to the video renderer RewindManager::SendFrame(outputBuffer, frameInfo.Width, frameInfo.Height, synchronous); }
bool GLVideo::SetScissor(const math::Rect2D& rect) { SetScissor(true); GLint posY; TexturePtr target = m_currentTarget.lock(); if (target) { posY = static_cast<GLint>(rect.pos.y); } else { posY = static_cast<GLint>(GetScreenSize().y) - static_cast<GLint>(rect.pos.y + rect.size.y); } if (m_scissor != rect) { m_scissor = rect; glScissor(static_cast<GLint>(rect.pos.x), posY, static_cast<GLsizei>(rect.size.x), static_cast<GLsizei>(rect.size.y)); } return true; }
static void UpdateDialogPosition(UIStatusWnd *const wnd) { int mainX = 0; int mainY = 0; int mainWidth = 0; int mainHeight = 0; int tonerRepDlgX = 0; int tonerRepDlgY = 0; int tonerRepDlgWidth = 0; int tonerRepDlgHeight = 0; int screenWidth = 0; int screenHeight = 0; if(wnd != NULL){ GtkWidget *mainWindow = UI_DIALOG(wnd)->window; GtkWidget *tonerRepDlg = UI_DIALOG(wnd->toner_replacement_dlg)->window; GetWindowPositionAndSize(mainWindow, &mainX, &mainY, &mainWidth, &mainHeight); GetWindowPositionAndSize(tonerRepDlg, &tonerRepDlgX, &tonerRepDlgY, &tonerRepDlgWidth, &tonerRepDlgHeight); GetScreenSize(mainWindow, &screenWidth, &screenHeight); if((mainX + mainWidth + tonerRepDlgWidth) <= screenWidth){ tonerRepDlgX = mainX + mainWidth; }else if((mainX - tonerRepDlgWidth) >= 0){ tonerRepDlgX = mainX - tonerRepDlgWidth; }else if((mainX + (mainWidth / 2)) < (screenWidth / 2)){ tonerRepDlgX = screenWidth - tonerRepDlgWidth; }else{ tonerRepDlgX = 0; } tonerRepDlgY = mainY; WindowMove(tonerRepDlg, tonerRepDlgX, tonerRepDlgY); } }
void Console::Initialize(void) { if(!initialized) { EnterCriticalSection(&Vars.cConsoleSection); POINT size = GetScreenSize(); int xsize = size.x; int ysize = size.y; // the console height is 30% of the screen size int height = (int)(((double)ysize)*.3); size = CalculateTextLen(">", 0); int charsize = size.x; int charheight = size.y-10; int cx = charsize+9; box = new BoxHook(NULL, 0, 0, xsize, height, 0xdf, 0); prompt = new TextHook(NULL, ">", 1, height, 0, 0); text = new TextHook(NULL, "", charsize+5, height, 0, 0); // the cursor's height is basically hand-crafted, if you change // the font, make sure to double check the char height cursor = new LineHook(NULL, cx, height-charheight, cx, height-2, 0xff); for(unsigned int i = 0; i < lineCount; i++) { lineBuffers[i] = new TextHook(NULL, "", 2+charheight, 2+charheight+(i*charheight), 0, 0); lineBuffers[i]->SetIsVisible(false); } box->SetIsVisible(false); prompt->SetIsVisible(false); text->SetIsVisible(false); cursor->SetIsVisible(false); initialized = true; LeaveCriticalSection(&Vars.cConsoleSection); } }
void GUISlider::SetPosition (sf::Vector2f position) { Sprite::SetPosition(position); sliderThingy->SetPosition(position); SetValue(value); float scaledWidth = width * baseScale.x; switch (mAlignH) { case LEFT: edgeLeft->SetPosition( sf::Vector2f( basePos.x , position.y ) ); edgeRight->SetPosition( sf::Vector2f( (basePos.x + scaledWidth - edgeRight->GetScreenSize().x / windowFakeScale) , position.y ) ); break; case CENTER: edgeLeft->SetPosition( sf::Vector2f( (basePos.x - scaledWidth / 2 + edgeLeft->GetScreenSize().x / 2 / windowFakeScale) , position.y ) ); edgeRight->SetPosition( sf::Vector2f( (basePos.x + scaledWidth / 2 - edgeRight->GetScreenSize().x / 2 / windowFakeScale) , position.y ) ); break; case RIGHT: edgeLeft->SetPosition( sf::Vector2f( -(-basePos.x + scaledWidth - edgeRight->GetScreenSize().x / windowFakeScale) , position.y ) ); edgeRight->SetPosition( sf::Vector2f( basePos.x , position.y ) ); break; } switch (mAlignV) { case TOP: sliderThingy->SetPosition(sf::Vector2f(sliderThingy->GetPosition().x, basePos.y - sliderThingy->GetScreenSize().y / 2 / windowFakeScale + GetScreenSize().y / 2 / windowFakeScale )); break; case MIDDLE: break; case BOTTOM: sliderThingy->SetPosition(sf::Vector2f(sliderThingy->GetPosition().x, basePos.y + sliderThingy->GetScreenSize().y / 2 / windowFakeScale - GetScreenSize().y / 2 / windowFakeScale )); break; } }
/* * returns 1 if at least one match, else returns 0 */ BOOL ShowCompletionMatches (LPTSTR str, INT charcount) { WIN32_FIND_DATA file; HANDLE hFile; BOOL found_dot = FALSE; INT curplace = 0; INT count; TCHAR path[MAX_PATH]; TCHAR fname[MAX_PATH]; TCHAR directory[MAX_PATH]; SHORT screenwidth; /* expand current file name */ count = charcount - 1; if (count < 0) count = 0; /* find front of word */ if (str[count] == _T('"')) { count--; while (count > 0 && str[count] != _T('"')) count--; } else { while (count > 0 && str[count] != _T(' ')) count--; } /* if not at beginning, go forward 1 */ if (str[count] == _T(' ')) count++; if (str[count] == _T('"')) count++; /* extract directory from word */ _tcscpy (directory, &str[count]); curplace = _tcslen (directory) - 1; if (curplace >= 0 && directory[curplace] == _T('"')) directory[curplace--] = _T('\0'); _tcscpy (path, directory); while (curplace >= 0 && directory[curplace] != _T('\\') && directory[curplace] != _T(':')) { directory[curplace] = 0; curplace--; } /* look for a . in the filename */ for (count = _tcslen (directory); path[count] != _T('\0'); count++) { if (path[count] == _T('.')) { found_dot = TRUE; break; } } if (found_dot) _tcscat (path, _T("*")); else _tcscat (path, _T("*.*")); /* current fname */ curplace = 0; hFile = FindFirstFile (path, &file); if (hFile != INVALID_HANDLE_VALUE) { UINT longestfname = 0; /* Get the size of longest filename first. */ do { if (_tcslen(file.cFileName) > longestfname) { longestfname = _tcslen(file.cFileName); /* Directories get extra brackets around them. */ if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) longestfname += 2; } } while (FindNextFile (hFile, &file)); FindClose (hFile); hFile = FindFirstFile (path, &file); /* Count the highest number of columns */ GetScreenSize(&screenwidth, NULL); /* For counting columns of output */ count = 0; /* Increase by the number of spaces behind file name */ longestfname += 3; /* find anything */ ConOutChar(_T('\n')); do { /* ignore . and .. */ if (!_tcscmp (file.cFileName, _T(".")) || !_tcscmp (file.cFileName, _T(".."))) continue; if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) _stprintf (fname, _T("[%s]"), file.cFileName); else _tcscpy (fname, file.cFileName); ConOutPrintf (_T("%*s"), - longestfname, fname); count++; /* output as much columns as fits on the screen */ if (count >= (screenwidth / longestfname)) { /* print the new line only if we aren't on the * last column, in this case it wraps anyway */ if (count * longestfname != (UINT)screenwidth) ConOutChar(_T('\n')); count = 0; } } while (FindNextFile (hFile, &file)); FindClose (hFile); if (count) ConOutChar(_T('\n')); } else { /* no match found */ MessageBeep (-1); return FALSE; } return TRUE; }
void Console::Draw(void) { static DWORD count = 0; EnterCriticalSection(&Vars.cConsoleSection); if(IsVisible()) { POINT size = GetScreenSize(); int xsize = size.x; int ysize = size.y; // the default console height is 30% of the screen size int height = (int)(((double)ysize)*.3); size = CalculateTextLen(">", 0); int charsize = size.x; int charheight = size.y-10; int cx = charsize+9; int linelen = 115; Console::height = height; int cmdsize = CalculateTextLen(cmd.str().c_str(), 0).x; if((cmdsize/xsize) > 0) Console::height += (cmdsize/xsize)*charheight + 1; // draw the box large enough to hold the whole thing D2GFX_DrawRectangle(0, 0, xsize, Console::height, 0xdf, 0); std::deque<std::string>::reverse_iterator it = lines.rbegin(); for(int i = lineCount-1; i >= 0 && it != lines.rend(); i--, it++) { if(CalculateTextLen(it->c_str(), 0).x > (xsize - (2+charheight)*2)) { std::list<std::string> buf; SplitLines(*it, linelen, ' ', buf); for(std::list<std::string>::iterator it = buf.begin(); it != buf.end(); it++) myDrawText(it->c_str(), 2+charheight, 2+charheight+((i--)*charheight), 0, 0); } else myDrawText(it->c_str(), 2+charheight, 2+charheight+(i*charheight), 0, 0); } if(IsEnabled()) { myDrawText(">", 1, height, 0, 0); int lx = cx + cmdsize - charsize + 5, ly = height-charheight; if(count % 30) D2GFX_DrawLine(lx, ly, lx, height-2, 0xFF, 0xFF); std::string cmdstr = cmd.str(); if(cmdstr.length() > 0) { if((cmdsize/xsize) > 0) { std::list<std::string> lines; SplitLines(cmdstr, linelen, ' ', lines); int i = 0; for(std::list<std::string>::iterator it = lines.begin(); it != lines.end(); it++, i++) myDrawText(it->c_str(), charsize+5, height+(charheight*i)+1, 0, 0); } else myDrawText(cmdstr.c_str(), charsize+5, height+1, 0, 0); } } } LeaveCriticalSection(&Vars.cConsoleSection); count++; }
void CMouseControl::OnDisplayChanged () { GetScreenSize(); RecomputeWorkingArea (); }
void GUISlider::HandleSFEvents (std::list<sf::Event>& sfEvents) { std::list<sf::Event>::iterator itSfEvent = sfEvents.begin(); while (itSfEvent != sfEvents.end()) { switch (itSfEvent->Type) { case sf::Event::MouseMoved: { sf::Rect<float> btnBounds(CalcFakePos().x - (GetScreenSize().x / 2), CalcFakePos().y - (GetScreenSize().y / 2 ), CalcFakePos().x + (GetScreenSize().x / 2), CalcFakePos().y + (GetScreenSize().y / 2 ) ); hover = btnBounds.Contains(itSfEvent->MouseMove.X, itSfEvent->MouseMove.Y); if (dragging && itSfEvent->MouseMove.X != lastMousePressedX) { float originalX = sliderThingy->GetPosition().x; float mouseMotionX = itSfEvent->MouseMove.X - lastMousePressedX; sliderThingy->Move(sf::Vector2f(mouseMotionX / windowFakeScale, 0)); // (width - (edgeRight->GetScreenSize().x / windowFakeScale / baseScale.x) * 2) // this is the width of the full bar without the edges float w = width - (edgeRight->GetScreenSize().x / windowFakeScale / baseScale.x) * 2; // zero position for the sliderThingy float zeroX = 0; switch (mAlignH) { case LEFT: zeroX = -sliderThingy->GetScreenSize().x / 2 / windowFakeScale / baseScale.x + edgeLeft->GetScreenSize().x / windowFakeScale / baseScale.x + basePos.x; break; case CENTER: zeroX = -w / 2 + basePos.x; break; case RIGHT: zeroX = sliderThingy->GetScreenSize().x / 2 / windowFakeScale / baseScale.x - edgeLeft->GetScreenSize().x / windowFakeScale / baseScale.x - w + basePos.x; break; } if (sliderThingy->GetPosition().x < zeroX) { sliderThingy->SetPosition(sf::Vector2f(zeroX, sliderThingy->GetPosition().y)); value = 0; } else if (sliderThingy->GetPosition().x > zeroX + w) { sliderThingy->SetPosition(sf::Vector2f(zeroX + w, sliderThingy->GetPosition().y)); value = 1; } else { value = (sliderThingy->GetPosition().x - (GetPosition().x - width / 2)) / width; } float mul = (sliderThingy->GetPosition().x - originalX) / (mouseMotionX / windowFakeScale); lastMousePressedX += (itSfEvent->MouseMove.X - lastMousePressedX) * mul; if (onChanged) onChanged(this->value); } } break; case sf::Event::MouseWheelMoved: if (hover) { value += Game->GetDeltaTime() * WHEELSCROLLSPD * itSfEvent->MouseWheel.Delta; SetValue(value); } break; case sf::Event::MouseButtonPressed: { sf::Vector2f wMouse = Game->ConvertCoordsWindowToWorld(itSfEvent->MouseButton.X, itSfEvent->MouseButton.Y); if (sliderThingy->Contains(wMouse)) { if (sliderThingy->IsOpaque(wMouse)) { dragging = true; lastMousePressedX = itSfEvent->MouseButton.X; } } else if (hover) { value = (itSfEvent->MouseButton.X - (CalcFakePos().x - GetScreenSize().x / 2)) / GetScreenSize().x; SetValue(value); dragging = true; lastMousePressedX = itSfEvent->MouseButton.X; } } break; case sf::Event::MouseButtonReleased: dragging = false; if (onChanged) onChanged(this->value); break; default: break; } itSfEvent++; } }
//INT CommandMore (LPTSTR cmd, LPTSTR param) int main (int argc, char **argv) { SHORT maxx,maxy; SHORT line_count=0,ch_count=0; DWORD i, last; HANDLE hFile = INVALID_HANDLE_VALUE; TCHAR szFullPath[MAX_PATH]; TCHAR szMsg[1024]; /*reading/writing buffer*/ TCHAR *buff; /*bytes written by WriteFile and ReadFile*/ DWORD dwRead,dwWritten; /*ReadFile() return value*/ BOOL bRet; hStdIn = GetStdHandle(STD_INPUT_HANDLE); hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); hStdErr = GetStdHandle(STD_ERROR_HANDLE); hApp = GetModuleHandle(NULL); buff=malloc(4096); if (!buff) { ConOutPuts(_T("Error: no memory")); return 1; } if (argc > 1 && _tcsncmp (argv[1], _T("/?"), 2) == 0) { if (LoadString(hApp, IDS_USAGE, buff, 4096 / sizeof(TCHAR)) < (int)(4096 / sizeof(TCHAR))) { CharToOem(buff, buff); ConOutPuts(buff); } free(buff); return 0; } hKeyboard = CreateFile (_T("CONIN$"), GENERIC_READ|GENERIC_WRITE, 0,NULL,OPEN_ALWAYS,0,0); GetScreenSize(&maxx,&maxy); FlushConsoleInputBuffer (hKeyboard); if(argc > 1) { GetFullPathNameA(argv[1], MAX_PATH, szFullPath, NULL); hFile = CreateFile (szFullPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0); if (hFile == INVALID_HANDLE_VALUE) { if (LoadString(hApp, IDS_FILE_ACCESS, szMsg, sizeof(szMsg) / sizeof(TCHAR)) < (int)(sizeof(szMsg) / sizeof(TCHAR))) { _stprintf(buff, szMsg, szFullPath); CharToOem(buff, buff); ConOutPuts(buff); } free(buff); return 0; } } else { hFile = hStdIn; } if (!LoadString(hApp, IDS_CONTINUE, szCont, sizeof(szCont) / sizeof(TCHAR))) { /* Shouldn't happen, so exit */ free(buff); return 1; } szContLength = _tcslen(szCont); do { bRet = ReadFile(hFile,buff,4096,&dwRead,NULL); for(last=i=0;i<dwRead && bRet;i++) { ch_count++; if(buff[i] == _T('\n') || ch_count == maxx) { ch_count=0; line_count++; if (line_count == maxy) { line_count = 0; WriteFile(hStdOut,&buff[last], i-last+1, &dwWritten, NULL); last=i+1; FlushFileBuffers (hStdOut); WaitForKey (); } } } if (last<dwRead && bRet) WriteFile(hStdOut,&buff[last], dwRead-last, &dwWritten, NULL); } while(dwRead>0 && bRet); free (buff); CloseHandle (hKeyboard); if (hFile != hStdIn) CloseHandle (hFile); return 0; }