r17979 by fschmid - Preview Mode: implemented stub functions for handling events and actions.

scribus-commit scribus-commit at lists.scribus.net
Tue Dec 25 13:32:46 UTC 2012


Author: fschmid
Date: Tue Dec 25 13:32:46 2012
New Revision: 17979

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17979
Log:
Preview Mode: implemented stub functions for handling events and actions.

Modified:
    trunk/Scribus/scribus/annotation.h
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/canvasmode_normal.h
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/ui/annot.cpp

Modified: trunk/Scribus/scribus/annotation.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17979&path=/trunk/Scribus/scribus/annotation.h
==============================================================================
--- trunk/Scribus/scribus/annotation.h (original)
+++ trunk/Scribus/scribus/annotation.h Tue Dec 25 13:32:46 2012
@@ -67,6 +67,19 @@
 			Action_GoToR_FileAbs	= 9,
 			Action_Named			= 10
 		};
+		enum AnnotationScriptEvents {
+			Java_ReleaseButton	= 0,
+			Java_PressButton	= 1,
+			Java_EnterWidget	= 2,
+			Java_LeaveWidget	= 3,
+			Java_FocusIn		= 4,
+			Java_FocusOut		= 5,
+			Java_SelectionChg	= 6,
+			Java_FieldFormat	= 7,
+			Java_FieldValidate	= 8,
+			Java_FieldCalculate	= 9
+		};
+
 		enum AnnotationFlags {
 			Flag_ReadOnly			=		   1,	// Bit  1
 			Flag_Required			=		   2,	// Bit  2

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17979&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Tue Dec 25 13:32:46 2012
@@ -85,6 +85,7 @@
 	m_objectDeltaPos.setXY(0,0 );
 	ySnap = 0;
 	xSnap = 0;
+	m_hoveredItem = NULL;
 }
 
 inline bool CanvasMode_Normal::GetItem(PageItem** pi)
@@ -135,6 +136,7 @@
 	m_objectDeltaPos.setXY(0,0 );
 	frameResizeHandle = -1;
 	shiftSelItems = false;
+	m_hoveredItem = NULL;
 	setModeCursor();
 	if (fromGesture)
 	{
@@ -355,7 +357,7 @@
 	//<<#10116 Show overflow counter HUD
 	if (!movingOrResizing && mouseIsOnPage)
 	{
-		PageItem* hoveredItem=NULL;
+		PageItem* hoveredItem = NULL;
 		hoveredItem = m_canvas->itemUnderCursor(m->globalPos(), hoveredItem, m->modifiers());
 		if (hoveredItem)
 		{
@@ -387,10 +389,20 @@
 						toolT = hoveredItem->itemText.plainText();
 					if (!toolT.isEmpty())
 						QToolTip::showText(m->globalPos() + QPoint(5, 5), toolT, m_canvas);
+					if (hoveredItem != m_hoveredItem)
+					{
+						if (m_hoveredItem)
+							handleMouseLeave(m_hoveredItem);
+						handleMouseEnter(hoveredItem);
+					}
+					m_hoveredItem = hoveredItem;
 				}
 				else
+				{
 					if (QToolTip::isVisible())
 						QToolTip::hideText();
+					m_hoveredItem = NULL;
+				}
 			}
 			else
 			{
@@ -410,6 +422,12 @@
 		{
 			if (QToolTip::isVisible())
 				QToolTip::hideText();
+			if (m_doc->drawAsPreview)
+			{
+				if (m_hoveredItem)
+					handleMouseLeave(m_hoveredItem);
+				m_hoveredItem = NULL;
+			}
 		}
 	}
 	//>>#10116
@@ -1280,6 +1298,8 @@
 {
 	currItem->annotation().setOnState(true);
 	currItem->update();
+	if (currItem->annotation().ActionType() == Annotation::Action_JavaScript)
+		handleJavaAction(currItem, Annotation::Java_PressButton);
 	m_doc->regionsChanged()->update(currItem->getVisualBoundingRect());
 }
 
@@ -1287,6 +1307,8 @@
 {
 	currItem->annotation().setOnState(true);
 	currItem->update();
+	if (currItem->annotation().ActionType() == Annotation::Action_JavaScript)
+		handleJavaAction(currItem, Annotation::Java_PressButton);
 	m_doc->regionsChanged()->update(currItem->getVisualBoundingRect());
 }
 
@@ -1303,8 +1325,6 @@
 				gItem->update();
 			}
 		}
