From 20a886a34a131b8dfb3939172348bcc955d34a5d Mon Sep 17 00:00:00 2001
From: Bryan Petty <bryan@ibaku.net>
Date: Wed, 16 Apr 2008 20:11:08 +0000
Subject: [PATCH] Added feature to the HTML manual to remember your preference
 to show or hide the inheritance diagram (shown by default now).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53235 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/doxygen/htmlfooter.inc |  2 +
 docs/doxygen/regen.bat      |  5 ++-
 docs/doxygen/regen.sh       |  5 ++-
 docs/doxygen/wxwidgets.js   | 76 +++++++++++++++++++++++++++++++++++++
 4 files changed, 84 insertions(+), 4 deletions(-)
 create mode 100644 docs/doxygen/wxwidgets.js

diff --git a/docs/doxygen/htmlfooter.inc b/docs/doxygen/htmlfooter.inc
index 06365b7411..b7fa53d103 100644
--- a/docs/doxygen/htmlfooter.inc
+++ b/docs/doxygen/htmlfooter.inc
@@ -16,6 +16,8 @@
 </tr>
 </table>
 
+<script src="wxwidgets.js" type="text/javascript"></script>
+
 </body>
 </html>
 
diff --git a/docs/doxygen/regen.bat b/docs/doxygen/regen.bat
index d52d7e7631..e3bfd0a54d 100644
--- a/docs/doxygen/regen.bat
+++ b/docs/doxygen/regen.bat
@@ -11,13 +11,14 @@ mkdir out\html\wxgtk 2>&1 >NUL
 mkdir out\html\wxmsw 2>&1 >NUL
 mkdir out\html\wxmac 2>&1 >NUL
 
-REM this image is not automatically copied by Doxygen because it's not
-REM used in doxygen documentation but only in our html footer...
+REM These not automatically copied by Doxygen because it's not
+REM used in doxygen documentation, only in our html footer.
 copy images\powered-by-wxwidgets.png out\html 2>&1 >NUL
 copy images\*logo.png out\html 2>&1 >NUL
 copy images\wxgtk\*png out\html\wxgtk 2>&1 >NUL
 copy images\wxmsw\*png out\html\wxmsw 2>&1 >NUL
 copy images\wxmac\*png out\html\wxmac 2>&1 >NUL
+copy wxwidgets.js out\html 2>&1 >NUL
 
 REM this CSS is automatically copied by Doxygen because it's
 REM included by our custom html header...
diff --git a/docs/doxygen/regen.sh b/docs/doxygen/regen.sh
index 00b0dbf354..586b4fdc05 100755
--- a/docs/doxygen/regen.sh
+++ b/docs/doxygen/regen.sh
@@ -25,14 +25,15 @@ cd $path
 mkdir -p out/html       # we need to copy files in this folder below
 mkdir -p out/html/wxmsw out/html/wxgtk out/html/wxmac
 
-# these images are not automatically copied by Doxygen because they're not
-# used in doxygen documentation but only in our html footer and by our
+# These are not automatically copied by Doxygen because they're not
+# used in doxygen documentation, only in our html footer and by our
 # custom aliases
 cp images/powered-by-wxwidgets.png out/html
 cp images/*logo.png out/html
 cp images/wxmsw/*png out/html/wxmsw
 cp images/wxmac/*png out/html/wxmac
 cp images/wxgtk/*png out/html/wxgtk
+cp wxwidgets.js out/html
 
 # this CSS is not automatically copied by Doxygen because it's
 # included by our custom html header...
diff --git a/docs/doxygen/wxwidgets.js b/docs/doxygen/wxwidgets.js
new file mode 100644
index 0000000000..b8586601f3
--- /dev/null
+++ b/docs/doxygen/wxwidgets.js
@@ -0,0 +1,76 @@
+// from w3schools
+function getCookie(c_name)
+{
+  if (document.cookie.length>0)
+  {
+    c_start=document.cookie.indexOf(c_name + "=");
+    if (c_start!=-1)
+    { 
+      c_start=c_start + c_name.length+1; 
+      c_end=document.cookie.indexOf(";",c_start);
+      if (c_end==-1) c_end=document.cookie.length;
+      return unescape(document.cookie.substring(c_start,c_end));
+    } 
+  }
+  return "";
+}
+// from w3schools
+function setCookie(c_name,value,expiredays)
+{
+  var exdate=new Date();
+  exdate.setDate(exdate.getDate()+expiredays);
+  document.cookie=c_name+ '=' +escape(value)+
+  ((expiredays==null) ? '' : ';expires='+exdate.toGMTString());
+}
+
+// Reimplementation of changeDisplayState
+function mychangeDisplayState( e )
+{
+  var num=this.id.replace(/[^[0-9]/g,'');
+  var button=this.firstChild;
+  var sectionDiv=document.getElementById('dynsection'+num);
+  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
+    sectionDiv.style.display='block';
+    button.src='open.gif';
+  }else{
+    sectionDiv.style.display='none';
+    button.src='closed.gif';
+  }
+
+  setCookie( 'sectionDiv.style.display', sectionDiv.style.display );
+
+}
+
+window.onload = function myinitDynSections()
+{
+  var divs=document.getElementsByTagName('div');
+  var sectionCounter=1;
+  for(var i=0;i<divs.length-1;i++){
+    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
+      var header=divs[i];
+      var section=divs[i+1];
+      var button=header.firstChild;
+      if (button!='IMG'){
+        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
+        button=document.createElement('img');
+        divs[i].insertBefore(button,divs[i].firstChild);
+      }
+      header.style.cursor='pointer';
+      header.onclick=mychangeDisplayState;
+      header.id='dynheader'+sectionCounter;
+      button.src='closed.gif';
+      section.id='dynsection'+sectionCounter;
+
+      var display = getCookie( 'sectionDiv.style.display' );
+      if ( display == '' ){
+        section.style.display='block'; // default
+      }else{
+        section.style.display=display;
+      }
+      setCookie( 'sectionDiv.style.display', section.style.display );
+
+      section.style.marginLeft='14px';
+      sectionCounter++;
+    }
+  }
+}
-- 
2.47.2