Exemple #1
0
BOOL CRectItem::OnChangeItemPosition(const CRect& rectPos)
{
	CMainView* pView = GetActiveView();
	if (pView == NULL)
		return FALSE;
	ASSERT_VALID(pView);

	CRect rc = rectPos;
	pView->ClientToDoc(rc);

	if (rc != GetRect())
	{
		// The following lines were commented out because of a bug 
		// in Microsoft Equation Editor 3.0.  The rc keeps growing
		// when activated/deactivated.
		// Uncomment them if necessary for other objects.

		/*
		// invalidate old item
		Invalidate();
		// update to new rectangle
		SetRect(rc);
		*/

		GetDocument()->SetModifiedFlag();

		/*
		CSize sizeExtent;
		GetCachedExtent(&sizeExtent);
		SetBaseSize(sizeExtent);
		*/

		// and invalidate new
		Invalidate();
	}
	return COleClientItem::OnChangeItemPosition(rectPos);
}
Exemple #2
0
// Rendering:
bool nuiWindow::Draw(nuiDrawContext* pContext)
{
  pContext->PushState();
  pContext->ResetState();
  nuiWindowManager* pRoot = dynamic_cast<nuiWindowManager*>(mpParent);

  pContext->EnableBlending(false);

  if (!mRawWindow)
  {
    nuiTheme* pTheme = GetTheme();
    NGL_ASSERT(pTheme);
    pTheme->DrawWindowShade(pContext, mRect.Size(), nuiColor(1.0f, 1.0f, 1.0f, GetMixedAlpha()), IsParentActive());

    pContext->PushClipping();
    pContext->Clip(GetRect().Size());
    pContext->EnableClipping(true);

    if (pRoot->GetActiveWindow() == this)
    {
      if (mMoving)
        pTheme->DrawMovingWindow(pContext, this);
      else
        pTheme->DrawActiveWindow(pContext, this);
    }
    else
      pTheme->DrawWindow(pContext,this);

    pTheme->Release();

    pContext->PopClipping();
  }

  DrawChildren(pContext);

  return true;
}
Exemple #3
0
void SceneEditorScreenMain::AddBodyItem(const WideString &text, bool isCloseable)
{
    BodyItem *c = new BodyItem();
    
    int32 count = bodies.size();
    c->headerButton = ControlsFactory::CreateButton(
                        Vector2(TAB_BUTTONS_OFFSET + count * (ControlsFactory::BUTTON_WIDTH + 1), 
                             BODY_Y_OFFSET - ControlsFactory::BUTTON_HEIGHT), 
                        text);

    c->headerButton->SetTag(count);
    c->headerButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnSelectBody));
    if(isCloseable)
    {
        c->closeButton = ControlsFactory::CreateCloseWindowButton(
                                        Rect(ControlsFactory::BUTTON_WIDTH - ControlsFactory::BUTTON_HEIGHT, 0, 
                                        ControlsFactory::BUTTON_HEIGHT, ControlsFactory::BUTTON_HEIGHT));
        c->closeButton->SetTag(count);
        c->closeButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnCloseBody));
        c->headerButton->AddControl(c->closeButton);
    }
    else 
    {
        c->closeButton = NULL;
    }


    Rect fullRect = GetRect();
    c->bodyControl = new EditorBodyControl(Rect(0, BODY_Y_OFFSET + 1, fullRect.dx, fullRect.dy - BODY_Y_OFFSET - 1));
    c->bodyControl->SetTag(count);    
    
    AddControl(c->headerButton);    
    bodies.push_back(c);
    
    //set as current
    c->headerButton->PerformEvent(UIControl::EVENT_TOUCH_UP_INSIDE);
}
void wxCodeCompletionBox::DoShowCompletionBox()
{
    CHECK_PTR_RET(m_stc);

    // guesstimate a line height
    wxMemoryDC dc;
    wxBitmap bmp(1, 1);
    dc.SelectObject(bmp);
    wxFont font = m_stc->StyleGetFont(0);
    dc.SetFont(font);
    wxSize textSize = dc.GetTextExtent("Tp");

    int lineHeight = textSize.y + 3; // 3 pixels margins
    wxRect rect = GetRect();
    wxSize screenSize = ::wxGetDisplaySize();

    // determine the box x position
    int wordStart = m_startPos;
    wxPoint pt = m_stc->PointFromPosition(wordStart);
    pt = m_stc->ClientToScreen(pt);
    pt.y += lineHeight;

    // Check Y axis
    if((pt.y + rect.GetHeight()) > screenSize.GetHeight()) {
        // the completion box goes out of the Y axis, move it up
        pt.y -= lineHeight;
        pt.y -= rect.GetHeight();
    }

    // Check X axis
    if((pt.x + rect.GetWidth()) > screenSize.GetWidth()) {
        // the completion box goes out of the X axis. Move it to the left
        pt.x -= ((pt.x + rect.GetWidth()) - screenSize.GetWidth());
    }
    Move(pt);
    Show();
}
Exemple #5
0
void MainEmuFrame::OnMoveAround( wxMoveEvent& evt )
{
	if( IsBeingDeleted() || !IsVisible() || IsIconized() ) return;

	// Uncomment this when doing logger stress testing (and then move the window around
	// while the logger spams itself)
	// ... makes for a good test of the message pump's responsiveness.
	if( EnableThreadedLoggingTest )
		Console.Warning( "Threaded Logging Test!  (a window move event)" );

	// evt.GetPosition() returns the client area position, not the window frame position.
	// So read the window's screen-relative position directly.
	g_Conf->MainGuiPosition = GetScreenPosition();

	// wxGTK note: X sends gratuitous amounts of OnMove messages for various crap actions
	// like selecting or deselecting a window, which muck up docking logic.  We filter them
	// out using 'lastpos' here. :)

	static wxPoint lastpos( wxDefaultCoord, wxDefaultCoord );
	if( lastpos == evt.GetPosition() ) return;
	lastpos = evt.GetPosition();

	if( g_Conf->ProgLogBox.AutoDock )
	{
		if (ConsoleLogFrame* proglog = wxGetApp().GetProgramLog())
		{
			if (!proglog->IsMaximized())
			{
				g_Conf->ProgLogBox.DisplayPosition = GetRect().GetTopRight();
				proglog->SetPosition(g_Conf->ProgLogBox.DisplayPosition);
			}
		}
	}

	evt.Skip();
}
void CFilterEdit::ResizeWindow()
{
	if (!::IsWindow(m_hWnd))
		return;

	CRect editrc, rc;
	GetRect(&editrc);
	GetClientRect(&rc);
	editrc.left = rc.left + 4;
	editrc.top = rc.top + 1;
	editrc.right = rc.right - 4;
	editrc.bottom = rc.bottom - 4;

	CWindowDC dc(this);
	HGDIOBJ oldFont = dc.SelectObject(GetFont()->GetSafeHandle());
	TEXTMETRIC tm = { 0 };
	dc.GetTextMetrics(&tm);
	dc.SelectObject(oldFont);

	m_rcEditArea.left = editrc.left + m_sizeInfoIcon.cx;
	m_rcEditArea.right = editrc.right - m_sizeCancelIcon.cx - 5;
	m_rcEditArea.top = (rc.Height() - tm.tmHeight) / 2;
	m_rcEditArea.bottom = m_rcEditArea.top + tm.tmHeight;

	m_rcButtonArea.left = m_rcEditArea.right + 5;
	m_rcButtonArea.right = rc.right;
	m_rcButtonArea.top = (((rc.bottom)-m_sizeCancelIcon.cy)/2);
	m_rcButtonArea.bottom = m_rcButtonArea.top + m_sizeCancelIcon.cy;

	m_rcInfoArea.left = 0;
	m_rcInfoArea.right = m_rcEditArea.left;
	m_rcInfoArea.top = (((rc.bottom)-m_sizeInfoIcon.cy)/2);
	m_rcInfoArea.bottom = m_rcInfoArea.top + m_sizeInfoIcon.cy;

	SetRect(&m_rcEditArea);
}
Exemple #7
0
void FileDialog::OnPaint()
{
	axGC* gc = GetGC();

	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	// Background.
	gc->SetColor(axColor(0.9, 0.9, 0.9), 1.0);
	gc->DrawRectangle(rect0);

	// Icon bar.
	axRect iconBarRect(1, 1, rect0.size.x - 1, 31);
	gc->DrawRectangle(iconBarRect);
	gc->DrawRectangleColorFade(iconBarRect, 
							  axColor(0.6, 0.6, 0.6), 1.0, 
							  axColor(0.7, 0.7, 0.7), 1.0);


	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(iconBarRect);

	// Folder name.
	gc->SetColor(axColor(0.2, 0.2, 0.2), 1.0);
	gc->SetFontSize(14);
	gc->DrawString(_dirNavigation->GetCurrentDirectoryName(), axPoint(50, 7));

	axRect buttonBarRect(1, rect0.size.y - 30, rect0.size.x - 1, 30);
	gc->DrawRectangle(buttonBarRect);
	gc->DrawRectangleColorFade(buttonBarRect, 
							  axColor(0.6, 0.6, 0.6), 1.0, 
							  axColor(0.7, 0.7, 0.7), 1.0);

	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(buttonBarRect);
}
CString CDiagramGroupbox::Export( UINT /*format*/ )
/* ============================================================
	Function :		CDiagramGroupbox::Export
	Description :	Exports this object to str using format
					
	Return :		CString		-	The resulting string
	Parameters :	UINT format	-	The format to export to
					
	Usage :			An example Export-function. In this case, 
					we are not using the format parameter, as 
					we only have one format.

   ============================================================*/
{
	return "";

	CString input( "\t<div class='controls' style='border-width:2;border-style:groove;position:absolute;left:%i;top:%i;width:%i;height:%i;'><div class='controls' style='position:absolute;left:6;top:-6;background-color:#c0c0c0;'>%s</div></div>" );
	CString str;
	CRect rect = GetRect();
	CString title = GetTitle();
	title.Replace( " ", "&nbsp;" );
	str.Format( input, rect.left - 2, rect.top - 2, rect.Width(), rect.Height(), title );
	return str;
}
Exemple #9
0
bool nuiPopupMenu::Draw(nuiDrawContext* pContext)
{
  nuiRect r = GetRect();

  NGL_ASSERT(!mRects.empty());
  nuiMenuRect* pRect = mRects[0];

  nuiTheme* pTheme = GetTheme();
  NGL_ASSERT(pTheme);

  pTheme->DrawMenuWindow(pContext, pRect->mRect, this);
  if (pRect->mpSBar->IsVisible())
    DrawChild(pContext, pRect->mpSBar);
  //it++;

  if (mShowFirstNode)
  {
    nuiWidgetPtr pWidget = mpTree->GetElement();
    NGL_ASSERT(pWidget);
    nuiRect rect = pWidget->GetRect();
    //Draw the main menu item (tree root item)
    pContext->SetFillColor(GetColor(eMenuTitleBg));
    pContext->DrawRect(rect, eStrokeAndFillShape);

    pContext->EnableBlending(true);
    nuiReflection ref(1.0f, .4f);
    ref.Draw(pContext, rect);
    pContext->EnableBlending(false);

    DrawChild(pContext, pWidget);
  }

  DrawTree(pContext, mpTree, 0);
  pTheme->Release();
  return true;
}
Exemple #10
0
// virtual, overloaded from nuiWidget, to be able to draw the oscillo manually
bool guiOscillo::Draw(nuiDrawContext* pContext)
{
 if (mrData.empty())
    return false;
  
  const nuiRect& rect = GetRect();
  
  uint32 s1 = mrData[0].size();
  uint32 s2 = rect.GetWidth();
  uint32 count = MIN(s1, s2);
  nuiSize hi = rect.GetHeight();
  nuiSize mid = hi / 2;

  nuiColor color[2];
  color[0] = nuiColor(84,117,203);
  color[1] = nuiColor(200,0,0);
  
  for (uint32 c = 0; c < mrData.size(); c++)
  {
    
    nuiRenderArray* pArray = new nuiRenderArray(GL_LINE_STRIP);
    pArray->EnableArray(nuiRenderArray::eColor, true);
    
    pArray->SetColor(color[c]);
    for (uint32 s = 0; s < count; s++)
    {
      float value = mrData[c][s];
      pArray->SetVertex(s, mid + hi * value);
      pArray->PushVertex();
    }
    
    pContext->DrawArray(pArray);
  }
  
  return true;
}
Exemple #11
0
        void    Widget::Render(RenderTarget& target, RenderQueue& queue) const
        {
            OnPaint(target, queue);

            if (mUseScissor)
            {
                Area& area = ResourceManager::Get()->WidgetArea;
                area.PushArea(GetRect(true));
                const FloatRect& top = area.GetTopArea();

                target.Flush();

                RenderChildren(target, queue);

                queue.SetScissor(true, Vector2f(top.Left, target.GetHeight() - top.Bottom), Vector2f(top.GetSize().x, top.GetSize().y));
                target.Flush();
                area.PopArea();
            }
            else
            {
                queue.SetScissor(false);
                RenderChildren(target, queue);
            }
        }
