Esempio n. 1
0
bool ZLTextView::onStylusPress(int x, int y) {
	AppLog("ZLTextView::onStylusPress 1");
	stopSelectionScrolling();

	myDoubleClickInfo.update(x, y, true);
	if (myDoubleClickInfo.Count > 10) {
		return true;
	}

	myTextAreaController.area().selectionModel().deactivate();

	shared_ptr<ZLTextModel> model = textArea().model();
  if (model.isNull()) {
	  return false;
	}
  AppLog("ZLTextView::onStylusPress 2");
	shared_ptr<ZLTextPositionIndicatorInfo> indicatorInfo = this->indicatorInfo();
	if (!indicatorInfo.isNull() &&
			(indicatorInfo->type() == ZLTextPositionIndicatorInfo::FB_INDICATOR) &&
			indicatorInfo->isSensitive()) {
		myTreeStateIsFrozen = true;
		bool indicatorAnswer = positionIndicator()->onStylusPress(x, y);
		myTreeStateIsFrozen = false;
		if (indicatorAnswer) {
			ZLApplication::Instance().refreshWindow();
			return true;
		}
	}
	AppLog("ZLTextView::onStylusPress 3");
	if (model->kind() == ZLTextModel::TREE_MODEL) {
		const ZLTextTreeNodeRectangle *node = textArea().treeNodeByCoordinates(x, y);
		if (node != 0) {
			int paragraphIndex = node->ParagraphIndex;
			ZLTextTreeParagraph *paragraph = (ZLTextTreeParagraph*)(*model)[paragraphIndex];

			paragraph->open(!paragraph->isOpen());
			myTextAreaController.rebuildPaintInfo(true);
			preparePaintInfo();
			if (paragraph->isOpen()) {
				int nextParagraphIndex = paragraphIndex + paragraph->fullSize();
				int lastParagraphIndex = textArea().endCursor().paragraphCursor().index();
				if (textArea().endCursor().isEndOfParagraph()) {
					++lastParagraphIndex;
				}
				if (lastParagraphIndex < nextParagraphIndex) {
					gotoParagraph(nextParagraphIndex, true);
					preparePaintInfo();
				}
			}
			const ZLTextWordCursor &startCursor = textArea().startCursor();
			int firstParagraphIndex = startCursor.paragraphCursor().index();
			if (startCursor.isStartOfParagraph()) {
				--firstParagraphIndex;
			}
			if (firstParagraphIndex >= paragraphIndex) {
				gotoParagraph(paragraphIndex);
				preparePaintInfo();
			}
			ZLApplication::Instance().refreshWindow();
			AppLog("ZLTextView::onStylusPress 4");
			return true;
		}
	}
	AppLog("ZLTextView::onStylusPress 5");
	return false;
}
Esempio n. 2
0
void stderr_vfprintf(void *, const char *format, va_list ap) {
	char buffer[BUF_SIZE];
	vsnprintf(buffer, sizeof(buffer), format, ap);
	AppLog(buffer);
}