예제 #1
0
void XGProgress::InitControl (void)
{
	XRect r;

	fControl = NULL;
	if (!_GAppearance) return;

	if (IsVisible()) {
		r = GetContentRect();
		ViewToGlobal(&r);
	} else {
		r.left = -20,
		r.top = -20,
		r.right = -10,
		r.bottom = -10;
	}

	Rect mr = r;
	fControl = ::NewControl(GetRootWindow(),
							&mr,
							"\p",
							false,
							fValue,
							fMin,
							fMax,
							kControlProgressBarProc,
							GetViewID());
}
예제 #2
0
bool TTreeView::Drop(Point where, 
					 long modifiers, 
					 long /* itemRef */, 
					 long flavor,
					 void *dataptr,
					 long datalen)
{
	TreeDropRecord d;
	long retval;
	
	if (!FindDropPoint(where)) return false;		// don't do it!
	d.tree = this;
	d.dropID = flavor;
	d.parent = fDropParent;
	d.child = fDropChild;
	d.modifiers = modifiers;
	d.len = datalen;
	d.data = dataptr;
	
	retval = DoDispatch(KEventTreeDoDrop,GetViewID(),(void *)&d);
	InvalView();									// redraw me regardless
	
	if (1 == retval) return true;
	return false;
}
예제 #3
0
ezQtEngineViewWidget::~ezQtEngineViewWidget()
{
  ezEditorEngineProcessConnection::s_Events.RemoveEventHandler(ezMakeDelegate(&ezQtEngineViewWidget::EngineViewProcessEventHandler, this));

  ezViewDestroyedMsgToEngine msg;
  msg.m_uiViewID = GetViewID();
  m_pDocumentWindow->GetDocument()->SendMessageToEngine(&msg);
  m_pDocumentWindow->RemoveViewWidget(this);
}
예제 #4
0
long XGPopControl::DoKey(long arg, void *)
{
	short hi,lo;
	
	hi = GETHIWORD(arg);
	lo = GETLOWORD(arg);
	if (hi & KSpecialKey) {
		switch (lo) {
			case KKeyUpCursor:
				SetValue(GetValue()-1);
				DoDispatch(KXGPopValue,GetViewID(),NULL);
				return 0;
			case KKeyDownCursor:
				SetValue(GetValue()+1);
				DoDispatch(KXGPopValue,GetViewID(),NULL);
				return 0;
		}
	} else {
	}
	return -1;
}
예제 #5
0
bool TTreeView::Accept(long, long, long flavor)
{
	TreeDropRecord d;
	
	fDropID = flavor;
	fDropParent = 0;
	fDropChild = 0;
	fDropPos.v = -1;
	
	d.tree = this;
	d.dropID = flavor;
	if (1 == DoDispatch(KEventTreeCanDrop,GetViewID(),(void *)&d)) return true;
	return false;
}
예제 #6
0
void XGPopControl::InitControl (void)
{
	XRect r;

	fControl = NULL;

	if (IsVisible()) {
		r = GetContentRect();
		ViewToGlobal(&r);
	} else {
		r.left = -20,
		r.top = -20,
		r.right = -10,
		r.bottom = -10;
	}
	
/*
 * #warning I inserted the kControlPopupFixedWidthVariant into here; how to deal???
 * maybe use an additional bool in the ArgStream that indicates whether or not to
 * size the control to fit.
 */

	fControl = ::NewControl(GetRootWindow(),
							&r,
							"\pP",
							false,
							popupTitleLeftJust,
							-12345,
							0,
							kControlPopupButtonProc | kControlPopupUseWFontVariant |
								kControlPopupFixedWidthVariant,
							GetViewID());
	if (!fControl) return;

	MenuHandle menu = NewMenu(0x4000 + GetViewID(), "\pP");
	SetMenuHandle(menu);
}
예제 #7
0
const ezObjectPickingResult& ezQtEngineViewWidget::PickObject(ezUInt16 uiScreenPosX, ezUInt16 uiScreenPosY) const
{
  if (!ezEditorEngineProcessConnection::GetSingleton()->IsEngineSetup())
  {
    m_LastPickingResult.Reset();
  }
  else
  {
    ezViewPickingMsgToEngine msg;
    msg.m_uiViewID = GetViewID();
    msg.m_uiPickPosX = uiScreenPosX * devicePixelRatio();
    msg.m_uiPickPosY = uiScreenPosY * devicePixelRatio();

    GetDocumentWindow()->GetDocument()->SendMessageToEngine(&msg);
  }

  return m_LastPickingResult;
}
예제 #8
0
XGPopControl::~XGPopControl()
{
	if (fPop) delete fPop;
	DeleteAll();
	fFont->Detach();
#if OPT_MACOS
	if (fControl) {
		MenuHandle menu = GetMenuHandle();
		SetMenuHandle(NULL);
		DeleteMenu(0x4000 + GetViewID());
		DisposeMenu(menu);
	}
#endif
#if OPT_WINOS
	if (fControl) {
		::DestroyWindow(fControl);
	}
#endif
}
예제 #9
0
ENDDISPATCH