Exemple #12
0
void nuiPositioner::Invalidate()
{
    // Get the rect of all the children:
    nuiRect rect;
    IteratorPtr pIt;
    //NGL_OUT(_T("nuiPositioner CalcIdealSize\n"));
    for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt))
    {
        nuiWidgetPtr pItem = pIt->GetWidget();
        nuiRect wrect(pItem->GetIdealRect());
        //NGL_OUT(_T("  WRect %ls\n"), wrect.GetValue().GetChars());
        rect.Union(rect,wrect.Size());
    }
    delete pIt;

    rect.SetPosition(mPPosition, GetRect().Size());

    nuiWidget::InvalidateRect(rect);
    SilentInvalidate();

    if (mpParent)
        ((nuiPositioner*)mpParent)->BroadcastInvalidate(this); //#HACK!
    DebugRefreshInfo();
}
BOOL CGumpButton::FromString( XML::Node* node )
{
	if (!CGumpEntity::FromString(node)) return FALSE;

	int normal, over, pressed;;

	XML::Node* gump_node = node->findNode("gump");
	if (gump_node) { 
		gump_node->lookupAttribute("normal", normal);
		gump_node->lookupAttribute("over", over);
		gump_node->lookupAttribute("pressed", pressed);
	}

	CSize size = GetRect().Size();
	SetConstraints(size,size);
	
	CGumpEditorDoc* pDoc = GfxGetGumpDocument(); ASSERT(pDoc);
	
	m_pGump[NORMAL] = pDoc->LoadGump(normal);
	m_pGump[HOVER] = pDoc->LoadGump(over);
	m_pGump[PRESSED] = pDoc->LoadGump(pressed);
	
	return TRUE;
}
void CLineNumberEdit::Prepare()
{
	// Calc sizes
	int width = CalcLineNumberWidth();
	CRect rect;
	GetClientRect( &rect );
	CRect rectEdit( rect );
	rect.right = width;
	rectEdit.left = rect.right + 3;

	// Setting the edit rect and
	// creating or moving child control
	SetRect( &rectEdit );
	if( m_line.m_hWnd )
		m_line.MoveWindow( 0, 0, width, rect.Height() );
	else
		m_line.Create(NULL,WS_CHILD | WS_VISIBLE | SS_NOTIFY, rect, this, 1 );

	GetRect( &rectEdit );

	// Update line number control data
	m_line.SetTopMargin( rectEdit.top );
	UpdateTopAndBottom();
}
Exemple #15
0
void duListCtrl::AdjustVisibleLine(int nTop)
{
	duRect rcListCtrl;
	GetRect(&rcListCtrl);

	int i;
	for (i = m_nFirstLine; i < m_vtLines.size(); i++)
	{
		duPlugin *pTemp = m_vtLines[i];
		if (pTemp)
		{
			duRect rcTemp;
			pTemp->GetRect(&rcTemp);
			
			pTemp->SetPosTop(nTop);
			pTemp->Resize(NULL);
			pTemp->SetVisible(TRUE); // 后面的控件还需要SetVisible(FALSE);
			
			nTop += rcTemp.Height();
			if (nTop >= rcListCtrl.Height())
				break;
		}
	}
}
CString CDiagramCombobox::Export( UINT /*format*/ )
/* ============================================================
	Function :		CDiagramCombobox::Export
	Description :	Exports this object to str using format
					
	Return :		CString		-	The resulting string
	Parameters :	UINT format	-	The format to export to
					
	Usage :			An example Export-function. In this case, 
					we are not using the format parameter, as 
					we only have one format.

   ============================================================*/
{
	return "";


	CString input( "\t<select class='controls' style='position:absolute;left:%i;top:%i;width:%i;height:%i;' onchange='JavaScript:comboboxHandler(this)' name='%s'></select>" );
	CString str;
	CRect rect = GetRect();
	str.Format( input, rect.left - 2, rect.top - 2, rect.Width(), rect.Height(), GetName() );

	return str;
}
Exemple #17
0
void ConsoleCanvas::MouseEvent(wxMouseEvent& event)
{
      m_pParent->SetCursor ( wxCURSOR_ARROW );

      int x,y;
      event.GetPosition(&x, &y);


//    Check the region of the Route/Leg button
#ifdef __WXMSW__
      if(event.LeftDown())
      {
            wxRegion rg(m_pLegRouteButton->GetRect());
            if(rg.Contains(x,y)  == wxInRegion)
            {
                  m_bShowRouteTotal = !m_bShowRouteTotal;
                  if(m_bShowRouteTotal)
                        pThisLegBox->SetLabel(_("Route"));
                  else
                        pThisLegBox->SetLabel(_("This Leg"));

                  pThisLegBox->Refresh(true);
            }
      }

///  Why is this necessary???
//    Because of the CaptureMouse call in chcanv.cpp when mouse enters concanv region

      wxRect rr = GetRect();
      if(!rr.Contains(x + rr.x, y + rr.y) )
            ReleaseMouse();

#endif


}
Exemple #18
0
void Player::Render(void) {

	if (m_pCharaterAnim != nullptr) {


		// Validate the image
		SGD_ASSERT(m_hImage != SGD::INVALID_HANDLE, "Entity::Render - image was not set!");

		SGD::Point ptOffset = SGD::Point{ 
			(m_ptPosition /*- m_szSize / 2*/).x - GameplayState::GetInstance()->GetWorldCamPosition().x,
			(m_ptPosition /*- m_szSize / 2*/).y - GameplayState::GetInstance()->GetWorldCamPosition().y 
		};
		SGD::Rectangle rectOffset = GetRect();
		rectOffset.Offset(-GameplayState::GetInstance()->GetWorldCamPosition().x, -GameplayState::GetInstance()->GetWorldCamPosition().y);

		// Draw the image
		SGD::GraphicsManager::GetInstance()->DrawRectangle(rectOffset, SGD::Color(255, 255, 0));
		//SGD::GraphicsManager::GetInstance()->DrawTexture(m_hImage, ptOffset, m_fRotation, m_szSize / 2, SGD::Color{ 255, 255, 255 });
		//SGD::GraphicsManager::GetInstance()->DrawTextureSection(m_hImage, ptOffset, {0.0f, 0.0f, 64.0f, 64.0f}, m_fRotation, m_szSize / 2, SGD::Color{ 255, 255, 255 });
		m_pCharaterAnim->Render(ptOffset, m_bIsFlipped);

	}

}
Exemple #19
0
void CStaticStatusBar::DrawBk(CDC *pDC)
{
	int crOldBk = pDC->GetBkColor();

	CRect rect;
	GetClientRect(&rect);

	//Background
	pDC->FillSolidRect(&rect, m_crBk);

	//Top line
	pDC->FillSolidRect(rect.left, rect.top, rect.Width(), 1, m_crTopSep);
	pDC->FillSolidRect(rect.left, rect.top + 1, rect.Width(), 1, m_crTopLeft);

	//Bottom line
	pDC->FillSolidRect(rect.left, rect.bottom, rect.Width(), 1, m_crBottomRight);

	PartData* pPartData = NULL;
	CRect rcPart;

	int nPane, nCount = m_mapParts.GetCount();
	for(nPane = 0; nPane < nCount; nPane++)
	{
		GetRect(nPane, &rcPart);

		m_mapParts.Lookup(nPane, pPartData);
		if(pPartData->nDrawType != SBT_NOBORDERS)
		{
			ASSERT((UINT)rcPart.Width() > m_nSepWidth);
			rcPart.left = rcPart.right - m_nSepWidth;
			DrawSep(pDC, &rcPart);
		}
	}
	
	pDC->SetBkColor(crOldBk);
}
void CXTPReportFilterEditControl::OnPaint()
{
	if (GetWindowTextLength() == 0 && ::GetFocus() != m_hWnd)
	{
		CPaintDC dc(this); // device context for painting

		CXTPFontDC autoFont(&dc, GetFont(), GetXtremeColor(COLOR_GRAYTEXT));

		// show hint text
		CString  strText = GetHint();

		CRect rc;
		GetClientRect(&rc);
		dc.FillSolidRect(rc, GetXtremeColor(COLOR_WINDOW));

		CRect rcText;
		GetRect(&rcText);
		dc.DrawText(strText, rcText, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_EDITCONTROL);
	}
	else
	{
		Default();
	}
}
void TBScrollBar::UpdateHandle()
{
	// Calculate the mover size and position
	bool horizontal = m_axis == AXIS_X;
	int available_pixels = horizontal ? GetRect().w : GetRect().h;
	int min_thickness_pixels = MIN(GetRect().h, GetRect().w);

	int visible_pixels = available_pixels;

	if (m_max - m_min > 0 && m_visible > 0)
	{
		double visible_proportion = m_visible / (m_visible + m_max - m_min);
		visible_pixels = (int)(visible_proportion * available_pixels);

		// Limit the size of the indicator to the slider thickness so that it doesn't
		// become too tiny when the visible proportion is very small.
		visible_pixels = MAX(visible_pixels, min_thickness_pixels);

		m_to_pixel_factor = (double)(available_pixels - visible_pixels) / (m_max - m_min)/*+ 0.5*/;
	}
	else
	{
		m_to_pixel_factor = 0;

		// If we can't scroll anything, make the handle invisible
		visible_pixels = 0;
	}

	int pixel_pos = (int)(m_value * m_to_pixel_factor);

	TBRect rect;
	if (horizontal)
		rect.Set(pixel_pos, 0, visible_pixels, GetRect().h);
	else
		rect.Set(0, pixel_pos, GetRect().w, visible_pixels);

	m_handle.SetRect(rect);
}
Exemple #22
0
void LodDistanceControl::Input(UIEvent *currentInput)
{
    if(-1 == mainTouch && UIEvent::PHASE_BEGAN == currentInput->phase)
    {
        mainTouch =  currentInput->tid;
    }

    
    if(mainTouch == currentInput->tid)
    {
        newPos = currentInput->point.x;
        Vector2 point = currentInput->point - GetPosition(true);

        switch (currentInput->phase) 
        {
            case UIEvent::PHASE_BEGAN:
            {
                leftEdge = Vector2(0.0f, 0.0f);
                rightEdge = Vector2(GetRect().dx, 0.0f);
                
                for(int32 iSlider = 0; iSlider < count - 1; ++iSlider)
                {
                    Rect intersectionRect = sliders[iSlider]->GetRect();
                    intersectionRect.x -= 1;
                    intersectionRect.dx += 2;
                    
                    if(intersectionRect.PointInside(point))
                    {
                        activeSlider = sliders[iSlider];
                        
                        if(iSlider)
                        {
                            leftEdge.x = sliders[iSlider - 1]->GetRect().x + sliders[iSlider - 1]->GetRect().dx;
                        }
                        if(iSlider < count - 2)
                        {
                            rightEdge.x = sliders[iSlider + 1]->GetRect().x;
                        }
                        
                        leftZone = zones[iSlider];
                        rightZone = zones[iSlider + 1];
                        
                        activeLodIndex = iSlider + 1;
                        
                        break;
                    }
                }
                
                oldPos = newPos;
                break;
            }
            case UIEvent::PHASE_DRAG:
            {
                UpdateSliderPos();

                break;
            }
            case UIEvent::PHASE_ENDED:
            {
                UpdateSliderPos();

                activeSlider = NULL;
                leftZone = rightZone = NULL;
                
                mainTouch = -1;
                activeLodIndex = -1;
                break;
            }
        }
    }
}
Exemple #23
0
void LodDistanceControl::SetDistances(float32 *newDistances, int32 newCount)
{
    Vector2 newSize = GetSize();
    newSize.y = (newCount + 1) * ControlsFactory::BUTTON_HEIGHT;
    SetSize(newSize);
    
    ReleaseControls();
    
    if(1 < newCount)
    {
        count = newCount;
        Memcpy(distances, newDistances, count * sizeof(float32));
        
        zones = new UIControl*[count];
        
        maxDistance = (distances[count - 1] < LodNode::MAX_LOD_DISTANCE) 
                                        ? LodNode::MAX_LOD_DISTANCE 
                                        : (LodNode::MAX_LOD_DISTANCE * 1.1f);
        
        Rect fullRect = GetRect();
        
        Color initialColor(0.8f, 0.5f, 0.1f, 1.0f);
        
        for(int32 iZone = 0; iZone < count; ++iZone)
        {
            float32 x = (iZone) ? distances[iZone] : 0.f;
            float32 dx = (iZone != count - 1) ? (distances[iZone + 1] - x) : (maxDistance - distances[iZone]);

            x = x * fullRect.dx / maxDistance;
            dx = dx * fullRect.dx / maxDistance;
            
            
            zones[iZone] = new UIControl(Rect(x, 0, dx, ControlsFactory::BUTTON_HEIGHT));
            zones[iZone]->SetInputEnabled(false, false);
            zones[iZone]->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
            
            float32 color = distances[iZone] / maxDistance;
            
            Color zoneColor;
            zoneColor.r = initialColor.r + color;
            zoneColor.g = initialColor.g + color;
            zoneColor.b = initialColor.b + color;
            zoneColor.a = 1.0f;
            
            if(1.0f < zoneColor.r) zoneColor.r -= (int32)zoneColor.r;
            if(1.0f < zoneColor.g) zoneColor.g -= (int32)zoneColor.g;
            if(1.0f < zoneColor.b) zoneColor.b -= (int32)zoneColor.b;
            
            zones[iZone]->GetBackground()->SetColor(zoneColor);
            
            AddControl(zones[iZone]);
        }
        
        sliders = new UIControl*[count - 1];
        for(int32 iSlider = 0; iSlider < count - 1; ++iSlider)
        {
            float32 x = distances[iSlider + 1] / maxDistance * fullRect.dx;
            sliders[iSlider] = new UIControl(Rect(x - 1, 0, 3, ControlsFactory::BUTTON_HEIGHT));
            sliders[iSlider]->SetInputEnabled(false, false);
            sliders[iSlider]->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
            sliders[iSlider]->GetBackground()->SetColor(Color(1.0f, 0.0f, 0.0f, 1.0f));
            
            AddControl(sliders[iSlider]);
        }
    }
    
    for(int32 iDist = 0; iDist < LodNode::MAX_LOD_LAYERS; ++iDist)
    {
        RemoveControl(distanceText[iDist]);
        RemoveControl(distanceTextValues[iDist]);
        
        if(iDist < count)
        {
            AddControl(distanceText[iDist]);
            distanceText[iDist]->SetText(Format(L"Distance_%d:", iDist));

            AddControl(distanceTextValues[iDist]);
            distanceTextValues[iDist]->SetText(Format(L"%3.0f", distances[iDist]));
        }
    }
}
Exemple #24
0
// 显示弹出菜单
void CMenuItem::ShowPopupMenu()
{
	// 如果已经显示了子菜单,则直接退出
	if(m_pPopupMenu)
	{
		return;
	}

	if(m_bIsPopup)
	{
		m_pPopupMenu = new CDuiMenu(DuiSystem::GetDefaultFont(), 12);
		m_pPopupMenu->SetAutoClose(FALSE);
		m_pPopupMenu->SetParent(this);
		m_pPopupMenu->m_clrRowHover = m_clrHover;	// 设置菜单菜单的背景色
		CPoint point;
		CRect rc = GetRect();
		point.SetPoint(rc.left + rc.Width(), rc.top);
		int nMenuWidth = rc.Width();

		CDlgBase* pParentDlg = GetParentDialog();
		// 如果菜单项定义了XML文件,则使用此菜单项定义的XML文件加载子菜单
		// 否则查找父菜单对象,找到对应的XML文件名,使用此XML文件名加载子菜单
		CString strXmlFile = _T("");		
		CDuiMenu* pParentMenu = GetParentMenu();
		if(pParentMenu)
		{
			if(!m_strMenuXml.IsEmpty())
			{
				// 使用菜单项定义的XML文件
				strXmlFile = m_strMenuXml;
			}else
			{
				// XML文件设置为父菜单对象的XML文件
				strXmlFile = pParentMenu->GetXmlFile();
			}
			// 必须将父菜单对象的自动关闭关掉,否则子菜单显示时候,父菜单失去焦点,会自动销毁
			pParentMenu->SetAutoClose(FALSE);
			// 转换子菜单的坐标
			::ClientToScreen(pParentMenu->GetSafeHwnd(), &point);

			// 将父菜单的预设值菜单项列表添加到子菜单中
			for (size_t i = 0; i < pParentMenu->m_vecMenuItemValue.size(); i++)
			{
				MenuItemValue& itemValue = pParentMenu->m_vecMenuItemValue.at(i);
				m_pPopupMenu->m_vecMenuItemValue.push_back(itemValue);
			}
		}

		if(!strXmlFile.IsEmpty())
		{
			BOOL bSucc = m_pPopupMenu->LoadXmlFile(strXmlFile, pParentDlg, point, WM_DUI_MENU, GetName());
			if(bSucc)	// 加载弹出菜单成功才显示弹出菜单
			{
				// 计算菜单的位置并显示
				CRect rc;
				m_pPopupMenu->GetWindowRect(&rc);
				// 如果超出屏幕右侧范围,则菜单窗口往左移动一些,移动到当前菜单的左侧
				int nScreenWidth= GetSystemMetrics(SM_CXFULLSCREEN);
				if(rc.right > nScreenWidth)
				{
					//rc.OffsetRect(nScreenWidth - rc.right -10, 0);	// 移动到屏幕最右侧
					rc.OffsetRect(-(nMenuWidth + rc.Width()), 0);	// 移动到当前菜单左侧
				}
				int nScreenHeight= GetSystemMetrics(SM_CYFULLSCREEN);
				if(rc.bottom > nScreenHeight)
				{
					rc.OffsetRect(0, -(rc.Height() - m_rc.Height()));	// 高度超出屏幕则改为下对齐方式
				}
				m_pPopupMenu->MoveWindow(rc);
				m_pPopupMenu->ShowWindow(SW_SHOW);
				m_pPopupMenu->SetAutoClose(TRUE);
			}else
			{
				// 弹出菜单加载失败,删除菜单对象
				delete m_pPopupMenu;
				m_pPopupMenu = NULL;
			}
		}
	}
}
NS_IMETHODIMP
nsBaseScreen::GetRectDisplayPix(int32_t *outLeft,  int32_t *outTop,
                                int32_t *outWidth, int32_t *outHeight)
{
  return GetRect(outLeft, outTop, outWidth, outHeight);
}
Exemple #26
0
/*------------------------------------------------------------------------*/
int sci_plot2d(char* fname, void *pvApiCtx)
{
    SciErr sciErr;

    int* piAddrl1 = NULL;
    double* l1 = NULL;
    int* piAddrl2 = NULL;
    double* l2 = NULL;
    double* lt = NULL;
    int iTypel1 = 0;
    int iTypel2 = 0;
    int lw = 0;

    int m1 = 0, n1 = 0, m2 = 0, n2 = 0;
    int test = 0, i = 0, j = 0, iskip = 0;
    int frame_def = 8;
    int *frame = &frame_def;
    int axes_def = 1;
    int *axes = &axes_def;

    /* F.Leray 18.05.04 : log. case test*/
    int size_x = 0, size_y = 0;
    char dataflag = 0;

    char* logFlags = NULL;
    int* style = NULL;
    double* rect = NULL;
    char* strf = NULL;
    char* legend = NULL;
    int* nax = NULL;
    BOOL flagNax = FALSE;
    char strfl[4];
    BOOL freeStrf = FALSE;

    rhs_opts opts[] =
    {
        { -1, "axesflag", -1, 0, 0, NULL},
        { -1, "frameflag", -1, 0, 0, NULL},
        { -1, "leg", -1, 0, 0, NULL},
        { -1, "logflag", -1, 0, 0, NULL},
        { -1, "nax", -1, 0, 0, NULL},
        { -1, "rect", -1, 0, 0, NULL},
        { -1, "strf", -1, 0, 0, NULL},
        { -1, "style", -1, 0, 0, NULL},
        { -1, NULL, -1, 0, 0, NULL}
    };

    if (nbInputArgument(pvApiCtx) == 0)
    {
        sci_demo(fname, pvApiCtx);
        return 0;
    }

    CheckInputArgument(pvApiCtx, 1, 9);

    iskip = 0;
    if (getOptionals(pvApiCtx, fname, opts) == 0)
    {
        ReturnArguments(pvApiCtx);
        return 0;
    }

    if (checkInputArgumentType(pvApiCtx, 1, sci_strings))
    {
        /* logflags */
        GetLogflags(pvApiCtx, fname, 1, opts, &logFlags);
        iskip = 1;
    }

    if (FirstOpt(pvApiCtx) == 2 + iskip)                                /** plot2d([loglags,] y, <opt_args>); **/
    {
        sciErr = getVarAddressFromPosition(pvApiCtx, 1 + iskip, &piAddrl2);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        sciErr = getVarType(pvApiCtx, piAddrl2, &iTypel2);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        // the argument can be a matrix of doubles or other
        // If it is not a matrix of doubles, call overload
        if (iTypel2 == sci_matrix)
        {

            // Retrieve a matrix of double at position 1 + iskip.
            sciErr = getMatrixOfDouble(pvApiCtx, piAddrl2, &m2, &n2, &l2);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1 + iskip);
                return 1;
            }
        }
        else
        {
            OverLoad(1);
            return 0;
        }

        if (m2 == 1 && n2 > 1)
        {
            m2 = n2;
            n2 = 1;
        }

        m1 = m2;
        n1 = n2;

        sciErr = allocMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m1, n1, &l1);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            Scierror(999, _("%s: Memory allocation error.\n"), fname);
            return 1;
        }

        for (i = 0; i < m2 ; ++i)
        {
            for (j = 0 ; j < n2 ;  ++j)
            {
                *(l1 + i + m2 * j) = (double) i + 1;
            }
        }
    }
    else if (FirstOpt(pvApiCtx) >= 3 + iskip)     /** plot2d([loglags,] x, y[, style [,...]]); **/
    {
        /* x */
        sciErr = getVarAddressFromPosition(pvApiCtx, 1 + iskip, &piAddrl1);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        sciErr = getVarType(pvApiCtx, piAddrl1, &iTypel1);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        // x can be a matrix of doubles or other
        // If x is not a matrix of doubles, call overload
        if (iTypel1 == sci_matrix)
        {

            // Retrieve a matrix of double at position 1 + iskip.
            sciErr = getMatrixOfDouble(pvApiCtx, piAddrl1, &m1, &n1, &l1);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1 + iskip);
                return 1;
            }
        }
        else
        {
            OverLoad(1);
            return 0;
        }

        /* y */
        sciErr = getVarAddressFromPosition(pvApiCtx, 2 + iskip, &piAddrl2);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        sciErr = getVarType(pvApiCtx, piAddrl2, &iTypel2);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        // y can be a matrix of doubles or other
        // If y is not a matrix of doubles, call overload
        if (iTypel2 == sci_matrix)
        {

            // Retrieve a matrix of double at position 1 + iskip.
            sciErr = getMatrixOfDouble(pvApiCtx, piAddrl2, &m2, &n2, &l2);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 2 + iskip);
                return 1;
            }
        }
        else
        {
            OverLoad(2);
            return 0;
        }

        test = (m1 * n1 == 0) ||
               ((m1 == 1 || n1 == 1) && (m2 == 1 || n2 == 1) && (m1 * n1 == m2 * n2))  ||
               ((m1 == m2) && (n1 == n2)) ||
               ((m1 == 1 && n1 == m2) || (n1 == 1 && m1 == m2));
        //CheckDimProp
        if (!test)
        {
            Scierror(999, _("%s: Wrong size for input arguments: Incompatible sizes.\n"), fname);
            return 1;
        }

        if (m1 * n1 == 0)
        {
            /* default x=1:n */
            sciErr = allocMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m2, n2, &lt);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(999, _("%s: Memory allocation error.\n"), fname);
                return 1;
            }

            if (m2 == 1 && n2 > 1)
            {
                m2 = n2;
                n2 = 1;
            }
            for (i = 0; i < m2 ; ++i)
            {
                for (j = 0 ; j < n2 ;  ++j)
                {
                    *(lt + i + m2 * j) = (double) i + 1;
                }
            }
            m1 = m2;
            n1 = n2;
            l1 = lt;
        }
        else if ((m1 == 1 || n1 == 1) && (m2 != 1 && n2 != 1))
        {
            /* a single x vector for mutiple columns for y */
            sciErr = allocMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m2, n2, &lt);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(999, _("%s: Memory allocation error.\n"), fname);
                return 1;
            }

            for (i = 0; i < m2 ; ++i)
            {
                for (j = 0 ; j < n2 ;  ++j)
                {
                    *(lt + i + m2 * j) = *(l1 + i);
                }
            }
            m1 = m2;
            n1 = n2;
            l1 = lt;
        }
        else if ((m1 == 1 && n1 == 1) && (n2 != 1))
        {
            /* a single y row vector  for a single x */
            sciErr = allocMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m1, n2, &lt);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(999, _("%s: Memory allocation error.\n"), fname);
                return 1;
            }

            for (j = 0 ; j < n2 ;  ++j)
            {
                lt[j] = *l1;
            }
            n1 = n2;
            l1 = lt;
        }
        else
        {
            if (m2 == 1 && n2 > 1)
            {
                m2 = n2;
                n2 = 1;
            }
            if (m1 == 1 && n1 > 1)
            {
                m1 = n1;
                n1 = 1;
            }
        }
    }
    else
    {
        Scierror(999, _("%s: Wrong number of mandatory input arguments. At least %d expected.\n"), fname, 1);
        return 0;
    }

    if (n1 == -1 || n2 == -1 || m1 == -1 || m2 == -1)
    {
        Scierror(999, _("%s: Wrong size for input arguments #%d and #%d.\n"), fname, 1, 2); /* @TODO : detail error */
        return 0;
    }

    sciGetStyle(pvApiCtx, fname, 3 + iskip, n1, opts, &style);
    GetStrf(pvApiCtx, fname, 4 + iskip, opts, &strf);
    GetLegend(pvApiCtx, fname, 5 + iskip, opts, &legend);
    GetRect(pvApiCtx, fname, 6 + iskip, opts, &rect);
    GetNax(pvApiCtx, 7 + iskip, opts, &nax, &flagNax);

    if (iskip == 0)
    {
        GetLogflags(pvApiCtx, fname, 8, opts, &logFlags);
    }

    freeStrf = !isDefStrf(strf);

    // Check strf [0-1][0-8][0-5]
    if (!isDefStrf(strf) && (strlen(strf) != 3 || strf[0] < '0' || strf[0] > '1' || strf[1] < '0' || strf[1] > '8' || strf[2] < '0' || strf[2] > '5'))
    {
        Scierror(999, _("%s: Wrong value for strf option: %s.\n"), fname, strf);
        if (freeStrf)
        {
            freeAllocatedSingleString(strf);
        }
        return -1;
    }

    if (isDefStrf(strf))
    {
        strcpy(strfl, DEFSTRFN);

        strf = strfl;
        if (!isDefRect(rect))
        {
            strfl[1] = '7';
        }
        if (!isDefLegend(legend))
        {
            strfl[0] = '1';
        }

        GetOptionalIntArg(pvApiCtx, fname, 9, "frameflag", &frame, 1, opts);
        if (frame != &frame_def)
        {
            if (*frame >= 0 && *frame <= 8)
            {
                strfl[1] = (char)(*frame + 48);
            }
            else
            {
                Scierror(999, _("%s: Wrong value for frameflag option.\n"), fname);
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                return -1;
            }
        }

        GetOptionalIntArg(pvApiCtx, fname, 9, "axesflag", &axes, 1, opts);
        if (axes != &axes_def)
        {
            if ((*axes >= 0 && *axes <= 5) || *axes == 9)
            {
                strfl[2] = (char)(*axes + 48);
            }
            else
            {
                Scierror(999, _("%s: Wrong value for axesflag option.\n"), fname);
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                return -1;
            }
        }
    }

    /* Make a test on log. mode : available or not depending on the bounds set by Rect arg. or xmin/xmax :
       Rect case :
       - if the min bound is strictly posivite, we can use log. mode
       - if not, send error message
       x/y min/max case:
       - we find the first strictly positive min bound in Plo2dn.c ?? */

    switch (strf[1])
    {
        case '0':
            /* no computation, the plot use the previous (or default) scale */
            break;
        case '1' :
        case '3' :
        case '5' :
        case '7':
            /* based on Rect arg */
            if (rect[0] > rect[2] || rect[1] > rect[3])
            {
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                Scierror(999, _("%s: Impossible status min > max in x or y rect data.\n"), fname);
                return -1;
            }

            if (rect[0] <= 0. && logFlags[1] == 'l') /* xmin */
            {
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                Scierror(999, _("%s: Bounds on x axis must be strictly positive to use logarithmic mode.\n"), fname);
                return -1;
            }

            if (rect[1] <= 0. && logFlags[2] == 'l') /* ymin */
            {
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                Scierror(999, _("%s: Bounds on y axis must be strictly positive to use logarithmic mode.\n"), fname);
                return -1;
            }

            break;
        case '2' :
        case '4' :
        case '6' :
        case '8':
        case '9':
            /* computed from the x/y min/max */
            if ((int)strlen(logFlags) < 1)
            {
                dataflag = 'g';
            }
            else
            {
                dataflag = logFlags[0];
            }

            switch (dataflag)
            {
                case 'e' :
                    size_x = (m1 != 0) ? 2 : 0;
                    break;
                case 'o' :
                    size_x = m1;
                    break;
                case 'g' :
                default  :
                    size_x = (n1 * m1);
                    break;
            }

            if (size_x != 0)
            {
                if (logFlags[1] == 'l' && sciFindStPosMin((l1), size_x) <= 0.0)
                {
                    if (freeStrf)
                    {
                        freeAllocatedSingleString(strf);
                    }
                    Scierror(999, _("%s: At least one x data must be strictly positive to compute the bounds and use logarithmic mode.\n"), fname);
                    return -1;
                }
            }

            size_y = (n1 * m1);

            if (size_y != 0)
            {
                if (logFlags[2] == 'l' && sciFindStPosMin((l2), size_y) <= 0.0)
                {
                    if (freeStrf)
                    {
                        freeAllocatedSingleString(strf);
                    }
                    Scierror(999, _("%s: At least one y data must be strictly positive to compute the bounds and use logarithmic mode\n"), fname);
                    return -1;
                }
            }

            break;
    }

    // open a figure if none already exists
    getOrCreateDefaultSubwin();

    Objplot2d (1, logFlags, (l1), (l2), &n1, &m1, style, strf, legend, rect, nax, flagNax);

    // Allocated by sciGetStyle (get_style_arg function in GetCommandArg.c)
    FREE(style);

    if (freeStrf)
    {
        freeAllocatedSingleString(strf);
    }

    AssignOutputVariable(pvApiCtx, 1) = 0;
    ReturnArguments(pvApiCtx);
    return 0;
}
bool CActionButton::containsTouchLocation( CCTouch* touch )
{
	return GetRect().containsPoint(convertTouchToNodeSpaceAR(touch));
}
Exemple #28
0
void AButton::OnSize(wxSizeEvent & WXUNUSED(event))
{
    mFocusRect = GetRect().Deflate( 3, 3 );
    Refresh(false);
}
Exemple #29
0
void Ctrl::RefreshFrame() {
	LLOG("RefreshFrame " << Name());
	RefreshFrame(Rect(GetRect().Size()).Inflated(overpaint));
}
Exemple #30
0
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
	GuiLock __;
	LEVELCHECK(w, this);
	LTIMING("CtrlPaint");
	Rect rect = GetRect().GetSize();
	Rect orect = rect.Inflated(overpaint);
	if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect))
		return;
	Ctrl *q;
	Rect view = rect;
	for(int i = 0; i < frame.GetCount(); i++) {
		LEVELCHECK(w, NULL);
		frame[i].frame->FramePaint(w, view);
		view = frame[i].view;
	}
	Rect oview = view.Inflated(overpaint);
	bool hasviewctrls = false;
	bool viewexcluded = false;
	for(q = firstchild; q; q = q->next)
		if(q->IsShown())
			if(q->InFrame()) {
				if(!viewexcluded && IsTransparent() && q->GetRect().Intersects(view)) {
					w.Begin();
					w.ExcludeClip(view);
					viewexcluded = true;
				}
				LEVELCHECK(w, q);
				Point off = q->GetRect().TopLeft();
				w.Offset(off);
				q->CtrlPaint(w, clip - off);
				w.End();
			}
			else
				hasviewctrls = true;
	if(viewexcluded)
		w.End();
	DOLEVELCHECK;
	if(!oview.IsEmpty()) {
		if(oview.Intersects(clip) && w.IsPainting(oview)) {
			LEVELCHECK(w, this);
			if(overpaint) {
				w.Clip(oview);
				w.Offset(view.left, view.top);
				Paint(w);
				PaintCaret(w);
				w.End();
				w.End();
			}
			else {
				w.Clipoff(view);
				Paint(w);
				PaintCaret(w);
				w.End();
			}
		}
	}
	if(hasviewctrls && !view.IsEmpty()) {
		Rect cl = clip & view;
		w.Clip(cl);
		for(q = firstchild; q; q = q->next)
			if(q->IsShown() && q->InView()) {
				LEVELCHECK(w, q);
				Rect qr = q->GetRect();
				Point off = qr.TopLeft() + view.TopLeft();
				Rect ocl = cl - off;
				if(ocl.Intersects(Rect(qr.GetSize()).Inflated(overpaint))) {
					w.Offset(off);
					q->CtrlPaint(w, cl - off);
					w.End();
				}
			}
		w.End();
	}
}