コード例 #1
0
ファイル: kguidivider.cpp プロジェクト: CarlHuff/kgui
void kGUIDividerObj::Draw(void)
{
	kGUICorners c;

	GetCorners(&c);
	kGUI::DrawRectBevel(c.lx,c.ty,c.rx,c.by,false);
}
コード例 #2
0
ファイル: kguimenu2.cpp プロジェクト: CarlHuff/kgui
bool kGUIMenuObj::UpdateInput(void)
{
	int i;
	kGUICorners c;
	kGUICorners tc;
	bool over;

	GetCorners(&c);

	/* is the mouse over the title area? */
	over=kGUI::MouseOver(&c);
	if(over)
	{
		/* if i'm not active then activate me */
		/* I need to be active so I can track the mouse when it moves */
		/* off of the header area so I can unhilight the last header under the cursor */
		if(m_track==false)
		{
			m_track=true;
			kGUI::AddUpdateTask(this,CALLBACKNAME(Track));
		}
		/* yes they have mouse over the tabs on the top */
		/* which tab is the mouse over? (if any) */
		for(i=0;i<m_numentries;++i)
		{
			tc.lx=c.lx+m_titlex.GetEntry(i);
			tc.rx=tc.lx+m_titlew.GetEntry(i);
			tc.ty=c.ty;
			tc.by=c.by;

			if(kGUI::MouseOver(&tc))
			{
				/* yes mouse is over this column */
				if(i!=m_colhover)
				{
					Dirty();
					m_colhover=i;
					if(m_depth)
					{
						CloseMenu();
						OpenMenu(m_entry.GetEntry(i),tc.lx,tc.by);
					}
				}

				/* are they clicking on the menu header? */
				if(kGUI::GetMouseClickLeft()==true)
				{
					kGUI::SetForceUsed(true);
					if(!m_depth)
						OpenMenu(m_entry.GetEntry(i),tc.lx,tc.by);
					else
						CloseMenu();
				}
				return(true);
			}
		}
	}
	return(false);
}
コード例 #3
0
ファイル: opennurbs_box.cpp プロジェクト: Arecius/opennurbs
ON_BoundingBox ON_Box::BoundingBox() const
{
  ON_BoundingBox bbox;
  ON_3dPoint corners[8];
  if ( GetCorners(corners) )
    bbox.Set(3,0,8,3,&corners[0].x,false);
  return bbox;
}
コード例 #4
0
ファイル: opennurbs_box.cpp プロジェクト: Arecius/opennurbs
bool ON_Box::GetCorners( ON_SimpleArray<ON_3dPoint>& corners ) const
{
  corners.Empty();
  corners.Reserve(8);
  bool rc = GetCorners(corners.Array());
  if (rc)
    corners.SetCount(8);
  return rc;
}
コード例 #5
0
ファイル: rect.cpp プロジェクト: PNCG/neuron
void RectView::CreateHandles () {
    Coord x[4], y[4];
    Viewer* v = GetViewer();
    
    if (v != nil) {
        GetCorners(x, y);
        _handles = new RubberHandles(nil, nil, x, y, 4, 0, HANDLE_SIZE);
        v->InitRubberband(_handles);
    }
}
コード例 #6
0
ファイル: kguibusy.cpp プロジェクト: t0mac0/kgui
void kGUIBusyRectObj::Draw(void)
{
    kGUICorners c;

    GetCorners(&c);
    if(m_isbar==true)
        kGUI::GetSkin()->DrawBusy(&c);
    else
        kGUI::GetSkin()->DrawBusy2(&c,(int)((double)m_offset*(100.0f/TICKSPERSEC)));
}
コード例 #7
0
ファイル: kguimenu2.cpp プロジェクト: CarlHuff/kgui
void kGUIMenuObj::Track(void)
{
	bool over;
	kGUICorners c;

	GetCorners(&c);

	/* is the mouse over the title area? */
	over=kGUI::MouseOver(&c);
	if(over==false && !m_depth)
	{
		kGUI::DelUpdateTask(this,CALLBACKNAME(Track));
		m_track=false;

		m_colhover=-1;
		Dirty();
	}
}
コード例 #8
0
ファイル: kguitab.cpp プロジェクト: CarlHuff/kgui
void kGUITabObj::Track(void)
{
	kGUICorners c;
	int l,r,h,exp;
	bool over;

	/* calc size of tab area */
	kGUI::GetSkin()->GetTabSize(&exp,&l,&r,&h);
	GetCorners(&c);
	c.by=c.ty+exp+(h*m_numtabrows);

	over=kGUI::MouseOver(&c);
	if(!over)
	{
		kGUI::DelUpdateTask(this,CALLBACKNAME(Track));
		m_track=false;
		DirtyTab(m_overtab);
		m_overtab=-1;
	}
}
コード例 #9
0
ファイル: opennurbs_box.cpp プロジェクト: Arecius/opennurbs
bool ON_Box::Transform( const ON_Xform& xform )
{
  ON_3dPoint corners[8];
  bool rc = GetCorners(corners);
  if ( rc )
  {
    ON_Plane xplane(plane);
    rc = xplane.Transform(xform);
    if ( rc )
    {
      int i;
      for ( i = 0; i < 8; i++ )
      {
        corners[i] = xform*corners[i];
      }
      double x0,x1,x,y0,y1,y,z0,z1,z;
      ON_3dVector v = corners[7] - plane.origin;
      x0 = x1 = v*plane.xaxis;
      y0 = y1 = v*plane.yaxis;
      z0 = z1 = v*plane.zaxis;
      for ( i = 0; i < 7; i++ )
      {
        v = corners[i] - plane.origin;
        x = v*plane.xaxis;
        if ( x < x0 ) x0 = x; else if (x > x1 ) x1 = x;
        y = v*plane.yaxis;
        if ( y < y0 ) y0 = y; else if (y > y1 ) y1 = y;
        z = v*plane.zaxis;
        if ( z < z0 ) z0 = z; else if (z > z1 ) z1 = z;
      }
      double tol = ON_SQRT_EPSILON;
      if ( fabs(dx.ParameterAt(x0)) > tol || fabs(dx.ParameterAt(x1)-1.0) > tol )
        dx.Set(x0,x1);
      if ( fabs(dy.ParameterAt(y0)) > tol || fabs(dy.ParameterAt(y1)-1.0) > tol )
        dy.Set(y0,y1);
      if ( fabs(dz.ParameterAt(z0)) > tol || fabs(dz.ParameterAt(z1)-1.0) > tol )
        dz.Set(z0,z1);
    }
  }
  return rc;
}
コード例 #10
0
ファイル: kguitab.cpp プロジェクト: CarlHuff/kgui
void kGUITabObj::Draw(void)
{
	int i,x,y;
	kGUICorners c;
	kGUICorners cc;
	int l,r,h,exp;
	kGUI::GetSkin()->GetTabSize(&exp,&l,&r,&h);
	int gap=(m_close==true)?18+8:8;

	kGUI::PushClip();
	GetCorners(&c);
	kGUI::ShrinkClip(&c);
	
	/* is there anywhere to draw? */
	if(kGUI::ValidClip())
	{
		/* draw background */
		kGUI::DrawRect(c.lx,c.ty+exp+(h*m_numtabrows),c.rx,c.ty+exp+(h*m_numtabrows)+1,DrawColor(145,167,180));
		kGUI::DrawRectBevel(c.lx,c.ty+exp+(h*m_numtabrows)+1,c.rx,c.by,false);
		
		/* draw tab names */
		for(i=0;i<m_numtabs;++i)
		{
			x=c.lx+m_tabx.GetEntry(i);
			y=c.ty+m_taby.GetEntry(i);
			kGUI::GetSkin()->DrawTab(x,y,GetTabWidth(i)+gap,i==m_curtab,i==m_overtab,m_close);
			DrawTab(i,m_tabnames.GetEntryPtr(i),x+6,y+3);
		}

		if(m_numtabs)	/* if no tabs then m_curtab is not valid doh! */
		{
			kGUI::PushClip();
			GetChildCorners(&cc);
			kGUI::ShrinkClip(&cc);
			if(kGUI::ValidClip())
				DrawC(m_tabgroups.GetEntry(m_curtab));	/* draw all children of the currently selected tab */
			kGUI::PopClip();
		}
	}
	kGUI::PopClip();
}
コード例 #11
0
ファイル: kguidivider.cpp プロジェクト: CarlHuff/kgui
bool kGUIDividerObj::UpdateInput(void)
{
	kGUICorners c;

	GetCorners(&c);
	if(kGUI::MouseOver(&c)==true)
	{
		kGUI::SetTempMouseCursor(MOUSECURSOR_ADJUSTVERT);

		if(this!=kGUI::GetActiveObj() && kGUI::GetMouseClickLeft()==true)
		{
			kGUI::PushActiveObj(this);
			SetCurrent();
		}
	}

	if(this==kGUI::GetActiveObj())
	{
		int dy;
		if(kGUI::GetMouseReleaseLeft()==true)
		{
			kGUI::PopActiveObj();
			return(true);
		}

		dy=kGUI::GetMouseDY();
		if(dy)
		{
			kGUIEvent e;

			e.m_value[0].i=dy;
			CallEvent(EVENT_AFTERUPDATE,&e);
		}
		kGUI::SetTempMouseCursor(MOUSECURSOR_ADJUSTVERT);

		return(true);
	}
	else
		return(false);
}
コード例 #12
0
ファイル: kguimenu2.cpp プロジェクト: CarlHuff/kgui
void kGUIMenuObj::Draw(void)
{
	int i;
	kGUICorners c;

	GetCorners(&c);
//	kGUI::DrawRect(c.lx,c.ty,c.rx,c.by,DrawColor(128,128,128));
	for(i=0;i<m_numentries;++i)
	{
		if(i==m_colhover)
		{
			if(!m_depth)
				kGUI::DrawRectFrame(c.lx+m_titlex.GetEntry(i),c.ty,c.lx+m_titlex.GetEntry(i)+m_titlew.GetEntry(i)+(TITLEGAPX<<1),c.by,DrawColor(192,192,255),DrawColor(64,64,255));
			else
			{
				kGUI::DrawRect(c.lx+m_titlex.GetEntry(i),c.ty,c.lx+m_titlex.GetEntry(i)+m_titlew.GetEntry(i)+(TITLEGAPX<<1),c.ty+1,DrawColor(128,128,128));
				kGUI::DrawRect(c.lx+m_titlex.GetEntry(i),c.ty,c.lx+m_titlex.GetEntry(i)+1,c.by,DrawColor(128,128,128));
				kGUI::DrawRect(c.lx+m_titlex.GetEntry(i)+m_titlew.GetEntry(i)+(TITLEGAPX<<1)-1,c.ty,c.lx+m_titlex.GetEntry(i)+m_titlew.GetEntry(i)+(TITLEGAPX<<1),c.by,DrawColor(128,128,128));
			}
		}
		m_title.GetEntryPtr(i)->Draw(c.lx+TITLEGAPX+m_titlex.GetEntry(i),c.ty+TITLEGAPY,0,0);
	}
}
コード例 #13
0
ファイル: kguitab.cpp プロジェクト: CarlHuff/kgui
/* only dirty a specific tab at the top, not the whole thing */
void kGUITabObj::DirtyTab(int tab)
{
	kGUICorners c;
	kGUICorners tc;
	int tw;
	int l,r,h,exp;
	int gap=(m_close==true)?18+8:8;

	/* -1 == no current overtab, so ignore */
	if(tab<0 || m_hidetabs)
		return;

	/* calc size of tab area */
	kGUI::GetSkin()->GetTabSize(&exp,&l,&r,&h);
	GetCorners(&c);
	tw=GetTabWidth(tab)+gap+l+r;
	tc.lx=c.lx+m_tabx.GetEntry(tab);
	tc.rx=tc.lx+tw;
	tc.ty=c.ty+m_taby.GetEntry(tab);
	tc.by=tc.ty+h;

	Dirty(&tc);
}
コード例 #14
0
ファイル: rect.cpp プロジェクト: PNCG/neuron
Command* RectView::InterpretManipulator (Manipulator* m) {
    DragManip* dm = (DragManip*) m;
    Editor* ed = dm->GetViewer()->GetEditor();
    Tool* tool = dm->GetTool();
    Transformer* rel = dm->GetTransformer();
    Command* cmd = nil;

    if (tool->IsA(GRAPHIC_COMP_TOOL)) {
        RubberRect* rr = (RubberRect*) dm->GetRubberband();
        Coord x0, y0, x1, y1;
        rr->GetCurrent(x0, y0, x1, y1);

        if (x0 != x1 || y0 != y1) {
            BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar");
            PatternVar* patVar = (PatternVar*) ed->GetState("PatternVar");
            ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar");

            if (rel != nil) {
                rel = new Transformer(rel);
                rel->Invert();
            }

            Graphic* pg = GetGraphicComp()->GetGraphic();
            SF_Rect* rect = new SF_Rect(x0, y0, x1, y1, pg);

            if (brVar != nil) rect->SetBrush(brVar->GetBrush());
            if (patVar != nil) rect->SetPattern(patVar->GetPattern());

            if (colVar != nil) {
                rect->SetColors(colVar->GetFgColor(), colVar->GetBgColor());
            }
            rect->SetTransformer(rel);
            Unref(rel);
            cmd = new PasteCmd(ed, new Clipboard(new RectComp(rect)));
        }

    } else if (tool->IsA(RESHAPE_TOOL)) {
        RubberGroup* rubberGroup = (RubberGroup*) dm->GetRubberband();
	RubberLine* rubberLine = (RubberLine*) rubberGroup->First();
        SF_Polygon* polygon;
        Coord x[4], y[4];
	Coord x0, y0;
        
	GetCorners(x, y);
	rubberLine->GetCurrent(x0, y0, x[_reshapeCorner], y[_reshapeCorner]);

        if (rel != nil) {
            rel = new Transformer(rel);
            rel->Invert();
        }
        polygon = new SF_Polygon(x, y, 4, GetGraphic());
        polygon->SetTransformer(rel);
        Unref(rel);
        cmd = new ReplaceCmd(ed, new PolygonComp(polygon));

    } else if (tool->IsA(MOVE_TOOL)) {
        SlidingLineList* sll;
        Transformer* rel = dm->GetTransformer();
        Coord* ox, *oy, *cx, *cy;
        float fx0, fy0, fx1, fy1;
        int n;

        sll = (SlidingLineList*) dm->GetRubberband();
        sll->GetOriginal(ox, oy, n);
        sll->GetCurrent(cx, cy, n);
        if (rel != nil) {
            rel->InvTransform(float(ox[0]), float(oy[0]), fx0, fy0);
            rel->InvTransform(float(cx[0]), float(cy[0]), fx1, fy1);
        }
        delete ox; delete oy; delete cx; delete cy;
        cmd = new MoveCmd(ed, fx1 - fx0, fy1 - fy0);

    } else if (tool->IsA(SCALE_TOOL)) {
        ScalingLineList* sll = (ScalingLineList*) dm->GetRubberband();
        float sxy = sll->CurrentScaling();

        cmd = new ScaleCmd(ed, sxy, sxy);

    } else if (tool->IsA(ROTATE_TOOL)) {
        RotatingLineList* rll = (RotatingLineList*) dm->GetRubberband();
        float angle = rll->CurrentAngle() - rll->OriginalAngle();

        cmd = new RotateCmd(ed, angle);

    } else {
        cmd = GraphicView::InterpretManipulator(m);
    }
    return cmd;
}
コード例 #15
0
ファイル: rect.cpp プロジェクト: PNCG/neuron
Manipulator* RectView::CreateManipulator (
    Viewer* v, Event& e, Transformer* rel, Tool* tool
) {
    Coord x[5], y[5];
    Rubberband* rub = nil;
    Manipulator* m = nil;

    if (tool->IsA(GRAPHIC_COMP_TOOL)) {
        v->Constrain(e.x, e.y);
        rub = new RubberRect(nil, nil, e.x, e.y, e.x, e.y);
        m = new DragManip(
	    v, rub, rel, tool, DragConstraint(XYEqual | Gravity)
	);

    } else if (tool->IsA(RESHAPE_TOOL)) {
	RubberGroup* rub = new RubberGroup(nil, nil);
	Coord x[4], y[4];
        v->Constrain(e.x, e.y);
	GetCorners(x, y);
	_reshapeCorner = ClosestPoint(x, y, 4, e.x, e.y);

	if (_reshapeCorner > 0) {
	    rub->Append(
		new RubberLine(
                    nil, nil, x[_reshapeCorner-1], y[_reshapeCorner-1], e.x,e.y
                )
	    );
	} else { 
	    rub->Append(new RubberLine(nil,nil,x[3],y[3],e.x,e.y));
	}

	if (_reshapeCorner < 3) {
	    rub->Append(
		new RubberLine(
                    nil, nil, x[_reshapeCorner+1], y[_reshapeCorner+1], e.x,e.y
                )
	    );
	} else { 
	    rub->Append(new RubberLine(nil, nil, x[0], y[0], e.x, e.y));
	}
        m = new DragManip(
	    v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity)
	);

    } else if (tool->IsA(MOVE_TOOL)) {
        v->Constrain(e.x, e.y);
        GetCorners(x, y);
        x[4] = x[0]; y[4] = y[0];
	rub = new SlidingLineList(nil, nil, x, y, 5, e.x, e.y);
        m = new DragManip(
	    v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity)
	);

    } else if (tool->IsA(SCALE_TOOL)) {
        v->Constrain(e.x, e.y);
        GetCorners(x, y);
        x[4] = x[0]; y[4] = y[0];
        rub = new ScalingLineList(nil,nil,x,y,5, (x[0]+x[2])/2, (y[0]+y[2])/2);
        m = new DragManip(v, rub, rel, tool, Gravity);

    } else if (tool->IsA(ROTATE_TOOL)) {
        v->Constrain(e.x, e.y);
        GetCorners(x, y);
        x[4] = x[0]; y[4] = y[0];
        rub = new RotatingLineList(
            nil, nil, x, y, 5, (x[0]+x[2])/2, (y[0]+y[2])/2, e.x, e.y
        );
        m = new DragManip(v, rub, rel, tool, Gravity);

    } else {
        m = GraphicView::CreateManipulator(v, e, rel, tool);
    }
    return m;
}
コード例 #16
0
ファイル: kguitab.cpp プロジェクト: CarlHuff/kgui
bool kGUITabObj::UpdateInput(void)
{
	kGUICorners c;
	kGUICorners tc;
	kGUICorners cb;
	int i,tw;
	int l,r,h,exp;
	bool over;
	int gap=(m_close==true)?18+8:8;

	if(m_hidetabs==false)
	{
		/* calc size of tab area */
		kGUI::GetSkin()->GetTabSize(&exp,&l,&r,&h);
		GetCorners(&c);
		c.by=c.ty+exp+(h*m_numtabrows);

		/* is the mouse over the tab button area? */
		over=kGUI::MouseOver(&c);
		if(over)
		{
			/* if i'm not active then activate me */
			/* I need to be active so I can track the mouse when it moves */
			/* off of the tab area so I can unhilight the last tab under the cursor */
			if(m_track==false && m_locked==false)
			{
				m_track=true;
				kGUI::AddUpdateTask(this,CALLBACKNAME(Track));
			}
			/* yes they have mouse over the tabs on the top */
			/* which tab is the mouse over? (if any) */
			for(i=0;i<m_numtabs;++i)
			{
				tw=GetTabWidth(i)+gap+l+r;
				tc.lx=c.lx+m_tabx.GetEntry(i);
				tc.rx=tc.lx+tw;
				tc.ty=c.ty+m_taby.GetEntry(i);
				tc.by=tc.ty+h;

				if(kGUI::MouseOver(&tc))
				{
					if(m_locked==false)
					{
						/* yes mouse is over this tab */
						if(i!=m_overtab)
						{
							DirtyTab(m_overtab);
							DirtyTab(i);
							m_overtab=i;
						}
						/* check for clicking on the close button */
						if(i==m_curtab && m_close && kGUI::GetMouseReleaseLeft()==true)
						{
							/* position of close button */
							cb.lx=tc.rx-r-16;
							cb.rx=cb.lx+14;
							cb.ty=tc.ty+2;
							cb.by=cb.ty+14;
							if(kGUI::MouseOver(&cb))
							{
								kGUIEvent e;

								e.m_value[0].i=m_curtab;		/* tab being closed */

								/* then call tabclicked closed callback, it is up to the app to actually handle */
								Dirty();
								CallEvent(EVENT_CLOSE,&e);
								return(true);
							}
						}
					}

					/* are they rightclicking on the tab? */
					if(kGUI::GetMouseClickRight()==true)
					{
						if(m_locked)
						{
							kGUIEvent e;
							e.m_value[0].i=i;

							CallEvent(EVENT_TRYMOVED,&e);
						}
						else if(m_overtab!=m_curtab)	/* set this to the current tab first */
						{
							kGUIEvent e;

							kGUI::ClearActiveStack();
							e.m_value[0].i=m_curtab;		/* save the old value */
							m_curtab=m_overtab;

							/* then call tabclicked callback */
							CallEvent(EVENT_MOVED,&e);
						}
						/* then call rightclick tab callback */
						CallEvent(EVENT_RIGHTCLICK);
					}
					if(kGUI::GetMouseReleaseLeft()==true)
					{
						if(m_locked)
						{
							kGUIEvent e;
							e.m_value[0].i=i;

							CallEvent(EVENT_TRYMOVED,&e);
						}
						else if(m_overtab!=m_curtab)
						{
							kGUIEvent e;

							kGUI::ClearActiveStack();
							e.m_value[0].i=m_curtab;		/* save the old value */
							m_curtab=m_overtab;
							Dirty();
							/* call the tabclicked callback */
							CallEvent(EVENT_MOVED,&e);
						}
					}
					return(true);
				}
			}
		}

		/* if we got here then the mouse is not hovering over any of the tabs */
		/* so we need to reset the overtab variable back to "not over any" (-1) */
		if(m_overtab!=-1)
		{
			DirtyTab(m_overtab);	/* redraw */
			m_overtab=-1;
		}
	}

	/* send input to children of currently selected tab */
	if(m_numtabs)
		return(UpdateInputC(m_tabgroups.GetEntry(m_curtab)));
	return(false);
}