/*	XGPopControl::DoInlineClose
 *
 *		Handle inline close operation. This is only sent when a
 *	popup control is created...
 */

long XGPopControl::DoInlineClose(long, void *parg)
{
	XGSPopupInline *p = (XGSPopupInline *)parg;
	XRect r,s;
	
	if (fPop) {
		fPop = NULL;
		
		/*
		 *	Alter my value
		 */
		
		fValue = p->value;
		DoDispatch(KXGPopValue,GetViewID(),NULL);
		
		/*
		 *	Reddraw me in the 'up' position
		 */
		
		XGDraw draw(this);
		fFont->Attach();
		draw.SetFont(fFont);

		r = GetContentRect();
		draw.Draw3DRect(r,KXGEButton);
		s = r;
		s.left = s.right - (s.bottom - s.top);
		InsetRect(&s,2,2);
		draw.Draw3DRect(s,KXGEOutset);
	}
	
	return 0;
}
예제 #10
0
long XGPopControl::DoWInternal(long, void *parg)
{
	XGSWInternalRecord *r = (XGSWInternalRecord *)parg;
	long newval;
	
	switch (GETHIWORD(r->wp)) {
		case CBN_CLOSEUP:
			/*
			 *	This message is sent when the value of this control has been
			 *	changed.
			 */
			
			newval = SendMessage(fControl,CB_GETCURSEL,0,NULL);
			if (newval != fValue) {
				fValue = newval;
				DoDispatch(KXGPopValue,GetViewID(),NULL);
			}
			break;
		default:
			break;
	}
	return 0;
}
예제 #11
0
void ezQtEngineViewWidget::SyncToEngine()
{
  ezViewRedrawMsgToEngine cam;
  cam.m_uiRenderMode = m_pViewConfig->m_RenderMode;
  cam.m_CameraUsageHint = m_pViewConfig->m_CameraUsageHint;

  float fov = m_pViewConfig->m_Camera.GetFovOrDim();
  if (m_pViewConfig->m_Camera.IsPerspective())
  {
    ezEditorPreferencesUser* pPref = ezPreferences::QueryPreferences<ezEditorPreferencesUser>();
    fov = pPref->m_fPerspectiveFieldOfView;
  }

  cam.m_uiViewID = GetViewID();
  cam.m_fNearPlane = m_pViewConfig->m_Camera.GetNearPlane();
  cam.m_fFarPlane = m_pViewConfig->m_Camera.GetFarPlane();
  cam.m_iCameraMode = (ezInt8)m_pViewConfig->m_Camera.GetCameraMode();
  cam.m_bUseCameraTransformOnDevice = m_pViewConfig->m_bUseCameraTransformOnDevice;
  cam.m_fFovOrDim = fov;
  cam.m_vDirForwards = m_pViewConfig->m_Camera.GetCenterDirForwards();
  cam.m_vDirUp = m_pViewConfig->m_Camera.GetCenterDirUp();
  cam.m_vDirRight = m_pViewConfig->m_Camera.GetCenterDirRight();
  cam.m_vPosition = m_pViewConfig->m_Camera.GetCenterPosition();
  cam.m_ViewMatrix = m_pViewConfig->m_Camera.GetViewMatrix();
  m_pViewConfig->m_Camera.GetProjectionMatrix((float)width() / (float)height(), cam.m_ProjMatrix);

  cam.m_uiHWND = (ezUInt64)(winId());
  cam.m_uiWindowWidth = width() * this->devicePixelRatio();
  cam.m_uiWindowHeight = height() * this->devicePixelRatio();
  cam.m_bUpdatePickingData = m_bUpdatePickingData;
  cam.m_bEnablePickingSelected =
      IsPickingAgainstSelectionAllowed() &&
      (!ezEditorInputContext::IsAnyInputContextActive() || ezEditorInputContext::GetActiveInputContext()->IsPickingSelectedAllowed());

  m_pDocumentWindow->GetEditorEngineConnection()->SendMessage(&cam);
}
예제 #12
0
ENDDISPATCH

