Example #1
0
bool ZUITextEngine::GetCursor(ZPoint inPoint, ZCursor& outCursor)
	{
	size_t selectStart, selectLength;
	this->GetSelection(selectStart, selectLength);
	if (selectLength != 0)
		{
		size_t cursorOffset = this->PointToOffset(this->FromHost(inPoint));
		if (cursorOffset >= selectStart && cursorOffset < selectStart + selectLength)
			{
			outCursor.Set(ZCursor::eCursorTypeArrow);
			return true;
			}
		}
	outCursor.Set(ZCursor::eCursorTypeIBeam);
	return true;
	}
Example #2
0
bool ZWindow::DispatchMessage(const ZMessage& inMessage)
	{
	if (ZMessageLooper::DispatchMessage(inMessage))
		return true;

	if (inMessage.Has("what"))
		{
		string theWhat = inMessage.GetString("what");
		if (theWhat == "Dispose")
			{
			delete this;
			return true;
			}
		else if (theWhat == "zoolib:ScreenLayoutChanged")
			{
			this->ForceOnScreen(true, true);
			return true;
			}
		else if (theWhat == "InvalidCursor")
			{
			fPostedCursorInvalid = false;
			ZCursor theCursor;
			bool gotIt = false;
			if (ZCaptureInput* theCaptureInput = fCaptureInput)
				{
				theCaptureInput->IncrementUseCount();
				if (ZSubPane* thePane = theCaptureInput->GetPane())
					gotIt = theCaptureInput->GetCursor(thePane->FromWindow(fLastMouseLocation), theCursor);
				theCaptureInput->DecrementUseCount();
				}
			else
				{
				ZPoint paneHitPoint = fLastMouseLocation - this->GetWindowOrigin();
				for (vector<ZWindowPane*>::iterator i = fVector_WindowPanes.begin(); i != fVector_WindowPanes.end(); ++i)
					{
					if ((*i)->GetVisible() && (*i)->CalcFrameRgn().Contains(paneHitPoint))
						{
						if (ZSubPane* hitPane = (*i)->FindPane(paneHitPoint - (*i)->GetLocation()))
							gotIt = hitPane->GetCursor(hitPane->FromWindow(paneHitPoint), theCursor);
						}
					}
				}
			// If neither the mouse tracker nor the enclosing pane set the cursor, ensure it's reset
			// to an arrow. If false is returned by the GetCursor methods they're supposed not to have
			// touched theCursor, but let's make sure and set it to be an arrow.
			if (!gotIt)
				theCursor.Set(ZCursor::eCursorTypeArrow);
			fOSWindow->SetCursor(theCursor);
			return true;
			}
		else if (theWhat == "zoolib:InvalidateMenuBar")
			{
			if (fPostedInvalidateMenuBar)
				{
				fPostedInvalidateMenuBar = false;
				ZMenuBar theMenuBar;
				this->GetWindowTarget()->DispatchInstallMenus(theMenuBar);
				fOSWindow->SetMenuBar(theMenuBar);
				}
			return true;
			}
		else if (theWhat == "zoolib:InvalidateAllMenuBars")
			{
			this->InvalidateWindowMenuBar();
			return true;
			}
		else if (theWhat == "zoolib:Close")
			{
			this->WindowCloseByUser();
			return true;
			}
		else if (theWhat == "zoolib:Zoom")
			{
			this->WindowZoomByUser();
			return true;
			}
		else if (theWhat == "zoolib:MouseDown")
			{
			this->WindowMessage_Mouse(inMessage);
			return true;
			}
		else if (theWhat == "zoolib:MouseUp")
			{
			this->WindowMessage_Mouse(inMessage);
			return true;
			}
		else if (theWhat == "zoolib:MouseEnter" || theWhat == "zoolib:MouseChange" || theWhat == "zoolib:MouseExit")
			{
			this->WindowMessage_Mouse(inMessage);
			return true;
			}
		else if (theWhat == "zoolib:CaptureCancelled")
			{
			this->WindowCaptureCancelled();
			return true;
			}
		else if (theWhat == "zoolib:FrameChange")
			{
			this->WindowFrameChange();
			return true;
			}
		else if (theWhat == "zoolib:ShownState")
			{
			this->WindowShownState((ZShownState)inMessage.GetInt32("shownState"));
			return true;
			}
		else if (theWhat == "zoolib:Activate")
			{
			if (fBackInkActive && fBackInkInactive && (fBackInkActive != fBackInkInactive))
				{
				if (!fBackInkActive->GetInk().IsSameAs(fBackInkInactive->GetInk()))
					this->InvalidateWindowRegion(ZDCRgn(this->GetSize()));
				}
			this->WindowActivate(inMessage.GetBool("active"));
			return true;
			}
		else if (theWhat == "zoolib:AppActivate")
			{
			this->WindowAppActivate(inMessage.GetBool("active"));
			return true;
			}
		else if (theWhat == "zoolib:Menu")
			{
			if (!this->WindowMenuMessage(inMessage) && fWindowSupervisor)
				fWindowSupervisor->WindowSupervisorPostMessage(inMessage);
			return true;
			}
		else if (theWhat == "zoolib:KeyDown")
			{
			this->WindowMessage_Key(inMessage);
			return true;
			}
		else if (theWhat == "zoolib:Idle")
			{
			this->WindowIdle();
			return true;
			}
		else if (theWhat == "zoolib:InvokeFunction")
			{
			if (MessageProc theProc = reinterpret_cast<MessageProc>(inMessage.GetPointer("function")))
				theProc(this, inMessage.GetValue("param"));
			return true;
			}
		}

	return false;
	}