-		currItem->annotation().setOnState(true);
-		currItem->update();
 	}
 	else
 	{
@@ -1318,9 +1338,11 @@
 				gItem->update();
 			}
 		}
-		currItem->annotation().setOnState(true);
-		currItem->update();
-	}
+	}
+	currItem->annotation().setOnState(true);
+	currItem->update();
+	if (currItem->annotation().ActionType() == Annotation::Action_JavaScript)
+		handleJavaAction(currItem, Annotation::Java_PressButton);
 	m_view->updateContents();
 }
 
@@ -1328,6 +1350,8 @@
 {
 	currItem->annotation().setOnState(false);
 	currItem->annotation().setCheckState(!currItem->annotation().IsChecked());
+	if (currItem->annotation().ActionType() == Annotation::Action_JavaScript)
+		handleJavaAction(currItem, Annotation::Java_ReleaseButton);
 	currItem->update();
 	m_doc->regionsChanged()->update(currItem->getVisualBoundingRect());
 }
@@ -1336,6 +1360,31 @@
 {
 	currItem->annotation().setOnState(false);
 	currItem->update();
+	switch (currItem->annotation().ActionType())
+	{
+		case Annotation::Action_JavaScript:
+			handleJavaAction(currItem, Annotation::Java_ReleaseButton);
+			break;
+		case Annotation::Action_GoTo:
+		case Annotation::Action_URI:
+		case Annotation::Action_GoToR_FileAbs:
+		case Annotation::Action_GoToR_FileRel:
+			handleLinkAnnotation(currItem);
+			break;
+		case Annotation::Action_ResetForm:
+			m_doc->ResetFormFields();
+			break;
+		case Annotation::Action_ImportData:
+			m_doc->ImportData();
+			break;
+		case Annotation::Action_SubmitForm:
+			m_doc->SubmitForm();
+			break;
+		case Annotation::Action_Named:
+			handleNamedAction(currItem);
+		default:
+			break;
+	}
 	m_doc->regionsChanged()->update(currItem->getVisualBoundingRect());
 }
 
@@ -1353,9 +1402,6 @@
 				gItem->update();
 			}
 		}
-		currItem->annotation().setCheckState(true);
-		currItem->annotation().setOnState(false);
-		currItem->update();
 	}
 	else
 	{
@@ -1370,11 +1416,63 @@
 				gItem->update();
 			}
 		}
-		currItem->annotation().setCheckState(true);
-		currItem->annotation().setOnState(false);
-		currItem->update();
-	}
+	}
+	currItem->annotation().setCheckState(true);
+	currItem->annotation().setOnState(false);
+	if (currItem->annotation().ActionType() == Annotation::Action_JavaScript)
+		handleJavaAction(currItem, Annotation::Java_ReleaseButton);
+	currItem->update();
 	m_view->updateContents();
