EVisibility STransformHandle::GetHandleVisibility() const { ETransformMode::Type TransformMode = Designer->GetTransformMode(); // Only show the handles for visible elements in the designer. FWidgetReference SelectedWidget = Designer->GetSelectedWidget(); if ( SelectedWidget.IsValid() ) { if ( !SelectedWidget.GetTemplate()->bHiddenInDesigner ) { switch ( TransformMode ) { case ETransformMode::Layout: { if ( UPanelSlot* TemplateSlot = SelectedWidget.GetTemplate()->Slot ) { if ( CanResize(TemplateSlot, DragDirection) ) { return EVisibility::Visible; } } break; } case ETransformMode::Render: return EVisibility::Visible; } } } return EVisibility::Collapsed; }
void CMFString::Append( const wchar_t* wszValue ) { HandleErrorOnCond(!m_Flags.fWideChar, "Invalid string format"); size_t newsize = LenToSize(m_BufferSize + wcslen(wszValue), sizeof(wchar_t)); if ( newsize > m_BufferSize && CanResize() ) Resize(newsize); wcscat_s(m_Buffer.pWChar, BufferLen(), wszValue); }
void CMFString::Append( const char* szValue ) { HandleErrorOnCond(!m_Flags.fChar, "Invalid string format"); size_t newsize = LenToSize(m_BufferSize + strlen(szValue), sizeof(char)); if ( newsize > m_BufferSize && CanResize() ) Resize(newsize); strcat_s(m_Buffer.pChar, BufferLen(), szValue); }
void CMFString::Set(const wchar_t* wszValue) { if ( wszValue == NULL ) { ReleaseBuffer(); return; } size_t newsize = LenToSize(wcslen(wszValue) + 1, sizeof(wchar_t)); if ( newsize > m_BufferSize && CanResize() ) Resize( newsize ); m_Flags.fWideChar = 1; m_Flags.fChar = 0; wcscpy_s(m_Buffer.pWChar, BufferLen(), wszValue); }
void CMFString::FromCharToWideChar( const char* szString ) { NyxAssert( NULL != szString, "invalid ansi string : null pointer" ); NyxAssert( m_Flags.fWideChar, "destination string isn't wide char" ); size_t Len = strlen(szString); size_t NewLen = MultiByteToWideChar(CP_ACP, MB_COMPOSITE, szString, (int)Len, NULL, 0); size_t nRequiredSize = LenToSize( NewLen+1, sizeof(wchar_t) ); if ( nRequiredSize > 0 ) { if ( CanResize() && nRequiredSize > m_BufferSize ) Resize(nRequiredSize); MultiByteToWideChar(CP_ACP, MB_COMPOSITE, szString, (int)Len, m_Buffer.pWChar, (int)BufferLen() ); m_Buffer.pWChar[NewLen] = 0; } }
void CMFString::Set(const char* szValue, EStringsFormat format) { if ( szValue == NULL ) { ReleaseBuffer(); return; } size_t newsize = LenToSize(strlen(szValue) + 1, sizeof(char)); if ( newsize > m_BufferSize && CanResize() ) Resize( newsize ); m_Flags.fChar = 1; m_Flags.fWideChar = 0; m_Format = format; strcpy_s(m_Buffer.pChar, BufferLen(), szValue); }
void CMFString::FromWideCharToChar( const wchar_t* wszString ) { NyxAssert( NULL != wszString, "invalid wide string : null pointer" ); NyxAssert( m_Flags.fChar, "destination string isn't ansi" ); size_t RequiredSize = 0; size_t SrcLen = wcslen(wszString); size_t NewLen = 0; NewLen = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wszString, (int)SrcLen, NULL, 0, " ", NULL); RequiredSize = LenToSize(NewLen+1, sizeof(char)); if ( RequiredSize > 0 ) { if ( CanResize() && RequiredSize > m_BufferSize ) Resize(RequiredSize); WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wszString, (int)SrcLen, m_Buffer.pChar, (int)BufferLen(), " ", NULL); m_Buffer.pChar[NewLen] = 0; } }
void COXSizeControlBar::OnLButtonDown(UINT nFlags, CPoint point) { if(!IsFloating()) { CPoint ptTest=point; // handle mouse click over close, restore buttons // m_pressedBtn=NONE; if(m_rectCloseBtn.PtInRect(ptTest)) { SetCapture(); m_pressedBtn=CLOSEBTN; RedrawCloseBtn(); return; } else if(m_rectResizeBtn.PtInRect(ptTest)) { if(CanResize()) { SetCapture(); m_pressedBtn=RESIZEBTN; RedrawResizeBtn(); } return; } else if (AfxGetMainWnd()->SendMessage(WM_QUERYSNAPPING)) { m_ptLButtonDown = point; m_bOkToDrag = TRUE; return; } } CControlBar::OnLButtonDown(nFlags, point); }
void CDock::ResizeDock(long nWidth, long nHeight) { DWORD n; CArea * pArea; DWORD nCurIter; m_nHeight = nHeight; m_nWidth = nWidth; // cleanup resize iteration // update fixed position for(n = 0; n < m_Areas.GetCount(); n++) { pArea = m_Areas.GetAt(n); pArea->m_nResizeIter = 1; if(pArea->m_posFixed.left != 0.0) { pArea->m_rc.left = LONG(m_nWidth * pArea->m_posFixed.left); pArea->m_rc.right = LONG(pArea->m_rc.left + pArea->m_posFixed.width); } if(pArea->m_posFixed.top != 0.0) { pArea->m_rc.top = LONG(m_nHeight * pArea->m_posFixed.top); pArea->m_rc.bottom = LONG(pArea->m_rc.top + pArea->m_posFixed.height); } } // resize stock panes m_StockLeft.m_rc.bottom = nHeight; m_StockRight.m_rc.left = m_StockRight.m_rc.right = nWidth; m_StockRight.m_rc.bottom = nHeight; m_StockTop.m_rc.right = nWidth; m_StockBottom.m_rc.right = nWidth; m_StockBottom.m_rc.bottom = m_StockBottom.m_rc.top = nHeight; // run through all panes and resize for(nCurIter = 0; nCurIter < 100; nCurIter++) { for(n = 0; n < m_Areas.GetCount(); n++) { pArea = m_Areas.GetAt(n); if(pArea->m_nResizeIter >= nCurIter) { // we can resize if we already resized all attached if(CanResize(pArea)) { ResizePane(pArea); } else { pArea->m_nResizeIter = nCurIter+1; } } } } // update position for all windows for(n = 0; n < m_Areas.GetCount(); n++) { pArea = m_Areas.GetAt(n); if(pArea->m_pWindow) { pArea->m_pWindow->SetWindowPos(HWND_BOTTOM, &(pArea->m_rc), SWP_NOZORDER); } } }
//***************************************************************************** bool CHTMLWidget::Parse( //Parse text buffer and add child widgets for each part. // //Params: const CStretchyBuffer &text) //(in) Text to parse. // //Returns: True if parse was successful, false if there was a parse error. { //Renderer init. ClearChildren(); this->wCurrentColumn = this->wX = 0; this->wY = this->wMargin; this->bSkipSpace = true; this->dwCurrentLinkTag = this->dwLinkTagStart; for (int i = First_Tag; i <= Tag_Count; ++i) // Including unknown aeTagLevel[i] = 0; mIdmap.clear(); static const WCHAR defaultColor[] = {We('F'),We('F'),We('F'),We('F'),We('F'),We('F'),We(0)}; this->wstrBGColor = defaultColor; //Parser init. XML_Parser parser = XML_ParserCreate(NULL); XML_SetUserData(parser, this); XML_SetElementHandler(parser, StartElement_cb, EndElement_cb); XML_SetCharacterDataHandler(parser, InElement_cb); // XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_NEVER); bool bResult = true; char *buf = (char*)(BYTE*)text; //size - 2 seems to fix "invalid token" errors at EOF (even at empty files). const UINT size = text.Size() - 2; //Parse the XML. static const char entities[] = "<?xml version=\"1.0\" encoding=\"" "UTF-8" "\"?>" "<!DOCTYPE html [" "<!ENTITY nbsp \"\xc2\xa0\">" //utf-8 for 0xa0 = unicode nbsp "]>"; if ((XML_Parse(parser, entities, strlen(entities), false) == XML_STATUS_ERROR) || (XML_Parse(parser, buf, size, true) == XML_STATUS_ERROR)) { //Some problem occurred. char errorStr[256]; _snprintf(errorStr, 256, "HTML Parse Error: %s at line %u:%u" NEWLINE, XML_ErrorString(XML_GetErrorCode(parser)), (UINT)XML_GetCurrentLineNumber(parser), (UINT)XML_GetCurrentColumnNumber(parser)); CFiles Files; Files.AppendErrorLog((char *)errorStr); #ifdef RUSSIAN_BUILD //Fix unsupported KOI8 encoded Cyrillic chars. // ConvertCyrillicEncodedXMLToUTF8(text); #endif AsciiToUnicode(errorStr, this->wstrStatus); bResult = false; } //Parser clean-up. XML_ParserFree(parser); NewLine(); //once done, ensure final line of text is included in height NewLine(true); //...and have a blank line at the bottom to look good //Render surface to display on screen. bool bCanResize = CanResize(); if (bCanResize) { this->pParent->ScrollAbsolute(0, 0); //scroll to top of page if (this->wY < this->pParent->GetH()) //stretch surface to fill container this->wY = this->pParent->GetH(); } UpdateHTMLSurface(); //Resize (if possible). if (bCanResize) Resize(this->pHTMLSurface->w, this->pHTMLSurface->h); return bResult; }
void COXSizeControlBar::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if(::GetCapture()==GetSafeHwnd()) { SIZEBARBTN pressedBtn=NONE; if(m_rectCloseBtn.PtInRect(point)) { pressedBtn=CLOSEBTN; } else if(m_rectResizeBtn.PtInRect(point) && CanResize()) { pressedBtn=RESIZEBTN; } if(m_pressedBtn!=pressedBtn) m_pressedBtn=pressedBtn; } RedrawButtons(); // In order to start dragging the left button must be down and the current point // must be at least 3 pixels away from the point where the button was pressed if (!m_bDragging && m_bOkToDrag && (nFlags & MK_LBUTTON) && (abs(point.x - m_ptLButtonDown.x) > 3 || abs(point.y - m_ptLButtonDown.y) > 3)) { m_bOkToDrag = FALSE; // reset the flag // Start dragging SaveMouseOffset(point); m_bDragging = TRUE; SetCapture(); ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEALL)); return; } // If we are already dragging if (m_bDragging) { CPoint ptScreen = point; ClientToScreen(&point); // Get the appropriate dock bar. If one is not found then float. CFrameWnd* pFrameWnd = DYNAMIC_DOWNCAST(CFrameWnd, ::AfxGetMainWnd()); if (pFrameWnd == NULL) { ReleaseCapture(); m_bDragging = FALSE; return; } // Handle pending WM_PAINT messages MSG msg; while (::PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_NOREMOVE)) { if (!GetMessage(&msg, NULL, WM_PAINT, WM_PAINT)) { ReleaseCapture(); m_bDragging = FALSE; return; } DispatchMessage(&msg); } if (m_pDockContext == NULL) pFrameWnd->FloatControlBar(this, point); else { COXSizeDockBar* pDockBar = COXSizeDockBar::GetAppropriateDockBar(point, this); if (pDockBar == NULL || nFlags & MK_CONTROL) { if (m_pDockBar != NULL) { COXSizeDockBar* pSizeDockBar = DYNAMIC_DOWNCAST(COXSizeDockBar, m_pDockBar); if (pSizeDockBar != NULL) pSizeDockBar->m_wndDockTabCtrl.RemoveTab(this); } pFrameWnd->FloatControlBar(this, point - m_ptOffset); } else { // Determine the docking rectangle CRect rectWindow; GetWindowRect(rectWindow); CRect rectDock; rectDock.SetRect(point.x, point.y, point.x + rectWindow.Width(), point.y + rectWindow.Height()); pDockBar->DockControlBar(this, rectDock); } } } else CControlBar::OnMouseMove(nFlags, point); }
int COXMulticlipboardDlg::AdjustSize(UINT nLast) { CRect rectDialog; CRect rectClient; CRect rectDesired; CRect rectStatic; CRect rect; GetClientRect(&rectClient); GetWindowRect(&rectDialog); //calculate desired rect for specified number //of the pockets CalculateDesiredRect(nLast+1, rectDesired); if (rectDesired==rectClient) { //it has the same size, //just make sure the pockets are //placed properly MovePockets(nLast); MoveStatic(); GetClientRect(&rect); InvalidateRect(&rect); return nLast+1; } //well, desired size is different from what we have //can we resize the dialog? if (CanResize()) { CRect rectOffset; rectOffset=rectDesired; rectOffset-=rectClient; rectDialog+=rectOffset; //move dialog to approved position MoveWindow(&rectDialog); //calculate and move static to a new position MoveStatic(); //move buttons to new positions MovePockets(nLast); GetClientRect(&rect); InvalidateRect(&rect); return nLast+1; } //no, cannot resize MoveStatic(); //calculate number of the pockets currently can be placed //on this dialog int n=0; for (n=nLast;n>=0;n--) { GetProposedRect(n,rect); rect.InflateRect(GetEdgeOffset(),GetEdgeOffset()); if (rectClient.PtInRect(rect.BottomRight()) && rectClient.PtInRect(rect.TopLeft())) break; } MovePockets(nLast); GetClientRect(&rect); InvalidateRect(&rect); return n+1; }