Example #1
0
nsSVGForeignObjectFrame::GetFrameForPoint(const nsPoint &aPoint)
{
  if (IsDisabled() || (GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD))
    return nsnull;

  nsIFrame* kid = GetFirstChild(nsnull);
  if (!kid)
    return nsnull;

  float x, y, width, height;
  static_cast<nsSVGElement*>(mContent)->
    GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);

  gfxMatrix tm = GetCanvasTM().Invert();
  if (tm.IsSingular())
    return nsnull;
  
  // Convert aPoint from app units in canvas space to user space:

  gfxPoint pt = gfxPoint(aPoint.x, aPoint.y) / PresContext()->AppUnitsPerDevPixel();
  pt = tm.Transform(pt);

  if (!gfxRect(0.0f, 0.0f, width, height).Contains(pt))
    return nsnull;

  // Convert pt to app units in *local* space:

  pt = pt * nsPresContext::AppUnitsPerCSSPixel();
  nsPoint point = nsPoint(NSToIntRound(pt.x), NSToIntRound(pt.y));

  nsIFrame *frame = nsLayoutUtils::GetFrameForPoint(kid, point);
  if (frame && nsSVGUtils::HitTestClip(this, aPoint))
    return frame;

  return nsnull;
}
wxTreeItemId BFBackupTree::FindItem (wxTreeItemId idStart, BFoid oid)
{
    wxTreeItemId            idCurr, idLast;
    wxTreeItemIdValue       idCookie;

    // check start item
    if (HasOID(idStart, oid))
        return idStart;

    if (ItemHasChildren(idStart))
    {
        for (idCurr = GetFirstChild(idStart, idCookie);
             idCurr.IsOk();
             idCurr = GetNextChild(idStart, idCookie))
        {
            idLast = FindItem(idCurr, oid);

            if (idLast.IsOk())
                return idLast;
        }
    }

    return wxTreeItemId();
}
nsresult XULTooltipElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
                                         const nsAttrValue* aValue,
                                         const nsAttrValue* aOldValue,
                                         nsIPrincipal* aSubjectPrincipal,
                                         bool aNotify) {
  if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::label) {
    // When the label attribute of this node changes propagate the text down
    // into child description element.
    nsCOMPtr<nsIContent> description = GetFirstChild();
    if (description && description->IsXULElement(nsGkAtoms::description)) {
      nsAutoString value;
      if (aValue) {
        aValue->ToString(value);
      }
      nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
          "XULTooltipElement::AfterSetAttr", [description, value]() {
            Element* descriptionElement = description->AsElement();
            descriptionElement->SetTextContent(value, IgnoreErrors());
          }));
    }
  }
  return nsXULElement::AfterSetAttr(aNameSpaceID, aName, aValue, aOldValue,
                                    aSubjectPrincipal, aNotify);
}
void CFormulaNode::RecalculateSize( int bRecalc )
{
	SizeFde sz( 0, 0 );
	int i = 0;

	sz = CFormulaExCalc::RecalculateSize( this );
	if( (i = RecalculateGrph( this, regetActiveCalc() )) != 0 )
	{
		sz = CFormulaExCalc::RecalculateSize( this );
		i = RecalculateGrph( this, regetActiveCalc() );
	}
	if( isHiddenNDisabled() )
	{
		sz.rwidth() = 0;
		if( GetParent() && GetParent()->GetSize().height() > 0 )
			sz.rheight() = GetParent()->GetSize().height();
		else
			sz.rheight() = GetDefaultSize().height();
	}
	Recalculate_VerticalCenter( sz );

	//=== 'mpadded' MathML element
	if( !isHiddenNDisabled() &&
		getAlignmentType() == FBtnChildPos::MSPACE_Exact_HeightDepth )
	{
		RealFde newValues[ MML_MPADDED_UNITS_LEN ] = { 0.0, 0.0, 0.0, 0.0 };
		RealFde childValues[ MML_MPADDED_UNITS_LEN ] = { 0.0, 0.0, 0.0, 0.0 };
		int iRet[ MML_MPADDED_UNITS_LEN ] = { -1, -1, -1, -1 };
		getChildDimensions_Vertical( childValues );
		getChildDimensions_Horizontal( childValues );

		getMathMLAttr().parseMPaddedAttr( newValues, childValues, iRet, ::getCurrentFormulatorStyle().getUnit2PX() );

		RealFde paddedLSpace = 0.0, paddedRSpace = 0.0;
		if( iRet[ MML_MPADDED_UNITS_LSPACE ] == 0 )
		{
			paddedLSpace = newValues[ MML_MPADDED_UNITS_LSPACE ];
		}
		if( iRet[ MML_MPADDED_UNITS_WIDTH ] == 0 )
		{
			RealFde width = newValues[ MML_MPADDED_UNITS_WIDTH ];
			RealFde delta = width - (paddedLSpace + childValues[ MML_MPADDED_UNITS_WIDTH ]);
			if( delta >= 0.0 )
				paddedRSpace = delta;
			else
			{
				paddedLSpace = width - childValues[ MML_MPADDED_UNITS_WIDTH ];
				if( paddedLSpace < 0.0 )
				{
					sz.rwidth() = width;
					paddedLSpace = 0.0;
				}
			}
		}

		RealFde paddedTSpace = 0.0, paddedBSpace = 0.0;
		if( iRet[ MML_MPADDED_UNITS_HEIGHT ] == 0 )
		{
			RealFde height = newValues[ MML_MPADDED_UNITS_HEIGHT ];
			RealFde delta = height - childValues[ MML_MPADDED_UNITS_HEIGHT ];
			if( delta >= 0 )
				paddedTSpace = delta;
			else
			{
				// not feasible 
			}
		}
		if( iRet[ MML_MPADDED_UNITS_DEPTH ] == 0 )
		{
			RealFde delta = newValues[ MML_MPADDED_UNITS_DEPTH ] - childValues[ MML_MPADDED_UNITS_DEPTH ];
			if( delta >= 0 )
				paddedBSpace = delta;
			else
			{
				// not feasible 
			}
		}

		if( paddedLSpace || paddedRSpace || paddedTSpace || paddedBSpace )
		{
			CNode *pNode = GetFirstChild();
			if( pNode && pNode->GetType() == NODE_FRAME )
			{
				CFrameNode *n1st = (CFrameNode*)pNode;
				n1st->setLeftIndent( paddedLSpace );
				n1st->setRightIndent( paddedRSpace );
				n1st->setTopIndent( paddedTSpace );
				n1st->setBottomIndent( paddedBSpace );
			}
		}
	}

	if( sz != GetSize() || i )
		SetSize( sz );

	if( bRecalc )
		GetParent()->RecalculateSize( bRecalc );
}
Example #5
0
nsresult
nsTextControlFrame::CalcIntrinsicSize(nsRenderingContext* aRenderingContext,
                                      nsSize&              aIntrinsicSize)
{
  // Get leading and the Average/MaxAdvance char width 
  nscoord lineHeight  = 0;
  nscoord charWidth   = 0;
  nscoord charMaxAdvance  = 0;

  nsRefPtr<nsFontMetrics> fontMet;
  nsresult rv =
    nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
  NS_ENSURE_SUCCESS(rv, rv);
  aRenderingContext->SetFont(fontMet);

  lineHeight =
    nsHTMLReflowState::CalcLineHeight(GetStyleContext(), NS_AUTOHEIGHT);
  charWidth = fontMet->AveCharWidth();
  charMaxAdvance = fontMet->MaxAdvance();

  // Set the width equal to the width in characters
  PRInt32 cols = GetCols();
  aIntrinsicSize.width = cols * charWidth;

  // To better match IE, take the maximum character width(in twips) and remove
  // 4 pixels add this on as additional padding(internalPadding). But only do
  // this if charMaxAdvance != charWidth; if they are equal, this is almost
  // certainly a fixed-width font.
  if (charWidth != charMaxAdvance) {
    nscoord internalPadding = NS_MAX(0, charMaxAdvance -
                                        nsPresContext::CSSPixelsToAppUnits(4));
    nscoord t = nsPresContext::CSSPixelsToAppUnits(1); 
   // Round to a multiple of t
    nscoord rest = internalPadding % t; 
    if (rest < t - rest) {
      internalPadding -= rest;
    } else {
      internalPadding += t - rest;
    }
    // Now add the extra padding on (so that small input sizes work well)
    aIntrinsicSize.width += internalPadding;
  } else {
    // This is to account for the anonymous <br> having a 1 twip width
    // in Full Standards mode, see BRFrame::Reflow and bug 228752.
    if (PresContext()->CompatibilityMode() == eCompatibility_FullStandards) {
      aIntrinsicSize.width += 1;
    }

    // Also add in the padding of our value div child.  Note that it hasn't
    // been reflowed yet, so we can't get its used padding, but it shouldn't be
    // using percentage padding anyway.
    nsMargin childPadding;
    nsIFrame* firstChild = GetFirstChild(nsnull);
    if (firstChild && firstChild->GetStylePadding()->GetPadding(childPadding)) {
      aIntrinsicSize.width += childPadding.LeftRight();
    } else {
      NS_ERROR("Percentage padding on value div?");
    }
  }

  // Increment width with cols * letter-spacing.
  {
    const nsStyleCoord& lsCoord = GetStyleText()->mLetterSpacing;
    if (eStyleUnit_Coord == lsCoord.GetUnit()) {
      nscoord letterSpacing = lsCoord.GetCoordValue();
      if (letterSpacing != 0) {
        aIntrinsicSize.width += cols * letterSpacing;
      }
    }
  }

  // Set the height equal to total number of rows (times the height of each
  // line, of course)
  aIntrinsicSize.height = lineHeight * GetRows();

  // Add in the size of the scrollbars for textarea
  if (IsTextArea()) {
    nsIFrame* first = GetFirstChild(nsnull);

    nsIScrollableFrame *scrollableFrame = do_QueryFrame(first);
    NS_ASSERTION(scrollableFrame, "Child must be scrollable");

    if (scrollableFrame) {
      nsMargin scrollbarSizes =
      scrollableFrame->GetDesiredScrollbarSizes(PresContext(), aRenderingContext);

      aIntrinsicSize.width  += scrollbarSizes.LeftRight();

      aIntrinsicSize.height += scrollbarSizes.TopBottom();;
    }
  }

  return NS_OK;
}
NS_IMETHODIMP
nsMathMLmfencedFrame::Reflow(nsPresContext*          aPresContext,
                             nsHTMLReflowMetrics&     aDesiredSize,
                             const nsHTMLReflowState& aReflowState,
                             nsReflowStatus&          aStatus)
{
  nsresult rv;
  aDesiredSize.width = aDesiredSize.height = 0;
  aDesiredSize.ascent = 0;
  aDesiredSize.mBoundingMetrics = nsBoundingMetrics();

  PRInt32 i;
  const nsStyleFont* font = GetStyleFont();
  nsRefPtr<nsFontMetrics> fm;
  nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
  aReflowState.rendContext->SetFont(fm);
  nscoord axisHeight, em;
  GetAxisHeight(*aReflowState.rendContext, fm, axisHeight);
  GetEmHeight(fm, em);
  // leading to be left at the top and the bottom of stretched chars
  nscoord leading = NSToCoordRound(0.2f * em); 

  /////////////
  // Reflow children
  // Asking each child to cache its bounding metrics

  // Note that we don't use the base method nsMathMLContainerFrame::Reflow()
  // because we want to stretch our fences, separators and stretchy frames using
  // the *same* initial aDesiredSize.mBoundingMetrics. If we were to use the base
  // method here, our stretchy frames will be stretched and placed, and we may
  // end up stretching our fences/separators with a different aDesiredSize.
  // XXX The above decision was revisited in bug 121748 and this code can be
  // refactored to use nsMathMLContainerFrame::Reflow() at some stage.

  nsReflowStatus childStatus;
  nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
  nsIFrame* firstChild = GetFirstChild(nsnull);
  nsIFrame* childFrame = firstChild;
  nscoord ascent = 0, descent = 0;
  if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
    // We use the ASCII metrics to get our minimum height. This way,
    // if we have borders or a background, they will fit better with
    // other elements on the line.
    ascent = fm->MaxAscent();
    descent = fm->MaxDescent();
  }
  while (childFrame) {
    nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
                                         | NS_REFLOW_CALC_BOUNDING_METRICS);
    nsHTMLReflowState childReflowState(aPresContext, aReflowState,
                                       childFrame, availSize);
    rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
                     childReflowState, childStatus);
    //NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
    if (NS_FAILED(rv)) {
      // Call DidReflow() for the child frames we successfully did reflow.
      DidReflowChildren(firstChild, childFrame);
      return rv;
    }

    SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
                                    childDesiredSize.mBoundingMetrics);

    nscoord childDescent = childDesiredSize.height - childDesiredSize.ascent;
    if (descent < childDescent)
      descent = childDescent;
    if (ascent < childDesiredSize.ascent)
      ascent = childDesiredSize.ascent;

    childFrame = childFrame->GetNextSibling();
  }

  /////////////
  // Ask stretchy children to stretch themselves

  nsBoundingMetrics containerSize;
  nsStretchDirection stretchDir = NS_STRETCH_DIRECTION_VERTICAL;

  GetPreferredStretchSize(*aReflowState.rendContext,
                          0, /* i.e., without embellishments */
                          stretchDir, containerSize);
  childFrame = firstChild;
  while (childFrame) {
    nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame);
    if (mathmlChild) {
      nsHTMLReflowMetrics childDesiredSize;
      // retrieve the metrics that was stored at the previous pass
      GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
                                     childDesiredSize.mBoundingMetrics);
      
      mathmlChild->Stretch(*aReflowState.rendContext, 
                           stretchDir, containerSize, childDesiredSize);
      // store the updated metrics
      SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
                                      childDesiredSize.mBoundingMetrics);
      
      nscoord childDescent = childDesiredSize.height - childDesiredSize.ascent;
      if (descent < childDescent)
        descent = childDescent;
      if (ascent < childDesiredSize.ascent)
        ascent = childDesiredSize.ascent;
    }
    childFrame = childFrame->GetNextSibling();
  }

  // bug 121748: for surrounding fences & separators, use a size that covers everything
  GetPreferredStretchSize(*aReflowState.rendContext,
                          STRETCH_CONSIDER_EMBELLISHMENTS,
                          stretchDir, containerSize);

  //////////////////////////////////////////
  // Prepare the opening fence, separators, and closing fence, and
  // adjust the origin of children.

  // we need to center around the axis
  nscoord delta = NS_MAX(containerSize.ascent - axisHeight, 
                         containerSize.descent + axisHeight);
  containerSize.ascent = delta + axisHeight;
  containerSize.descent = delta - axisHeight;

  /////////////////
  // opening fence ...
  ReflowChar(aPresContext, *aReflowState.rendContext, mOpenChar,
             NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel, 
             axisHeight, leading, em, containerSize, ascent, descent);
  /////////////////
  // separators ...
  for (i = 0; i < mSeparatorsCount; i++) {
    ReflowChar(aPresContext, *aReflowState.rendContext, &mSeparatorsChar[i],
               NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel,
               axisHeight, leading, em, containerSize, ascent, descent);
  }
  /////////////////
  // closing fence ...
  ReflowChar(aPresContext, *aReflowState.rendContext, mCloseChar,
             NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel,
             axisHeight, leading, em, containerSize, ascent, descent);

  //////////////////
  // Adjust the origins of each child.
  // and update our bounding metrics

  i = 0;
  nscoord dx = 0;
  nsBoundingMetrics bm;
  PRBool firstTime = PR_TRUE;
  if (mOpenChar) {
    PlaceChar(mOpenChar, ascent, bm, dx);
    aDesiredSize.mBoundingMetrics = bm;
    firstTime = PR_FALSE;
  }

  childFrame = firstChild;
  while (childFrame) {
    nsHTMLReflowMetrics childSize;
    GetReflowAndBoundingMetricsFor(childFrame, childSize, bm);
    if (firstTime) {
      firstTime = PR_FALSE;
      aDesiredSize.mBoundingMetrics  = bm;
    }
    else  
      aDesiredSize.mBoundingMetrics += bm;

    FinishReflowChild(childFrame, aPresContext, nsnull, childSize, 
                      dx, ascent - childSize.ascent, 0);
    dx += childSize.width;

    if (i < mSeparatorsCount) {
      PlaceChar(&mSeparatorsChar[i], ascent, bm, dx);
      aDesiredSize.mBoundingMetrics += bm;
    }
    i++;

    childFrame = childFrame->GetNextSibling();
  }

  if (mCloseChar) {
    PlaceChar(mCloseChar, ascent, bm, dx);
    if (firstTime)
      aDesiredSize.mBoundingMetrics  = bm;
    else  
      aDesiredSize.mBoundingMetrics += bm;
  }

  aDesiredSize.width = aDesiredSize.mBoundingMetrics.width;
  aDesiredSize.height = ascent + descent;
  aDesiredSize.ascent = ascent;

  SetBoundingMetrics(aDesiredSize.mBoundingMetrics);
  SetReference(nsPoint(0, aDesiredSize.ascent));

  // see if we should fix the spacing
  FixInterFrameSpacing(aDesiredSize);

  // Finished with these:
  ClearSavedChildMetrics();

  // Set our overflow area
  GatherAndStoreOverflow(&aDesiredSize);

  aStatus = NS_FRAME_COMPLETE;
  NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
  return NS_OK;
}
Example #7
0
void DoFontDetails(HWND hwnd,
                         TCHAR *str, size_t SizeofStr,
                         TCHAR *title, size_t SizeofTitle)
{	
	int        index;
	HWND       hwndChild;
	HCOMPONENT hFontHandle;
	DWORD      dwSize, dwResult;
	HCURSOR    hOldCursor;
#ifndef WIN32
	FARPROC    lpfnDlgProc;
#endif

	if (!(hwndChild = GetDlgItem(hwnd, IDC_FONTLIST)))
	{
		return;
	}

	if ((index = ListBox_GetCurSel(hwndChild)) == LB_ERR)
	{
		return;
	}

  	if (!(hFontHandle =
	     (HCOMPONENT)ListBox_GetItemData(hwndChild, index)))
	{
		return;
	}

	lpPeriphFontInfo = (PeripheralFontInfo *)
	                   HP_GLOBAL_ALLOC_DLL(sizeof(PeripheralFontInfo));
	if (lpPeriphFontInfo IS NULL)
	{
		return;
	}
	dwSize = sizeof(PeripheralFontInfo);

	// From here on out we must dispose of lpPeriphFontInfo.

	// Give 'em the hour glass
	hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
	dwResult = PALGetComponentObject(hPeripheral,
	                                 hFontHandle,
	                                 OT_PERIPHERAL_FONT_INFO, 0,
	                                 lpPeriphFontInfo,
	                                 &dwSize);
	// Back to previous cursor
	SetCursor(hOldCursor);

	if (dwResult IS RC_BAD_HANDLE)
	{
		enum RetryStati RetryStatus;
		int  oldIndex = index;

		// Bad handle...enumerate again.

		RetryStatus = RetryAndSelectString(hwndChild,
		                                   &index,
						   &hFontHandle);

		if (RetryStatus IS RetrySuccess)
		{

			// Give 'em the hour glass
			hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
			dwResult = PALGetComponentObject(hPeripheral,
			                          hFontHandle,
			                          OT_PERIPHERAL_FONT_INFO,
			                          0,
			                          lpPeriphFontInfo,
			                          &dwSize);
			// Back to previous cursor
			SetCursor(hOldCursor);
		}
		else // not found or some other failure
		{
			index = oldIndex;

			// if the listbox is now empty, disable both buttons
			// index is set where the selected font was and
			// WARNING WARNING it may be out of bounds!

			SelectNextBest(hwndChild, index);
			dwResult = RC_FAILURE;
			// Don't put up the details sheet.

		} // not found or some other failure
	} // if (dwResult IS RC_BAD_HANDLE)

	if (dwResult ISNT RC_SUCCESS)
	{
		HP_GLOBAL_FREE(lpPeriphFontInfo);
		lpPeriphFontInfo = NULL;
		LoadString(hInstance, IDS_FONT_INFO_FAILED, str, SizeofStr);
		LoadString(hInstance, IDS_PRTR_TITLE, title, SizeofTitle);
		MessageBox(GetParent(hDisk), str, title, MB_OK);
		return;
	}

#ifdef WIN32
  	DialogBox(hInstance, MAKEINTRESOURCE(IDD_FONT_DETAILS), hwnd,
	          (DLGPROC)FontDetailsProc);
#else
	hFontDialog = GetWindowFont(GetFirstChild(hwnd));
	lpfnDlgProc = MakeProcInstance((FARPROC)FontDetailsProc, hInstance);
	EnableWindow(GetParent(hwnd), FALSE);
  	DialogBox(hInstance, MAKEINTRESOURCE(IDD_FONT_DETAILS), hwnd,
	          (DLGPROC)lpfnDlgProc);
	EnableWindow(GetParent(hwnd), TRUE);
  	FreeProcInstance(lpfnDlgProc);
  	SetActiveWindow(GetParent(hwnd));
#endif		  	
	HP_GLOBAL_FREE(lpPeriphFontInfo);
	lpPeriphFontInfo = NULL;
} // DoFontDetails
Example #8
0
void CAttachOp::WriteXML(TiXmlNode *root)
{
	TiXmlElement * element = heeksCAD->NewXMLElement( "AttachOp" );
	heeksCAD->LinkXMLEndChild( root,  element );

	element->SetDoubleAttribute( "tolerance", m_tolerance);
	element->SetDoubleAttribute( "minz", m_min_z);
	element->SetDoubleAttribute( "material_allowance", m_material_allowance);

	// write solid ids
#ifdef OP_SKETCHES_AS_CHILDREN
	for (HeeksObj *object = GetFirstChild(); object != NULL; object = GetNextChild())
	{
		if (object->GetIDGroupType() != SolidType)continue;
		int solid = object->GetID();
#else
	for (std::list<int>::iterator It = m_solids.begin(); It != m_solids.end(); It++)
    {
		int solid = *It;
#endif
		TiXmlElement * solid_element = heeksCAD->NewXMLElement( "solid" );
		heeksCAD->LinkXMLEndChild( element, solid_element );
		solid_element->SetAttribute("id", solid);
	}

	COp::WriteBaseXML(element);
}

// static member function
HeeksObj* CAttachOp::ReadFromXMLElement(TiXmlElement* element)
{
	CAttachOp* new_object = new CAttachOp;

	element->Attribute("tolerance", &new_object->m_tolerance);
	element->Attribute("minz", &new_object->m_min_z);
	element->Attribute("material_allowance", &new_object->m_material_allowance);

	std::list<TiXmlElement *> elements_to_remove;

	// read solid ids
	for(TiXmlElement* pElem = heeksCAD->FirstXMLChildElement( element ) ; pElem; pElem = pElem->NextSiblingElement())
	{
		std::string name(pElem->Value());
		if(name == "solid"){
			for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
			{
				std::string name(a->Name());
				if(name == "id"){
					int id = a->IntValue();
					new_object->m_solids.push_back(id);
				}
			}
			elements_to_remove.push_back(pElem);
		}
	}

	for (std::list<TiXmlElement*>::iterator itElem = elements_to_remove.begin(); itElem != elements_to_remove.end(); itElem++)
	{
		heeksCAD->RemoveXMLChild( element, *itElem);
	}

	new_object->ReadBaseXML(element);

	return new_object;
}
Example #9
0
void CLocalTreeView::Refresh()
{
	wxLogNull nullLog;

	const wxString separator = wxFileName::GetPathSeparator();

	std::list<t_dir> dirsToCheck;

#ifdef __WXMSW__
	int prevErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);

	wxTreeItemIdValue tmp;
	wxTreeItemId child = GetFirstChild(m_drives, tmp);
	while (child)
	{
		if (IsExpanded(child))
		{
			wxString drive = GetItemText(child);
			int pos = drive.Find(_T(" "));
			if (pos != -1)
				drive = drive.Left(pos);

			t_dir dir;
			dir.dir = drive + separator;
			dir.item = child;
			dirsToCheck.push_back(dir);
		}

		child = GetNextSibling(child);
	}
#else
	t_dir dir;
	dir.dir = separator;
	dir.item = GetRootItem();
	dirsToCheck.push_back(dir);
#endif

	CFilterManager filter;

	while (!dirsToCheck.empty())
	{
		t_dir dir = dirsToCheck.front();
		dirsToCheck.pop_front();

		// Step 1: Check if directory exists
		CLocalFileSystem local_filesystem;
		if (!local_filesystem.BeginFindFiles(dir.dir, true))
		{
			// Dir does exist (listed in parent) but may not be accessible.
			// Recurse into children anyhow, they might be accessible again.
			wxTreeItemIdValue value;
			wxTreeItemId child = GetFirstChild(dir.item, value);
			while (child)
			{
				t_dir subdir;
				subdir.dir = dir.dir + GetItemText(child) + separator;
				subdir.item = child;
				dirsToCheck.push_back(subdir);

				child = GetNextSibling(child);
			}
			continue;
		}

		// Step 2: Enumerate subdirectories on disk and sort them
		std::list<wxString> dirs;

		wxString file;
		const wxLongLong size(-1);
		bool was_link;
		bool is_dir;
		int attributes;
		wxDateTime date;
		while (local_filesystem.GetNextFile(file, was_link, is_dir, 0, &date, &attributes))
		{
			if (file == _T(""))
			{
				wxGetApp().DisplayEncodingWarning();
				continue;
			}

			if (filter.FilenameFiltered(file, dir.dir, true, size, true, attributes, date.IsValid() ? &date : 0))
				continue;

			dirs.push_back(file);
		}
		dirs.sort(sortfunc);

		bool inserted = false;

		// Step 3: Merge list of subdirectories with subtree.
		wxTreeItemId child = GetLastChild(dir.item);
		std::list<wxString>::reverse_iterator iter = dirs.rbegin();
		while (child || iter != dirs.rend())
		{
			int cmp;
			if (child && iter != dirs.rend())
#ifdef __WXMSW__
				cmp = GetItemText(child).CmpNoCase(*iter);
#else
				cmp = GetItemText(child).Cmp(*iter);
#endif
			else if (child)
				cmp = 1;
			else
				cmp = -1;

			if (!cmp)
			{
				// Found item with same name. Mark it for further processing
				if (!IsExpanded(child))
				{
					wxString path = dir.dir + *iter + separator;
					if (!CheckSubdirStatus(child, path))
					{
						t_dir subdir;
						subdir.dir = path;
						subdir.item = child;
						dirsToCheck.push_front(subdir);
					}
				}
				else
				{
					t_dir subdir;
					subdir.dir = dir.dir + *iter + separator;
					subdir.item = child;
					dirsToCheck.push_front(subdir);
				}
				child = GetPrevSibling(child);
				++iter;
			}
			else if (cmp > 0)
			{
				// Subdirectory currently in tree no longer exists.
				// Delete child from tree, unless current selection
				// is in the subtree.
				wxTreeItemId sel = GetSelection();
				while (sel && sel != child)
					sel = GetItemParent(sel);
				wxTreeItemId prev = GetPrevSibling(child);
				if (!sel)
					Delete(child);
				child = prev;
			}
			else if (cmp < 0)
			{
				// New subdirectory, add treeitem
				wxString fullname = dir.dir + *iter + separator;
				wxTreeItemId newItem = AppendItem(dir.item, *iter, GetIconIndex(::dir, fullname),
#ifdef __WXMSW__
						-1
#else
						GetIconIndex(opened_dir, fullname)
#endif
					);

				CheckSubdirStatus(newItem, fullname);
				++iter;
				inserted = true;
			}
		}
		if (inserted)
			SortChildren(dir.item);
	}
Example #10
0
std::ostream &
	TOSub::
	Release(std::ostream & s) const
{
	if (GetChildCount() == 1)
	{
		// -3;
		s << '-';
		Token &
			t = GetFirstChild();
		// TODO: Handle
		// a = -(-b);
		if (RequireBrackets(t, true))
		{
			s << '(';
			t.Release(s);
			s << ')';
		}
		else
		{
			t.Release(s);
		}
		return s;
	}
	Token
		& left = GetChild(0),
		& right = GetChild(1);
	// * 140
	// + 130
	if (RequireBrackets(left, false))
	{
		// The thing on the right
		// has children and a lower
		// lbp, meaning it needs
		// brackets.
		s << '(';
		left.Release(s);
		s << ')';
	}
	else
	{
		left.Release(s);
	}
	if (right.GetType() == TokenType::TO_SUB && right.GetChildCount() == 1)
	{
		// a - -b
		// a + b
		s << '+';
		Token &
			cur = right.GetFirstChild();
		// + and - have the same LBP
		if (RequireBrackets(cur, true))
		{
			s << '(';
			cur.Release(s);
			s << ')';
		}
		else
		{
			cur.Release(s);
		}
	}
	else
	{
		// a-- - b
		if (left.GetType() == TokenType::TO_INC_POST)
		{
			// Ouptut a space
			s << ' ';
		}
		// Output this operator
		s << '-';
		if (right.GetType() == TokenType::TO_INC_PRE)
		{
			// a - --b
			// Ouptut a space
			s << ' ';
			right.Release(s);
		}
		else if (RequireBrackets(right, true))
		{
			// The thing on the right
			// has children and a lower
			// lbp, meaning it needs
			// brackets.
			s << '(';
			right.Release(s);
			s << ')';
		}
		else
		{
			right.Release(s);
		}
	}
	return s;
}
Example #11
0
TBWidget *TBLayout::GetFirstInLayoutOrder() const
{
	return m_packed.mode_reverse_order ? GetLastChild() : GetFirstChild();
}
Example #12
0
void nuiContainer::InternalSetLayout(const nuiRect& rect, bool PositionChanged, bool SizeChanged)
{
  CheckValid();
  if (mNeedSelfLayout || SizeChanged)
  {
    mInSetRect = true;
    SetRect(rect);
    mInSetRect = false;
    Invalidate();
  }
  else
  {
    // Is this case the widget have just been moved inside its parent. No need to re layout it, only change the rect...
    mRect = rect;
    
    if (mNeedLayout)
    {
      // The children need to be re layed out (at least one of them!).
      nuiContainer::IteratorPtr pIt = GetFirstChild(false);
      do
      {
        nuiWidgetPtr pItem = pIt->GetWidget();
        if (pItem)
        {
          // The rect of each child doesn't change BUT we still ask for its ideal rect.
          nuiRect rect(pItem->GetBorderedRect());
          nuiRect ideal(pItem->GetIdealRect());
          
          if (pItem->HasUserPos()) 	 
          { 	 
            rect = ideal; 	 
          } 	 
          else if (pItem->HasUserSize())
          {
            rect.SetSize(ideal.GetWidth(), ideal.GetHeight());
          }
          else
          {
            // Set the widget to the size of the parent
          }
          
          pItem->SetLayout(rect);
        }
      } while (GetNextChild(pIt));
      delete pIt;
      
    }
  }
  
  //#TEST:
#ifdef NUI_CHECK_LAYOUTS
  IteratorPtr pIt;
  for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
  {
    nuiWidgetPtr pItem = pIt->GetWidget();
    if (pItem->IsVisible())
    {
      NGL_ASSERT(!pItem->GetNeedLayout());
    }
  }
  delete pIt;
  //#TEST end
#endif
}
Example #13
0
uint32 MultiDataIO :: GetPacketMaximumSize() const
{
   return (HasChildren()) ? GetFirstChild()->GetPacketMaximumSize() : 0;
}
Example #14
0
NS_IMETHODIMP
nsPopupSetFrame::List(FILE* out, PRInt32 aIndent) const
{
  IndentBy(out, aIndent);
  ListTag(out);
#ifdef DEBUG_waterson
  fprintf(out, " [parent=%p]", static_cast<void*>(mParent));
#endif
  if (HasView()) {
    fprintf(out, " [view=%p]", static_cast<void*>(GetView()));
  }
  if (nsnull != mNextSibling) {
    fprintf(out, " next=%p", static_cast<void*>(mNextSibling));
  }
  if (nsnull != GetPrevContinuation()) {
    fprintf(out, " prev-continuation=%p", static_cast<void*>(GetPrevContinuation()));
  }
  if (nsnull != GetNextContinuation()) {
    fprintf(out, " next-continuation=%p", static_cast<void*>(GetNextContinuation()));
  }
  fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
  if (0 != mState) {
    fprintf(out, " [state=%08x]", mState);
  }
  fprintf(out, " [content=%p]", static_cast<void*>(mContent));
  nsPopupSetFrame* f = const_cast<nsPopupSetFrame*>(this);
  if (f->HasOverflowRect()) {
    nsRect overflowArea = f->GetOverflowRect();
    fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y,
            overflowArea.width, overflowArea.height);
  }
  fprintf(out, " [sc=%p]", static_cast<void*>(mStyleContext));
  nsIAtom* pseudoTag = mStyleContext->GetPseudoType();
  if (pseudoTag) {
    nsAutoString atomString;
    pseudoTag->ToString(atomString);
    fprintf(out, " pst=%s",
            NS_LossyConvertUTF16toASCII(atomString).get());
  }

  // Output the children
  nsIAtom* listName = nsnull;
  PRInt32 listIndex = 0;
  PRBool outputOneList = PR_FALSE;
  do {
    nsIFrame* kid = GetFirstChild(listName);
    if (nsnull != kid) {
      if (outputOneList) {
        IndentBy(out, aIndent);
      }
      outputOneList = PR_TRUE;
      nsAutoString tmp;
      if (nsnull != listName) {
        listName->ToString(tmp);
        fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
      }
      fputs("<\n", out);
      while (nsnull != kid) {
        // Verify the child frame's parent frame pointer is correct
        NS_ASSERTION(kid->GetParent() == (nsIFrame*)this, "bad parent frame pointer");

        // Have the child frame list
        nsIFrameDebug*  frameDebug = do_QueryFrame(kid);
        if (frameDebug) {
          frameDebug->List(out, aIndent + 1);
        }
        kid = kid->GetNextSibling();
      }
      IndentBy(out, aIndent);
      fputs(">\n", out);
    }
    listName = GetAdditionalChildListName(listIndex++);
  } while(nsnull != listName);

  // XXXmats the above is copy-pasted from nsContainerFrame::List which is lame,
  // clean this up after bug 399111 is implemented.

  if (mPopupList) {
    fputs("<\n", out);
    ++aIndent;
    IndentBy(out, aIndent);
    nsAutoString tmp;
    nsGkAtoms::popupList->ToString(tmp);
    fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
    fputs(" for ", out);
    ListTag(out);
    fputs(" <\n", out);
    ++aIndent;
    for (nsPopupFrameList* l = mPopupList; l; l = l->mNextPopup) {
      nsIFrameDebug* frameDebug = do_QueryFrame(l->mPopupFrame);
      if (frameDebug) {
        frameDebug->List(out, aIndent);
      }
    }
    --aIndent;
    IndentBy(out, aIndent);
    fputs(">\n", out);
    --aIndent;
    IndentBy(out, aIndent);
    fputs(">\n", out);
    outputOneList = PR_TRUE;
  }

  if (!outputOneList) {
    fputs("<>\n", out);
  }

  return NS_OK;
}
Example #15
0
Python CWaterline::AppendTextToProgram(CMachineState *pMachineState)
{
	Python python;

    ReloadPointers();   // Make sure all the solids in m_solids are included as child objects.

	CTool *pTool = CTool::Find(m_tool_number);
	if(pTool == NULL)
	{
		return(python);
	}

	python << CDepthOp::AppendTextToProgram(pMachineState);

	// write the corner radius
	python << _T("corner_radius = float(");
	double cr = pTool->m_params.m_corner_radius - pTool->m_params.m_flat_radius;
	if(cr<0)cr = 0.0;
	python << ( cr / theApp.m_program->m_units ) << _T(")\n");

	heeksCAD->CreateUndoPoint();

	//write stl file
	std::list<HeeksObj*> solids;
	for (HeeksObj *object = GetFirstChild(); object != NULL; object = GetNextChild())
	{
	    if (object->GetType() != SolidType && object->GetType() != StlSolidType)
	    {
	        continue;
	    }

		if (object != NULL)
		{
			// Need to rotate a COPY of the solid by the fixture settings.
			HeeksObj* copy = object->MakeACopy();
			if (copy != NULL)
			{
				double m[16];	// A different form of the transformation matrix.
				CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::YZ), m );
                copy->ModifyByMatrix(m);

                CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XZ), m );
                copy->ModifyByMatrix(m);

                CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XY), m );
                copy->ModifyByMatrix(m);

                solids.push_back(copy);
            } // End if - then
        } // End if - then
	} // End for


    wxStandardPaths standard_paths;
    wxFileName filepath( standard_paths.GetTempDir().c_str(), wxString::Format(_T("waterline%d.stl"), number_for_stl_file).c_str() );
	number_for_stl_file++;

	heeksCAD->SaveSTLFile(solids, filepath.GetFullPath(), m_params.m_tolerance);

	// We don't need the duplicate solids any more.  Delete them.
	for (std::list<HeeksObj*>::iterator l_itSolid = solids.begin(); l_itSolid != solids.end(); l_itSolid++)
	{
		heeksCAD->Remove( *l_itSolid );
	} // End for
	heeksCAD->Changed();

    python << _T("ocl_funcs.waterline( filepath = ") << PythonString(filepath.GetFullPath()) << _T(", ")
            << _T("tool_diameter = ") << pTool->CuttingRadius() * 2.0 << _T(", ")
            << _T("corner_radius = ") << pTool->m_params.m_corner_radius / theApp.m_program->m_units << _T(", ")
            << _T("step_over = ") << m_params.m_step_over / theApp.m_program->m_units << _T(", ")
            << _T("mat_allowance = ") << m_params.m_material_allowance / theApp.m_program->m_units << _T(", ")
            << _T("clearance = clearance, ")
            << _T("rapid_safety_space = rapid_safety_space, ")
            << _T("start_depth = start_depth, ")
            << _T("step_down = step_down, ")
            << _T("final_depth = final_depth, ")
            << _T("units = ") << theApp.m_program->m_units << _T(", ")
            << _T("x0 = ") << m_params.m_box.m_x[0] / theApp.m_program->m_units << _T(", ")
            << _T("y0 = ") << m_params.m_box.m_x[1] / theApp.m_program->m_units << _T(", ")
            << _T("x1 = ") << m_params.m_box.m_x[3] / theApp.m_program->m_units << _T(", ")
            << _T("y1 = ") << m_params.m_box.m_x[4] / theApp.m_program->m_units << _T(", ")
            << _T("tolerance = ") << m_params.m_tolerance << _T(")\n");

	return(python);
}
Example #16
0
void CRemoteTreeView::RefreshItem(wxTreeItemId parent, const CDirectoryListing& listing, bool will_select_parent)
{
	SetItemImages(parent, false);

	wxTreeItemIdValue cookie;
	wxTreeItemId child = GetFirstChild(parent, cookie);
	if (!child || GetItemText(child).empty()) {
		DisplayItem(parent, listing);
		return;
	}

	CFilterManager filter;

	wxString const path = listing.path.GetPath();

	wxArrayString dirs;
	for (unsigned int i = 0; i < listing.GetCount(); ++i) {
		if (!listing[i].is_dir())
			continue;

		if (!filter.FilenameFiltered(listing[i].name, path, true, -1, false, 0, listing[i].time))
			dirs.push_back(listing[i].name);
	}

	auto const& sortFunc = CFileListCtrlSortBase::GetCmpFunction(m_nameSortMode);
	dirs.Sort(sortFunc);

	bool inserted = false;
	child = GetLastChild(parent);
	wxArrayString::reverse_iterator iter = dirs.rbegin();
	while (child && iter != dirs.rend()) {
		int cmp = sortFunc(GetItemText(child), *iter);

		if (!cmp) {
			CServerPath childPath = listing.path;
			childPath.AddSegment(*iter);

			CDirectoryListing subListing;
			if (m_pState->m_pEngine->CacheLookup(childPath, subListing) == FZ_REPLY_OK) {
				if (!GetLastChild(child) && HasSubdirs(subListing, filter))
					AppendItem(child, _T(""), -1, -1);
				SetItemImages(child, false);
			}
			else
				SetItemImages(child, true);

			child = GetPrevSibling(child);
			++iter;
		}
		else if (cmp > 0) {
			// Child no longer exists
			wxTreeItemId sel = GetSelection();
			while (sel && sel != child)
				sel = GetItemParent(sel);
			wxTreeItemId prev = GetPrevSibling(child);
			if (!sel || will_select_parent)
				Delete(child);
			child = prev;
		}
		else if (cmp < 0) {
			// New directory
			CServerPath childPath = listing.path;
			childPath.AddSegment(*iter);

			CDirectoryListing subListing;
			if (m_pState->m_pEngine->CacheLookup(childPath, subListing) == FZ_REPLY_OK) {
				wxTreeItemId childItem = AppendItem(parent, *iter, 0, 2, 0);
				if (childItem) {
					SetItemImages(childItem, false);

					if (HasSubdirs(subListing, filter)) {
						AppendItem(childItem, _T(""), -1, -1);
					}
				}
			}
			else {
				wxTreeItemId childItem = AppendItem(parent, *iter, 1, 3, 0);
				if (childItem) {
					SetItemImages(childItem, true);
				}
			}

			++iter;
			inserted = true;
		}
	}
	while (child) {
		// Child no longer exists
		wxTreeItemId sel = GetSelection();
		while (sel && sel != child)
			sel = GetItemParent(sel);
		wxTreeItemId prev = GetPrevSibling(child);
		if (!sel || will_select_parent)
			Delete(child);
		child = prev;
	}
	while (iter != dirs.rend()) {
		CServerPath childPath = listing.path;
		childPath.AddSegment(*iter);

		CDirectoryListing subListing;
		if (m_pState->m_pEngine->CacheLookup(childPath, subListing) == FZ_REPLY_OK) {
			wxTreeItemId childItem = AppendItem(parent, *iter, 0, 2, 0);
			if (childItem) {
				SetItemImages(childItem, false);

				if (HasSubdirs(subListing, filter)) {
					AppendItem(childItem, _T(""), -1, -1);
				}
			}
		}
		else {
			wxTreeItemId childItem = AppendItem(parent, *iter, 1, 3, 0);
			if (childItem) {
				SetItemImages(childItem, true);
			}
		}

		++iter;
		inserted = true;
	}

	if (inserted)
		SortChildren(parent);
}
Example #17
0
void RegTreeCtrl::GoTo(const wxString& location)
{
    wxStringTokenizer tk(location, wxT("\\"));

    wxTreeItemId id = GetRootItem();

#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    while ( tk.HasMoreTokens() )
    {
        wxString subkey = tk.GetNextToken();

        wxTreeItemId idCurrent = id;
        if ( !IsExpanded(idCurrent) )
            Expand(idCurrent);

        wxTreeItemIdValue dummy;
        id = GetFirstChild(idCurrent, dummy);

        if ( idCurrent == GetRootItem() )
        {
            // special case: we understand both HKCU and HKEY_CURRENT_USER here
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
            for ( size_t key = 0; key < wxRegKey::nStdKeys; key++ )
            {
                if ( subkey == wxRegKey::GetStdKeyName(key)
                     || subkey == wxRegKey::GetStdKeyShortName(key) )
                {
                    break;
                }

                id = GetNextChild(idCurrent, dummy);
            }
        }
        else
        {
            // enum all children
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
            while ( id.IsOk() )
            {
                if ( subkey == ((TreeNode *)GetItemData(id))->m_strName )
                    break;

                id = GetNextChild(idCurrent, dummy);
            }
        }

        if ( !id.IsOk() )
        {
            wxLogError(wxT("No such key '%s'."), location.c_str());

            return;
        }
    }

    if ( id.IsOk() )
        SelectItem(id);
}
Example #18
0
void CRemoteTreeView::RefreshItem(wxTreeItemId parent, const CDirectoryListing& listing, bool will_select_parent)
{
	SetItemImages(parent, false);

	wxTreeItemIdValue cookie;
	wxTreeItemId child = GetFirstChild(parent, cookie);
	if (!child || GetItemText(child) == _T(""))
	{
		DisplayItem(parent, listing);
		return;
	}

	CFilterManager filter;

	const wxString path = listing.path.GetPath();

	std::list<wxString> dirs;
	for (unsigned int i = 0; i < listing.GetCount(); i++)
	{
		if (!listing[i].is_dir())
			continue;

		if (!filter.FilenameFiltered(listing[i].name, path, true, -1, false, 0, listing[i].has_date() ? &listing[i].time : 0))
			dirs.push_back(listing[i].name);
	}

	dirs.sort(sortfunc);

	bool inserted = false;
	child = GetLastChild(parent);
	std::list<wxString>::reverse_iterator iter = dirs.rbegin();
	while (child && iter != dirs.rend())
	{
		int cmp = GetItemText(child).CmpNoCase(*iter);
		if (!cmp)
			cmp = GetItemText(child).Cmp(*iter);

		if (!cmp)
		{
			CServerPath path = listing.path;
			path.AddSegment(*iter);

			CDirectoryListing subListing;
			if (m_pState->m_pEngine->CacheLookup(path, subListing) == FZ_REPLY_OK)
			{
				if (!GetLastChild(child) && HasSubdirs(subListing, filter))
					AppendItem(child, _T(""), -1, -1);
				SetItemImages(child, false);
			}
			else
				SetItemImages(child, true);

			child = GetPrevSibling(child);
			iter++;
		}
		else if (cmp > 0)
		{
			// Child no longer exists
			wxTreeItemId sel = GetSelection();
			while (sel && sel != child)
				sel = GetItemParent(sel);
			wxTreeItemId prev = GetPrevSibling(child);
			if (!sel || will_select_parent)
				Delete(child);
			child = prev;
		}
		else if (cmp < 0)
		{
			// New directory
			CServerPath path = listing.path;
			path.AddSegment(*iter);

			CDirectoryListing subListing;
			if (m_pState->m_pEngine->CacheLookup(path, subListing) == FZ_REPLY_OK)
			{
				wxTreeItemId child = AppendItem(parent, *iter, 0, 2, 0);
				SetItemImages(child, false);

				if (HasSubdirs(subListing, filter))
					AppendItem(child, _T(""), -1, -1);
			}
			else
			{
				wxTreeItemId child = AppendItem(parent, *iter, 1, 3, 0);
				if (child)
					SetItemImages(child, true);
			}

			iter++;
			inserted = true;
		}
	}
	while (child)
	{
		// Child no longer exists
		wxTreeItemId sel = GetSelection();
		while (sel && sel != child)
			sel = GetItemParent(sel);
		wxTreeItemId prev = GetPrevSibling(child);
		if (!sel || will_select_parent)
			Delete(child);
		child = prev;
	}
	while (iter != dirs.rend())
	{
		CServerPath path = listing.path;
		path.AddSegment(*iter);

		CDirectoryListing subListing;
		if (m_pState->m_pEngine->CacheLookup(path, subListing) == FZ_REPLY_OK)
		{
			wxTreeItemId child = AppendItem(parent, *iter, 0, 2, 0);
			SetItemImages(child, false);

			if (HasSubdirs(subListing, filter))
				AppendItem(child, _T(""), -1, -1);
		}
		else
		{
			wxTreeItemId child = AppendItem(parent, *iter, 1, 3, 0);
			SetItemImages(child, true);
		}

		iter++;
		inserted = true;
	}

	if (inserted)
		SortChildren(parent);
}
/* virtual */ nsresult
nsMathMLmpaddedFrame::Place(nsIRenderingContext& aRenderingContext,
                            PRBool               aPlaceOrigin,
                            nsHTMLReflowMetrics& aDesiredSize)
{
  nsresult rv =
    nsMathMLContainerFrame::Place(aRenderingContext, PR_FALSE, aDesiredSize);
  if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
    DidReflowChildren(GetFirstChild(nsnull));
    return rv;
  }

  nscoord height = mBoundingMetrics.ascent;
  nscoord depth  = mBoundingMetrics.descent;
  // In MathML2 (http://www.w3.org/TR/MathML2/chapter3.html#presm.mpadded),
  // lspace is "the amount of space between the left edge of a bounding box
  // and the start of the rendering of its contents' bounding box" and the
  // default is zero.
  //
  // In MathML3 draft
  // http://www.w3.org/TR/2007/WD-MathML3-20070427/chapter3.html#id.3.3.6.2,
  // lspace is "the amount of space between the left edge of the bounding box
  // and the positioning poin [sic] of the mpadded element" and the default is
  // "same as content".
  //
  // In both cases, "MathML renderers should ensure that, except for the
  // effects of the attributes, relative spacing between the contents of
  // mpadded and surrounding MathML elements is not modified by replacing an
  // mpadded element with an mrow element with the same content."
  nscoord lspace = 0;
  // In MATHML3, "width" will be the bounding box width and "advancewidth" will
  // refer "to the horizontal distance between the positioning point of the
  // mpadded and the positioning point for the following content".  MathML2
  // doesn't make the distinction.
  nscoord width  = mBoundingMetrics.width;

  PRInt32 pseudoUnit;

  // update width
  pseudoUnit = (mWidthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF)
             ? NS_MATHML_PSEUDO_UNIT_WIDTH : mWidthPseudoUnit;
  UpdateValue(mWidthSign, pseudoUnit, mWidth,
              lspace, mBoundingMetrics, width);

  // update "height" (this is the ascent in the terminology of the REC)
  pseudoUnit = (mHeightPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF)
             ? NS_MATHML_PSEUDO_UNIT_HEIGHT : mHeightPseudoUnit;
  UpdateValue(mHeightSign, pseudoUnit, mHeight,
              lspace, mBoundingMetrics, height);

  // update "depth" (this is the descent in the terminology of the REC)
  pseudoUnit = (mDepthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF)
             ? NS_MATHML_PSEUDO_UNIT_DEPTH : mDepthPseudoUnit;
  UpdateValue(mDepthSign, pseudoUnit, mDepth,
              lspace, mBoundingMetrics, depth);

  // update lspace -- should be *last* because lspace is overwritten!!
  pseudoUnit = (mLeftSpacePseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF)
             ? NS_MATHML_PSEUDO_UNIT_LSPACE : mLeftSpacePseudoUnit;
  UpdateValue(mLeftSpaceSign, pseudoUnit, mLeftSpace,
              lspace, mBoundingMetrics, lspace);

  // do the padding now that we have everything
  // The idea here is to maintain the invariant that <mpadded>...</mpadded> (i.e.,
  // with no attributes) looks the same as <mrow>...</mrow>. But when there are
  // attributes, tweak our metrics and move children to achieve the desired visual
  // effects.

  if (mLeftSpaceSign != NS_MATHML_SIGN_INVALID) { // there was padding on the left
    // dismiss the left italic correction now (so that our parent won't correct us)
    mBoundingMetrics.leftBearing = 0;
  }

  if (mLeftSpaceSign != NS_MATHML_SIGN_INVALID ||
      mWidthSign != NS_MATHML_SIGN_INVALID) { // there was padding on the right
    // dismiss the right italic correction now (so that our parent won't correct us)
    mBoundingMetrics.width = PR_MAX(0, lspace + width);
    mBoundingMetrics.rightBearing = mBoundingMetrics.width;
  }

  nscoord dy = height - mBoundingMetrics.ascent;
  nscoord dx = lspace;

  mBoundingMetrics.ascent = height;
  mBoundingMetrics.descent = depth;

  aDesiredSize.ascent += dy;
  aDesiredSize.width = mBoundingMetrics.width;
  aDesiredSize.height += dy + depth - mBoundingMetrics.descent;
  aDesiredSize.mBoundingMetrics = mBoundingMetrics;

  mReference.x = 0;
  mReference.y = aDesiredSize.ascent;

  if (aPlaceOrigin) {
    // Finish reflowing child frames, positioning their origins.
    PositionRowChildFrames(dx, aDesiredSize.ascent);
  }

  return NS_OK;
}
Example #20
0
bool nuiScrollView::SetChildrenRect(nuiSize x, nuiSize y, nuiSize xx, nuiSize yy, nuiSize scrollv, nuiSize scrollh)
{  
  #ifdef _DEBUG_LAYOUT
  if (GetDebug())
  {
    NGL_OUT(_T("\tnuiScrollView::SetChildrenRect: (%f, %f) (%f, %f) - (%f, %f)\n"), x, y, xx, yy, scrollv, scrollh);
  }
  #endif
  
  nuiRect VisibleRect = GetRect().Size();
  VisibleRect.Right() -= scrollv;
  VisibleRect.Bottom() -= scrollh;
  
  nuiRange& hrange = mpHorizontal->GetRange();
  nuiRange& vrange = mpVertical->GetRange();
  nuiSize XOffset = hrange.GetValue();
  nuiSize YOffset = vrange.GetValue();

  if (mSmoothScrolling)
  {
    if (mTimerOn)
    {
      if (!mHThumbPressed)
        XOffset = mXOffset;
      if (!mVThumbPressed)
        YOffset = mYOffset;
    }
  }

  XOffset = (nuiSize)ToNearest(XOffset);
  YOffset = (nuiSize)ToNearest(YOffset);

  if (!mFillChildren)
  {
    IteratorPtr pIt;  
    for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
    {
      nuiWidgetPtr pItem = pIt->GetWidget();
      if (pItem != mpVertical && pItem != mpHorizontal)
      {
        nuiRect rect = pItem->GetIdealRect();
        rect.Move(-XOffset, -YOffset);

        float w = rect.GetWidth();
        float h = rect.GetHeight();
        
        if (mForceNoHorizontal)
          w = xx;
        if (mForceNoVertical)
          h = yy;
        
        rect.SetSize(w, h);

        #ifdef _DEBUG_LAYOUT
        if (GetDebug())
        {
          NGL_OUT(_T("\tnuiScrollView::SetChildrenRect: SetLayout(%s)\n"), rect.GetValue().GetChars());
        }
        #endif

        pItem->SetLayout(rect);
        rect = VisibleRect;
        LocalToLocal(pItem, rect);
        //pItem->SetVisibleRect(rect);
      }
    }
    delete pIt;
  }
  else
  {
    if (x < xx - scrollv)
      x = xx - scrollv;
    if (y < yy - scrollh)
      y = yy - scrollh;

    IteratorPtr pIt;  
    for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
    {
      nuiWidgetPtr pItem = pIt->GetWidget();
      if (pItem != mpVertical && pItem != mpHorizontal)
      {
        float w = x, h = y;

        if (mForceNoHorizontal)
				{
          w = xx - scrollv;
				}
        if (mForceNoVertical)
				{
          h = yy - scrollh;
				}
        
        nuiRect rect(-XOffset, -YOffset, w, h);
          
        #ifdef _DEBUG_LAYOUT
        if (GetDebug())
        {
          NGL_OUT(_T("\tnuiScrollView::SetChildrenRect: SetLayout(%s)\n"), rect.GetValue().GetChars());
        }
        #endif
        
        pItem->SetLayout(rect);

        rect = VisibleRect;
        LocalToLocal(pItem, rect);
        pItem->SetVisibleRect(rect);
      }
    }
    delete pIt;
  }

  return true;
}
Example #21
0
Python CAttachOp::AppendTextToProgram(CMachineState *pMachineState)
{
	Python python;

 #ifdef OP_SKETCHES_AS_CHILDREN
   ReloadPointers();   // Make sure all the solids in m_solids are included as child objects.
#endif

	python << COp::AppendTextToProgram(pMachineState);

	//write stl file
	std::list<HeeksObj*> solids;
	std::list<HeeksObj*> copies_to_delete;
#ifdef OP_SKETCHES_AS_CHILDREN
    for (HeeksObj *object = GetFirstChild(); object != NULL; object = GetNextChild())
    {
	    if (object->GetType() != SolidType && object->GetType() != StlSolidType)
	    {
	        continue;
	    }

#else
	for (std::list<int>::iterator It = m_solids.begin(); It != m_solids.end(); It++)
    {
		HeeksObj* object = heeksCAD->GetIDObject(SolidType, *It);
#endif
		if (object != NULL)
		{
			if(1/* to do pMachineState->Fixture().GetMatrix() == gp_Trsf()*/)
			{
				solids.push_back(object);
			}
		} // End if - then
	} // End for


    wxStandardPaths standard_paths;
    wxFileName filepath( standard_paths.GetTempDir().c_str(), wxString::Format(_T("surface%d.stl"), number_for_stl_file).c_str() );
	number_for_stl_file++;

	heeksCAD->SaveSTLFile(solids, filepath.GetFullPath(), 0.01);

	// We don't need the duplicate solids any more.  Delete them.
	for (std::list<HeeksObj*>::iterator l_itSolid = copies_to_delete.begin(); l_itSolid != copies_to_delete.end(); l_itSolid++)
	{
		delete *l_itSolid;
	} // End for

	python << _T("nc.attach.units = ") << theApp.m_program->m_units << _T("\n");
	python << _T("nc.attach.attach_begin()\n");
	python << _T("nc.nc.creator.stl = ocl_funcs.STLSurfFromFile(") << PythonString(filepath.GetFullPath()) << _T(")\n");
	python << _T("nc.nc.creator.minz = ") << m_min_z << _T("\n");
	python << _T("nc.nc.creator.material_allowance = ") << m_material_allowance << _T("\n");

	pMachineState->m_attached_to_surface = this;

	return(python);
} // End AppendTextToProgram() method

static void on_set_tolerance(double value, HeeksObj* object){((CAttachOp*)object)->m_tolerance = value;}
static void on_set_min_z(double value, HeeksObj* object){((CAttachOp*)object)->m_min_z = value;}
static void on_set_material_allowance(double value, HeeksObj* object){((CAttachOp*)object)->m_material_allowance = value;}

void CAttachOp::GetProperties(std::list<Property *> *list)
{
#ifdef OP_SKETCHES_AS_CHILDREN
	AddSolidsProperties(list, this);
#else
	AddSolidsProperties(list, m_solids);
#endif
	list->push_back(new PropertyLength(_("tolerance"), m_tolerance, this, on_set_tolerance));
	list->push_back(new PropertyLength(_("minimum z"), m_min_z, this, on_set_min_z));
	list->push_back(new PropertyLength(_("material allowance"), m_material_allowance, this, on_set_material_allowance));
	COp::GetProperties(list);
}
Example #22
0
void Ctrl::ApplyLayout()
{
	GuiLock __;
	for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
		q->ApplyLayout();
}
Example #23
0
void  Ctrl::ScrollView(const Rect& _r, int dx, int dy)
{
	GuiLock __;
	if(IsFullRefresh() || !IsVisible())
		return;
	Size vsz = GetSize();
	dx = sgn(dx) * min(abs(dx), vsz.cx);
	dy = sgn(dy) * min(abs(dy), vsz.cy);
	Rect r = _r & vsz;
	Ctrl *w;
	for(w = this; w->parent; w = w->parent)
		if(w->InFrame()) {
			Refresh();
			return;
		}
	if(!w || !w->top) return;
	Rect view = InFrame() ? GetView() : GetClippedView();
	Rect sr = (r + view.TopLeft()) & view;
	sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft();
	if(w->AddScroll(sr, dx, dy))
		Refresh();
	else {
		LTIMING("ScrollCtrls1");
		Top *top = GetTopCtrl()->top;
		for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
			if(q->InView()) {
				Rect cr = q->GetRect();
				if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs
					Rect to = cr;
					GetTopRect(to, false);
					if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
						Rect from = cr.Offseted(-dx, -dy);
						GetTopRect(from, false);
						MoveCtrl *m = FindMoveCtrlPtr(top->move, q);
						if(m && m->from == from && m->to == to) {
							LLOG("ScrollView Matched " << from << " -> " << to);
							m->ctrl = NULL;
							goto done;
						}
					}

					if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
						Rect from = to;
						to = cr.Offseted(dx, dy);
						GetTopRect(to, false);
						MoveCtrl& m = top->scroll_move.Add(q);
						m.from = from;
						m.to = to;
						m.ctrl = q;
						LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to);
						goto done;
					}
					cr &= r;
					if(!cr.IsEmpty()) {
						Refresh(cr);
						Refresh(cr + Point(dx, dy));
					}
				done:;
				}
			}
	}
}
Example #24
0
bool wxSTEditorTreeCtrl::HandleMenuEvent(wxCommandEvent &event)
{
    int win_id  = event.GetId();
    wxTreeItemId id = GetSelection();

    wxSTETreeItemData* data = NULL;
    if (id)
        data = (wxSTETreeItemData*)GetItemData(id);

    switch (win_id)
    {
        case ID_STT_FILE_OPEN :
        {
            if (id)
            {
                wxTreeEvent treeEvent(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, this, id);
                OnTreeCtrl(treeEvent);
            }
            return true;
        }
        case ID_STT_FILE_CLOSE :
        {
            if (id && m_steNotebook && data)
            {
                m_steNotebook->ClosePage(data->m_page_num, true);
            }
            return true;
        }
        case ID_STT_FILE_PROPERTIES :
        {
            if (id && m_steNotebook && data && data->m_notePage)
            {
                wxSTEditor* editor = wxDynamicCast(data->m_notePage, wxSTEditor);

                if (!editor && wxDynamicCast(data->m_notePage, wxSTEditorSplitter))
                    editor = wxDynamicCast(data->m_notePage, wxSTEditorSplitter)->GetEditor();

                if (editor)
                    editor->ShowPropertiesDialog();
            }
            return true;
        }
        case ID_STT_EXPAND_ALL :
        {
            ExpandAll();
            return true;
        }
        case ID_STT_COLLAPSE_ALL :
        {
            // Can't CollapseAll() if root node is hidden.
            wxTreeItemIdValue cookie;
            wxTreeItemId rootId = GetRootItem();
            wxTreeItemId childId = GetFirstChild(rootId, cookie);
            for (; childId; childId = GetNextChild(rootId, cookie))
            {
                CollapseAllChildren(childId);
            }
            return true;
        }
        case ID_STT_SHOW_FILENAME_ONLY :
        case ID_STT_SHOW_FILEPATH_ONLY :
        case ID_STT_SHOW_PATH_THEN_FILENAME :
        case ID_STT_SHOW_ALL_PATHS :
        {
            SetDisplayType((FileDisplay_Type)(win_id-ID_STT_SHOW_FILENAME_ONLY));
            return true;
        }
    }

    return false;
}
Example #25
0
void MyTreeCtrl::CreateButtonsImageList(int size)
{
    if ( size == -1 )
    {
        SetButtonsImageList(NULL);
        return;
    }

    // Make an image list containing small icons
    wxImageList *images = new wxImageList(size, size, true);

    // should correspond to TreeCtrlIcon_xxx enum
    wxBusyCursor wait;
    wxIcon icons[4];
    icons[0] = wxIcon(icon3_xpm);   // closed
    icons[1] = wxIcon(icon3_xpm);   // closed, selected
    icons[2] = wxIcon(icon5_xpm);   // open
    icons[3] = wxIcon(icon5_xpm);   // open, selected

    for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
    {
        int sizeOrig = icons[i].GetWidth();
        if ( size == sizeOrig )
        {
            images->Add(icons[i]);
        }
        else
        {
            images->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size, size)));
        }
    }

    AssignButtonsImageList(images);
