예제 #1
0
bool BContainer::GetConnectorsSaveString(int* i,CString* str)
{
	BItem* element;
	DWORD parentOffset = 0;
	CString	tempConnector;

	element = GetElement(*i);
	parentOffset = element->offset;
	if(!HasChildren(element))
	{
		str->SetString("");
		return true;
	}
	str->SetString("");
	*i+=1;
	while(*i<this->GetNrElements())
	{
		element = GetElement(*i);
		if(element->offset <=parentOffset)
			break;
		if(!GetConnectorStr(i,&tempConnector))
			return false;
		str->Append(tempConnector);
		str->Append("=>");
	}
	*i-=1;

	if(str->Right(2).Compare("=>")==0)
		str->SetString(str->Left(str->GetLength() -2));
	return true;
}
wxTreeItemId luProjTree::findItemByData(const wxTreeItemId& parent, const wxString& data)
{
	if (!parent.IsOk()) return parent;

	ItemData* item = dynamic_cast<ItemData*>(GetItemData(parent));
	if (item && item->GetName() == data)
		return parent;

	if (item) gkPrintf("%s", (const char*)item->GetName());

	if (HasChildren(parent))
	{
		wxTreeItemIdValue cookie;
		wxTreeItemId item = GetFirstChild(parent, cookie);
		while (item.IsOk())
		{
			wxTreeItemId find = findItemByData(item, data); //find is item self or children.
			if (find.IsOk()) return find;

			item = GetNextChild(item, cookie);
		}
	}

	return wxTreeItemId(); //not found
}
예제 #3
0
void PHPOutlineTree::BuildTree(const wxFileName& filename)
{
    m_filename = filename;
    PHPSourceFile sourceFile(filename, NULL);
    sourceFile.SetParseFunctionBody(false);
    sourceFile.Parse();
    wxWindowUpdateLocker locker(this);
    DeleteAllItems();

    wxTreeItemId root = AddRoot(wxT("Root"));

    wxImageList* images = new wxImageList(clGetScaledSize(16), clGetScaledSize(16), true);
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/globals")));            // 0
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/function_private")));   // 1
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/function_protected"))); // 2
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/function_public")));    // 3
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/member_private")));     // 4
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/member_protected")));   // 5
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/member_public")));      // 6
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/namespace")));          // 7
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/class")));              // 8
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/enumerator")));         // 9
    AssignImageList(images);

    // Build the tree view
    BuildTree(root, sourceFile.Namespace());

    if(HasChildren(GetRootItem())) {
        ExpandAll();
    }
}
예제 #4
0
void GUIWindow::RemoveChild(GUIWindow* child)
{
	// Check if the request is valid.
	if (!HasChildren())
	{
		MessageBoxA(0, "Tried to remove a child from a window that has no children!", "Error!", MB_OK);
		return;
	}
	
	bool FoundChild = false;
	for (unsigned int i = 0; i < Children.size()-1; i++)
	{
		if ( Children[i] == child )
		{
			Children[i]->Parent = 0;
			Children.erase(Children.begin()+i);
			FoundChild = true;
			break;
		}
	}

	// Make sure it worked.
	if (!FoundChild)
	{
		MessageBoxA(0, "Tried to remove a child window from a window that it is not a child of!", "Error!", MB_OK);
	}
}
예제 #5
0
void
CMVarNode::Update
	(
	CMVarNode* node
	)
{
	SetValue(node->GetValue());
	SetValid(node->ValueIsValid());

	// value or pointer

	if (!node->HasChildren())
		{
		MakePointer(node->itsIsPointerFlag);
		if (itsIsPointerFlag && HasChildren())
			{
			UpdateContent();
			}
		}

	// struct or static array

	else if (SameElements(node))
		{
		MakePointer(node->itsIsPointerFlag, kJFalse);
		MergeChildren(node);
		}
	else
		{
		MakePointer(node->itsIsPointerFlag, kJFalse);
		StealChildren(node);
		}
}
예제 #6
0
const IBFact* IBFactVisitor::Next()
{
	// ici j'ai fait tout ce que j'avais à faire avec le dernier node

	// -> on passe à l'enfant suivant
	if (NextChild() == false)
	{
		// on a parcouru tout les enfants

		if (m_Stack.size() == 0)
			return NULL;

		// -> On pop
		m_Stack.pop_back();

		// -> on s'occupe du parent
		return LastFact();
	}
	else
	{
		// on push tout les enfants possible
		while (HasChildren(LastFact()))
		{
			m_Stack.push_back(IBFactVisitor::Iterator(LastFact()));
		}

		return LastFact();
	}
}
예제 #7
0
GUIWindow::~GUIWindow(void)
{
	if (HasChildren())
	{
		for (unsigned int i = 0; i < Children.size()-1; i++)
		{
			delete Children[i];
		}
	}
}
예제 #8
0
std::ostream &
	TKReturn::
	Release(std::ostream & s) const
{
	s << "return";
	if (HasChildren())
	{
		DoSpacePar(GetFirstChild(), s);
	}
	return s;
}
예제 #9
0
JBoolean
CMVarNode::OKToOpen()
	const
{
	if (itsIsPointerFlag && !HasChildren())
		{
		const_cast<CMVarNode*>(this)->UpdateContent();
		}

	return JNamedTreeNode::OKToOpen();
}
예제 #10
0
/**
 * Returns true if the supplied item has children
 */
