Source: sidebar.h


Annotated List
Files
Globals
Hierarchy
Index
/*
******************************************************************************
*  File Name  :  sidebar.h  -  application header file
*  Created on :  Friday, June 21, 2002
*  Product id :  KitClasses  version 1.0  -  KInterDev Add-on Classes for KDE
*   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  Copyright :  © 2002 by Bruce Hunt    Supporting Cast
*  Email     :  SuppCast@users.sourceforge.net
*  Web site  :  http://kinterdev.sourceforge.net
******************************************************************************
*  This program is being provided under the LICENSING terms and conditions as
*  specified in the file "COPYING" which has been included with this software
*  package. This program is distributed WITHOUT ANY WARRANTY, without even the
*  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
******************************************************************************
*    M o d i f i c a t i o n   L o g
*   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  07-27-2002 BFH Added setButton member with bool "on" option
*
*****************************************************************************/
#ifndef KIT_SIDEBAR_H
#define KIT_SIDEBAR_H

#include "icontextmenu.h"

#include 
#include 
#include 

class QButtonGroup;
class QScrollView;
class QToolButton;

class KConfig;
class KPopupMenu;
class KPushButton;

class KitIconTextMenu;
class KitIconSizeMenu;
class KitSbButtonGroup;
class KitSbScrollView;
class dsGrpLst;
class dsBtnLst;
/**
 * KitSideBar is a widget similar to a toolbar in functionality but in a sidebar fashion.
 *
 * The buttons in this sidebar are tied to the KDE environment.
 * Thus when "default" is selected on the icon size menu the Desktop icon size
 * from the control center is used for the icon size in the application group bar.
 * The bar width is calculated from the fontmetrics of the icon text string
 * and is derived from font settings in the KDE control center..
 *
 * @short A sidebar with toolbutton functionality.
 * @author Bruce Hunt 
 */
class KitSideBar : public QFrame
{
   Q_OBJECT

public:
   /**
    * Constructor
    */
   KitSideBar( QWidget * parent, const char * name = 0 );
   /**
    * Destructor
    */
   ~KitSideBar();
   /**
    * @return the current icon size - this is the actual icon size
    */
   int iconSize();
   /**
    * @return the current icon size selected - this could be 0 for Default
    */
   int iconSizeSetting();
   /**
    * @return the icon text setting
    */
   KitIconTextMenu::IconText iconText();
   /**
    * Adds a button to a sidebar.
    * @param barId the id of the bar to add the button to
    * @param icon the name of the icon of the button
    * @param text the button text
    * @param tip the button tooltip
    * @param id the id of the button (if -1 the group button count is used for the id)
    * @param quit the button is a "quit application" button (kapp->quit())
    * @return the id of the button
    */
   int addButton( int barId, const QString icon, const QString text, const QString tip = QString::null, int id = -1, bool quit = false );
   /**
    * Change an existing button.
    * @param barId the id of the bar to add the button to
    * @param id the id of the button
    * @param icon the name of the icon of the button
    * @param text the button text
    * @param tip the button tooltip
    */
   void changeButton( int barId, int id, const QString icon, const QString text, const QString tip = QString::null );
   /**
    * Remove an existing button.
    * @param barId the id of the bar to add the button to
    * @param id the id of the button
    */
   void removeButton( int barId, int id );
   /**
    * Sets a sidebar button status. This method will not emit button clicked() or pressed() signals.
    * @param barId the id of the bar
    * @param btnId the id of the button
    * @param on sets status of the button
    * @return true if removed
    */
   void setDown( int barId, int btnId, bool down );
   /**
    * Creates a button sidebar group
    * @param text the button text.
    * @param id the id of the button bar
    * @return the id of the bar created
    */
   int createButtonBar( const QString text, int id = -1 );
   /**
    * @return the id of the currently visable bar or -1 if no bar exists
    */
   int currentBar();
   /**
    * Get pointer to a bar.
    * @param barId the id of the bar
    * @return the pointer of the bar button group
    */
   QButtonGroup * getBarPtr( int barId );
   /**
    * Shows a sidebar group.
    * @param barId the id of the bar
    */
   void showBar( int barId );
   /**
    * Not yet implemented
    */
   void createClipTray();
   /**
    * Applies the saved configuration settings.
    * @param group then configuration file group name
    */
   void applySettings( KConfig * config, const QString group = "Sidebar" );
   /**
    * Saves the current settings - does not save the sidebar contents.
    * @param group then configuration file group name
    */
   void saveSettings( KConfig * config, const QString group = "Sidebar" );

public slots:
   /**
    * Sets a sidebar button down. This method emits button clicked() and pressed() signals.
    * @param barId the id of the bar
    * @param btnId the id of the button
    */
   void setButton( int barId, int btnId );
   /**
    * Sets the icon size
    */
   void setIconSize( int size );
   /**
    * Sets the icon text position
    */
   void setIconText( KitIconTextMenu::IconText it );

signals:
   /**
    * Sidebar group activated.
    * @param barId the id of the bar
    */
   void barActivated( int barId );
   /**
    * Sidebar button clicked
    * @param barId the id of the bar
    * @param btnId the id of the button
    */
   void buttonClicked( int barId, int btnId );
   /**
    * Emitted when the sidebar is hidden
    */
   void hidden();

protected:
   /**
    * Used for RMB event to display popup menu
    */
   void mouseReleaseEvent( QMouseEvent * event );

protected slots:
   /**
    * Shows the RMB popup menu.
    */
   void showPopup();
   /**
    * Hides the entire sidebar.
    */
   void pumHide();

private:
   enum BorderPix{ PushPix = 16, ToolPix = 32 };

   QPtrList glPtrLst;
   dsGrpLst * dsGrpLstElm;
   QPtrList blPtrLst;
   dsBtnLst * dsBtnLstElm;

   bool bClipTray;
   bool bHaveBar;
   int iCurBarId;
   int iIconSizeItm;
   int iIconSize;
   int iIconSizeSet;
   KitIconTextMenu::IconText itIconText;

   QColor barColor;
   QScrollView * prvBarPtr;

   KPopupMenu * puMnu;
   KitIconTextMenu * puTpm;
   KitIconSizeMenu * puIsm;

   void calcButtonSpacing();
   int calcButtonWidth( int, QButton *, const QString );
   int calcTextWidth( int, int, QButton *, const QString );
   void createPopup();
   int getBarId( QButtonGroup * );
   void resizeWidth();

private slots:
   void gblFontChanged();
   void gblIconChanged( int );
   void gblPaletteChanged();
   void showClipTray();
   void showButtonBar( KPushButton * );
   void slotButtonClicked( QButtonGroup *, int );
};
/**
 * Private implementation for KitSideBar support.
 * @author Bruce Hunt 
 */
class KitSbButtonGroup : public QVButtonGroup
{
   Q_OBJECT

public:
   KitSbButtonGroup( QWidget * parent, const char * name = 0 );
   ~KitSbButtonGroup();

signals:
   void clicked( QButtonGroup * grp, int id );

private slots:
   void slotClicked( int id );
};
/**
 * Private implementation for KitSideBar support.
 * @author Bruce Hunt 
 */
class KitSbScrollView : public QScrollView
{
   Q_OBJECT

public:
   KitSbScrollView( QWidget * parent, const char * name = 0 );
   ~KitSbScrollView();

signals:
   void createPopup();

protected:
   void contentsMouseReleaseEvent( QMouseEvent * evt );
};

#endif

Generated by: bhunt on Lurch on Sun Nov 24 02:45:27 2002, using kdoc 2.0a54.