[rkward-cvs] SF.net SVN: rkward: [941] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Nov 26 23:49:23 UTC 2006


Revision: 941
          http://svn.sourceforge.net/rkward/?rev=941&view=rev
Author:   tfry
Date:     2006-11-26 15:49:23 -0800 (Sun, 26 Nov 2006)

Log Message:
-----------
Start giving catched R X11 device windows some added value

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/TODO
    trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc
    trunk/rkward/rkward/windows/rkmdiwindow.h
    trunk/rkward/rkward/windows/rkwindowcatcher.cpp
    trunk/rkward/rkward/windows/rkwindowcatcher.h
    trunk/rkward/rkward/windows/rkworkplace.cpp

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2006-11-26 17:58:55 UTC (rev 940)
+++ trunk/rkward/ChangeLog	2006-11-26 23:49:23 UTC (rev 941)
@@ -1,3 +1,6 @@
+- R X11 device windows are now managed by rkward, with the following initial features:
+- R X11 device windows: attach to / detach from workplace (they start detached)
+- R X11 device windows: toggle between normal resize mode and (settable) fixed size with scrollbars
 - fixed: selecting Window->Close in a detached window would only close the internal view, not the window
 - when detaching a window, give it a more reasonable size
 - do not open the same script url twice (instead the corresponding window is raised on the second attempt)

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2006-11-26 17:58:55 UTC (rev 940)
+++ trunk/rkward/TODO	2006-11-26 23:49:23 UTC (rev 941)
@@ -26,8 +26,6 @@
 UI-stuff
 	- Access to dev.copy (), dev.print (), and a function to copy gaphics to rkward output
 		- probably in Windows-menu for now
-		- also allow scroll-bar mode
-		- When attaching an X11 window, it should always go into fixed scroll-bar mode
 	- Output window should gain some sort of auto-update functionality:
 		- After user commands, should check, whether the output file was modified. If so, reload
 	- Option to save workplace per session instead of per workspace

Modified: trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc
===================================================================
--- trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc	2006-11-26 17:58:55 UTC (rev 940)
+++ trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc	2006-11-26 23:49:23 UTC (rev 941)
@@ -1,9 +1,24 @@
 <!DOCTYPE kpartgui>
 <kpartgui name="rkward" version="0.4.2">
 	<MenuBar>
-		<Menu name="plot" noMerge="1"><text>&Plot</text>
-			<Action name="close"/>
+		<Menu name="plot"><text>&Plot Device</text>
+			<Action name="device_activate"/>
+			<Separator/>
+			<Action name="device_print"/>
+			<Action name="device_copy_to_output"/>
+			<Action name="device_copy_to_r_object"/>
+			<Action name="device_copy_to_file"/>
 			<Merge/>
 		</Menu>
+		<Menu name="view"><text>&View</text>
+			<Action name="toggle_fixed_size"/>
+			<Separator/>
+			<Action name="set_fixed_size_1"/>
+			<Action name="set_fixed_size_2"/>
+			<Action name="set_fixed_size_3"/>
+			<Action name="set_fixed_size_manual"/>
+			<Merge/>
+		</Menu>
+		<Merge/>
 	</MenuBar>
 </kpartgui>
\ No newline at end of file

Modified: trunk/rkward/rkward/windows/rkmdiwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.h	2006-11-26 17:58:55 UTC (rev 940)
+++ trunk/rkward/rkward/windows/rkmdiwindow.h	2006-11-26 23:49:23 UTC (rev 941)
@@ -67,6 +67,10 @@
 	bool isAttached () { return (state == Attached); };
 /** Activate (raise) this window, regardless of whether it is attached or detached */
 	void activate ();
+/** If your mdi window should perform any adjustments before being attached, reimplement this function */
+	virtual void prepareToBeAttached () {};
+/** If your mdi window should perform any adjustments before being detached, reimplement this function */
+	virtual void prepareToBeDetached () {};
 signals:
 /** This signal is emitted, whenever the window caption was changed.
 @param RKMDIWindow* a pointer to this window */

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2006-11-26 17:58:55 UTC (rev 940)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2006-11-26 23:49:23 UTC (rev 941)
@@ -66,7 +66,14 @@
 
 
 