bool BOM_TABLE_MODEL::IsContainer( const wxDataViewItem& aItem ) const
{
    auto row = ItemToRow( aItem );

    if( row )
    {
        return row->HasChildren();
    }

    return true;
}
예제 #11
0
void CXTPReportRecord::TreeAddRef()
{
	InternalAddRef();
	if (HasChildren())
	{
		for (int nChild = 0; nChild < GetChilds()->GetCount(); nChild++)
		{
			GetChilds()->GetAt(nChild)->TreeAddRef();
		}
	}
}
예제 #12
0
void CXTPReportRecord::TreeRelease()
{
	if (HasChildren())
	{
		for (int nChild = 0; nChild < GetChilds()->GetCount(); nChild++)
		{
			GetChilds()->GetAt(nChild)->TreeRelease();
		}
	}
	InternalRelease();
}
void FPropertyTableRow::Tick() 
{
	//@todo Create similar logic to handle if the column is the object and row is the property [12/7/2012 Justin.Sargent]
	if ( !HasChildren() && !DataSource->AsPropertyPath().IsValid() )
	{
		const TSharedRef< IPropertyTable > TableRef = GetTable();
		const TWeakObjectPtr< UObject > Object = DataSource->AsUObject();

		if ( !Object.IsValid() )
		{
			TableRef->RemoveRow( SharedThis( this ) );
		}
		else
		{
			TSharedPtr< FPropertyNode > Node = TableRef->GetObjectPropertyNode( Object );
			if(!Node.IsValid())
			{
				TableRef->RemoveRow( SharedThis( this ) );
				return;
			}

			Node = FPropertyNode::FindPropertyNodeByPath( GetTable()->GetRootPath(), Node.ToSharedRef() );
			if ( !Node.IsValid() )
			{
				TableRef->RemoveRow( SharedThis( this ) );
				return;
			}

			Node = FPropertyNode::FindPropertyNodeByPath( GetPartialPath(), Node.ToSharedRef() );

			if ( !Node.IsValid() )
			{
				TableRef->RemoveRow( SharedThis( this ) );
				return;
			}

			EPropertyDataValidationResult Result = Node->EnsureDataIsValid();

			if ( Result == EPropertyDataValidationResult::ObjectInvalid )
			{
				TableRef->RemoveRow( SharedThis( this ) );
			}
			else if ( Result == EPropertyDataValidationResult::ArraySizeChanged )
			{
				TableRef->RequestRefresh();
			}
			else if ( Result != EPropertyDataValidationResult::DataValid )
			{
				Refresh();
			}
		}
	}
}
예제 #14
0
// context menu event
void fileDissectTreeCtrl::OnItemMenu(wxTreeEvent& event)
{
	wxMenu mnuPopup;
	wxTreeItemId id = event.GetItem();
	wxMenuItem *pm;

	pm = mnuPopup.Append(IDM_NODE_EXPANDBELOW, wxT("E&xpand children"));
	if (!HasChildren(id))
		pm->Enable(false);

	pm = mnuPopup.Append(IDM_NODE_COLLAPSEBELOW, wxT("&Collapse children"));
	if (!HasChildren(id))
		pm->Enable(false);

	pm = mnuPopup.Append(IDM_NODE_HIGHLIGHT, wxT("&Highlight"));
	if (!GetItemData(id))
		pm->Enable(false);

	wxPoint pt = event.GetPoint();
    PopupMenu(&mnuPopup, pt);
}
예제 #15
0
wxTreeItemId wxTreeCtrlEx::GetLastItem() const
{
	wxTreeItemId cur = GetRootItem();
	if (cur.IsOk() && GetWindowStyle() & wxTR_HIDE_ROOT) {
		cur = GetLastChild(cur);
	}

	while (cur.IsOk() && HasChildren(cur) && IsExpanded(cur)) {
		cur = GetLastChild(cur);
	}

	return cur;
}
예제 #16
0
void PHPOutlineTree::BuildTree(const wxFileName& filename)
{
    m_filename = filename;
    PHPSourceFile sourceFile(filename, NULL);
    sourceFile.SetParseFunctionBody(false);
    sourceFile.Parse();
    wxWindowUpdateLocker locker(this);
    DeleteAllItems();

    wxTreeItemId root = AddRoot(wxT("Root"));

    // Build the tree view
    BuildTree(root, sourceFile.Namespace());

    if(HasChildren(GetRootItem())) { ExpandAll(); }
}
예제 #17
0
const IBFact* IBFactVisitor::Begin()
{
	m_Stack.clear();

	m_itGoals = m_oPlanner.GetGoals().begin();

	if (m_itGoals == m_oPlanner.GetGoals().end())
		return NULL;

	while (HasChildren(LastFact()))
	{
		m_Stack.push_back(IBFactVisitor::Iterator(LastFact()));
	}

	return LastFact();
}
예제 #18
0
wxTreeItemId wxTreeCtrlEx::GetPrevItemSimple(wxTreeItemId const& item) const
{
	wxTreeItemId cur = GetPrevSibling(item);
	if (cur.IsOk()) {
		while (cur.IsOk() && HasChildren(cur) && IsExpanded(cur)) {
			cur = GetLastChild(cur);
		}
	}
	else {
		cur = GetItemParent(item);
		if (cur.IsOk() && cur == GetRootItem() && (GetWindowStyle() & wxTR_HIDE_ROOT)) {
			cur = wxTreeItemId();
		}
	}
	return cur;
}
예제 #19
0
int clRowEntry::CalcItemWidth(wxDC& dc, int rowHeight, size_t col)
{
    wxUnusedVar(col);
    if(col >= m_cells.size()) { return 0; }

    clCellValue& cell = GetColumn(col);
    wxFont f = clScrolledPanel::GetDefaultFont();
    if(cell.GetFont().IsOk()) { f = cell.GetFont(); }
    dc.SetFont(f);

    int item_width = X_SPACER;
    if(cell.IsBool()) {
        // add the checkbox size
        item_width += rowHeight;
        item_width += X_SPACER;
    } else if(cell.IsChoice()) {
        item_width += rowHeight;
        item_width += X_SPACER;
    }

    wxSize textSize = dc.GetTextExtent(cell.GetValueString());
    if((col == 0) && !IsListItem()) {
        // always make room for the twist button
        item_width += rowHeight;
    }
    int bitmapIndex = cell.GetBitmapIndex();
    if(IsExpanded() && HasChildren() && cell.GetBitmapSelectedIndex() != wxNOT_FOUND) {
        bitmapIndex = cell.GetBitmapSelectedIndex();
    }

    if(bitmapIndex != wxNOT_FOUND) {
        const wxBitmap& bmp = m_tree->GetBitmap(bitmapIndex);
        if(bmp.IsOk()) {
            item_width += X_SPACER;
            item_width += bmp.GetScaledWidth();
            item_width += X_SPACER;
        }
    }
    if((col == 0) && !IsListItem()) {
        int itemIndent = (GetIndentsCount() * m_tree->GetIndent());
        item_width += itemIndent;
    }
    item_width += textSize.GetWidth();
    item_width += clHeaderItem::X_SPACER;
    return item_width;
}
예제 #20
0
GUIWindow *GUIWindow::ChildAtPoint(Point coord)
{
	if (!HasChildren())
	{
		return (GUIWindow*)0;
	}

	for (int i = Children.size()-1; i >= 0; i--)
	{
		if (Collision::PointToRect(Children[i]->ClientToWindow(coord), Children[i]->ClientArea) && Children[i]->IsVisible())
		{
			//return Children[i-1]->FindChildAtPoint(coord);
			return Children[i];
		}
	}

	return (GUIWindow*)0;
}
예제 #21
0
int32 MultiDataIO :: Read(void * buffer, uint32 size)
{
   if (HasChildren())
   {
      int32 ret = GetFirstChild()->Read(buffer, size);
      if (ret < 0) 
      {
         if ((_absorbPartialErrors)&&(_childIOs.GetNumItems() > 1))
         {
            (void) _childIOs.RemoveHead();
            return Read(buffer, size);  // try again with the new first child
         }
         else return -1;
      }
      else if (ret > 0) return (SeekAll(1, ret, IO_SEEK_CUR)==B_NO_ERROR) ? ret : -1;
   }
   return 0;
}
예제 #22
0
void PHPFileLayoutTree::Construct()
{
    // Sanity
    if(!m_editor || !m_manager) return;

    wxString text = m_editor->GetTextRange(0, m_editor->GetLength());
    PHPSourceFile source(text);
    source.SetParseFunctionBody(false);
    source.SetFilename(m_editor->GetFileName());
    source.Parse();

    DeleteAllItems();
    wxTreeItemId root = AddRoot(wxT("Root"));

    wxImageList* images = new wxImageList(16, 16, true);
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/globals")));            // 0
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/function_private")));   // 1
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/function_protected"))); // 2
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/function_public")));    // 3
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/member_private")));     // 4
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/member_protected")));   // 5
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/member_public")));      // 6
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/namespace")));          // 7
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/class")));              // 8
    images->Add(m_manager->GetStdIcons()->LoadBitmap(wxT("cc/16/enumerator")));         // 9
    AssignImageList(images);

    // Build the tree view
    BuildTree(root, source.Namespace());

    if(HasChildren(GetRootItem())) {
        wxTreeItemIdValue cookie;
        wxTreeItemId child = GetFirstChild(GetRootItem(), cookie);
        if(child.IsOk()) {
            SelectItem(child);
            ScrollTo(child);
        }
        ExpandAll();
    }
}
wxTreeItemId luProjTree::findItemByText(const wxTreeItemId& parent, const wxString& text)
{
	if (!parent.IsOk()) return parent;

	if (GetItemText(parent) == text)
		return parent;

	if (HasChildren(parent))
	{
		wxTreeItemIdValue cookie;
		wxTreeItemId item = GetFirstChild(parent, cookie);
		while (item.IsOk())
		{
			wxTreeItemId find = findItemByText(item, text); //find is item self or children.
			if (find.IsOk()) return find;

			item = GetNextChild(item, cookie);
		}
	}

	return wxTreeItemId(); //not found
}
예제 #24
0
bool BContainer::DeleteElement(BItem* currentProperty)
{
	BItem* el;
	BItem* parent;
	UINT parentOffset = 0;
	int i;
	i = GetElementPos(currentProperty);
	if(i < 0)
		return false;
	int j = i+1;
	parentOffset = currentProperty->offset;

	while(j<vElements.GetSize())
	{
		el = (BItem*)vElements.GetPointer(j);
		if(el->offset > parentOffset)
		{
			el->ShowWindow(SW_HIDE);
			vElements.Delete(j);
		}
		else
			break;
	}

	el = (BItem*)vElements.GetPointer(i);
	el->ShowWindow(SW_HIDE);
	
	parent = this->GetParent(i);		
	vElements.Delete(i);

	if(!HasChildren(parent))
		parent->collapsed = ITEM_NO_COLLAPSE;
	
	return true;
	

}
예제 #25
0
uint32 MultiDataIO :: GetPacketMaximumSize() const
{
   return (HasChildren()) ? GetFirstChild()->GetPacketMaximumSize() : 0;
}
예제 #26
0
void SpatialGraphKDNode::Render()
{
	if( HasChildren() )
	{
		LHC->Render();
		RHC->Render();
		return;
	}

	if( theSpatialGraph.GetDrawBlocked() )
	{
		if( bBlocked )
		{
			glColor4f(1,0,0,0.25f);
			BBox.RenderBox();
		}
	}

	if( theSpatialGraph.GetDrawBounds() )
	{
		glColor4f(0,0,0,1.f);
		BBox.RenderOutline();
	}


	Vector2 centroid = BBox.Centroid();

	if( theSpatialGraph.GetDrawNodeIndex() )
	{
		Vector2 screenCenter = MathUtil::WorldToScreen( centroid.X, centroid.Y );
		//Print some vals
		glColor3f(0,1.f,1.f);
		DrawGameText( IntToString(Index), "ConsoleSmall", (unsigned int)screenCenter.X, (unsigned int)screenCenter.Y );
	}

	if( theSpatialGraph.GetDrawGraph() && !bBlocked )
	{
		glColor3f(1.f,0.f,0.f);
		
		float linePoints[4];
		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(2, GL_FLOAT, 0, linePoints);
		for( unsigned int i = 0; i < Neighbors.size(); i++ )
		{
			if( Neighbors[i]->bBlocked || !NeighborLOS[i] )
				continue;

			//draw centroid to centroid half way point
			Vector2 neighbor = Neighbors[i]->BBox.Centroid();
			neighbor = centroid + ((neighbor - centroid) * 0.6f);
			
			linePoints[0] = centroid.X;
			linePoints[1] = centroid.Y;
			linePoints[2] = neighbor.X;
			linePoints[3] = neighbor.Y;
			glDrawArrays(GL_LINES, 0, 2);
		}
	}

	if( theSpatialGraph.GetDrawGridPoints() )
	{
		glColor3f(1.f,0.f,0.f);
		Vector2List gridPoints;
		int xPoints, yPoints;
		GetGridPoints(gridPoints, xPoints, yPoints );

		for( unsigned int i = 0; i < gridPoints.size(); i++ )
		{
			DrawPoint( gridPoints[i], Tree->GetSmallestDimensions().X * 0.15f );
		}

	}
}
예제 #27
0
파일: Partition.c 프로젝트: lersek/edk2
/**
  Stop this driver on ControllerHandle. Support stopping any child handles
  created by this driver.

  @param  This              Protocol instance pointer.
  @param  ControllerHandle  Handle of device to stop driver on
  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of
                            children is zero stop the entire bus driver.
  @param  ChildHandleBuffer List of Child Handles to Stop.

  @retval EFI_SUCCESS       This driver is removed ControllerHandle
  @retval other             This driver was not removed from this device

**/
EFI_STATUS
EFIAPI
PartitionDriverBindingStop (
  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,
  IN  EFI_HANDLE                    ControllerHandle,
  IN  UINTN                         NumberOfChildren,
  IN  EFI_HANDLE                    *ChildHandleBuffer
  )
{
  EFI_STATUS              Status;
  UINTN                   Index;
  EFI_BLOCK_IO_PROTOCOL   *BlockIo;
  EFI_BLOCK_IO2_PROTOCOL  *BlockIo2;
  BOOLEAN                 AllChildrenStopped;
  PARTITION_PRIVATE_DATA  *Private;
  EFI_DISK_IO_PROTOCOL    *DiskIo;
  EFI_GUID                *TypeGuid;

  BlockIo  = NULL;
  BlockIo2 = NULL;
  Private = NULL;

  if (NumberOfChildren == 0) {
    //
    // In the case of re-entry of the PartitionDriverBindingStop, the
    // NumberOfChildren may not reflect the actual number of children on the
    // bus driver. Hence, additional check is needed here.
    //
    if (HasChildren (ControllerHandle)) {
      DEBUG((EFI_D_ERROR, "PartitionDriverBindingStop: Still has child.\n"));
      return EFI_DEVICE_ERROR;
    }

    //
    // Close the bus driver
    //
    gBS->CloseProtocol (
          ControllerHandle,
          &gEfiDiskIoProtocolGuid,
          This->DriverBindingHandle,
          ControllerHandle
          );
    //
    // Close Parent BlockIO2 if has.
    //
    gBS->CloseProtocol (
           ControllerHandle,
           &gEfiDiskIo2ProtocolGuid,
           This->DriverBindingHandle,
           ControllerHandle
           );

    gBS->CloseProtocol (
          ControllerHandle,
          &gEfiDevicePathProtocolGuid,
          This->DriverBindingHandle,
          ControllerHandle
          );
    return EFI_SUCCESS;
  }

  AllChildrenStopped = TRUE;
  for (Index = 0; Index < NumberOfChildren; Index++) {
    gBS->OpenProtocol (
           ChildHandleBuffer[Index],
           &gEfiBlockIoProtocolGuid,
           (VOID **) &BlockIo,
           This->DriverBindingHandle,
           ControllerHandle,
           EFI_OPEN_PROTOCOL_GET_PROTOCOL
           );
    //
    // Try to locate BlockIo2.
    //
    gBS->OpenProtocol (
           ChildHandleBuffer[Index],
           &gEfiBlockIo2ProtocolGuid,
           (VOID **) &BlockIo2,
           This->DriverBindingHandle,
           ControllerHandle,
           EFI_OPEN_PROTOCOL_GET_PROTOCOL
           );


    Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
    if (Private->InStop) {
      //
      // If the child handle is going to be stopped again during the re-entry
      // of DriverBindingStop, just do nothing.
      //
      break;
    }
    Private->InStop = TRUE;

    BlockIo->FlushBlocks (BlockIo);

    if (BlockIo2 != NULL) {
      Status = BlockIo2->FlushBlocksEx (BlockIo2, NULL);
      DEBUG((EFI_D_ERROR, "PartitionDriverBindingStop: FlushBlocksEx returned with %r\n", Status));
    } else {
      Status = EFI_SUCCESS;
    }

    gBS->CloseProtocol (
           ControllerHandle,
           &gEfiDiskIoProtocolGuid,
           This->DriverBindingHandle,
           ChildHandleBuffer[Index]
           );

    if (IsZeroGuid (&Private->TypeGuid)) {
      TypeGuid = NULL;
    } else {
      TypeGuid = &Private->TypeGuid;
    }

    //
    // All Software protocols have be freed from the handle so remove it.
    // Remove the BlockIo Protocol if has.
    // Remove the BlockIo2 Protocol if has.
    //
    if (BlockIo2 != NULL) {
      //
      // Some device drivers might re-install the BlockIO(2) protocols for a
      // media change condition. Therefore, if the FlushBlocksEx returned with
      // EFI_MEDIA_CHANGED, just let the BindingStop fail to avoid potential
      // reference of already stopped child handle.
      //
      if (Status != EFI_MEDIA_CHANGED) {
        Status = gBS->UninstallMultipleProtocolInterfaces (
                         ChildHandleBuffer[Index],
                         &gEfiDevicePathProtocolGuid,
                         Private->DevicePath,
                         &gEfiBlockIoProtocolGuid,
                         &Private->BlockIo,
                         &gEfiBlockIo2ProtocolGuid,
                         &Private->BlockIo2,
                         &gEfiPartitionInfoProtocolGuid,
                         &Private->PartitionInfo,
                         TypeGuid,
                         NULL,
                         NULL
                         );
      }
    } else {
      Status = gBS->UninstallMultipleProtocolInterfaces (
                       ChildHandleBuffer[Index],
                       &gEfiDevicePathProtocolGuid,
                       Private->DevicePath,
                       &gEfiBlockIoProtocolGuid,
                       &Private->BlockIo,
                       &gEfiPartitionInfoProtocolGuid,
                       &Private->PartitionInfo,
                       TypeGuid,
                       NULL,
                       NULL
                       );
    }

    if (EFI_ERROR (Status)) {
      Private->InStop = FALSE;
      gBS->OpenProtocol (
             ControllerHandle,
             &gEfiDiskIoProtocolGuid,
             (VOID **) &DiskIo,
             This->DriverBindingHandle,
             ChildHandleBuffer[Index],
             EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
             );
    } else {
      FreePool (Private->DevicePath);
      FreePool (Private);
    }

    if (EFI_ERROR (Status)) {
      AllChildrenStopped = FALSE;
      if (Status == EFI_MEDIA_CHANGED) {
        break;
      }
    }
  }

  if (!AllChildrenStopped) {
    return EFI_DEVICE_ERROR;
  }

  return EFI_SUCCESS;
}
void
GPMProcessEntry::Update
	(
	const JFloat elapsedTime
	)
{
	itsPercentMemory = 0;

#ifdef _J_HAS_PROC
	try
	{
		ReadStat();
		ReadStatM();

		JSize mem;
		if (GPMGetSystemMemory(&mem))
			{
			itsPercentMemory = JFloat(itsResident * 100) / mem;
			}

		// shared across #if
		ReadCmdline();	// not in ctor, to make ctor faster
	}
	catch (...)
	{
		itsState = kZombie;
//		std::cerr << "failed to update: " << itsPID << std::endl;
	}
#elif defined _J_HAS_SYSCTL
	{
	int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, itsPID };

	kinfo_proc entry;
	size_t len = sizeof(entry);
	int result = sysctl(mib, 4, &entry, &len, NULL, 0);
	if (result != 0)
		{
		itsState = kZombie;
		}
	else
		{
		itsCommand  = entry.kp_proc.p_comm;
		itsPPID     = entry.kp_eproc.e_ppid;
		itsPriority = entry.kp_proc.p_priority;
		itsNice     = entry.kp_proc.p_nice;
		itsSize     = 0;
		itsResident = 0;
		itsShare    = 0;
		itsUTime    = entry.kp_proc.p_uticks;
		itsSTime    = entry.kp_proc.p_sticks;

		if (entry.kp_proc.p_stat == SSLEEP)
			{
			itsState = kSleep;
			}
		else if (entry.kp_proc.p_stat == SSTOP)
			{
			itsState = kStopped;
			}
		else if (entry.kp_proc.p_stat == SZOMB)
			{
			itsState = kZombie;
			}
		else
			{
			itsState = kRun;
			}

		JSize mem;
		if (GPMGetSystemMemory(&mem))
			{
			itsPercentMemory = JFloat(itsResident) / mem;
			}
		}

	// shared across #if
	ReadCmdline();	// not in ctor, to make ctor faster
	}
