/************************************************************************* * * Copyright: Varol Okan 2007 * License: GPL v2.0 * Authors: Varol Okan * * * The SystemMenu is built of multiple pieces. * The MySQL table used to build it is : * SystemMenu ( * idx int auto_increment, -> idx * parent_idx int references idx, -> the parent of this entry (must be a menu-entry) * sequence int, -> on a per SubMenu ordering of the entries * folder tinyint(1), -> bool is folder ? yes / no. * icon_text varchar(64), -> Text below Icon * icon_color varchar(10), -> Color of text ( Do we need this ? ) * icon text, -> Icon image * win_x int, -> the window coord of the app to open ( 0 for menus ) * win_y int, -> the window coord of the app to open ( 0 for menus ) * win_width int, -> the window coord of the app to open ( 0 for menus ) * win_height int, -> the window coord of the app to open ( 0 for menus ) * execute text, -> the command to execute ( empty for menus ) * params text -> the parameters for the command ( empty for menus ) * ); * * This table is read in through this PHP file and will create the menu * structure for the SystemMenu for ALL users. * * o Tangle through multiple SubMenus, getting back gets to the top level SubMenu instead of the previous SubMenu * o Button Arrows are off * - Up / Down buttons of main menu * - User configuration through MySQL * - Load system wide Config (menu items) from MySQL * - handle resize window correctly * *************************************************************************/ /* while ( 1 ) { $iRootIdx = 0; // starting with the root dir select idx, folder, icont_text, icon_color, icon, win_x, win_y, win_height, win_width, execute, params from SystemMenu where parent_idx=$iRootIdx order by sequence, idx; if ( $folder == true ) { echo "this._addMenu ( $parentObj, $iconText, $iconColor, $icon )\n"; } else echo "this._addApp ( $parentObj, $iconText, $iconColor, $icon, $winX, $winY, $winH, $winW, $execute, $params )\n"; } */ ////////////////////////////////////////////////////////////////// // // This is the class which handles the menu items (submenu and icons) // // This class handles the fade in/out of the associated SubMenus. // It has an array of SubMenus // It has two important vars // this._activeSubMenu // this._changeToSubMenu // ////////////////////////////////////////////////////////////////// qx.Class.define ( "ao.SystemMenu.InnerMenu", { extend : qx.ui.layout.VerticalBoxLayout, construct : function ( myParent ) { this.base ( arguments ); this._subMenuLevel = 0; // root MenuLevel //this.setSpacing ( 5 ); this.setMarginTop ( 10 ); this.setMarginBottom ( 10 ); this.setVerticalChildrenAlign ( "bottom" ); this.setHorizontalChildrenAlign ( "center" ); this._mainBar = myParent; this._subMenuOfMainMenu = 0; // the first level of SubMenu which is currently active this._activeSubMenu = 0; this._changeToSubMenu = 0; this._activePane = 0; // set only when clickig SubMenu of RootMenu this._changeToPane = 0; // set only when clickig SubMenu of RootMenu this._currentOpacity = ao.SystemMenu.MainBar.fadeSpeed; this._direction = 0; this._iVisibleStartItem = 0; this._iNrOfVisibleItems = 1; this._timer = new qx.client.Timer ( 5 ); this._timer.addEventListener ( "interval", this._onAnimateTimer, this ); }, members : { // public member functions. addMenuItem : function ( item ) { this.add ( item ); }, up : function ( ) { this._iVisibleStartItem++; if ( this._iVisibleStartItem >= this.getChildrenLength ( ) - this._iNrOfVisibleItems ) { this._iVisibleStartItem = this.getChildrenLength ( ) - this._iNrOfVisibleItems; this._mainBar._buttonUp.hide ( ); } else this._mainBar._buttonUp.show ( ); if ( this._iVisibleStartItem <= 0 ) { this._iVisibleStartItem = 0; this._mainBar._buttonDown.hide ( ); } else this._mainBar._buttonDown.show ( ); this.reshow ( ); }, down : function ( ) { this._iVisibleStartItem --; if ( this._iVisibleStartItem <= 0 ) { this._iVisibleStartItem = 0; this._mainBar._buttonDown.hide ( ); } else this._mainBar._buttonDown.show ( ); this._mainBar._buttonUp.show ( ); this.reshow ( ); }, // overloaded function to catch resizing event. _changeInnerHeight : function ( newH, oldH ) { this.base ( arguments, newH, oldH ); this._iNrOfVisibleItems = Math.floor ( this.getOffsetHeight ( ) / ao.SystemMenu.MainBar.itemHeight ); if ( this._iNrOfVisibleItems < this.getChildrenLength ( ) ) this._iVisibleStartItem = this.getChildrenLength ( ) - this._iNrOfVisibleItems-1; this.up ( ); }, // overloaded function to calc the propper number of items to be displayed. _afterAppear : function ( ) { this.base ( arguments ); this._iNrOfVisibleItems = Math.floor ( this.getOffsetHeight ( ) / ao.SystemMenu.MainBar.itemHeight ); if ( this._iNrOfVisibleItems < this.getChildrenLength ( ) ) this._iVisibleStartItem = this.getChildrenLength ( ) - this._iNrOfVisibleItems-1; this.up ( ); }, reshow : function ( ) { // Called when the up / down buttons are pressed or when the main Browser window is resized. iVisibleEndItem = this._iVisibleStartItem + this._iNrOfVisibleItems; var kids = this.getChildren ( ); for ( t=0; t= this._iVisibleStartItem ) && ( t= this._iVisibleStartItem ) && ( t 0 ) this._currentOpacity--; else this._timer.stop ( ); } // So we have the new position. this._activeSubMenu._innerMenu.setOpacity ( ( 1.0 - this._currentOpacity / ao.SystemMenu.MainBar.fadeSpeed ) ); this._activePane.setOpacity ( ( 1.0 - this._currentOpacity / ao.SystemMenu.MainBar.fadeSpeed ) * ao.SystemMenu.MainBar.paneOpacity ); } }// End of members ... } ); ////////////////////////////////////////////////////////////////// // // This is the class which handles the menu items // (submenu nd icons) itelf. // ////////////////////////////////////////////////////////////////// qx.Class.define ( "ao.SystemMenu.MenuItem", { extend : qx.ui.embed.HtmlEmbed, construct : function ( parentMenu, icon, iconText, iconColor ) { this.base ( arguments ); this.set ( { width: ao.SystemMenu.MainBar.itemWidth, height: ao.SystemMenu.MainBar.itemHeight } ); this._parent = parentMenu; this._icon = icon; this._iconText = iconText; this._iconColor = iconColor; var html="