+#include <qscrollview.h>
+#include <qvbox.h>
+#include <qlabel.h>
 
+#include <kactionclasses.h>
+#include <kdialogbase.h>
+#include <knuminput.h>
+
 RKCatchedX11Window::RKCatchedX11Window (WId window_to_embed, int device_number) : RKMDIWindow (0, X11Window) {
 	RK_TRACE (MISC);
 
@@ -77,10 +84,18 @@
 	RKCatchedX11Window::device_number = device_number;
 
 	QVBoxLayout *layout = new QVBoxLayout (this);
-	QXEmbedCopy *capture = new QXEmbedCopy (this);
+	box_widget = new QVBox (this);
+	layout->addWidget (box_widget);
+	scroll_widget = new QScrollView (this);
+	scroll_widget->hide ();
+	layout->addWidget (scroll_widget);
+	xembed_container = new QVBox (box_widget);
+	dynamic_size = true;
+	dynamic_size_action->setChecked (true);
+
+	QXEmbedCopy *capture = new QXEmbedCopy (xembed_container);
 	capture->setProtocol (QXEmbedCopy::XPLAIN);
 	connect (capture, SIGNAL (embeddedWindowDestroyed ()), this, SLOT (deleteLater ()));
-	layout->addWidget (capture);
 
 	KWin::WindowInfo wininfo = KWin::windowInfo (window_to_embed);
 	setGeometry (wininfo.frameGeometry ());
@@ -104,9 +119,94 @@
 	return part;
 }
 
+void RKCatchedX11Window::prepareToBeAttached () {
+	RK_TRACE (MISC);
 
+	dynamic_size_action->setChecked (false);
+	toggleFixedSize ();
+	dynamic_size_action->setEnabled (false);
+}
 