#endif

	SetName(itsCommand);
	ShouldBeOpenable(HasChildren());

	itsTime	        = (itsUTime + itsSTime) / sysconf(_SC_CLK_TCK);
	JSize totalTime	= (itsLastUTime == 0 || itsLastSTime == 0) ? 0 : (itsUTime - itsLastUTime) + (itsSTime - itsLastSTime);
	itsLastUTime	= itsUTime;
	itsLastSTime	= itsSTime;
	itsPercentCPU	= elapsedTime == 0 || itsState == kZombie ? 0 : JFloat(totalTime * 1000 / sysconf(_SC_CLK_TCK)) / (10 * elapsedTime);
}
예제 #29
0
void clRowEntry::Render(wxWindow* win, wxDC& dc, const clColours& c, int row_index, clSearchText* searcher)
{
    wxUnusedVar(searcher);
    wxRect rowRect = GetItemRect();
    bool zebraColouring = (m_tree->HasStyle(wxTR_ROW_LINES) || m_tree->HasStyle(wxDV_ROW_LINES));
    bool even_row = ((row_index % 2) == 0);

    // Define the clipping region
    bool hasHeader = (m_tree->GetHeader() && !m_tree->GetHeader()->empty());

    // Not cell related
    clColours colours = c;
    if(zebraColouring) {
        // Set Zebra colouring, only if no user colour was provided for the given line
        colours.SetItemBgColour(even_row ? c.GetAlternateColour() : c.GetBgColour());
    }

    // Override default item bg colour with the user's one
    if(GetBgColour().IsOk()) { colours.SetItemBgColour(GetBgColour()); }
    wxRect selectionRect = rowRect;
    wxPoint deviceOrigin = dc.GetDeviceOrigin();
    selectionRect.SetX(-deviceOrigin.x);
    if(IsSelected()) {
        DrawSimpleSelection(win, dc, selectionRect, colours);
    } else if(IsHovered()) {
        dc.SetPen(colours.GetHoverBgColour());
        dc.SetBrush(colours.GetHoverBgColour());
        dc.DrawRectangle(selectionRect);
    } else if(colours.GetItemBgColour().IsOk()) {
        dc.SetBrush(colours.GetItemBgColour());
        dc.SetPen(colours.GetItemBgColour());
        dc.DrawRectangle(selectionRect);
    }

    // Per cell drawings
    for(size_t i = 0; i < m_cells.size(); ++i) {
        bool last_cell = (i == (m_cells.size() - 1));
        colours = c; // reset the colours
        wxFont f = clScrolledPanel::GetDefaultFont();
        clCellValue& cell = GetColumn(i);
        if(cell.GetFont().IsOk()) { f = cell.GetFont(); }
        if(cell.GetTextColour().IsOk()) { colours.SetItemTextColour(cell.GetTextColour()); }
        if(cell.GetBgColour().IsOk()) { colours.SetItemBgColour(cell.GetBgColour()); }
        dc.SetFont(f);
        wxColour buttonColour = IsSelected() ? colours.GetSelbuttonColour() : colours.GetButtonColour();
        wxRect cellRect = GetCellRect(i);

        // We use a helper class to clip the drawings this ensures that if we exit the scope
        // the clipping region is restored properly
        clClipperHelper clipper(dc);
        if(hasHeader) { clipper.Clip(cellRect); }

        int textXOffset = cellRect.GetX();
        if((i == 0) && !IsListItem()) {
            // The expand button is only make sense for the first cell
            if(HasChildren()) {
                wxRect buttonRect = GetButtonRect();
                buttonRect.Deflate(1);
                textXOffset += buttonRect.GetWidth();
                if(m_tree->IsNativeTheme() && !IS_OSX) {
                    int flags = wxCONTROL_CURRENT;
                    if(IsExpanded()) { flags |= wxCONTROL_EXPANDED; }
                    int button_width = wxSystemSettings::GetMetric(wxSYS_SMALLICON_X);
                    wxRect modButtonRect = buttonRect;
                    modButtonRect.SetWidth(button_width);
                    modButtonRect.SetHeight(button_width);
                    modButtonRect = modButtonRect.CenterIn(buttonRect);
                    wxRendererNative::Get().DrawTreeItemButton(win, dc, modButtonRect, flags);
                } else {
                    wxRect buttonRect = GetButtonRect();
                    if(textXOffset >= cellRect.GetWidth()) {
                        // if we cant draw the button (off screen etc)
                        SetRects(GetItemRect(), wxRect());
                        continue;
                    }
                    buttonRect.Deflate((buttonRect.GetWidth() / 3), (buttonRect.GetHeight() / 3));
                    wxRect tribtn = buttonRect;
                    dc.SetPen(wxPen(buttonColour, 2));
                    if(IsExpanded()) {
                        tribtn.SetHeight(tribtn.GetHeight() - tribtn.GetHeight() / 2);
                        tribtn = tribtn.CenterIn(buttonRect);
                        wxPoint middleLeft = wxPoint((tribtn.GetLeft() + tribtn.GetWidth() / 2), tribtn.GetBottom());
                        dc.DrawLine(tribtn.GetTopLeft(), middleLeft);
                        dc.DrawLine(tribtn.GetTopRight(), middleLeft);
                    } else {
                        tribtn.SetWidth(tribtn.GetWidth() - tribtn.GetWidth() / 2);
                        tribtn = tribtn.CenterIn(buttonRect);

                        wxPoint middleLeft = wxPoint(tribtn.GetRight(), (tribtn.GetY() + (tribtn.GetHeight() / 2)));
                        wxPoint p1 = tribtn.GetTopLeft();
                        wxPoint p2 = tribtn.GetBottomLeft();
                        dc.DrawLine(p1, middleLeft);
                        dc.DrawLine(middleLeft, p2);
                    }
                }

            } else {
                wxRect buttonRect(rowRect);
                buttonRect.SetWidth(rowRect.GetHeight());
                buttonRect.Deflate(1);
                textXOffset += buttonRect.GetWidth();
                if(textXOffset >= cellRect.GetWidth()) {
                    SetRects(GetItemRect(), wxRect());
                    continue;
                }
            }
        }
        int itemIndent = IsListItem() ? clHeaderItem::X_SPACER : (GetIndentsCount() * m_tree->GetIndent());
        int bitmapIndex = cell.GetBitmapIndex();
        if(IsExpanded() && HasChildren() && cell.GetBitmapSelectedIndex() != wxNOT_FOUND) {
            bitmapIndex = cell.GetBitmapSelectedIndex();
        }

        // Draw checkbox
        if(cell.IsBool()) {
            // Render the checkbox
            textXOffset += X_SPACER;
            int checkboxSize = GetCheckBoxWidth(win);
            wxRect checkboxRect = wxRect(textXOffset, rowRect.GetY(), checkboxSize, checkboxSize);
            checkboxRect = checkboxRect.CenterIn(rowRect, wxVERTICAL);
            dc.SetPen(colours.GetItemTextColour());
            RenderCheckBox(win, dc, colours, checkboxRect, cell.GetValueBool());
            cell.SetCheckboxRect(checkboxRect);
            textXOffset += checkboxRect.GetWidth();
            textXOffset += X_SPACER;
        } else {
            cell.SetCheckboxRect(wxRect()); // clear the checkbox rect
        }

        // Draw the bitmap
        if(bitmapIndex != wxNOT_FOUND) {
            const wxBitmap& bmp = m_tree->GetBitmap(bitmapIndex);
            if(bmp.IsOk()) {
                textXOffset += IsListItem() ? 0 : X_SPACER;
                int bitmapY = rowRect.GetY() + ((rowRect.GetHeight() - bmp.GetScaledHeight()) / 2);
                // if((textXOffset + bmp.GetScaledWidth()) >= cellRect.GetWidth()) { continue; }
                dc.DrawBitmap(bmp, itemIndent + textXOffset, bitmapY, true);
                textXOffset += bmp.GetScaledWidth();
                textXOffset += X_SPACER;
            }
        }

        // Draw the text
        wxRect textRect(dc.GetTextExtent(cell.GetValueString()));
        textRect = textRect.CenterIn(rowRect, wxVERTICAL);
        int textY = textRect.GetY();
        int textX = (i == 0 ? itemIndent : clHeaderItem::X_SPACER) + textXOffset;
        RenderText(win, dc, colours, cell.GetValueString(), textX, textY, i);
        textXOffset += textRect.GetWidth();
        textXOffset += X_SPACER;

        if(cell.IsChoice()) {
            // draw the drop down arrow. Make it aligned to the right
            wxRect dropDownRect(cellRect.GetTopRight().x - rowRect.GetHeight(), rowRect.GetY(), rowRect.GetHeight(),
                                rowRect.GetHeight());
            dropDownRect = dropDownRect.CenterIn(rowRect, wxVERTICAL);
            DrawingUtils::DrawDropDownArrow(win, dc, dropDownRect, wxNullColour);
            // Keep the rect to test clicks
            cell.SetDropDownRect(dropDownRect);
            textXOffset += dropDownRect.GetWidth();
            textXOffset += X_SPACER;
            
            // Draw a separator line between the drop down arrow and the rest of the cell content
            dropDownRect.Deflate(3);
            dropDownRect = dropDownRect.CenterIn(rowRect, wxVERTICAL);
            dc.SetPen(wxPen(colours.GetHeaderVBorderColour(), 1, PEN_STYLE));
            dc.DrawLine(dropDownRect.GetTopLeft(), dropDownRect.GetBottomLeft());
            
        } else {
            cell.SetDropDownRect(wxRect());
        }

        if(!last_cell) {
            cellRect.SetHeight(rowRect.GetHeight());
            dc.SetPen(wxPen(colours.GetHeaderVBorderColour(), 1, PEN_STYLE));
            dc.DrawLine(cellRect.GetTopRight(), cellRect.GetBottomRight());
        }
    }
}
예제 #30
0
void CXTPReportRecord::DoPropExchange(CXTPPropExchange* pPX)
{
	PX_Bool(pPX, _T("Locked"), m_bLocked);
	PX_Bool(pPX, _T("Editable"), m_bEditable);

	BOOL bPreview = m_pPreviewItem != NULL;
	PX_Bool(pPX, _T("Preview"), bPreview);


	int nCount = GetItemCount();

	CXTPPropExchangeEnumeratorPtr pEnumItems(pPX->GetEnumerator(_T("Item")));

	if (pPX->IsStoring())
	{
		POSITION posItem = pEnumItems->GetPosition((DWORD)nCount);

		for (int i = 0; i < nCount; i++)
		{
			CXTPReportRecordItem* pItem = GetItem(i);
			ASSERT(pItem);
			if (!pItem)
				AfxThrowArchiveException(CArchiveException::badClass);

			CXTPPropExchangeSection secItem(pEnumItems->GetNext(posItem));
			PX_Object(&secItem, pItem, RUNTIME_CLASS(CXTPReportRecordItem));
		}
	}
	else
	{
		RemoveAll();

		POSITION posItem = pEnumItems->GetPosition();

		while (posItem)
		{
			CXTPReportRecordItem* pItem = NULL;

			CXTPPropExchangeSection sec(pEnumItems->GetNext(posItem));
			PX_Object(&sec, pItem, RUNTIME_CLASS(CXTPReportRecordItem));

			if (!pItem)
				AfxThrowArchiveException(CArchiveException::badClass);

			AddItem(pItem);
		}
	}

	//------------------------------------------------------------
	if (bPreview)
	{
		CXTPPropExchangeSection secPreviewItem(pPX->GetSection(_T("PreviewItem")));

		if (pPX->IsLoading())
		{
			CMDTARGET_RELEASE(m_pPreviewItem);
		}

		PX_Object(&secPreviewItem, m_pPreviewItem, RUNTIME_CLASS(CXTPReportRecordItemPreview));

		if (m_pPreviewItem && pPX->IsLoading())
		{
			m_pPreviewItem->m_pRecord = this;
		}
	}

	//------------------------------------------------------------
	if (pPX->GetSchema() > _XTP_SCHEMA_1041)
	{
		BOOL bHasChildren = HasChildren();
		PX_Bool(pPX, _T("HasChildren"), bHasChildren, FALSE);

		if (bHasChildren)
		{
			CXTPPropExchangeSection secChildren(pPX->GetSection(_T("Children")));
			GetChilds()->_DoPropExchange(&secChildren);
		}
		else if (m_pChildren)
		{
			m_pChildren->RemoveAll();
		}
	}
}