#else
void MyTreeCtrl::CreateButtonsImageList(int WXUNUSED(size))
{
#endif
}

int MyTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
                               const wxTreeItemId& item2)
{
    if ( m_reverseSort )
    {
        // just exchange 1st and 2nd items
        return wxTreeCtrl::OnCompareItems(item2, item1);
    }
    else
    {
        return wxTreeCtrl::OnCompareItems(item1, item2);
    }
}

void MyTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent,
                                     size_t numChildren,
                                     size_t depth,
                                     size_t folder)
{
    if ( depth > 0 )
    {
        bool hasChildren = depth > 1;

        wxString str;
        for ( size_t n = 0; n < numChildren; n++ )
        {
            // at depth 1 elements won't have any more children
            if ( hasChildren )
                str.Printf(wxT("%s child %u"), wxT("Folder"), unsigned(n + 1));
            else
                str.Printf(wxT("%s child %u.%u"), wxT("File"), unsigned(folder), unsigned(n + 1));

            // here we pass to AppendItem() normal and selected item images (we
            // suppose that selected image follows the normal one in the enum)
            int image, imageSel;
            if ( wxGetApp().ShowImages() )
            {
                image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
                imageSel = image + 1;
            }
            else
            {
                image = imageSel = -1;
            }
            wxTreeItemId id = AppendItem(idParent, str, image, imageSel,
                                         new MyTreeItemData(str));

            // and now we also set the expanded one (only for the folders)
            if ( hasChildren && wxGetApp().ShowImages() )
            {
                SetItemImage(id, TreeCtrlIcon_FolderOpened,
                             wxTreeItemIcon_Expanded);
            }

            // remember the last child for OnEnsureVisible()
            if ( !hasChildren && n == numChildren - 1 )
            {
                m_lastItem = id;
            }

            AddItemsRecursively(id, numChildren, depth - 1, n + 1);
        }
    }
    //else: done!
}