/*	TTreeView::DoKeyEvent
 *
 *		Tree event
 */

long TTreeView::DoKeyEvent(long arg, void *)
{
	TreeEventRecord tevent;
	TableDrawRecord tr;
	short i;
	short mods;
	short key;
	uint32 item;
	
	key = GETLOWORD(arg);
	mods = GETHIWORD(arg);
	
	if (mods & KSpecialKey) {
		/*
		 *	Scan for the various arrow keys
		 */
		
		switch (key) {
			case KKeyUpCursor:
				if (fLength <= 0) return 0;
				for (i = 0; i < fLength; ++i) {
					fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
					if (tr.entry->fSelected) {
						--i;
						break;
					}
				}
				if (i >= fLength || i < 0) i = 0;
				fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
				if (!(mods & KKeyShift)) {
					ClearSelection();
				}
				SetSelected((uint32)tr.entry,true);
				tevent.child = (uint32)tr.entry;
				DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
				return 0;
			case KKeyDownCursor:
				if (fLength <= 0) return 0;
				for (i = fLength - 1; i >= 0; --i) {
					fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
					if (tr.entry->fSelected) {
						++i;
						break;
					}
				}
				if (i >= fLength || i < 0) i = fLength - 1;
				fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
				if (!(mods & KKeyShift)) {
					ClearSelection();
				}
				SetSelected((uint32)tr.entry,true);
				tevent.child = (uint32)tr.entry;
				DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
				return 0;
			case KKeyLeftCursor:
				if (fSelectedCount == 1) {
					item = 0;
					if (fSelection->fOpen) {
						item = (uint32)fSelection;
					} else {
						item = (uint32)(fSelection->parent);
					}
					
					if (item) {
						OpenItem( item, false );
						SetSelection( item );
						
						tevent.child = item;
						DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
					}
				}
				return 0;
			case KKeyRightCursor:
				if (fSelectedCount == 1) {
					item = (uint32)(fSelection->child);
					if (item) {
						OpenItem( (uint32)fSelection, true );
						SetSelection( item );
						
						tevent.child = item;
						DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
					}
				}
				return 0;
			default:
				return -1;
		}
	} else {
		/*
		 *	Scan for the regular keys
		 */
		
#if 0
		if (key == 0x0D) {
			/*
			 *	Enter key == double-click
			 */
			
			if (fSelect != NULL) {
				tevent.child = (uint32)fSelect;
				DoDispatch(KEventTreeDoubleClick,GetViewID(),(void *)&tevent);
			}
			return 0;
		} else if (key == ' ') {
			/*
			 *	Space key == open/close item
			 */
			
			if (fSelect) {
				OpenItem((uint32)fSelect,!(fSelect->fOpen));
				return 0;
			}
		}
#endif
		return -1;
	}
}
예제 #13
0
bool TTreeView::FindDropPoint(Point where)
{
	XRect r;
	long len;
	long x,y;
	long h;
	long i;
	short inset;
	TableDrawRecord tr;
	TreeDropRecord tevent;
	TableEntryRecord *parent;
	TableEntryRecord *child;
	Point pos;
	
	if (!fDrawFlag) EnableDrawing();

	/*
	 *	Set up for drawing
	 */
	
	XGDraw draw(this);
	
	/*
	 *	Get the drawing parameters so I know where to draw
	 */
	
	r = GetContentRect();
	GetScrollParams(&x,&y,&h);
	x *= h;
	
	len = (r.bottom - r.top + h - 1) / h;
	len += y;
	if (len > fLength) len = fLength;
	
	/*
	 *	Iterate through text.
	 */
	
	for (i = y; i < len; i++) {
		fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
		
		r.top = (i - y) * h;
		r.bottom = r.top + h;
		r.left = 22 * tr.inset - x;
		
		/*
		 *	Determine relative position of drag point to the above
		 *	calculated rectangle
		 */
		
		if ((r.top + r.bottom)/2 > where.v) {
			break;
		}
	}
	
	/*
	 *	We have where I think the insertion point goes
	 */
	
	if (i == 0) {
		/*
		 *	This is being inserted into the root of this thing
		 */
		
		parent = NULL;
		child = NULL;
	} else {
		i--;
		fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
		
		r.left = 22 * tr.inset - x;
		if (where.h > r.left + 30) {
			/*
			 *	Drop into this object
			 */
			
			parent = tr.entry;
			child = NULL;
		} else {
			/*
			 *	Drop after this object
			 */
			
			parent = tr.entry->parent;
			child = tr.entry;
		}
	}
	
	/*
	 *	Now figure out if I can drop here. If not, iterate upwards.
	 */
	
	tevent.tree = this;
	tevent.dropID = fDropID;
	tevent.len = 0;
	tevent.data = NULL;
	for (;;) {
		tevent.parent = (uint32)parent;
		tevent.child = (uint32)child;
		if (0 != DoDispatch(KEventTreeDropHere,GetViewID(),(void *)&tevent)) break;
		
		if (child) {
			/*
			 *	Can this be dropped into the parent anywhere?
			 */
			
			child = NULL;
		} else if (parent) {
			/*
			 *	If I can't be dropped inside, can I be dropped alongside?
			 */
			
			child = parent;
			parent = parent->parent;
		} else {
			DrawDropPoint(draw,fDropPos);
			fDropPos.h = -1;
			fDropPos.v = -1;
			return false;			// can't drop anywhere in this...
		}
	}

	/*
	 *	Now that I know where this is going, figure out where the
	 *	hilite should go.
	 */
	
	pos.h = -1;
	pos.v = -1;
	if (child == NULL) {
		if (parent == NULL) {
			/*
			 *	This can only be selected if we're at the top.
			 */
			
			pos.h = 0;
			pos.v = 0;
		} else {
			/*
			 *	Find the parent and insert below it
			 */
			
			for (i = 0; i < fLength; i++) {
				fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
				if (parent == tr.entry) break;
			}
			if ((i >= y-1) && (i < len)) {
				pos.v = (i - y + 1) * h;
				pos.h = 22 * (1 + tr.inset) - x;
			}
		}
	} else {
		/*
		 *	Find this child and insert right after.
		 */
		
		for (i = 0; i < fLength; i++) {
			fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
			if (child == tr.entry) break;
		}
		
		/*
		 *	Now find the item that is at my indent level right
		 *	after me.
		 */
		
		inset = tr.inset;
		for (i++; i < fLength; i++) {
			fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
			if (tr.inset <= inset) break;
		}
		
		if ((i >= y) && (i <= len)) {
			pos.v = (i - y) * h;
			pos.h = 22 * inset - x;
		}
	}
	
	if ((pos.h != fDropPos.h) || (pos.v != fDropPos.v)) {
		DrawDropPoint(draw,fDropPos);
		DrawDropPoint(draw,pos);
		fDropPos = pos;
	}
	
	fDropParent = (uint32)parent;
	fDropChild = (uint32)child;
				
	return true;
}
예제 #14
0
bool TTreeView::DoMouseDown(Point where, short flags)
{
	XRect r,t;
	long len;
	long x,y;
	long h;
	long i;
	short lh,lt;
	short it;
	TableDrawRecord tr;
	short at;
	TreeEventRecord tevent;
	
	XGDraw draw(this);
	draw.SetFont(XGFont::LoadFont(1));
	if (!fDrawFlag) EnableDrawing();
	SetFocus();

	tevent.ev_flags = flags;
	
	/*
	 *	Get the drawing parameters so I know where these are
	 */
	
	r = GetContentRect();
	GetScrollParams(&x,&y,&h);
	x *= h;
	
	len = (r.bottom - r.top + h - 1) / h;
	len += y;
	if (len > fLength) len = fLength;
	
	lh = draw.GetFontHeight();			// lh == line height
	lt = (h-1-lh)/2;					// lt == line top (of label)
	it = (h-17)/2;						// it == icon top (for 16x16 icon)
	at = (h-13)/2;						// at == arrow top
	
	/*
	 *	Iterate through buttons
	 */
	
	for (i = y; i < len; i++) {
		fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
		if (1 || tr.inset > 0) {
			
			if (tr.entry->child || tr.entry->fChildDefer) {
				t.top = (i - y) * h + at;
				t.left = 22 * (tr.inset) - x + 2;

				t.bottom = t.top + 12;
				t.right = t.left + 12;
				if (PtInRect(where,&t)) {
					/*
					 *	Clicked on open icon.
					 */
					
					if (tr.entry->child == NULL) {
						/*
						 *	Defer open--dispatch event to give the
						 *	app a chance to fill in the children
						 */
						
						tevent.child = (uint32)tr.entry;
						DoDispatch(KEventTreeOpen,GetViewID(),(void *)&tevent);
					}
					tr.entry->fOpen = !(tr.entry->fOpen);
					Update();
					return false;
				}
			}
		}	
	}

	/*
	 *	Iterate through text.
	 */
	
	for (i = y; i < len; i++) {
		char buffer[256];
		
		fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
		GetItemData( (uint32)tr.entry, buffer, sizeof(buffer)-1 );
		
		r.top = (i - y) * h;
		r.bottom = r.top + h;
		r.left = 22 * (tr.inset+1) - x;
		r.right = r.left + draw.StringWidth(buffer) + 6;
		if (tr.entry->icon) r.right += 16;
		if (PtInRect(where,&r)) {
			/*
			 *	Clicked on an object
			 */
			
			fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
			tevent.child = (uint32)tr.entry;
			if (flags & KKeyShift) {
				SetSelected((uint32)tr.entry, !tr.entry->fSelected);
			} else {
				SetSelection((uint32)tr.entry);
			}
			if (flags & KDoubleClick) {
				/*
				 *	We double-clicked on this object
				 */
				
				DoDispatch(KEventTreeDoubleClick,GetViewID(),(void *)&tevent);
			} else {
				/*
				 *	We single-clicked here
				 */
				 
				DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
				
				if ((tr.entry->dragID) && XGDragger::Wait(this,where)) {
					/*
					 *	Should I drag?
					 */
					
					TreeDragRecord tdr;
					
					tdr.tree = this;
					tdr.dragID = (uint32)tr.entry;
					if (0 == DoDispatch(KEventTreeStartDrag,GetViewID(),(void *)&tdr)) {
						return false;
					}
					
					/*
					 *	Drag this one item
					 */
					 
					if ((tr.entry->dragSize.h != -1) && (tr.entry->dragSize.v != -1)) {
						r.left = where.h;
						r.top = where.v;
						r.right = r.left + tr.entry->dragSize.h;
						r.bottom = r.top + tr.entry->dragSize.v;
					}
					
					XGDragger drag(this,tr.entry->fInternDrag);
					
					/*char buffer[256];
					short len;
					len = fData.GetData(tr.entry->dragData,sizeof(buffer),buffer);
					
					drag.AddObject(1,tr.entry->dragID,buffer,len,&r);*/
					char buffer[256];
					int len = GetExtraData((uint32)tr.entry, buffer, sizeof(buffer));
					
					drag.AddObject(1,tr.entry->dragID, buffer, len, &r);
					drag.Track();
				}
			}
			
			return false;
		}
	}
	
	/*
	 *	If we get here, we didn't click on anything. Clear selection
	 */
	
	ClearSelection();
	tevent.child = NULL;
	DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
	return false;
}
예제 #15
0
bool XGPopControl::DoMouseDown(Point where, short flags)
{
#if OPT_MACOS || OPT_XWIN
	#pragma unused(flags)
#endif

#if OPT_MACOS
	if (fControl) {
		XGDraw draw(this,false);
		if (fFont) {
			fFont->Attach();
			draw.SetFont(fFont);
		}
		ViewToGlobal(&where);
		if (::TrackControl(fControl,where,NULL)) {
			fValue = GetControlValue(fControl) - 1;
			DoDispatch(KXGPopValue,GetViewID(),NULL);
		}
		return false;
	}
#endif

#if OPT_WINOS
	if (fControl) {
		SetFocus();
		return XGControl::DoMouseDown(where, flags);
	}
	return false;
#endif

#if OPT_XWIN || OPT_MACOS
	/*
	 *	If we get here, simulating popup. Happens when we dont' have
	 *	an appearance manager
	 */
	
	XRect r,s;
	XGDraw draw(this);
	fFont->Attach();
	draw.SetFont(fFont);
	
	/*
	 *	Capture focus
	 */
	
#if OPT_WINOS || OPT_XWIN
	SetFocus();
#endif
	
	/*
	 *	Draw the gadget down
	 */
	
	r = GetContentRect();
	draw.Draw3DRect(r,KXGEInButton);
	s = r;
	s.left = s.right - (s.bottom - s.top);
	InsetRect(&s,2,2);
	draw.Draw3DRect(s,KXGEInset);
	
	/*
	 *	Pop up the list
	 */
	
	r = GetContentRect();
	fPop = XGInlinePopup::Create(this,r,fFontID,&fList,fValue);
	SetCapture(fPop);

	return true;
#endif
}