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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Jan 8 21:25:29 UTC 2007


Revision: 1105
          http://svn.sourceforge.net/rkward/?rev=1105&view=rev
Author:   tfry
Date:     2007-01-08 13:25:29 -0800 (Mon, 08 Jan 2007)

Log Message:
-----------
Adding CSS for help, and in page navigation

Modified Paths:
--------------
    trunk/rkward/rkward/pages/Makefile.am
    trunk/rkward/rkward/pages/rkward_for_r_users.rkh
    trunk/rkward/rkward/pages/rkward_welcome.rkh
    trunk/rkward/rkward/plugins/makemakefileam.php
    trunk/rkward/rkward/windows/rkhtmlwindow.cpp
    trunk/rkward/rkward/windows/rkhtmlwindow.h

Added Paths:
-----------
    trunk/rkward/rkward/pages/rkward_help.css

Modified: trunk/rkward/rkward/pages/Makefile.am
===================================================================
--- trunk/rkward/rkward/pages/Makefile.am	2007-01-08 19:28:22 UTC (rev 1104)
+++ trunk/rkward/rkward/pages/Makefile.am	2007-01-08 21:25:29 UTC (rev 1105)
@@ -2,5 +2,6 @@
 dist_pages_DATA = \
 	rkward_welcome.rkh \
 	rkward_for_new_users.rkh \
-	rkward_for_r_users.rkh
+	rkward_for_r_users.rkh \
+	rkward_help.css
 

Modified: trunk/rkward/rkward/pages/rkward_for_r_users.rkh
===================================================================
--- trunk/rkward/rkward/pages/rkward_for_r_users.rkh	2007-01-08 19:28:22 UTC (rev 1104)
+++ trunk/rkward/rkward/pages/rkward_for_r_users.rkh	2007-01-08 21:25:29 UTC (rev 1105)
@@ -4,7 +4,7 @@
 	<summary>
 	Briefly explains the main components of RKWard, assuming the user is already familiar with basic concepts of R.
 	</summary>
-	<section title="The Console">
+	<section title="The Console" id="console">
 	First things first: An emulation of the standard R console can be found at the bottom on the screen. There you will notice several buttons, one of which is labelled "R Console" and has a console icon.
 
 	This console works almost exactly like the regular R text console, so you can start working right away. Differences include:
@@ -16,37 +16,37 @@
 		<li>While the cursor is on an R symbol or function, pressing F2 will search the R help for that symbol. Also available from the Help menu, or the right mouse button menu</li>
 	</ul>
 	</section>
-	<section title="Script Editors">
+	<section title="Script Editors" id="script_editor">
 	Often it is more conventient to write scripts in a separate file, instead of typing them directly in the console. To open a new script editor (with syntax highlighting, and many more features), chose File->New->Script File, or open an already existing Script file using File->Open R Script File.
 
 	You will note that the editor opens in a new window in the main workplace (the area of the window, that you are most likely reading this text, in). You can open any number of Script editor windows at the same time.
 
 	To run the code in a script editor window, either copy and paste it to the console, or chose one of the actions in the Run menu. such as Run All or Run Selection. Note: The contents of the menus may change according to the type of active window. Hence, if you look at the Run menu while reading this, there will be no entries.
 	</section>
-	<section title="Workspace View">
+	<section title="Workspace View" id="workspace_browser">
 	RKWard comes with a "workspace view" or "object browser". By default this is available by clicking on "Workspace" on the left side of the application window. This allows you to examine and manipulate all objects in the R workspace. In case you are not familiar with this aspect of R (usually not directly visible): All the symbols you create are children of the so-called ".GlobalEnv" environment (see <link href="rkward://rhelp/.GlobalEnv"/>). Symbols defined in loaded libraries are located in their own environments.
 
 	The object browser provides function to select with types of object are shown (on the top). Hovering the mouse over an item will show some additional information on the symbol. Right-clicking on an item will show available actions.
 	</section>
-	<section title="R Help">
+	<section title="R Help" id="rhelp">
 	By default R help pages are shown as HTML, inside RKWard. You can invoke the help in the usual way by running e.g. "?print" or "help (print)" or "help.start ()" in the console. Additionally, there is a tool window to search your installed R help pages. This is accessible using a button located at the bottom of the window (next to the console button). To view a help page found using this tool, double click on it.
 	</section>
-	<section title="Managing installed and loaded Libraries">
+	<section title="Managing installed and loaded Libraries" id="library_management">
 	RKWard provides an advanced dialog to have installation, updating, and loading of packages. This is available from Workspace->Configure Packages.
 	</section>
