예제 #1
0
	void OnMouseClick(GMouse &m)
	{
		GRect r = GetClient();
		r.Size(2, 2);
		if (r.Overlap(m.x, m.y))
		{
			int i = m.y / Ly;
			if (i == 0)
			{
				Colour->Value(0);
			}
			else
			{
				Colour->Value(Colour->Presets[i-1]);
			}

			Visible(false);
		}
	}
예제 #2
0
파일: GRect.cpp 프로젝트: FEI17N/Lgi
void GRegion::Subtract(GRect *b)
{
	if (b && b->Valid())
	{
		GRect Sub = *b;
		int StartSize = Size;

		Normal();
		Sub.Normal();

		for (int i=0; i<StartSize; )
		{
			GRect c = *(a + i);
			if (c.Overlap(&Sub))
			{
				if (Sub.y1 > c.y1)
				{
					GRect *n = NewOne();
					n->x1 = c.x1;
					n->y1 = c.y1;
					n->x2 = c.x2;
					n->y2 = Sub.y1 - 1;
				}

				if (Sub.y2 < c.y2)
				{
					GRect *n = NewOne();
					n->x1 = c.x1;
					n->y1 = Sub.y2 + 1;
					n->x2 = c.x2;
					n->y2 = c.y2;
				}

				if (Sub.x1 > c.x1)
				{
					GRect *n = NewOne();
					n->x1 = c.x1;
					n->y1 = max(Sub.y1, c.y1);
					n->x2 = Sub.x1 - 1;
					n->y2 = min(Sub.y2, c.y2);
				}

				if (Sub.x2 < c.x2)
				{
					GRect *n = NewOne();
					n->x1 = Sub.x2 + 1;
					n->y1 = max(Sub.y1, c.y1);
					n->x2 = c.x2;
					n->y2 = min(Sub.y2, c.y2);
				}

				Delete(i);
				StartSize--;
			}
			else
			{
				i++;
			}
		}
	}	
}
예제 #3
0
파일: GView.cpp 프로젝트: FEI17N/Lgi
bool GView::_Mouse(GMouse &m, bool Move)
{
	ThreadCheck();
	
	#if 0
	if (!Move)
	{
		m.Trace("_Mouse");
		::GArray<GViewI*> _m;
		for (GViewI *i=this; i; i=i->GetParent())
		{
			_m.Add(i);
		}
		for (int n=0; n<_m.Length(); n++)
		{
			GViewI *i=_m[_m.Length()-1-n];
			char s[256];
			ZeroObj(s);
			memset(s, ' ', (n+1)*2);
			LgiTrace("%s%s %s\n", s, i->GetClass(), i->GetPos().GetStr());
		}
	}
	#endif

	#if DEBUG_MOUSE_EVENTS
	LgiTrace("%s:%i - _Mouse([%i,%i], %i)\n", _FL, m.x, m.y, Move);
	#endif

	if
	(
		!_View
		||
		(
			GetWindow()
			&&
			!GetWindow()->HandleViewMouse(this, m)
		)
	)
	{
		#if DEBUG_MOUSE_EVENTS
		LgiTrace("%s:%i - HandleViewMouse consumed event, _View=%p\n", _FL, _View);
		#endif
		return false;
	}

	GViewI *cap = _Capturing;
	#if DEBUG_MOUSE_EVENTS
	LgiTrace("%s:%i - _Capturing=%p/%s\n", _FL, _Capturing, _Capturing ? _Capturing->GetClass() : NULL);
	#endif
	if (_Capturing)
	{
		if (Move)
		{
			GMouse Local = lgi_adjust_click(m, _Capturing);
			LgiToGtkCursor(_Capturing, _Capturing->GetCursor(Local.x, Local.y));
			#if DEBUG_MOUSE_EVENTS
			LgiTrace("%s:%i - Local=%i,%i\n", _FL, Local.x, Local.y);
			#endif
			_Capturing->OnMouseMove(Local); // This can set _Capturing to NULL
		}
		else
		{
			_Capturing->OnMouseClick(lgi_adjust_click(m, _Capturing));
		}
	}
	else
	{
		if (Move)
		{
			bool Change = false;
			GViewI *o = WindowFromPoint(m.x, m.y);
			if (_Over != o)
			{
				#if DEBUG_MOUSE_EVENTS
				LgiTrace("%s:%i - _Over changing from %p/%s to %p/%s\n", _FL,
						_Over, _Over ? _Over->GetClass() : NULL,
						o, o ? o->GetClass() : NULL);
				#endif
				if (_Over)
					_Over->OnMouseExit(lgi_adjust_click(m, _Over));
				_Over = o;
				if (_Over)
					_Over->OnMouseEnter(lgi_adjust_click(m, _Over));
			}
		}
			
		GView *Target = dynamic_cast<GView*>(_Over ? _Over : this);

		GRect Client = Target->GView::GetClient(false);
		
		m = lgi_adjust_click(m, Target, !Move);
		if (!Client.Valid() || Client.Overlap(m.x, m.y))
		{
			LgiToGtkCursor(Target, Target->GetCursor(m.x, m.y));

			if (Move)
			{
				Target->OnMouseMove(m);
			}
			else
			{
				#if 0
				if (!Move)
				{
					char Msg[256];
					sprintf(Msg, "_Mouse Target %s", Target->GetClass());
					m.Trace(Msg);
				}
				#endif
				Target->OnMouseClick(m);
			}
		}
		else if (!Move)
		{
			#if DEBUG_MOUSE_EVENTS
			LgiTrace("%s:%i - Click outside %s %s %i,%i\n", _FL, Target->GetClass(), Client.GetStr(), m.x, m.y);
			#endif
		}
	}
	
	return true;
}