void MyTreeCtrl::AddTestItemsToTree(size_t numChildren,
                                    size_t depth)
{
    int image = wxGetApp().ShowImages() ? MyTreeCtrl::TreeCtrlIcon_Folder : -1;
    wxTreeItemId rootId = AddRoot(wxT("Root"),
                                  image, image,
                                  new MyTreeItemData(wxT("Root item")));
    if ( !HasFlag(wxTR_HIDE_ROOT) && image != -1 )
    {
        SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
    }

    AddItemsRecursively(rootId, numChildren, depth, 0);

    // set some colours/fonts for testing
    if ( !HasFlag(wxTR_HIDE_ROOT) )
        SetItemFont(rootId, *wxITALIC_FONT);

    wxTreeItemIdValue cookie;
    wxTreeItemId id = GetFirstChild(rootId, cookie);
    SetItemTextColour(id, *wxBLUE);

    id = GetNextChild(rootId, cookie);
    id = GetNextChild(rootId, cookie);
    SetItemTextColour(id, *wxRED);
    SetItemBackgroundColour(id, *wxLIGHT_GREY);
}
Example #26
0
wxTreeItemId wxSTEditorTreeCtrl::FindOrInsertItem(const wxArrayString& treePath,
                                                  STE_TreeCtrlFindInsert_Type find_type)
{
    wxCHECK_MSG(treePath.GetCount() > 0, wxTreeItemId(), wxT("Nothing to insert"));

    int n = 0, count = treePath.GetCount();

    // check for and add "Root" if not only_find
    wxTreeItemId parentId = GetRootItem();
    if (!parentId)
    {
        if (find_type == STE_TREECTRL_FIND)
            return wxTreeItemId();

        parentId = AddRoot(_("Root"), -1, -1, NULL);
    }

    wxTreeItemIdValue rootCookie;
    wxTreeItemId id = GetFirstChild(parentId, rootCookie);

    // check for and add first path if not only_find
    if (!id)
    {
        if (find_type == STE_TREECTRL_FIND)
            return wxTreeItemId();

        parentId = id = AppendItem(parentId, treePath[n],
                                   (n < count-1) ? STE_TREECTRL_IMAGE_FOLDER : -1,
                                   -1, NULL);
        n++;
    }

    // Iterate though the path list
    while (id && (n < count))
    {
        if (GetItemText(id) == treePath[n])
        {
            if (n == count - 1)       // found the existing item w/ full path
            {
                if (find_type == STE_TREECTRL_INSERT)
                    return AppendItem(parentId, treePath[n],
                                      (n < count-1) ? STE_TREECTRL_IMAGE_FOLDER : -1,
                                      -1, NULL);
                else
                    return id;
            }

            parentId = id;
            id = GetFirstChild(id, rootCookie); // next path part
            n++;
        }
        else
        {
            id = GetNextSibling(id);         // find this path part
        }

        if (!id)
        {
            if (find_type == STE_TREECTRL_FIND)
                return wxTreeItemId();

            id = parentId;                              // use last good parent
            for (; n < count; n++)                      // append rest of path
            {
                id = AppendItem(id, treePath[n],
                                (n < count-1) ? STE_TREECTRL_IMAGE_FOLDER : -1,
                                -1, NULL);

                if (n == count - 1)
                    return id;
            }
        }

    }

    return wxTreeItemId();
}
Example #27
0
void CFormulaNode::Recalculate_VerticalCenter( const SizeFde &sz )
{
	RealFde vc = sz.height() / 2.0;

	switch( getAlignmentType() )
	{
	case FBtnChildPos::Child:
		if( getAlignmentValue() >= 1 && (getAlignmentValue() - 1) < getGraphPrimNumber() )
		{
			const RectFde& _t = getGraphPrimitivePositionRect( getAlignmentValue() - 1 );
			vc = (_t.top() + _t.bottom()) / 2.0;
		}
		break;
	case FBtnChildPos::Child_Average:
		if( getAlignmentValue() >= 1 && (getAlignmentValue() - 1) < getGraphPrimNumber() )
		{
			vc = 0.0;
			for( long i = 0; i <= getAlignmentValue() - 1; i++ )
			{
				const RectFde& _t = getGraphPrimitivePositionRect( i );
				vc += _t.top() + _t.bottom();
			}
			vc = vc / (getAlignmentValue() * 2.0);
		}
		break;
	case FBtnChildPos::MSPACE_Exact_HeightDepth:
	case FBtnChildPos::Frame:
		if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() )
		{
			CNode *pNode = GetChild( getAlignmentValue() - 1 );
			if( pNode )
				vc = pNode->GetPosition().y() + pNode->GetVerticalCenter();
		}
		break;
	case FBtnChildPos::Frame_Blank_Average:
		{
			CNode *pNodeFirst = GetFirstChild();
			CNode *pNodeLast  = GetLastChild();
			if( pNodeFirst != NULL && pNodeLast != NULL )
			{
				vc = (pNodeFirst->GetPosition().y() + pNodeFirst->GetSize().height() + pNodeLast->GetPosition().y()) / 2.0;
			}
		}
		break;
	case FBtnChildPos::Half:
		break;

	case FBtnChildPos::TableAxis:
		if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() )
		{
			CNode *pNode = GetChild( getAlignmentValue() - 1 );
			if( pNode )
				vc = pNode->GetPosition().y() + pNode->GetSize().height() / 2.0;
		}
		break;

	case FBtnChildPos::TableCenter2Baseline:
	case FBtnChildPos::TableTop2Baseline:
	case FBtnChildPos::TableBottom2Baseline:
		{
			RealFde asc = ::getCurrentDefaultAscent( GetLevel() );
			RealFde h = ::getCurrentDefaultSize( GetLevel() ).height();
			vc = getAscent( sz ) - asc + h - asc / 2.0;
		}
		break;

	default:
		break;
	}

	SetVerticalCenter( vc );
}
Example #28
0
void CRemoteTreeView::ApplyFilters(bool resort)
{
	std::list<struct _parents> parents;

	const wxTreeItemId root = GetRootItem();
	wxTreeItemIdValue cookie;
	for (wxTreeItemId child = GetFirstChild(root, cookie); child; child = GetNextSibling(child)) {
		CServerPath path = GetPathFromItem(child);
		if (path.empty())
			continue;

		struct _parents dir;
		dir.item = child;
		dir.path = path;
		parents.push_back(dir);
	}

	CFilterManager filter;
	while (!parents.empty()) {
		struct _parents parent = parents.back();
		parents.pop_back();

		if (resort) {
			SortChildren(parent.item);
		}

		CDirectoryListing listing;
		if (m_pState->m_pEngine->CacheLookup(parent.path, listing) == FZ_REPLY_OK)
			RefreshItem(parent.item, listing, false);
		else if (filter.HasActiveFilters()) {
			for (wxTreeItemId child = GetFirstChild(parent.item, cookie); child; child = GetNextSibling(child)) {
				CServerPath path = GetPathFromItem(child);
				if (path.empty())
					continue;

				if (filter.FilenameFiltered(GetItemText(child), path.GetPath(), true, -1, false, 0, CDateTime())) {
					wxTreeItemId sel = GetSelection();
					while (sel && sel != child)
						sel = GetItemParent(sel);
					if (!sel) {
						Delete(child);
						continue;
					}
				}

				struct _parents dir;
				dir.item = child;
				dir.path = path;
				parents.push_back(dir);
			}

			// The stuff below has already been done above in this one case
			continue;
		}
		for (wxTreeItemId child = GetFirstChild(parent.item, cookie); child; child = GetNextSibling(child)) {
			CServerPath path = GetPathFromItem(child);
			if (path.empty())
				continue;

			struct _parents dir;
			dir.item = child;
			dir.path = path;
			parents.push_back(dir);
		}
	}
}
Example #29
0
int CFormulaNode::RunCalc()
{
	if( !getCalc() )
	{
		if( getCalcButtonID().length() )
			setMissButton();
		return 0;
	}
	if( !getCalc()->isPositionRunExist() ) return 0;

	QVector<RealFde> frames_ltrb;
	frames_ltrb.fill( 0.0, 4 * GetChildCount() );
	QVector<RealFde> frames_margin_ltrb;
	frames_margin_ltrb.fill( 0.0, 4 * GetChildCount() );
	QVector<RealFde> primitive_ltrb;
	primitive_ltrb.fill( 0.0, 4 * GetChildCount() );

	long i;
	CNode *pCurNode = GetFirstChild();
	if( pCurNode->GetType() != NODE_FRAME ) return 0;
	for( i = 0; i < GetChildCount() && pCurNode; pCurNode = pCurNode->GetNext(), i++ )
	{
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] = pCurNode->GetPosition().x();
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] = pCurNode->GetPosition().y();
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] = pCurNode->GetPosition().x() + pCurNode->GetSize().width();
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] = pCurNode->GetPosition().y() + pCurNode->GetSize().height();

		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] = ((CFrameNode*) pCurNode)->getLeftIndent();
		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] = ((CFrameNode*) pCurNode)->getTopIndent();
		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] = ((CFrameNode*) pCurNode)->getRightIndent();
		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] = ((CFrameNode*) pCurNode)->getBottomIndent();
	}

	for( i = 0; i < getGraphPrimNumber(); i++ )
	{
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 0 ) );
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 1 ) );
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 2 ) );
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 3 ) );
	}

	UseBtnCalc_InitByThisSize( *getCalc() );
	int ret = getCalc()->PositionRun( frames_ltrb, frames_margin_ltrb, primitive_ltrb );

	// reset parent margins
	UseBtnCalc_ChangeThisMargin( *getCalc() );

	for( i = 0; i < getGraphPrimNumber(); i++ )
	{
		if( getCalc()->isFormulaTypeGraphics( i ) )
		{
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Left,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] );
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Top,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] );
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Right,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] );
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Bottom,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] );
		}
	}

	if( ret )
	{
		pCurNode = GetFirstChild();
		i = 0;
		while( pCurNode )
		{
			((CFrameNode*) pCurNode)->setLeftIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] );
			((CFrameNode*) pCurNode)->setTopIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] );
			((CFrameNode*) pCurNode)->setRightIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] );
			((CFrameNode*) pCurNode)->setBottomIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] );
			pCurNode = pCurNode->GetNext();
			i++;
		}
		RecalculateSizeChild();
	}

	return ret;
}
Example #30
0
wxTreeItemId CRemoteTreeView::MakeParent(CServerPath path, bool select)
{
	std::vector<wxString> pieces;
	pieces.reserve(path.SegmentCount() + 1);
	while (path.HasParent()) {
		pieces.push_back(path.GetLastSegment());
		path = path.GetParent();
	}
	wxASSERT(!path.GetPath().empty());
	pieces.push_back(path.GetPath());

	const wxTreeItemId root = GetRootItem();
	wxTreeItemId parent = root;

	for (std::vector<wxString>::const_reverse_iterator iter = pieces.rbegin(); iter != pieces.rend(); ++iter) {
		if (iter != pieces.rbegin())
			path.AddSegment(*iter);

		wxTreeItemIdValue cookie;
		wxTreeItemId child = GetFirstChild(parent, cookie);
		if (child && GetItemText(child).empty()) {
			Delete(child);
			child = wxTreeItemId();
			if (parent != root)
				ListExpand(parent);
		}
		for (child = GetFirstChild(parent, cookie); child; child = GetNextSibling(child)) {
			const wxString& text = GetItemText(child);
			if (text == *iter)
				break;
		}
		if (!child) {
			CDirectoryListing listing;

			if (m_pState->m_pEngine->CacheLookup(path, listing) == FZ_REPLY_OK) {
				child = AppendItem(parent, *iter, 0, 2, path.HasParent() ? 0 : new CItemData(path));
				SetItemImages(child, false);
			}
			else {
				child = AppendItem(parent, *iter, 1, 3, path.HasParent() ? 0 : new CItemData(path));
				SetItemImages(child, true);
			}
			SortChildren(parent);

			auto nextIter = iter;
			++nextIter;
			if (nextIter != pieces.rend())
				DisplayItem(child, listing);
		}
		if (select && iter != pieces.rbegin()) {
#ifndef __WXMSW__
			// Prevent CalculatePositions from being called
			wxGenericTreeItem *anchor = m_anchor;
			m_anchor = 0;
#endif
			Expand(parent);
#ifndef __WXMSW__
			m_anchor = anchor;
#endif
		}

		parent = child;
	}

	return parent;
}