-	<section title="Window management">
+	<section title="Window management" id="window_management">
 	All windows shown in the main view area can be detached to a separate top level window using Windows->Detach. Similarily, detached windows can be attached to the main workplace using Window->Attach.
 
 	Windows can be closed using Windows->Close (Ctrl+W by default).
 
 	Tool windows (e.g. the R Console) can be detached and re-attached using the arrow-icon in their window border.
 	</section>
-	<section title="Editing data">
+	<section title="Editing data" id="editing_data">
 	RKWard provides a buit-in editor for data.frames. In fact, you can edit many data.frames at the same time, and even while running lengthy calculations. Still the data is stored as a regular data.frame in R. To explore the data editor, either chose File->New->Dataset, or right click a data.frame in the Workspace browser, and chose Edit from the menu.
 
 	Support for adding other types of data, esp. single vectors is planned, but not currently supported.
 	</section>
-	<section title="Everything else">
+	<section title="Everything else" id="more">
 	You will notice that RKWard provides a lot of further menu options. These provide access to functionality in R. In fact, they do so by generating R syntax from settings made in a graphical dialog. For instance, select Analysis->Descriptive Statistics. You will notice a small window at the bottom (can be toggled on or off using the "Code" button) that contains the R code needed to generate these statistics. This way, even if you prefer to script your code by hand, you can use dialogs to gain snippets of code for functions you are less familiar with in R.
 
 	Also, all commands that are executed get shown in the Command Log, available as a tool window next to the R Console.

Added: trunk/rkward/rkward/pages/rkward_help.css
===================================================================
--- trunk/rkward/rkward/pages/rkward_help.css	                        (rev 0)
+++ trunk/rkward/rkward/pages/rkward_help.css	2007-01-08 21:25:29 UTC (rev 1105)
@@ -0,0 +1,60 @@
+#main {
+	margin-right: 11em;
+}
+
+#main h1 {
+	font-size: 1.5em;
+	color: gray;
+	text-align: center;
+	margin-top: 1em;
+	margin-bottom: 1em;
+	padding: 0;
+}
+
+#main h2 {
+	font-size: 1.2em;
+	color: gray;
+	margin-top: 1em;
+	margin-bottom: 0.5em;
+	padding: 0;
+}
+
+#main h3 {
+	font-size: 1.1em;
+	color: gray;
+	margin-top: 1em;
+	margin-bottom: 0em;
+	padding: 0;
+}
+
+#main h4 {
+	font-size: 1em;
+	font-weight: bold;
+	color: gray;
+	margin-top: 0.5em;
+	margin-bottom: 0em;
+	padding: 0;
+}
+
+#main p {
+	margin-top: 0em;
+	margin-bottom: 0.5em;
+	padding: 0;
+}
+
+#navigation {
+	position: fixed;
+	top: 1em;
+	right: 0.5em;
+	width: 10em;
+	border: 1px solid silver;
+}
+
+#navigation p {
+	font-size: 0.9em;
+	margin-top: 0em;
+	margin-bottom: 0.5em;
+	text-indent: -1em;
+	margin-left: 1.5em;
+	margin-right: 0.2em;
+}
\ No newline at end of file

Modified: trunk/rkward/rkward/pages/rkward_welcome.rkh
===================================================================
--- trunk/rkward/rkward/pages/rkward_welcome.rkh	2007-01-08 19:28:22 UTC (rev 1104)
+++ trunk/rkward/rkward/pages/rkward_welcome.rkh	2007-01-08 21:25:29 UTC (rev 1105)
@@ -8,17 +8,17 @@
 	By default, this page is shown each time RKWard is started. You can disable / re-enable this behavior under Settings->Configure RKWard->General.
 	</summary>
 
-	<section title="Introduction to RKWard">
+	<section title="Introduction to RKWard" id="introduction">
 	RKWard is a GUI frontend and IDE to <link href="http://www.r-project.org">R</link>, a powerful scripting language for statistical computing. It aims to provide useful features both to experienced users of R, wishing to exploit R's scripting capabilities, as well as to users new to R, looking for an easy way to do carry out statistical computation tasks.
 	</section>
 
-	<section title="Getting Started">
+	<section title="Getting Started" id="getting_started">
 	Due to the large differences in prior knowledge of R, we provide two different guides for getting started with RKWard. The first is aimed at users with some knowledge of the R language, and focuses on introducing the IDE features of RKWard: <link href="rkward://page/rkward_for_r_users" />.
 
 	The second gives a more hands on introduction to getting started with RKWard, but does not go quite as deep. If you have never users R or RKWard before, you should start with this guide, then later read the page linked to above: <link href="rkward://page/rkward_for_new_users" />.
 	</section>
 