+void RKCatchedX11Window::prepareToBeDetached () {
+	RK_TRACE (MISC);
 
+	dynamic_size_action->setEnabled (true);
+}
+
+void RKCatchedX11Window::toggleFixedSize () {
+	RK_TRACE (MISC);
+
+	if (dynamic_size == dynamic_size_action->isChecked ()) return;
+	dynamic_size = dynamic_size_action->isChecked ();
+
+	if (dynamic_size_action->isChecked ()) {
+		scroll_widget->removeChild (xembed_container);
+		xembed_container->reparent (box_widget, QPoint (0, 0), true);
+		scroll_widget->hide ();
+		box_widget->show ();
+		xembed_container->setMinimumSize (5, 5);
+		xembed_container->setMaximumSize (32767, 32767);
+	} else {
+		xembed_container->setFixedSize (xembed_container->size ());
+		xembed_container->reparent (scroll_widget->viewport (), QPoint (0, 0), true);
+		scroll_widget->addChild (xembed_container);
+		box_widget->hide ();
+		scroll_widget->show ();
+	}
+}
+
+void RKCatchedX11Window::setFixedSize1 () {
+	RK_TRACE (MISC);
+
+	dynamic_size_action->setChecked (false);
+	toggleFixedSize ();		// apparently KToggleAction::setChecked () does not invoke the slot!
+	xembed_container->setFixedSize (500, 500);
+}
+
+void RKCatchedX11Window::setFixedSize2 () {
+	RK_TRACE (MISC);
+
+	dynamic_size_action->setChecked (false);
+	toggleFixedSize ();		// see setFixedSize1 () above
+	xembed_container->setFixedSize (1000, 1000);
+}
+
+void RKCatchedX11Window::setFixedSize3 () {
+	RK_TRACE (MISC);
+
+	dynamic_size_action->setChecked (false);
+	toggleFixedSize ();		// see setFixedSize1 () above
+	xembed_container->setFixedSize (2000, 2000);
+}
+
+void RKCatchedX11Window::setFixedSizeManual () {
+	RK_TRACE (MISC);
+
+// TODO: not very pretty, yet
+	KDialogBase *dialog = new KDialogBase (this, 0, true, i18n ("Specify fixed size"), KDialogBase::Ok|KDialogBase::Cancel);
+	QVBox *page = dialog->makeVBoxMainWidget ();
+
+	QLabel *label = new QLabel (i18n ("Width"), page);
+	KIntSpinBox *width = new KIntSpinBox (5, 32767, 1, xembed_container->width (), 10, page);
+
+	label = new QLabel (i18n ("Height"), page);
+	KIntSpinBox *height = new KIntSpinBox (5, 32767, 1, xembed_container->height (), 10, page);
+
+	dialog->exec ();
+
+	if (dialog->result () == QDialog::Accepted) {
+		dynamic_size_action->setChecked (false);
+		toggleFixedSize ();		// see setFixedSize1 () above
+
+		xembed_container->setFixedSize (width->value (), height->value ());
+	}
+
+	delete dialog;
+}
+
+
+
+
 RKCatchedX11WindowPart::RKCatchedX11WindowPart (RKCatchedX11Window *window) : KParts::Part (0) {
 	RK_TRACE (MISC);
 
@@ -117,6 +217,14 @@
 	RKCatchedX11WindowPart::window = window;
 
 	setXMLFile ("rkcatchedx11windowpart.rc");
+
+	window->dynamic_size_action = new KToggleAction (i18n ("Draw area follows size of window"), 0, window, SLOT (toggleFixedSize ()), actionCollection (), "toggle_fixed_size");
+
+	new KAction (i18n ("Set fixed size 500x500"), 0, window, SLOT (setFixedSize1 ()), actionCollection (), "set_fixed_size_1");
+	new KAction (i18n ("Set fixed size 1000x1000"), 0, window, SLOT (setFixedSize2 ()), actionCollection (), "set_fixed_size_2");
+	new KAction (i18n ("Set fixed size 2000x2000"), 0, window, SLOT (setFixedSize3 ()), actionCollection (), "set_fixed_size_3");
+	new KAction (i18n ("Set specified fixed size..."), 0, window, SLOT (setFixedSizeManual ()), actionCollection (), "set_fixed_size_manual");
+
 }
 
 RKCatchedX11WindowPart::~RKCatchedX11WindowPart () {

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.h	2006-11-26 17:58:55 UTC (rev 940)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.h	2006-11-26 23:49:23 UTC (rev 941)
@@ -77,6 +77,10 @@
 #include "rkmdiwindow.h"
 
 class RKCatchedX11WindowPart;
+class KToggleAction;
+class QXEmbedCopy;
+class QScrollView;
+class QVBox;
 
 /** An R X11 device window managed by rkward */
 class RKCatchedX11Window : public RKMDIWindow {
@@ -89,10 +93,27 @@
 	KParts::Part *getPart ();
 	QString getRDescription () { return "unimplemtend"; };
 	bool isModified () { return false; };
+
+	void prepareToBeAttached ();
+	void prepareToBeDetached ();
+public slots:
+	/** Do not invoke directly. Meant to be called from the toggle action */
+	void toggleFixedSize ();
+	void setFixedSize1 ();
+	void setFixedSize2 ();
+	void setFixedSize3 ();
+	void setFixedSizeManual ();
 private:
+	friend class RKCatchedX11WindowPart;
 	int device_number;
 	WId embedded;
 	RKCatchedX11WindowPart *part;
+	QVBox *xembed_container;
+	QScrollView *scroll_widget;
+	QVBox *box_widget;
+
+	bool dynamic_size;
+	KToggleAction *dynamic_size_action;
 };
 
 class RKCatchedX11WindowPart : public KParts::Part {

Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp	2006-11-26 17:58:55 UTC (rev 940)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp	2006-11-26 23:49:23 UTC (rev 941)
@@ -64,6 +64,7 @@
 	RK_TRACE (APP);
 	RK_ASSERT (windows.find (window) != windows.end ());		// This should not happen for now.
 
+	window->prepareToBeAttached ();
 	window->state = RKMDIWindow::Attached;
 	view ()->addPage (window);
 
@@ -75,6 +76,7 @@
 	RK_TRACE (APP);
 	RK_ASSERT (windows.find (window) != windows.end ());		// Can't detach a window that is not registered
 
+	window->prepareToBeDetached ();
 	window->state = RKMDIWindow::Detached;
 
 	RK_ASSERT (window->getPart ());


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list