" + iconText + "
"; this.setHtml ( html ); this.addEventListener ( "click", this._onClicked, this ); parentMenu.addMenuItem ( this ); }, members : { setExecute : function ( execute, params, winX, winY, winWidth, winHeight ) { this._theExecutable = execute; this._params = params; this._winX = winX; this._winY = winY; this._winWidth = winWidth; this._winHeight = winHeight; }, _onClicked : function ( ) { if ( this._theExecutable == "" ) { alert("No executable for button : " + this._iconText); } else { var app = new ao.AppLoader ( this._theExecutable ); app.setParams ( this._params, this._winX, this._winY, this._winWidth, this._winHeight ); app.start ( ); this._parent._rootMenu.menuButtonClicked ( 0 ); // fade out. //this._parent.hide ( ); } } }// End of members ... } ); ////////////////////////////////////////////////////////////////// // // This is the class which handles the menu items // (submenu nd icons) itelf. // ////////////////////////////////////////////////////////////////// qx.Class.define ( "ao.SystemMenu.SubMenu", { extend : qx.ui.layout.HorizontalBoxLayout, construct : function ( rootMenu, parentMenu, icon, iconText, iconColor ) { this.base ( arguments ); this.set ( { width: ao.SystemMenu.MainBar.subMenuWidth, height : ao.SystemMenu.MainBar.itemWidth } ); //this.setHeight ( ao.SystemMenu.MainBar.itemHeight ); this._direction = 0; this._subMenuLevel = parentMenu._subMenuLevel + 1; this._parent = parentMenu; this._rootMenu = rootMenu; this._icon = icon; this._iconText = iconText; this._iconColor = iconColor; this._pane = 0; this._subMenuCount = 0; this._innerMenu = new qx.ui.layout.HorizontalBoxLayout; this._iconObj = new qx.ui.embed.HtmlEmbed; this._iconObj.set ( { width: ao.SystemMenu.MainBar.subMenuWidth, height: ao.SystemMenu.MainBar.itemHeight } ); var html="

