void Displayer::HandleEvents()
{
	sf::Event Event;

	while (win->GetEvent(Event))
    {
		// window resized
		if (Event.Type == sf::Event::Resized)
		{
			#if (DEBUG_GENERAL_LEVEL >= 1)
				prt("window resized");
			#endif
			int width = Event.Size.Width;
			int height = Event.Size.Height;
			
			// Out with the old view, in with the new
			if (!view)
				delete view;
			view = new sf::View(sf::FloatRect(0,0,(float) width, (float) height));
			win->SetView(*view);
		
			glViewport(0, 0, width, height);
			
			if (!width && !height)
				EnableDrawing(false);
			else
				EnableDrawing(true);
		}
		
        // Window closed
        if (Event.Type == sf::Event::Closed)
		{
			#if (DEBUG_GENERAL_LEVEL >= 1)
				prt("window closed via x")
			#endif
			win->Close();
		}
            

        // Escape key pressed
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
		{
			#if (DEBUG_GENERAL_LEVEL >= 1)
				prt("window closed via ESC key")
			#endif
			win->Close();
		}
            
    }
}
示例#2
0
void TTreeView::DoActivate(bool flag)
{
	EnableDrawing();
	
	XGDraw draw(this);
	draw.SetFont(XGFont::LoadFont(1));
	for (uint32 item = GetFirstSelected(); item; item = GetNextSelected( item )) {
		RedrawItem(draw,(TableEntryRecord *)item);
	}

	XGView::DoActivate(flag);
}
示例#3
0
static void EndThumbTracking ( void ) {
	
//	hdlwindowinfo h = shellwindowinfo;

	EnableDrawing ();

	DisposeRgn ( gSaveClip );

//	if (flverticalscroll)
//		setscrollbarcurrent ((**h).vertscrollbar, (**h).vertscrollinfo.cur);
//	else
//		setscrollbarcurrent ((**h).horizscrollbar, (**h).horizscrollinfo.cur);

	return;
	} /*EndThumbTracking*/
示例#4
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;
}
示例#5
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;
}
示例#6
0
void TTreeView::DoSizeView()
{
	EnableDrawing();	

	RecalcScroll();
}
示例#7
0
pascal void ScrollThumbActionProc (void) {

	SInt32 theValue;
    hdlscrollbar hscrollbar;
    Point thePoint;
    Rect theRect;
    long ctscroll;
	tydirection dir;
	long currvalue;
	hdlwindowinfo h = shellwindowinfo;
	short baselineoffset;

    if (h == nil) /*defensive driving*/
    	return;

	hscrollbar = (**h).vertscrollbar;
	
	if (!flverticalscroll)
		hscrollbar = (**h).horizscrollbar;
	
	zerorect (&theRect);
	
	GetBestControlRect (hscrollbar, &theRect, &baselineoffset);
 	//theRect = (**hscrollbar).contrlRect;
 	
 	if (flverticalscroll)
		
		insetrect (&theRect, -kThumbTrackLengthSlop, -kThumbTrackWidthSlop);
		
 	else
		
		insetrect (&theRect, -kThumbTrackWidthSlop, -kThumbTrackLengthSlop);
	
    GetMouse (&thePoint);
        
    if (pointinrect (thePoint, theRect))
		
		theValue = CalcValueFromPoint (hscrollbar, thePoint);
		
	else
		
		theValue = gStartValue;
		
	currvalue = (**h).vertscrollinfo.cur;
	
	if (theValue != GetControlValue (hscrollbar)) {	// if we scrolled
		
		EnableDrawing ();

		ctscroll = theValue - GetControlValue (hscrollbar);
		
		dir = scrolldirection (flverticalscroll, ctscroll > 0);	
		
	 	(*shellglobals.scrollroutine) (dir, false, abs (ctscroll));
	 	
		(**h).vertscrollinfo.cur = theValue;

		DisableDrawing ();
		} /*if*/
	
	return;
	} /*ScrollThumbActionProc*/