+}
+
+void CanvasMode_Normal::handleJavaAction(PageItem* currItem, int event)
+{
+	QString scriptCode = "";
+	switch (event)
+	{
+		case Annotation::Java_PressButton:
+			scriptCode = currItem->annotation().D_act();
+			break;
+		case Annotation::Java_ReleaseButton:
+			scriptCode = currItem->annotation().Action();
+			break;
+		case Annotation::Java_EnterWidget:
+			scriptCode = currItem->annotation().E_act();
+			break;
+		case Annotation::Java_LeaveWidget:
+			scriptCode = currItem->annotation().X_act();
+			break;
+		case Annotation::Java_FocusIn:
+			scriptCode = currItem->annotation().Fo_act();
+			break;
+		case Annotation::Java_FocusOut:
+			scriptCode = currItem->annotation().Bl_act();
+			break;
+		case Annotation::Java_SelectionChg:
+			scriptCode = currItem->annotation().K_act();
+			break;
+		case Annotation::Java_FieldFormat:
+			scriptCode = currItem->annotation().F_act();
+			break;
+		case Annotation::Java_FieldValidate:
+			scriptCode = currItem->annotation().V_act();
+			break;
+		case Annotation::Java_FieldCalculate:
+			scriptCode = currItem->annotation().C_act();
+			break;
+		default:
+			break;
+	}
+	if (!scriptCode.isEmpty())
+	{
+		// Execute the JavasScript Code
+//		qDebug() << "JavaScript:" << scriptCode;
+	}
+}
+
+void CanvasMode_Normal::handleNamedAction(PageItem* currItem)
+{
+//	qDebug() << "Named Action:" << currItem->annotation().Action();
 }
 
 void CanvasMode_Normal::handleLinkAnnotation(PageItem* currItem)
@@ -1404,12 +1502,26 @@
 
 void CanvasMode_Normal::handleFocusOut(PageItem* currItem)
 {
-//	qDebug() << "Focus Out" << currItem->itemName();
+	if (currItem->annotation().ActionType() == Annotation::Action_JavaScript)
+		handleJavaAction(currItem, Annotation::Java_FocusOut);
 }
 
 void CanvasMode_Normal::handleFocusIn(PageItem* currItem)
 {
-//	qDebug() << "Focus In" << currItem->itemName();
+	if (currItem->annotation().ActionType() == Annotation::Action_JavaScript)
+		handleJavaAction(currItem, Annotation::Java_FocusIn);
+}
+
+void CanvasMode_Normal::handleMouseLeave(PageItem* currItem)
+{
+	if (currItem->annotation().ActionType() == Annotation::Action_JavaScript)
+		handleJavaAction(currItem, Annotation::Java_LeaveWidget);
+}
+
+void CanvasMode_Normal::handleMouseEnter(PageItem* currItem)
+{
+	if (currItem->annotation().ActionType() == Annotation::Action_JavaScript)
+		handleJavaAction(currItem, Annotation::Java_EnterWidget);
 }
 
 void CanvasMode_Normal::keyPressEvent(QKeyEvent *e)

Modified: trunk/Scribus/scribus/canvasmode_normal.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17979&path=/trunk/Scribus/scribus/canvasmode_normal.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.h (original)
+++ trunk/Scribus/scribus/canvasmode_normal.h Tue Dec 25 13:32:46 2012
@@ -66,9 +66,13 @@
 	void handleCheckBoxRelease(PageItem* currItem);
 	void handlePushButtonRelease(PageItem* currItem);
 	void handleRadioButtonRelease(PageItem* currItem);
+	void handleJavaAction(PageItem* currItem, int event);
+	void handleNamedAction(PageItem* currItem);
 	void handleLinkAnnotation(PageItem* currItem);
 	void handleFocusOut(PageItem* currItem);
 	void handleFocusIn(PageItem* currItem);
+	void handleMouseLeave(PageItem* currItem);
+	void handleMouseEnter(PageItem* currItem);
 	bool SeleItem(QMouseEvent *m);
 	void createContextMenu(PageItem *currItem, double mx, double my);
 
@@ -85,6 +89,7 @@
 	LineMove* lineMoveGesture;
 	RulerGesture* guideMoveGesture;
 	bool m_lastPosWasOverGuide;
+	PageItem* m_hoveredItem;
 
 public slots:
 	void importToPage();

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17979&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Dec 25 13:32:46 2012
@@ -18013,3 +18013,107 @@
 	}
 	return NULL;
 }