" + iconText + "
"; //var html="

" + iconText + "
"; this._iconObj.setHtml ( html ); // to get the right width. parentMenu._subMenuCount++; this._button = new qx.ui.form.Button ( "", "icons/buttonRight.png" ); this._button.set ( { left: -ao.SystemMenu.MainBar.buttonWidth, height: ao.SystemMenu.MainBar.itemHeight } ); this._button.setZIndex ( 101 ); this._button.addEventListener ( "click", this._onClicked, this ); this.add ( this._iconObj, this._button ); if ( parentMenu._subMenuLevel == 0 ) { this.setWidth ( ao.SystemMenu.MainBar.paneWidth ); this._iconObj.set ( { width: ao.SystemMenu.MainBar.paneWidth, height: ao.SystemMenu.MainBar.itemWidth } ); this._pane = new qx.ui.layout.HorizontalBoxLayout; this._pane.set ( { left: -ao.SystemMenu.MainBar.buttonWidth, height: (ao.SystemMenu.MainBar.itemWidth + 20), top: -10, backgroundColor : ao.SystemMenu.MainBar.subMenuBGColor } ); this._pane.setZIndex ( 100 ); this._pane.setOpacity ( 0.0 ); // initially invisible this._pane.hide ( ); this.add ( this._pane ); } //else // this.setMargin ( 10 ); this._innerMenu.setOpacity ( 0.0 ); this._innerMenu.setZIndex ( 101 ); this._innerMenu.hide ( ); this._innerMenu.addToDocument ( ); parentMenu.addMenuItem ( this ); }, members : { addMenuItem : function ( item ) { this._innerMenu.add ( item ); }, _onClicked : function ( ) { // This function will fade the subMenu in/out // If this is a subMenu of a SubMenu then if ( this._direction == 0 ) // Right this._direction = 1; else this._direction = 0; // If this is a SubMenu of the RootMenu if ( this._pane != 0 ) { this._button.setIcon ( "icons/buttonLeft.png" ); this._rootMenu._changeToPane = this._pane; this._rootMenu.menuButtonClicked ( this ); this._rootMenu._subMenuOfMainMenu = this; // required to revert to the right SubMenu } else this._rootMenu.menuButtonClicked ( this ); } }// End of members ... } ); // End ao::SystemMenu::SubMenu ////////////////////////////////////////////////////////////////// // // This is the class for the system menu ( left side ) // ////////////////////////////////////////////////////////////////// qx.Class.define("ao.SystemMenu.MainBar", { extend : qx.ui.basic.Image, statics : { paneWidth : 110, itemWidth : 80, itemHeight : 80, subMenuWidth : 96, // buttonWidth : 16, // fixed through icons paneOpacity : 0.5, // for both MainMenu and SubMenus fadeSpeed : 30, // higher number = slower animSpeed : 48, // higher number = slower mainBarBGColor : '#FF8811', // Orange subMenuBGColor : "blue" }, construct : function ( ) { this.base ( arguments, "icons/left.png", 40, 40 ); this.set ( { left: 0, bottom: -2 } ); this.setZIndex ( 101 ); this.setOpacity ( 1.0 ); this.setResizeToInner ( true ); this._direction = 0; this._currentPos = ao.SystemMenu.MainBar.paneWidth; this._timer = new qx.client.Timer ( 5 ); this._pane = new qx.ui.layout.HorizontalBoxLayout; this._pane.set ( { left: -ao.SystemMenu.MainBar.paneWidth, width: ao.SystemMenu.MainBar.paneWidth, top: 0, bottom: 40, backgroundColor : ao.SystemMenu.MainBar.mainBarBGColor } ); this._pane.setZIndex ( 100 ); this._pane.setOpacity ( ao.SystemMenu.MainBar.paneOpacity ); this._pane.addToDocument ( ); this.addToDocument ( ); // Next we want to add two buttons. Top and Bottom for scrlling this._buttonUp = new qx.ui.form.Button ( "", "icons/buttonUp.png" ); this._buttonUp.set ( { left: -ao.SystemMenu.MainBar.paneWidth, top: 0, width: ao.SystemMenu.MainBar.paneWidth } ); this._buttonUp.setZIndex ( 101 ); this._buttonUp.addToDocument ( ); this._buttonDown = new qx.ui.form.Button ( "", "icons/buttonDown.png" ); this._buttonDown.set ( { left: -ao.SystemMenu.MainBar.paneWidth, bottom: 40, width: ao.SystemMenu.MainBar.paneWidth } ); this._buttonDown.setZIndex ( 101 ); this._buttonDown.addToDocument ( ); // And finally we can add the Layout to handle the added icons etc. this._rootMenu = new ao.SystemMenu.InnerMenu ( this ); // qx.ui.layout.VerticalBoxLayout ( ); this._rootMenu.set ( { left: -ao.SystemMenu.MainBar.paneWidth, width: ao.SystemMenu.MainBar.paneWidth, top: 0, bottom: 55 } ); this._rootMenu.setZIndex ( 101 ); this._rootMenu.addToDocument ( ); this.addEventListener ( "click", this._onSystemClicked, this ); this._buttonUp.addEventListener ( "click", this._onButtonUp, this ); this._buttonDown.addEventListener ( "click", this._onButtonDown, this ); this._timer.addEventListener ( "interval", this._onAnimateTimer, this ); this._initMe ( ); }, members : { // Private functions ... // This function will build the buttons / folder belonging to the SystemMenu // php wil parse through the apps folder and // - create a app - button for each /apps//app_conf.php file (if empty no icon will be used) // - create a SubMenu for each dir under /apps conaining menu_conf.php _initMe : function ( ) { /* ? php function readMenu ( $parentID ) { while ( 1 ) { $iRootIdx = 0; // starting with the root dir select idx, folder, icont_text, icon_color, icon, win_x, win_y, win_height, win_width, execute, params from SystemMenu where parent_idx=$parentID order by sequence, idx; if ( array.size > 0 ) { if ( $folder == true ) { echo "this._addMenu ( $parentObj, $iconText, $iconColor, $icon )\n"; readMenu ( $parentID ) } else echo "this._addApp ( $parentObj, $iconText, $iconColor, $icon, $winX, $winY, $winW, $winH, $execute, $params )\n"; } } } ? > */ var menu = null; var subMenu = null; menu = this._addMenu ( this._rootMenu, "Internet", "#C0C0C0", "icons/Internet.png" ); this._addApp ( menu, "Astra
Browse", "#C0C0C0", "apps/AstraBrowser/AstraBrowser.png", 20, 20, 0, 0, "AstraBrowser/AstraBrowser", "" ); this._addApp ( menu, "Chat", "#C0C0C0", "icons/IM.png", 20, 20, 0, 0, "Chat/Chat", "" ); this._addApp ( menu, "eMail", "#C0C0C0", "icons/EMail.png", 20, 20, 0, 0, "email/email", "" ); this._addApp ( menu, "Astra
Feed", "#C0C0C0", "icons/RSS.png", 20, 20, 0, 0, "Feed/Feed", "" ); menu = this._addMenu ( this._rootMenu, "Games", "#C0C0C0", "icons/Games.png" ); subMenu = this._addMenu ( menu, "Arcade", "#C0C0C0", "icons/Arcade.png" ); this._addApp ( subMenu, "Frozen
Bubbles", "#C0C0C0", "apps/games/Bubbles/Bubbles.png", 20, 20, 0, 0, "games/Bubbles/Bubbles", "" ); this._addApp ( subMenu, "Tetris", "#C0C0C0", "apps/games/Tetris/Tetris.png", 20, 20, 0, 0, "games/Tetris/Tetris/php", "" ); //subMenu = this._addMenu ( menu, "Board", "#C0C0C0", "icons/Desktop.png" ); this._addApp ( menu, "Chess", "#C0C0C0", "apps/games/Chess/Chess.png", 20, 20, 0, 0, "games/Chess/Chess", "" ); //menu = this._addMenu ( this._rootMenu, "Office", "#C0C0C0", "icons/Desktop.png" ); this._addApp ( this._rootMenu, "Editor", "#C0C0C0", "icons/Editor.png", 20, 20, 0, 0, "FCKEditor/FCKEditor", "" ); menu = this._addMenu ( this._rootMenu, "Utils", "#C0C0C0", "icons/Utils.png" ); this._addApp ( menu, "Calendar", "#C0C0C0", "icons/Calendar.png", 20, 20, 0, 0, "Calendar/Calendar/php", "" ); this._addApp ( menu, "Calc", "#C0C0C0", "icons/Calc.png", 20, 20, 0, 0, "Calc/Calc", "" ); this._addApp ( menu, "Notes", "#C0C0C0", "icons/Notes.png", 20, 20, 0, 0, "Notes/Notes", "" ); this._addApp ( menu, "OnTrack", "#C0C0C0", "icons/OnTrack.png", 20, 20, 0, 0, "OnTrack/OnTrack", "" ); this._addApp ( menu, "35mm", "#C0C0C0", "apps/35mm/35mm.png", 20, 20, 0, 0, "35mm/35mm", "" ); menu = this._addMenu ( this._rootMenu, "System", "#C0C0C0", "icons/System.png" ); this._addApp ( menu, "Wiki", "#C0C0C0", "icons/mediawiki.png", 20, 20, 0, 0, "Wiki/Wiki", "" ); this._addApp ( menu, "Bugzilla", "#C0C0C0", "icons/Bugzilla.png", 20, 20, 0, 0, "Bugzilla/Bugzilla", "" ); this._addApp ( menu, "Progress", "#C0C0C0", "icons/Progress.png", 140, 20, 850, 400, "iFrame/iFrame", "http://www.astranos.org/progress/progress.html" ); this._addApp ( this._rootMenu, "Setup", "#C0C0C0", "icons/Desktop.png", 20, 20, 0, 0, "Setup/Setup/php", "" ); }, _addApp : function ( parentMenu, iconText, iconColor, icon, winX, winY, winW, winH, execute, params ) { var item = new ao.SystemMenu.MenuItem ( parentMenu, icon, iconText, iconColor ); item.setExecute ( execute, params, winX, winY, winW, winH ); return item; }, _addMenu : function ( parentMenu, iconText, iconColor, icon ) { var menu = new ao.SystemMenu.SubMenu ( this._rootMenu, parentMenu, icon, iconText, iconColor ); return menu; }, _onSystemClicked : function ( e ) { if ( this._direction == 0 ) { // left this.setSource ( "icons/up.png" ); this._direction = 1; this._rootMenu.reshow ( ); } else { this.setSource ( "icons/left.png" ); this._direction = 0; if ( this._rootMenu._activePane != 0 ) { this._rootMenu._activePane.hide ( ); this._rootMenu._activePane.setOpacity ( 0.0 ); } if ( this._rootMenu._activeSubMenu != 0 ) { this._rootMenu._activeSubMenu._innerMenu.setOpacity ( 0.0 ); this._rootMenu._activeSubMenu._innerMenu.hide ( ); } this._rootMenu._activePane = 0; this._rootMenu._activeSubMenu = 0; } if ( this._timer.getEnabled ( ) == false ) this._timer.start ( ); }, _onAnimateTimer : function ( e ) { if ( this._direction == 0 ) { // move right if ( this._currentPos < ao.SystemMenu.MainBar.animSpeed ) this._currentPos++; else this._timer.stop ( ); } else { // move left if ( this._currentPos > 0 ) this._currentPos--; else this._timer.stop ( ); } var currentPos = eval ( - this._currentPos / ao.SystemMenu.MainBar.animSpeed * ao.SystemMenu.MainBar.paneWidth ); // So we have the new position. this._pane.set ( { left: currentPos } ); this._buttonUp.set ( { left: currentPos } ); this._buttonDown.set ( { left: currentPos } ); this._rootMenu.set ( { left: currentPos } ); }, _onButtonUp : function ( ) { this._rootMenu.up ( ); }, _onButtonDown : function ( ) { this._rootMenu.down ( ); } } // end of members }); /* ?php function recReadDir ( $dir ) { $d = dir ( $dir ); if ( $d ) { while ( false !== ( $entry = $d->read ( ) ) ) { if ( ( $entry != '.' ) && ( $entry != '..' ) ) { $entry = $dir.'/'.$entry; if( is_dir ( $entry ) ) { if ( file_exists ( $entry.'/app_conf.php' ) ) echo "this._addApp ( \"$entry\" );\n"; else if ( file_exists ( $entry.'/menu_conf.php' ) ) echo "this._addMenu ( \"".$entry."\" );\n"; recReadDir ( $entry ); } } } $d->close ( ); } } recReadDir ( "../apps" ); this._addApp ( "../apps/Calc/Calc.js" ); ?> */