-	<section title="General Information">
+	<section title="General Information" id="further_info">
 	For more general information on RKWard, who writes it, how to help, further questions, etc. refer to <link href="http://rkward.sourceforge.net/">the project homepage</link>.
 	</section>
 </document>

Modified: trunk/rkward/rkward/plugins/makemakefileam.php
===================================================================
--- trunk/rkward/rkward/plugins/makemakefileam.php	2007-01-08 19:28:22 UTC (rev 1104)
+++ trunk/rkward/rkward/plugins/makemakefileam.php	2007-01-08 21:25:29 UTC (rev 1105)
@@ -32,7 +32,7 @@
 	
 	while (false !== ($file = readdir($thisdir))) {
 		if (!is_dir ($ndir . $file)) {
-			if ((substr ($file, -4) == ".xml") || (substr ($file, -4) == ".php") || (substr ($file, -10) == ".pluginmap") || (substr ($file, -4) == ".rkh") || (substr ($file, -4) == ".png")) {
+			if ((substr ($file, -4) == ".xml") || (substr ($file, -4) == ".php") || (substr ($file, -10) == ".pluginmap") || (substr ($file, -4) == ".rkh") || (substr ($file, -4) == ".png") || (substr ($file, -4) == ".css")) {
 				if ($file != "makemakefileam.php") {
 					array_push ($files, $file);
 				}

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2007-01-08 19:28:22 UTC (rev 1104)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2007-01-08 21:25:29 UTC (rev 1105)
@@ -55,7 +55,7 @@
 	pLayout->addWidget (khtmlpart->widget ());
 
 	// We have to connect this in order to allow browsing.
-	connect (khtmlpart->browserExtension (), SIGNAL(openURLRequest (const KURL &, const KParts::URLArgs &)), this, SLOT (slotOpenURLRequest (const KURL &, const KParts::URLArgs &)));
+	connect (khtmlpart->browserExtension (), SIGNAL (openURLRequestDelayed (const KURL &, const KParts::URLArgs &)), this, SLOT (slotOpenURLRequest (const KURL &, const KParts::URLArgs &)));
 	connect (khtmlpart, SIGNAL (completed ()), this, SLOT (loadDone ()));
 
 	url_history.setAutoDelete (true);
@@ -398,13 +398,15 @@
 	bool success = false;
 	XMLHelper *component_xml = new XMLHelper ();
 	XMLHelper *help_xml = new XMLHelper ();
+	QStringList anchors, anchornames;
 
 	while (true) {		// dirty hack to streamline exit code: breaking from this while, before success is set to true will cause the XMLHelpers to be deleted, and false returned.
 		RKComponentHandle *chandle = 0;
 		QString help_file_name;
 		QDomElement element;
 		QDomElement component_doc_element;
-		QString help_base_dir;
+		QString help_base_dir = RKCommonFunctions::getRKWardDataDir () + "pages/";
+		QString css_filename = "file://" + help_base_dir + "rkward_help.css";
 
 		// determine help file, and prepare
 		if (for_component) {
@@ -419,8 +421,6 @@
 			if (help_file_name.isNull ()) break;
 			help_file_name = QFileInfo (chandle->getFilename ()).dir (true).filePath (help_file_name);
 		} else {
-			help_base_dir = RKCommonFunctions::getRKWardDataDir () + "pages/";
-
 			help_file_name = help_base_dir + url.path () + ".rkh";
 		}
 		RK_DO (qDebug ("rendering help page for local file %s", help_file_name.latin1 ()), APP, DL_DEBUG);
@@ -440,7 +440,7 @@
 				page_title = element.text ();
 			}
 		}
-		khtmlpart->write ("<html><head><title>" + page_title + "</title></head>\n<body>\n<h1>" + page_title + "</h1>\n");
+		khtmlpart->write ("<html><head><title>" + page_title + "</title><link rel=\"stylesheet\" type=\"text/css\" href=\"" + css_filename + "\"></head>\n<body><div id=\"main\">\n<h1>" + page_title + "</h1>\n");
 
 		// fix all elements containing an "src" attribute
 		QDir base_path (QFileInfo (help_file_name).dirPath (true));
@@ -456,26 +456,38 @@
 		// render the sections
 		element = help_xml->getChildElement (help_doc_element, "summary", DL_INFO);
 		if (!element.isNull ()) {
+			khtmlpart->write (makeAnchor ("summary"));
 			khtmlpart->write ("<h2>" + i18n ("Summary") + "</h2>\n");
 			khtmlpart->write (renderHelpFragment (element));
+			anchors.append ("summary");
+			anchornames.append (i18n ("Summary"));
 		}
 
 		element = help_xml->getChildElement (help_doc_element, "usage", DL_INFO);
 		if (!element.isNull ()) {
+			khtmlpart->write (makeAnchor ("usage"));
 			khtmlpart->write ("<h2>" + i18n ("Usage") + "</h2>\n");
 			khtmlpart->write (renderHelpFragment (element));
+			anchors.append ("usage");
+			anchornames.append (i18n ("Usage"));
 		}
 
 		XMLChildList section_elements = help_xml->getChildElements (help_doc_element, "section", DL_INFO);
 		for (XMLChildList::iterator it = section_elements.begin (); it != section_elements.end (); ++it) {
-			khtmlpart->write ("<h2>" + help_xml->getStringAttribute (*it, "title", QString (), DL_WARNING) + "</h2>\n");
+			QString title = help_xml->getStringAttribute (*it, "title", QString (), DL_WARNING);
+			QString id = help_xml->getStringAttribute (*it, "id", QString (), DL_WARNING);
+			khtmlpart->write (makeAnchor (id));
+			khtmlpart->write ("<h2>" + title + "</h2>\n");
 			khtmlpart->write (renderHelpFragment (*it));
+			anchors.append (id);
+			anchornames.append (title);
 		}
 
 		// the section "settings" is the most complicated, as the labels of the individual GUI items has to be fetched from the component description. Of course it is only meaningful for component help, and not rendered for top level help pages.
 		if (for_component) {
 			element = help_xml->getChildElement (help_doc_element, "settings", DL_INFO);
 			if (!element.isNull ()) {
+				khtmlpart->write (makeAnchor ("settings"));
 				khtmlpart->write ("<h2>" + i18n ("GUI settings") + "</h2>\n");
 				XMLChildList setting_elements = help_xml->getChildElements (element, QString (), DL_WARNING);
 				for (XMLChildList::iterator it = setting_elements.begin (); it != setting_elements.end (); ++it) {
@@ -498,17 +510,47 @@
 						help_xml->displayError (&(*it), "Tag not allowed, here", DL_WARNING);
 					}
 				}
+
+				anchors.append ("settings");
+				anchornames.append (i18n ("GUI settings"));
 			}
 		}
 
+		// "related" section
 		element = help_xml->getChildElement (help_doc_element, "related", DL_INFO);
 		if (!element.isNull ()) {
+			khtmlpart->write (makeAnchor ("related"));
 			khtmlpart->write ("<h2>" + i18n ("Related functions and pages") + "</h2>\n");
 			khtmlpart->write (renderHelpFragment (element));
+			anchors.append ("related");
+			anchornames.append (i18n ("Related functions and pages"));
 		}
 
+		// create a navigation bar
+		KURL url_copy = url;
+		QString navigation;
+		QStringList::const_iterator names_it = anchornames.constBegin ();
+		for (QStringList::const_iterator it = anchors.constBegin (); it != anchors.constEnd (); ++it) {
+			if (!((*it).isNull () || (*names_it).isNull ())) {
+				url_copy.setRef (*it);
+				navigation.append ("<p><a href=\"" + url_copy.url () + "\">" + *names_it + "</a></p>\n");
+			}
+
+			if (names_it != anchornames.constEnd ()) {
+				++names_it;
+			} else {
+				RK_ASSERT (false);
+			}
+		}
+		khtmlpart->write ("</div><div id=\"navigation\">" + navigation + "</div>");
 		khtmlpart->write ("</body></html>\n");
 		khtmlpart->end ();
+
+		QString ref = url.ref ();
+		if (!ref.isEmpty ()) {
+			khtmlpart->gotoAnchor (ref);
+		}
+
 		success = true;
 		break;
 	}
@@ -592,4 +634,9 @@
 	return (RKComponentMap::getComponentHandle (path_segments.join ("::")));
 }
 
+QString RKHelpWindow::makeAnchor (const QString &name) {
+	return ("<a name=\"" + name + "\">");
+}
+
+
 #include "rkhtmlwindow.moc"

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h	2007-01-08 19:28:22 UTC (rev 1104)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h	2007-01-08 21:25:29 UTC (rev 1105)
@@ -164,6 +164,7 @@
 	QString renderHelpFragment (QDomElement &fragment);
 	void prepareHelpLink (QDomElement *link_element);
 	RKComponentHandle *componentPathToHandle (QString path);
+	QString makeAnchor (const QString &name);
 };
 
 #endif


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