+
+/* Functions for PDF Form Actions */
+
+void ScribusDoc::SubmitForm()
+{
+}
+
+void ScribusDoc::ImportData()
+{
+}
+
+void ScribusDoc::ResetFormFields()
+{
+	QList<PageItem*> allItems;
+	PageItem* it = NULL;
+	uint counter = 0;
+	for (uint lc = 0; lc < 2; ++lc)
+	{
+		switch (lc)
+		{
+			case 0:
+				counter = MasterItems.count();
+				break;
+			case 1:
+				counter = DocItems.count();
+				break;
+		}
+		for (uint d = 0; d < counter; ++d)
+		{
+			switch (lc)
+			{
+				case 0:
+					it = MasterItems.at(d);
+					break;
+				case 1:
+					it = DocItems.at(d);
+					break;
+			}
+			if (it->isGroup())
+				allItems = it->asGroupFrame()->getItemList();
+			else
+				allItems.append(it);
+			for (int ii = 0; ii < allItems.count(); ii++)
+			{
+				it = allItems.at(ii);
+				if (it->isAnnotation())
+				{
+					if ((it->annotation().Type() == Annotation::RadioButton) || (it->annotation().Type() == Annotation::Checkbox))
+						it->annotation().setCheckState(it->annotation().IsChk());
+					it->annotation().setOnState(false);
+					it->annotation().setOpen(false);
+				}
+			}
+			allItems.clear();
+		}
+	}
+	for (QHash<int, PageItem*>::iterator itf = FrameItems.begin(); itf != FrameItems.end(); ++itf)
+	{
+		it = itf.value();
+		if (it->isGroup())
+			allItems = it->asGroupFrame()->getItemList();
+		else
+			allItems.append(it);
+		for (int ii = 0; ii < allItems.count(); ii++)
+		{
+			it = allItems.at(ii);
+			if (it->isAnnotation())
+			{
+				if ((it->annotation().Type() == Annotation::RadioButton) || (it->annotation().Type() == Annotation::Checkbox))
+					it->annotation().setCheckState(it->annotation().IsChk());
+				it->annotation().setOnState(false);
+				it->annotation().setOpen(false);
+			}
+		}
+		allItems.clear();
+	}
+	QStringList patterns = getUsedPatterns();
+	for (int c = 0; c < patterns.count(); ++c)
+	{
+		ScPattern pa = docPatterns[patterns[c]];
+		for (int o = 0; o < pa.items.count(); o++)
+		{
+			it = pa.items.at(o);
+			if (it->isGroup())
+				allItems = it->asGroupFrame()->getItemList();
+			else
+				allItems.append(it);
+			for (int ii = 0; ii < allItems.count(); ii++)
+			{
+				it = allItems.at(ii);
+				if (it->isAnnotation())
+				{
+					if ((it->annotation().Type() == Annotation::RadioButton) || (it->annotation().Type() == Annotation::Checkbox))
+						it->annotation().setCheckState(it->annotation().IsChk());
+					it->annotation().setOnState(false);
+					it->annotation().setOpen(false);
+				}
+			}
+			allItems.clear();
+		}
+	}
+	changed();
+	regionsChanged()->update(QRect());
+}

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17979&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Tue Dec 25 13:32:46 2012
@@ -1769,6 +1769,13 @@
 	void itemSelection_Weld();
 	void itemSelection_EditWeld();
 	void restartAutoSaveTimer();
+
+/* Functions for PDF Form Actions */
+
+public:
+	void SubmitForm();
+	void ImportData();
+	void ResetFormFields();
 };
 
 Q_DECLARE_METATYPE(ScribusDoc*);

