void CXTPSkinObjectTab::DrawTab(CDC* pDC, int iItem) { CXTPClientRect rc(this); CTabCtrl* pTabCtrl = (CTabCtrl*)this; // Get the current tab selection. int iCurSel = pTabCtrl->GetCurSel(); // Get the tab item size. CRect rcItem; pTabCtrl->GetItemRect(iItem, &rcItem); if (!CRect().IntersectRect(rcItem, rc)) return; CRect rcItemFocus(rcItem); // Draw the tab item. BOOL bSelected = (iItem == iCurSel); FillTabFace(pDC, rcItem, iItem, pTabCtrl->GetItemCount(), bSelected); DrawTabIcon(pDC, rcItem, iItem); DrawTabText(pDC, rcItem, iItem, iItem, bSelected); // draw the focus rect if (bSelected && ::GetFocus() == m_hWnd && (SendMessage(WM_QUERYUISTATE) & UISF_HIDEFOCUS) == 0) { rcItemFocus.DeflateRect(GetMetrics()->m_cxEdge / 2, GetMetrics()->m_cyEdge / 2); pDC->DrawFocusRect(&rcItemFocus); } }
NS_IMETHODIMP nsThebesFontMetrics::GetStrikeout(nscoord& aOffset, nscoord& aSize) { aOffset = ROUND_TO_TWIPS(GetMetrics().strikeoutOffset); aSize = ROUND_TO_TWIPS(GetMetrics().strikeoutSize); return NS_OK; }
BOOL CXTPSkinObjectFrame::OnHookDefWindowProc(UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult) { if (nMessage == WM_CTLCOLORBTN || nMessage == WM_CTLCOLORDLG || nMessage == WM_CTLCOLORSTATIC || nMessage == WM_CTLCOLOREDIT || nMessage == WM_CTLCOLORLISTBOX) { if (m_strClassName == _T("COMBOBOX")) return FALSE; if (nMessage == WM_CTLCOLOREDIT || nMessage == WM_CTLCOLORLISTBOX) { ::SetBkColor((HDC)wParam, GetColor(COLOR_WINDOW)); ::SetTextColor((HDC)wParam, GetColor(COLOR_WINDOWTEXT)); lResult = (LRESULT)GetMetrics()->m_brushWindow; return TRUE; } if (CWnd::GrayCtlColor((HDC)wParam, (HWND)lParam, (UINT)(nMessage - WM_CTLCOLORMSGBOX), GetMetrics()->m_brushDialog, 0)) { lResult = (LRESULT)GetClientBrush((HDC)wParam, (HWND)lParam, (UINT)(nMessage - WM_CTLCOLORMSGBOX)); return TRUE; } } return CXTPSkinObject::OnHookDefWindowProc(nMessage, wParam, lParam, lResult); }
BOOL CXTPSkinObjectFrame::IsSizeBox() { HWND hWnd = m_hWnd; CXTPWindowRect rcChild(hWnd); int cxEdge = GetMetrics()->m_cxEdge; int cyEdge = GetMetrics()->m_cyEdge; while (hWnd) { if (GetWindowLong(hWnd, GWL_STYLE) & WS_SIZEBOX) { if ((GetWindowLong(hWnd, GWL_STYLE) & WS_MAXIMIZE)) return FALSE; CPoint ptParent = CXTPClientRect(hWnd).BottomRight(); ::ClientToScreen(hWnd, &ptParent); if ((rcChild.right + cxEdge < ptParent.x) || (rcChild.bottom + cyEdge < ptParent.y)) { return FALSE; } return hWnd ? TRUE : FALSE; } if (((GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) == 0) || ((GetWindowLong(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)) break; hWnd = ::GetParent(hWnd); } return FALSE; }
NS_IMETHODIMP nsThebesFontMetrics::GetMaxHeight(nscoord &aHeight) { aHeight = CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics())) + CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup)); return NS_OK; }
int CZipBitmap::GetWidth() { if (!m_iWidth) GetMetrics(); return m_iWidth; }
void LabelElement::Render() { auto m = GetMetrics(); auto gui = GUI::Get(); auto textProgram = ShaderRegistry::GetProgram("text"); textProgram->Use(); gui->camera->SetUniforms(textProgram.get()); glUniform4f(textProgram->GetUniform("color"), 1,1,1, 1); auto size = m->topRight - m->bottomLeft; auto scalexy = size/textMesh->size; auto scale = std::min(scalexy.x, scalexy.y); auto tmbl = m->bottomLeft + vec2{0, textMesh->size.y * scalexy.y}; Debug::PointUI(m->topRight); Debug::PointUI(m->bottomLeft); Debug::PointUI(m->bottomLeft + vec2{0, textMesh->size.y * scale}, vec3{1,1,0}); Debug::PointUI(tmbl, vec3{1,0,0}); Debug::PointUI(tmbl + textMesh->size * vec2{1,-1} * scale, vec3{0,1,0}); Debug::PointUI(tmbl + textMesh->size * vec2{1,-1} * scale * .5f, vec3{0,0,1}); textMesh->modelMatrix = glm::translate(vec3{tmbl, 0}) * glm::scale(vec3{scale}); textMesh->Render(); }
HBRUSH CXTPSkinObjectFrame::FillBackground(CDC* pDC, LPCRECT lprc, int nMessage /*= WM_CTLCOLORSTATIC*/) { HBRUSH hBrush = ::GetParent(m_hWnd) ? (HBRUSH)::SendMessage(::GetParent(m_hWnd), nMessage, (WPARAM)pDC->GetSafeHdc(), (LRESULT)m_hWnd) : NULL; if (hBrush) { if ((DWORD_PTR)hBrush < XTP_SKINMETRICS_COLORTABLESIZE) { hBrush = GetMetrics()->m_brTheme[(DWORD_PTR)hBrush - 1]; } ::FillRect(pDC->GetSafeHdc(), lprc, hBrush); return hBrush; } pDC->FillSolidRect(lprc, GetColor(COLOR_3DFACE)); return GetMetrics()->m_brTheme[COLOR_3DFACE]; }
NS_IMETHODIMP nsThebesFontMetrics::GetAveCharWidth(nscoord& aAveCharWidth) { // Use CEIL instead of ROUND for consistency with GetMaxAdvance aAveCharWidth = CEIL_TO_TWIPS(GetMetrics().aveCharWidth); return NS_OK; }
int CZipBitmap::GetHeight() { if (!m_iHeight) GetMetrics(); return m_iHeight; }
CRect CXTPSkinObjectTab::GetHeaderRect() { CRect rcHeader; GetClientRect(&rcHeader); CTabCtrl* pTabCtrl = (CTabCtrl*)this; // get the selected tab item rect. CRect rcItem; pTabCtrl->GetItemRect(pTabCtrl->GetCurSel(), &rcItem); DWORD dwStyle = GetStyle(); if (IsRight(dwStyle)) { rcHeader.left = rcItem.left; } else if (IsLeft(dwStyle)) { rcHeader.right = rcItem.right; } else if (IsBottom(dwStyle)) { rcHeader.top = rcItem.top; } else { rcHeader.bottom = (rcHeader.top + rcItem.Height()) * pTabCtrl->GetRowCount() + GetMetrics()->m_cyEdge; } return rcHeader; }
BOOL CXTPSkinObjectToolBar::OnEraseBkgnd(CDC* pDC) { if (GetStyle() & (TBSTYLE_TRANSPARENT | TBSTYLE_CUSTOMERASE)) { return CXTPSkinObjectFrame::OnEraseBkgnd(pDC); } HBRUSH hbr = (HBRUSH)(DWORD_PTR)GetClassLongPtr(m_hWnd, GCLP_HBRBACKGROUND); BOOL bChanged = FALSE; if (hbr > 0 && (ULONG_PTR)hbr < (ULONG_PTR)XTP_SKINMETRICS_COLORTABLESIZE) { HBRUSH hbrTheme = GetMetrics()->m_brTheme[(ULONG_PTR)hbr - 1]; SetClassLongPtr(m_hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)hbrTheme); bChanged = TRUE; } BOOL bResult = (BOOL)::DefWindowProc(m_hWnd, WM_ERASEBKGND, (WPARAM)pDC->GetSafeHdc(), 0); if (bChanged) { SetClassLongPtr(m_hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)hbr); } return bResult; }
PRInt32 nsFontMetrics::GetMaxStringLength() { const gfxFont::Metrics& m = GetMetrics(); const double x = 32767.0 / m.maxAdvance; PRInt32 len = (PRInt32)floor(x); return PR_MAX(1, len); }
void ButtonElement::Update() { auto gui = GUI::Get(); auto b = &gui->builder; auto m = GetMetrics(); b->depth = m->depth; b->Add9Slice(m->bottomLeft, m->topRight, slice, buttonSize, 3.f); }
NS_IMETHODIMP nsThebesFontMetrics::GetUnderline(nscoord& aOffset, nscoord& aSize) { aOffset = ROUND_TO_TWIPS(mFontGroup->GetUnderlineOffset()); aSize = ROUND_TO_TWIPS(GetMetrics().underlineSize); return NS_OK; }
int32_t nsFontMetrics::GetMaxStringLength() { const gfxFont::Metrics& m = GetMetrics(); const double x = 32767.0 / m.maxAdvance; int32_t len = (int32_t)floor(x); return std::max(1, len); }
// Get the glyphID of a space PRUint32 gfxFT2FontBase::GetSpaceGlyph() { NS_ASSERTION(GetStyle()->size != 0, "forgot to short-circuit a text run with zero-sized font?"); GetMetrics(); return mSpaceGlyph; }
HBRUSH CXTPSkinObjectFrame::GetFillBackgroundBrush(CDC* pDC, int nMessage) { if (GetParent() == NULL) return GetMetrics()->m_brTheme[COLOR_3DFACE]; HBRUSH hBrush = (HBRUSH)::SendMessage(GetParent()->GetSafeHwnd(), nMessage, (WPARAM)pDC->GetSafeHdc(), (LPARAM)m_hWnd); if (hBrush) { if ((DWORD_PTR)hBrush < XTP_SKINMETRICS_COLORTABLESIZE) { hBrush = GetMetrics()->m_brTheme[(DWORD_PTR)hBrush - 1]; } return hBrush; } return nMessage == WM_CTLCOLOREDIT || nMessage == WM_CTLCOLORLISTBOX ? GetMetrics()->m_brushWindow : GetMetrics()->m_brTheme[COLOR_3DFACE]; }
float RenderDevice::calcBaselineAscent(const std::wstring& key) { auto pFont = this->getStockedFont(key); if (pFont == nullptr) return 0; DWRITE_FONT_METRICS metrics; pFont->GetMetrics(&metrics); return metrics.ascent; }
void TelegrafSocket::SendMetrics() { ServerInstance->Logs->Log("TELEGRAF", DEBUG, "Sending Telegraf Metrics.."); TelegrafLine line = GetMetrics(); creator->metrics.loopTimes.clear(); creator->metrics.loopTimes.reserve(10); std::string out(line.format()); WriteData(out); ServerInstance->Logs->Log("TELEGRAF", DEBUG, "Sent Telegraf metrics: %s", out.c_str()); }
void CXTPSkinObjectFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) { if (IsFlatScrollBarInitialized()) { m_spi[SB_VERT].fVisible = FALSE; m_spi[SB_HORZ].fVisible = FALSE; CXTPSkinObject::OnNcCalcSize(bCalcValidRects, lpncsp); return; } m_rcBorders = GetSchema()->CalcFrameBorders(this); lpncsp[0].rgrc->top += m_rcBorders.top; lpncsp[0].rgrc->left += m_rcBorders.left; lpncsp[0].rgrc->right -= m_rcBorders.right; lpncsp[0].rgrc->bottom -= m_rcBorders.bottom; DWORD dwStyle = GetStyle(); m_spi[SB_VERT].fVisible = dwStyle & WS_VSCROLL; m_spi[SB_HORZ].fVisible = dwStyle & WS_HSCROLL; if (m_spi[SB_VERT].fVisible) { if (GetExStyle() & (WS_EX_LAYOUTRTL | WS_EX_LEFTSCROLLBAR)) lpncsp[0].rgrc->left += GetMetrics()->m_cxVScroll; else lpncsp[0].rgrc->right -= GetMetrics()->m_cxVScroll; } if (m_spi[SB_HORZ].fVisible) { lpncsp[0].rgrc->bottom -= GetMetrics()->m_cyHScroll; } if (lpncsp[0].rgrc->bottom < lpncsp[0].rgrc->top) lpncsp[0].rgrc->bottom = lpncsp[0].rgrc->top; if (lpncsp[0].rgrc->right < lpncsp[0].rgrc->left) lpncsp[0].rgrc->right = lpncsp[0].rgrc->left; }
BOOL CXTPSkinObjectFrame::OnHookMessage(UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult) { if (nMessage == WM_CTLCOLORBTN || nMessage == WM_CTLCOLORDLG || nMessage == WM_CTLCOLORSTATIC || nMessage == WM_CTLCOLORLISTBOX || nMessage == WM_CTLCOLOREDIT) { if (m_strClassName == _T("COMBOBOX")) return FALSE; if (IsDefWindowProcAvail(nMessage) && (m_dwDialogTexture != ETDT_ENABLETAB || !m_bActiveX)) { return FALSE; } if (nMessage == WM_CTLCOLORLISTBOX || nMessage == WM_CTLCOLOREDIT) { ::SetBkColor((HDC)wParam, GetColor(COLOR_WINDOW)); ::SetTextColor((HDC)wParam, GetColor(COLOR_WINDOWTEXT)); lResult = (LRESULT)GetMetrics()->m_brushWindow; return TRUE; } // handle standard gray backgrounds if enabled if (CWnd::GrayCtlColor((HDC)wParam, (HWND)lParam, (UINT)(nMessage - WM_CTLCOLORMSGBOX), GetMetrics()->m_brushDialog, 0)) { lResult = (LRESULT)GetClientBrush((HDC)wParam, (HWND)lParam, (UINT)(nMessage - WM_CTLCOLORMSGBOX)); return TRUE; } } if (nMessage == WM_ERASEBKGND && m_dwDialogTexture == ETDT_ENABLETAB) { ::SetBrushOrgEx((HDC)wParam, 0, 0, NULL); FillRect((HDC)wParam, CXTPClientRect(this), GetClientBrush((HDC)wParam, m_hWnd, CTLCOLOR_DLG)); return TRUE; } return CXTPSkinObject::OnHookMessage(nMessage, wParam, lParam, lResult); }
nscoord nsFontMetrics::SpaceWidth() { // For vertical text with mixed or sideways orientation, we want the // width of a horizontal space (even if we're using vertical line-spacing // metrics, as with "writing-mode:vertical-*;text-orientation:mixed"). return CEIL_TO_TWIPS( GetMetrics(mVertical && mTextOrientation == NS_STYLE_TEXT_ORIENTATION_UPRIGHT ? gfxFont::eVertical : gfxFont::eHorizontal).spaceWidth); }
//----------------------------- FUNCTION -------------------------------------* int CTransBmp::GetHeight() /*>>>> Result height of bitmap <<<<*/ { if ((m_iWidth == 0) || (m_iHeight == 0)){ GetMetrics(); } return m_iHeight; }
void CXTPSkinObjectTab::DrawTabIcon(CDC* pDC, CRect& rcItem, int iItem) { CTabCtrl* pTabCtrl = (CTabCtrl*)this; TC_ITEM tci; tci.mask = TCIF_IMAGE; BOOL bResult = pTabCtrl->GetItem(iItem, &tci); #ifdef _UNICODE if (!bResult) { TC_ITEMA tcia; ::ZeroMemory(&tcia, sizeof(TC_ITEMA)); tcia.mask = TCIF_IMAGE; bResult = (BOOL)::SendMessage(pTabCtrl->m_hWnd, TCM_GETITEMA, iItem, (LPARAM)&tcia); tci.iImage = tcia.iImage; } #endif if (!bResult) return; CImageList* pImageList = pTabCtrl->GetImageList(); if (!pImageList || tci.iImage < 0) return; CPoint point = rcItem.TopLeft(); DWORD dwStyle = GetStyle(); if (IsHorz(dwStyle)) { point.Offset(GetMetrics()->m_cxEdge * 2, IsTop(dwStyle) ? GetMetrics()->m_cyEdge : 1); } else { point.Offset(IsLeft(dwStyle) ? GetMetrics()->m_cxEdge : 1, GetMetrics()->m_cyEdge * 2); } // Draw any associated icons. pImageList->Draw(pDC, tci.iImage, point, ILD_TRANSPARENT); IMAGEINFO info; ::ZeroMemory(&info, sizeof(info)); pImageList->GetImageInfo(tci.iImage, &info); CRect rcImage(info.rcImage); if (IsHorz(dwStyle)) { rcItem.left += rcImage.Width() + GetMetrics()->m_cxEdge; } else { rcItem.top += rcImage.Height() + GetMetrics()->m_cyEdge; } }
void on_diagnostic_button_clicked (GtkToolButton *toolbutton, gpointer user_data) { GtkNotebook* notebook = (GtkNotebook*)lookup_widget(main_window, "notebook1"); int n = gtk_notebook_get_current_page (notebook); if(n!=2) gtk_notebook_set_current_page(notebook, 2); // this is because of the TODO a few lines above // else // gtk_notebook_set_current_page(notebook, my_mode-1); GetMetrics(); }
HBRUSH CXTPSkinObjectFrame::GetClientBrush(HDC hDC, HWND hWnd, UINT nCtlColor) { if (m_dwDialogTexture != ETDT_ENABLETAB) { GrayCtlColor(hDC, hWnd, nCtlColor, GetMetrics()->m_brushDialog, GetColor(COLOR_BTNTEXT)); return GetMetrics()->m_brushDialog; } if (GetMetrics()->m_brushTabControl == NULL) { CWindowDC dcWindow(this); CXTPSkinManagerClass* pClass = GetSkinManager()->GetSkinClass(this, _T("TAB")); CString strImageFile = pClass->GetThemeString(TABP_BODY, 0, TMT_STOCKIMAGEFILE); if (strImageFile.IsEmpty()) { return GetMetrics()->m_brushDialog; } CXTPSkinImage* pImage = pClass->GetImages()->LoadFile(m_pManager->GetResourceFile(), strImageFile); if (!pImage) { return GetMetrics()->m_brushDialog; } CRect rc(0, 0, pImage->GetWidth(), pImage->GetHeight()); CBitmap bmp; bmp.CreateCompatibleBitmap(&dcWindow, rc.Width(), rc.Height()); CXTPCompatibleDC dc(&dcWindow, bmp); pImage->DrawImage(&dc, rc, rc, CRect(0, 0, 0, 0), COLORREF_NULL, ST_TRUESIZE, FALSE); GetMetrics()->m_brushTabControl = ::CreatePatternBrush(bmp); } if (hWnd != m_hWnd) { CXTPWindowRect rcPaint(hWnd); CXTPWindowRect rcBrush(m_hWnd); ::SetBrushOrgEx(hDC, rcBrush.left - rcPaint.left, rcBrush.top - rcPaint.top, NULL); ::SetBkMode(hDC, TRANSPARENT); ::SetTextColor(hDC, GetColor(COLOR_BTNTEXT)); } return GetMetrics()->m_brushTabControl; }
void on_notebook1_switch_page (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data) { char ar[500]; extern char my_arena[]; /* need to fix these TODO *btw: the idea is this: if you click on the diag screen you get if(my_mode==-1) my_mode=page_num; printf("::::%d\n",my_mode); */ GetCurrentArena(ar); if(page_num == 0) { if(my_mode==1) return; my_mode=1; if(strcmp(ar,"")!=0) { Vector("",""); } return; } if(page_num==1) { if(my_mode==2) return; my_mode=2; if(strcmp(ar,"")==0) { Vector(my_arena,""); GetVectors(my_arena); } return; } if(page_num==2) { //if(my_mode==2) // my_mode=-1; GetMetrics(); } }
BOOL CXTPSkinObjectFrame::OnEraseBkgnd(CDC* pDC) { HBRUSH hbr = (HBRUSH)(DWORD_PTR)GetClassLongPtr(m_hWnd, GCLP_HBRBACKGROUND); BOOL bChanged = FALSE; if (hbr > 0 && (ULONG_PTR)hbr < (ULONG_PTR)XTP_SKINMETRICS_COLORTABLESIZE) { HBRUSH hbrTheme = GetMetrics()->m_brTheme[(ULONG_PTR)hbr - 1]; SetClassLongPtr(m_hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)hbrTheme); bChanged = TRUE; } BOOL bResult = CXTPSkinObject::OnEraseBkgnd(pDC); if (bChanged) { SetClassLongPtr(m_hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)hbr); } return bResult; }
nscoord nsFontMetrics::SpaceWidth() { return CEIL_TO_TWIPS(GetMetrics().spaceWidth); }