//--------------------------------------------------------- inline double CVIEW_Map_Control::_Get_Client2World(double Length) { wxRect rClient(GetClientSize()); CSG_Rect rWorld(m_pMap->Get_World(rClient)); return( Length * rWorld.Get_XRange() / (double)rClient.GetWidth() ); }
//--------------------------------------------------------- inline double CVIEW_Map_Control::_Get_World(double xClient) { wxRect rClient(_Get_Client()); CSG_Rect rWorld(m_pMap->Get_World(rClient)); return( xClient * rWorld.Get_XRange() / (double)rClient.GetWidth() ); }
// Finds the index of the tab, which contains the given point. int IndexFromPoint(int x, int y, bool *inXbutton=nullptr) { Point point(x, y); Graphics graphics(hwnd); GraphicsPath shapes(data->Points, data->Types, data->Count); GraphicsPath shape; GraphicsPathIterator iterator(&shapes); iterator.NextMarker(&shape); ClientRect rClient(hwnd); REAL yPosTab = inTitlebar ? 0.0f : REAL(rClient.dy - height - 1); graphics.TranslateTransform(1.0f, yPosTab); for (int i = 0; i < Count(); i++) { Point pt(point); graphics.TransformPoints( CoordinateSpaceWorld, CoordinateSpaceDevice, &pt, 1); if (shape.IsVisible(pt, &graphics)) { iterator.NextMarker(&shape); if (inXbutton) *inXbutton = shape.IsVisible(pt, &graphics) ? true : false; return i; } graphics.TranslateTransform(REAL(width + 1), 0.0f); } if (inXbutton) *inXbutton = false; return -1; }
static int SecurityDeleteAuthorization( pointer value, XID id) { SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value; unsigned short name_len, data_len; char *name, *data; int status; int i; OtherClientsPtr pEventClient; /* Remove the auth using the os layer auth manager */ status = AuthorizationFromID(pAuth->id, &name_len, &name, &data_len, &data); assert(status); status = RemoveAuthorization(name_len, name, data_len, data); assert(status); (void)status; /* free the auth timer if there is one */ if (pAuth->timer) TimerFree(pAuth->timer); /* send revoke events */ while ((pEventClient = pAuth->eventClients)) { /* send revocation event event */ ClientPtr client = rClient(pEventClient); if (!client->clientGone) { xSecurityAuthorizationRevokedEvent are; are.type = SecurityEventBase + XSecurityAuthorizationRevoked; are.sequenceNumber = client->sequence; are.authId = pAuth->id; WriteEventsToClient(client, 1, (xEvent *)&are); } FreeResource(pEventClient->resource, RT_NONE); } /* kill all clients using this auth */ for (i = 1; i<currentMaxClients; i++) if (clients[i]) { SecurityStateRec *state; state = dixLookupPrivate(&clients[i]->devPrivates, stateKey); if (state->haveState && state->authId == pAuth->id) CloseDownClient(clients[i]); } SecurityAudit("revoked authorization ID %d\n", pAuth->id); xfree(pAuth); return Success; } /* SecurityDeleteAuthorization */
void CXTPSyntaxEditTipWnd::OnPaint() { CPaintDC dc(this); // device context for painting CXTPClientRect rClient(this); if (IsOwnerDrawn()) OwnerDrawTip(&dc, rClient); else DrawTip(&dc, rClient); }
//--------------------------------------------------------- inline wxPoint CVIEW_Map_Control::_Get_World2Client(const TSG_Point &Point) { wxRect rClient(GetClientSize()); CSG_Rect rWorld(m_pMap->Get_World(rClient)); double World2Client = (double)rClient.GetWidth() / rWorld.Get_XRange(); return( wxPoint( (int)(0.5 + (Point.x - rWorld.Get_XMin()) * World2Client), rClient.GetHeight() - (int)(0.5 + (Point.y - rWorld.Get_YMin()) * World2Client) )); }
//--------------------------------------------------------- void CVIEW_Map::On_Paint(wxPaintEvent &event) { if( m_Ruler_Size > 1 ) { wxPaintDC dc(this); wxRect rClient(wxPoint(0, 0), GetClientSize()), rMap(rClient); rMap.Deflate(m_Ruler_Size - 1); dc.DrawLine(rMap .GetLeft (), rClient.GetTop (), rMap .GetLeft (), rClient.GetBottom()); dc.DrawLine(rMap .GetRight(), rClient.GetTop (), rMap .GetRight(), rClient.GetBottom()); dc.DrawLine(rClient.GetLeft (), rMap .GetTop (), rClient.GetRight(), rMap .GetTop ()); dc.DrawLine(rClient.GetLeft (), rMap .GetBottom(), rClient.GetRight(), rMap .GetBottom()); } event.Skip(); }
// Invalidates the tab's region in the client area. void Invalidate(int index) { if (index < 0) return; Graphics graphics(hwnd); GraphicsPath shapes(data->Points, data->Types, data->Count); GraphicsPath shape; GraphicsPathIterator iterator(&shapes); iterator.NextMarker(&shape); Region region(&shape); ClientRect rClient(hwnd); REAL yPosTab = inTitlebar ? 0.0f : REAL(rClient.dy - height - 1); graphics.TranslateTransform(REAL((width + 1) * index) + 1.0f, yPosTab); HRGN hRgn = region.GetHRGN(&graphics); InvalidateRgn(hwnd, hRgn, FALSE); DeleteObject(hRgn); }
int LTScreenshotEditDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialog::OnCreate(lpCreateStruct) == -1) return -1; CRect rClient(0,0,0,0); o_ScreenshotEditCtrl.CreateScreenshotEditCtrl(this, rClient); o_ColorPicker.Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rClient, this, 100112); o_ColorPicker.SetCallback(this); p_DrawToolbar = new LTDrawToolBar; p_DrawToolbar->SetListener(this); p_DrawToolbar->Create(NULL, NULL, WS_VISIBLE | WS_CHILD, rClient, this, 10001); // TODO: Add your specialized creation code here return 0; }
void CRuntimeDlg::AutoFit() { // iterate all the child controls accumulating the largest bottom right coord CRect rClient(0, 0, 0, 0); CWnd* pCtrl = GetWindow(GW_CHILD); while (pCtrl) { CRect rCtrl; pCtrl->GetWindowRect(rCtrl); ScreenToClient(rCtrl); rClient.right = max(rClient.right, rCtrl.right); rClient.bottom = max(rClient.bottom, rCtrl.bottom); pCtrl = pCtrl->GetNextWindow(); } // add border rClient.right += m_rBorders.right; rClient.bottom += m_rBorders.bottom; // calc new window rect CRect rWindow; GetWindowRect(rWindow); CalcWindowRect(rClient); rClient = CRect(rWindow.TopLeft(), rClient.Size()); CPoint ptTopLeft = GetInitialPos(); if (ptTopLeft.x != -1 || ptTopLeft.y != -1) rClient.OffsetRect(ptTopLeft - rClient.TopLeft()); else // match centerpoints of old and new rClient.OffsetRect(rWindow.CenterPoint() - rClient.CenterPoint()); MoveWindow(rClient); }
static int SecurityDeleteAuthorization(void *value, XID id) { SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr) value; unsigned short name_len, data_len; const char *name; char *data; int status; int i; OtherClientsPtr pEventClient; /* Remove the auth using the os layer auth manager */ status = AuthorizationFromID(pAuth->id, &name_len, &name, &data_len, &data); assert(status); status = RemoveAuthorization(name_len, name, data_len, data); assert(status); (void) status; /* free the auth timer if there is one */ if (pAuth->timer) TimerFree(pAuth->timer); /* send revoke events */ while ((pEventClient = pAuth->eventClients)) { /* send revocation event event */ xSecurityAuthorizationRevokedEvent are = { .type = SecurityEventBase + XSecurityAuthorizationRevoked, .authId = pAuth->id }; WriteEventsToClient(rClient(pEventClient), 1, (xEvent *) &are); FreeResource(pEventClient->resource, RT_NONE); } /* kill all clients using this auth */ for (i = 1; i < currentMaxClients; i++) if (clients[i]) { SecurityStateRec *state; state = dixLookupPrivate(&clients[i]->devPrivates, stateKey); if (state->haveState && state->authId == pAuth->id) CloseDownClient(clients[i]); } SecurityAudit("revoked authorization ID %lu\n", (unsigned long)pAuth->id); free(pAuth); return Success; } /* SecurityDeleteAuthorization */ /* resource delete function for RTEventClient */ static int SecurityDeleteAuthorizationEventClient(void *value, XID id) { OtherClientsPtr pEventClient, prev = NULL; SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr) value; for (pEventClient = pAuth->eventClients; pEventClient; pEventClient = pEventClient->next) { if (pEventClient->resource == id) { if (prev) prev->next = pEventClient->next; else pAuth->eventClients = pEventClient->next; free(pEventClient); return Success; } prev = pEventClient; } /*NOTREACHED*/ return -1; /* make compiler happy */ } /* SecurityDeleteAuthorizationEventClient */
void CCJOutlookBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle( lpDrawItemStruct->hDC ); CRect rcItem(lpDrawItemStruct->rcItem); CRect rClient(rcItem); CRect rText; CPoint Pt(((rcItem.Width() - 32) /2 ), rcItem.top + 15); CContentItems pContents = m_pContents[ lpDrawItemStruct->itemID ]; HICON hIcon = m_ImageListNormal.ExtractIcon( pContents.GetImageID()); // deflate the client rect, and set up item and // text rect's. rClient.DeflateRect( 8, 5 ); rcItem.CopyRect( rClient ); rText.CopyRect( rClient ); rText.top += 45; rText.bottom += 10; // set the text color to white, and background mode // to transparent. pDC->SetTextColor( ::GetSysColor( COLOR_WINDOW ) ); pDC->SetBkMode( TRANSPARENT ); // draw the button icon and text. if( lpDrawItemStruct->itemAction& ODA_DRAWENTIRE ) { pDC->DrawIcon( Pt, hIcon ); pDC->DrawText( pContents.GetText(), rText, DT_CENTER | DT_WORDBREAK ); } // if the left mouse button is pressed, offset // the button icon. if( m_bLBDown ) { Pt.x += 2; Pt.y += 2; rcItem.OffsetRect( 2, 2 ); } // deflate the button rect, and move up. rcItem.DeflateRect( 4, 16 ); rcItem.top -= 8; // Draw the button icon and text, if the mouse is over the // button, draw the 3d rect, either pressed, // or not pressed depending on left mouse button. if(( lpDrawItemStruct->itemState& ODS_SELECTED ) && ( lpDrawItemStruct->itemAction& ( ODA_SELECT | ODA_DRAWENTIRE ))) { rcItem.left = ( rcItem.Width()/2 )-5; rcItem.right = rcItem.left+37; if( m_bHilight ) { if( m_bLBDown ) { pDC->Draw3dRect( rcItem, ::GetSysColor( COLOR_3DDKSHADOW ), ::GetSysColor( COLOR_BTNFACE ) ); } else { pDC->Draw3dRect( rcItem, ::GetSysColor( COLOR_BTNFACE ), ::GetSysColor( COLOR_3DDKSHADOW ) ); } } pDC->DrawIcon( Pt, hIcon ); pDC->DrawText( pContents.GetText(), rText, DT_CENTER | DT_WORDBREAK ); } if( !( lpDrawItemStruct->itemState& ODS_SELECTED ) && ( lpDrawItemStruct->itemAction& ODA_SELECT )) { pDC->FillSolidRect( rClient, ::GetSysColor( COLOR_3DSHADOW ) ); pDC->DrawIcon(Pt, hIcon); pDC->DrawText(pContents.GetText(), rText, DT_CENTER|DT_WORDBREAK); } }
void CIconListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your code to draw the specified item CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if ((int)lpDrawItemStruct->itemID < 0) { // If there are no elements in the List Box // based on whether the list box has Focus or not // draw the Focus Rect or Erase it, if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && (lpDrawItemStruct->itemState & ODS_FOCUS)) { pDC->DrawFocusRect(&lpDrawItemStruct->rcItem); } else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && !(lpDrawItemStruct->itemState & ODS_FOCUS)) { pDC->DrawFocusRect(&lpDrawItemStruct->rcItem); } return; } CRect rcItem(lpDrawItemStruct->rcItem); // To draw the focus rect. CRect rClient(rcItem); // Rect to highlight the Item CRect rText(rcItem); // Rect To display the Text CPoint Pt( rcItem.left , rcItem.top ); // Point To draw the Image // if the Image list exists for the list box // adjust the Rect sizes to accomodate the Image for each item. if(m_pImageList) { rClient.left += 16; rText.left += 16; rText.top += 2; } else { rText.top += 2; } COLORREF crText; CString strText; // Image information in the item data. int iImg = (int)lpDrawItemStruct->itemData; // If item selected, draw the highlight rectangle. // Or if item deselected, draw the rectangle using the window color. if ((lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE))) { CBrush br(::GetSysColor(COLOR_HIGHLIGHT)); pDC->FillRect(&rClient, &br); } else if (!(lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & ODA_SELECT)) { CBrush br(::GetSysColor(COLOR_WINDOW)); pDC->FillRect(&rClient, &br); } // If the item has focus, draw the focus rect. // If the item does not have focus, erase the focus rect. if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && (lpDrawItemStruct->itemState & ODS_FOCUS)) { pDC->DrawFocusRect(&rcItem); } else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && !(lpDrawItemStruct->itemState & ODS_FOCUS)) { pDC->DrawFocusRect(&rcItem); } // To draw the Text set the background mode to Transparent. int iBkMode = pDC->SetBkMode(TRANSPARENT); if (lpDrawItemStruct->itemState & ODS_SELECTED) crText = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); else if (lpDrawItemStruct->itemState & ODS_DISABLED) crText = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT)); else crText = pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); // Get the item text. GetText(lpDrawItemStruct->itemID, strText); // Setup the text format. UINT nFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER; if (GetStyle() & LBS_USETABSTOPS) nFormat |= DT_EXPANDTABS; // if the ImageList is Existing and there is an associated Image // for the Item, draw the Image. if(m_pImageList && (iImg != -1 ) ) m_pImageList->Draw(pDC,iImg,Pt,ILD_NORMAL); //Draw the Text pDC->DrawText(strText, -1, &rText, nFormat | DT_CALCRECT); pDC->DrawText(strText, -1, &rText, nFormat); pDC->SetTextColor(crText); pDC->SetBkMode(iBkMode); }
void CIconListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your code to draw the specified item CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if (((LONG)(lpDrawItemStruct->itemID) >= 0) && (lpDrawItemStruct->itemAction & (ODA_DRAWENTIRE | ODA_SELECT))){ CRect rcItem(lpDrawItemStruct->rcItem); // To draw the focus rect. CRect rClient(rcItem.left,rcItem.top,rcItem.right,rcItem.bottom); // Rect to highlight the Item CRect rText(rClient); // Rect To display the Text CPoint Pt( rClient.left , rClient.top ); // Point To draw the Image // if the Image list exists for the list box // adjust the Rect sizes to accomodate the Image for each item. int cyItem = GetItemHeight(lpDrawItemStruct->itemID); if (m_cyText == 0) { CClientDC dc(this); CFont* pOldFont = dc.SelectObject(GetFont()); TEXTMETRIC tm; VERIFY (dc.GetTextMetrics ( &tm )); dc.SelectObject(pOldFont); m_cyText = tm.tmHeight; } if(m_pImageList) { rClient.left += 32; rText.left += 32; rText.top += max(0, (cyItem - m_cyText) / 2); } else { rText.top += max(0, (cyItem - m_cyText) / 2); } COLORREF crText; CString strText; // Image information in the item data. int iImg = (int)lpDrawItemStruct->itemData; // If item selected, draw the highlight rectangle. // Or if item deselected, draw the rectangle using the window color. if ((lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE))) { CBrush br(::GetSysColor(COLOR_HIGHLIGHT)); //CRect r(rcItem.left+10,rcItem.top,rcItem.right,rcItem.bottom); pDC->FillRect(&rClient, &br); } else if (!(lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & ODA_SELECT)) { CBrush br(::GetSysColor(COLOR_WINDOW)); //CRect r(rcItem.left+10,rcItem.top,rcItem.right,rcItem.bottom); pDC->FillRect(&rClient, &br); } // If the item has focus, draw the focus rect. // If the item does not have focus, erase the focus rect. if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && (lpDrawItemStruct->itemState & ODS_FOCUS)) { pDC->DrawFocusRect(&rcItem); } else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && !(lpDrawItemStruct->itemState & ODS_FOCUS)) { pDC->DrawFocusRect(&rcItem); } // To draw the Text set the background mode to Transparent. //lpDrawItemStruct->CtlID if (lpDrawItemStruct->itemState & ODS_SELECTED) crText = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); else if (lpDrawItemStruct->itemState & ODS_DISABLED) crText = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT)); else crText = pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); // Get the item text. GetText(lpDrawItemStruct->itemID, strText); int iBkMode = pDC->SetBkMode(TRANSPARENT); // Setup the text format. UINT nFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER; if (GetStyle() & LBS_USETABSTOPS) nFormat |= DT_EXPANDTABS; // if the ImageList is Existing and there is an associated Image // for the Item, draw the Image. if(m_pImageList && (iImg != -1 )){ m_pImageList->Draw(pDC,iImg,Pt,ILD_NORMAL); CPen myPen; myPen.CreatePen(PS_SOLID,2,RGB(255,0,0)); pDC->SetROP2(R2_NOTXORPEN); CPen* oldPen=pDC->SelectObject(&myPen); pDC->Rectangle(Pt.x,Pt.y,Pt.x+32,Pt.y+32); pDC->SelectObject(oldPen); } //Draw the Text pDC->DrawText(strText, -1, &rText, nFormat | DT_CALCRECT); pDC->DrawText(strText, -1, &rText, nFormat); pDC->SetTextColor(crText); pDC->SetBkMode(iBkMode); } }