Modified: trunk/Scribus/scribus/ui/annot.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17979&path=/trunk/Scribus/scribus/ui/annot.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/annot.cpp (original)
+++ trunk/Scribus/scribus/ui/annot.cpp Tue Dec 25 13:32:46 2012
@@ -600,7 +600,7 @@
 	palTxt.setColor(QPalette::Base, palette().color(QPalette::Window));
 	if ((item->annotation().ActionType() == Annotation::Action_JavaScript) || (item->annotation().AAact()))
 		EditJava->setPlainText(item->annotation().Action());
-	ScrEdited = 0;
+	ScrEdited = Annotation::Java_ReleaseButton;
 	SelAction->setCurrentIndex(0);
 	EditJava->setReadOnly(true);
 	EditJava->setAutoFillBackground(true);
@@ -2056,25 +2056,25 @@
 			item->annotation().setActionType(Annotation::Action_JavaScript);
 			switch (ScrEdited)
 			{
-				case 0:
+				case Annotation::Java_PressButton:
 					item->annotation().setAction(EditJava->toPlainText());
 					break;
-				case 1:
+				case Annotation::Java_ReleaseButton:
 					item->annotation().setD_act(EditJava->toPlainText());
 					break;
-				case 2:
+				case Annotation::Java_EnterWidget:
 					item->annotation().setE_act(EditJava->toPlainText());
 					break;
-				case 3:
+				case Annotation::Java_LeaveWidget:
 					item->annotation().setX_act(EditJava->toPlainText());
 					break;
-				case 4:
+				case Annotation::Java_FocusIn:
 					item->annotation().setFo_act(EditJava->toPlainText());
 					break;
-				case 5:
+				case Annotation::Java_FocusOut:
 					item->annotation().setBl_act(EditJava->toPlainText());
 					break;
-				case 6:
+				case Annotation::Java_SelectionChg:
 					item->annotation().setK_act(EditJava->toPlainText());
 					break;
 			}
@@ -2331,49 +2331,49 @@
 {
 	switch (ScrEdited)
 	{
-	case 0:
+	case Annotation::Java_ReleaseButton:
 		item->annotation().setAction(EditJava->toPlainText());
 		break;
-	case 1:
+	case Annotation::Java_PressButton:
 		item->annotation().setD_act(EditJava->toPlainText());
 		break;
-	case 2:
+	case Annotation::Java_EnterWidget:
 		item->annotation().setE_act(EditJava->toPlainText());
 		break;
-	case 3:
+	case Annotation::Java_LeaveWidget:
 		item->annotation().setX_act(EditJava->toPlainText());
 		break;
-	case 4:
+	case Annotation::Java_FocusIn:
 		item->annotation().setFo_act(EditJava->toPlainText());
 		break;
-	case 5:
+	case Annotation::Java_FocusOut:
 		item->annotation().setBl_act(EditJava->toPlainText());
 		break;
-	case 6:
+	case Annotation::Java_SelectionChg:
 		item->annotation().setK_act(EditJava->toPlainText());
 		break;
 	}
 	switch (it)
 	{
-	case 0:
+	case Annotation::Java_ReleaseButton:
 		EditJava->setPlainText(item->annotation().Action());
 		break;
-	case 1:
+	case Annotation::Java_PressButton:
 		EditJava->setPlainText(item->annotation().D_act());
 		break;
-	case 2:
+	case Annotation::Java_EnterWidget:
 		EditJava->setPlainText(item->annotation().E_act());
 		break;
-	case 3:
+	case Annotation::Java_LeaveWidget:
 		EditJava->setPlainText(item->annotation().X_act());
 		break;
-	case 4:
+	case Annotation::Java_FocusIn:
 		EditJava->setPlainText(item->annotation().Fo_act());
 		break;
-	case 5:
+	case Annotation::Java_FocusOut:
 		EditJava->setPlainText(item->annotation().Bl_act());
 		break;
-	case 6:
+	case Annotation::Java_SelectionChg:
 		EditJava->setPlainText(item->annotation().K_act());
 		break;
 	}




More information about the scribus-commit mailing list