dslinux/user/pixil/packages/viewml/viewml/kdeui AUTHORS CHANGES.kdatepicker ChangeLog Makefile.am Makefile.in USERS.kdatepicker arrow_down.xbm arrow_left.xbm arrow_right.xbm arrow_up.xbm error.xpm exclamation.xpm info.xpm kbutton.cpp kbutton.h kbuttonbox.cpp kbuttonbox.h kcolorbtn.cpp kcolorbtn.h kcolordlg.cpp kcolordlg.h kcombo.cpp kcombo.h kcontainer.cpp kcontainer.h kcontrol.cpp kcontrol.h kcursor.cpp kcursor.h kdatepik.cpp kdatepik.h kdatetbl.cpp kdatetbl.h kdbtn.cpp kdbtn.h keditcl.h keditcl1.cpp keditcl2.cpp kfontdialog.cpp kfontdialog.h kiconloaderdialog.cpp kiconloaderdialog.h kintegerline.cpp kintegerline.h kkeydialog.cpp kkeydialog.h kled.cpp kled.h kledlamp.cpp kledlamp.h klined.cpp klined.h kmenubar.cpp kmenubar.h kmsgbox.cpp kmsgbox.h knewpanner.cpp knewpanner.h knotebook.cpp knotebook.h kpanner.cpp kpanner.h kpopmenu.cpp kpopmenu.h kprogress.cpp kprogress.h kquickhelp.cpp kquickhelp.h krestrictedline.cpp krestrictedline.h kruler.cpp kruler.h kselect.cp! p kselect.h kseparator.cpp kseparator.h kslider.cpp kslider.h kspinbox.cpp kspinbox.h kstatusbar.cpp kstatusbar.h ktabbar.cpp ktabbar.h ktabctl.cpp ktabctl.h ktablistbox.cpp ktablistbox.h ktmainwindow.cpp ktmainwindow.h ktoolbar.cpp ktoolbar.h ktoolboxmgr.cpp ktoolboxmgr.h ktopwidget.cpp ktopwidget.h ktreelist.cpp ktreelist.h kurllabel.cpp kurllabel.h kwizard.cpp kwizard.h kwmmapp.cpp kwmmapp.h question.xpm stopsign.xpm

amadeus dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:26:36 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/pixil/packages/viewml/viewml/kdeui
In directory antilope:/tmp/cvs-serv11916/packages/viewml/viewml/kdeui

Added Files:
	AUTHORS CHANGES.kdatepicker ChangeLog Makefile.am Makefile.in 
	USERS.kdatepicker arrow_down.xbm arrow_left.xbm 
	arrow_right.xbm arrow_up.xbm error.xpm exclamation.xpm 
	info.xpm kbutton.cpp kbutton.h kbuttonbox.cpp kbuttonbox.h 
	kcolorbtn.cpp kcolorbtn.h kcolordlg.cpp kcolordlg.h kcombo.cpp 
	kcombo.h kcontainer.cpp kcontainer.h kcontrol.cpp kcontrol.h 
	kcursor.cpp kcursor.h kdatepik.cpp kdatepik.h kdatetbl.cpp 
	kdatetbl.h kdbtn.cpp kdbtn.h keditcl.h keditcl1.cpp 
	keditcl2.cpp kfontdialog.cpp kfontdialog.h 
	kiconloaderdialog.cpp kiconloaderdialog.h kintegerline.cpp 
	kintegerline.h kkeydialog.cpp kkeydialog.h kled.cpp kled.h 
	kledlamp.cpp kledlamp.h klined.cpp klined.h kmenubar.cpp 
	kmenubar.h kmsgbox.cpp kmsgbox.h knewpanner.cpp knewpanner.h 
	knotebook.cpp knotebook.h kpanner.cpp kpanner.h kpopmenu.cpp 
	kpopmenu.h kprogress.cpp kprogress.h kquickhelp.cpp 
	kquickhelp.h krestrictedline.cpp krestrictedline.h kruler.cpp 
	kruler.h kselect.cpp kselect.h kseparator.cpp kseparator.h 
	kslider.cpp kslider.h kspinbox.cpp kspinbox.h kstatusbar.cpp 
	kstatusbar.h ktabbar.cpp ktabbar.h ktabctl.cpp ktabctl.h 
	ktablistbox.cpp ktablistbox.h ktmainwindow.cpp ktmainwindow.h 
	ktoolbar.cpp ktoolbar.h ktoolboxmgr.cpp ktoolboxmgr.h 
	ktopwidget.cpp ktopwidget.h ktreelist.cpp ktreelist.h 
	kurllabel.cpp kurllabel.h kwizard.cpp kwizard.h kwmmapp.cpp 
	kwmmapp.h question.xpm stopsign.xpm 
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it

--- NEW FILE: klined.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Sven Radej (sven.radej at iname.com)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
// This was taken from filentry.cpp
// fileentry.cpp is part of KFM II, by Torben Weis
// changed to accept Tab, maybe this should be switchable (constructor)
// 'cause a tabbed dialog will stop working ..

#include <qlineedit.h>
#include "klined.h"

#include <qkeycode.h>


KLined::KLined (QWidget *parent, const char *name)
  : QLineEdit (parent, name)
{
  installEventFilter (this);
}

KLined::~KLined ()
{
  removeEventFilter (this);
}

void KLined::cursorAtEnd ()
{
  QKeyEvent ev( Event_KeyPress, Key_End, 0, 0 );
  QLineEdit::keyPressEvent( &ev );
}

bool KLined::eventFilter (QObject *, QEvent *e)
{
  if (e->type() == Event_KeyPress)
    {
      QKeyEvent *k = (QKeyEvent *) e;
      
      if ( ((k->state() == ControlButton) && (k->key() == Key_S || k->key() == Key_D))
	   || k->key() == Key_Tab) {   
	      if (k->key() == Key_Tab || k->key() == Key_S)
		      emit completion ();
	      else
		      emit rotation ();
	      cursorAtEnd();
	      return TRUE;
      }
    }
  return FALSE;
}
#include "klined.moc"


--- NEW FILE: kquickhelp.h ---
// ---------------------------------------------------------------------------
//
//   QuickHelp: an improved mini-help system for KDE
//
// ---------------------------------------------------------------------------
//
//   This file is part of the KDE libraries
//
//   Copyright (C) 1997 Mario Weilguni <mweilguni at kde.org>
//
//   This library is free software; you can redistribute it and/or
//   modify it under the terms of the GNU Library General Public
//   License as published by the Free Software Foundation; either
//   version 2 of the License, or (at your option) any later version.
//
//   This library is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//   Library General Public License for more details.
//
//   You should have received a copy of the GNU Library General Public License
//   along with this library; see the file COPYING.LIB.  If not, write to
//   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
//   Boston, MA 02111-1307, USA.
//
// ---------------------------------------------------------------------------

#ifndef __QUICKHELP__H__
#define __QUICKHELP__H__

#include <qframe.h>
#include <qlist.h>
#include <qpopupmenu.h>


/**
 * Provides a helpsystem for KDE. It's mainly intended for those parts of the
 * program, where tooltips (@see QToolTip) give too little advice and calling
 * the HTML help viewer is overkill (or just too slow). For example, some 
 * programs have quite complex dialogs, and if you want to provide help you
 * can use a full-blown HTML-helpsystem (and typically nobody really reads it),
 * or tooltips (which provide too less information, and it's nerving to move
 * the mouse over a widget and to wait if a tooltip pops up. The solution to
 * this is QuickHelp (at least for me :-)
 * 
 * Normally, a Quickhelp just looks like a simple QToolTip, but it has some 
 * differences:
 *
 * 1. Tooltips only pop up when you leave the mouse over a widget for a short
 *    period of time. It's not possible to pop up upon request, as it is with
 *    QuickHelp
 *
 * 2. Tooltips do not allow formatting text.
 *
 *
 * Here are the highlights of QuickHelp:
 * o Requires few memory. The amount depends on the length of the help text you
 *   provide, plus a few hundreds of bytes of memory for QuickHelp itself and
 *   a few bytes for each widget you want to use QuickHelp with (8 bytes)
 *
 * o Text formatting: bold, italic, underline, reduce and enlarge font size, basic
 *   colors like red, green... as well as colors provided as RGB values
 *
 * o Hyperlinks, which calls the HTML-viewer to provider more information or 
 *   related information
 *
 * o Shadows. A QuickHelp has a shadow (at least when the underlying X-server 
 *   supports that feature. It is planned to make this configureable.
 *
 * o Font selection: QuickHelp allows to select basic fonts: the default fonts,
 *   the fixed system font currently.
 *
 * o Easy to use: just add a line like this:
 *     QuickHelp::add(myWidget, "text text text");
 *
 * o Web-integration: hyperlinks to ftp:, http:, file:, info:, man: and 
 *   mailto: protokolls are available
 * 
 *
 * 
 * TODO LIST:
 *
 * o make shadow configurable instead of compile time option (easy)
 * o faster painting, avoid to much QFont stuff (fairly easy)
 * o better event handling. Clear the mouse event that closed the
 *   KQuickHelp to avoid the underlaying widgets to get that event.
 * o Maybe all KQuickHelp text in one file?
 * o kdoc compliant documentation
 * o purify
 * 
 */

struct KQuickTip {
  QWidget *widget;
  QString txt;
};

struct KQuickHelp_Token {
  const char *token;
  int tokenID;
};

class KQuickHelp_Link {
public:
  QRect area;
  QString link;
};

class KQuickHelpWindow : public QFrame {
  Q_OBJECT
public:
  KQuickHelpWindow();
  ~KQuickHelpWindow() {}

  void newText();
  void popup(QString text, int atX, int atY);
  
  virtual void mouseMoveEvent(QMouseEvent *);
  virtual void mousePressEvent(QMouseEvent *);
  virtual void keyPressEvent(QKeyEvent *);
  virtual void paintEvent(QPaintEvent *);
  void paint(QPainter *p, int &, int &);  
  virtual void show();
  virtual void hide();

signals:
  void hyperlink(QString);

private:
  QString token();

  QString activeLink;
  QCursor defaultCursor;
  int tokIndex;
  QString txt;

  QList<KQuickHelp_Link> linkAreas;
  static QColor stdColors[];
  static KQuickHelp_Token tokens[];
};


class KQuickHelp : public QObject {
  Q_OBJECT
public:  
  KQuickHelp();
  
  static const char *add(QWidget *, const char *);
  static void remove(QWidget *);

private:
  virtual bool eventFilter(QObject *, QEvent *);
  
private slots:
  void getKQuickHelp(int);
  void widgetDestroyed();
  void hyperlinkRequested(QString);

private:
  QWidget *current;
  QString currentText;
  QPoint currentPos;

  static QList<KQuickTip> *tips;
  static KQuickHelp *instance;
  static QPopupMenu *menu;
  static KQuickHelpWindow *window;  
};


#endif

--- NEW FILE: kledlamp.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Richard Moore (moorer at cs.man.ac.uk)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
// CDE style LED lamp widget for Qt
// Richard J. Moore 23.11.96
// Email: moorer at cs.man.ac.uk

#ifndef LED_LAMP_H
#define LED_LAMP_H

#include <qframe.h>

/** 
* KLedLamp provides a CDE style LED lamp widget.
*
* @short A CDE-style LED lamp widget.
* @author Richard J. Moore (moorer at cs.man.ac.uk)
* @version $Id: kledlamp.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
*/
class KLedLamp : public QFrame
{
  Q_OBJECT
public:
/** 
* Construct a KLedLamp widget 
*/
  KLedLamp(QWidget *parent=0);

/** 
* Possible states of a KLedLamp 
*/
  enum State { On, Off };

/** 
* Retrieve the state of the KLedLamp 
*/
  State state() const { return s; }
  
/** 
* Set the state of the KLedLamp 
*/
  void setState(State state) { s= state; paintEvent(0); }

/** 
* Toggle the state of the KLedLamp 
*/
  void toggleState() { if (s == On) s= Off; else if (s == Off) s= On; paintEvent(0); }
public slots:
  void toggle() { toggleState(); };
  void on() { setState(On); };
  void off() { setState(Off); };
protected:
  void drawContents(QPainter *);
private:
  const int width;
  const int height;
  const int dx;
  State s;
};


#endif





--- NEW FILE: kcontainer.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1998 Jorge Monteiro <jomo at casema.net>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#ifndef __KCONTAINER_H__
#define __KCONTAINER_H__

#include <qframe.h>
#include <qlist.h>

/**
 * KContainerLayoutItem is a internal class used by KConatinerLayout 
 * @see KContainerLayout
 * This class represents one widget inside the one KContainerLayout
 * 
 * @short KContainerLayoutItem
 * @internal
 * @author Jorge Monteiro <jomo at casema.net>
 * @version 0.1
 */
class KContainerLayoutItem
{
public:
    /**
     * Creates one KContIem
     *
     * @param w The widget associated with this KContainerLayoutItem
     * @param e Expand will make the widget to use all space alocated to it
     * @param f Fill will make the widget be sized to ocupy all the space allocated to it. Only makes sense with expand = TRUE
     * @param p Padding is the size the widget will use as borders on both sides of the space allocated to it.
     */
    KContainerLayoutItem(QWidget *w,bool e=FALSE,bool f=FALSE,int p=0)
    {
	_widget = w;
	_expand = e;
	_fill = f;
	_padding = p;
    }
    void setExpand(bool b)		{ _expand = b; }
    void setFill(bool b)		{ _fill = b; }
    void setPadding(int i)		{ _padding = i; }
    QWidget *widget()			{ return _widget; }
    const bool expand() const		{ return _expand; }
    const bool fill() const		{ return _fill; }
    const int padding() const		{ return _padding; }
protected:
    QWidget *_widget;
    bool _expand;
    bool _fill;
    int _padding;
};

/**
 * KContainerLayout is a class that will manage layout of it's child widgets.
 * Here is an example of using this class:
 *
 * 
 * @short KContainerLayout is a class that will manage layout of it's child widgets.
 * @author Jorge Monteiro <jomo at casema.net>
 * @version 0.1
 */
class KContainerLayout : public QFrame
{
Q_OBJECT
public:
enum { Horizontal = 0, Vertical };
    /**
     * Constructs a KContainerLayout as child of parent
     * 
     * @param parent The parent widget of the KContainerLayout
     * @param name The name of the widget
     * @param orientation The orientation of the container, either KContainerLayout::Horizontal or KContainer::Vertical
     * @param homogeneous If the container should split available size by all KContainerLayoutItem in equal parts
     * @param spacing The space to add between each widget and between the first/last and the borders
     * @param f Flags @see QFrame#QFrame
     * @param allowLines Flags @see QFrame#QFrame
     */
    KContainerLayout(QWidget * parent=0, const char * name=0, 
    		int orientation = KContainerLayout::Horizontal,
		bool homogeneos = FALSE,
		int spacing = 5, WFlags f=0, bool allowLines=TRUE);
    /**
     * The destructor
     */
    virtual ~KContainerLayout();
    /**
     * Returns the number of widgets inside this container
     */
    int getNumberOfWidgets() const;
    /**
     * Pack one widget to the start of the container after the previously packed on start widgets
     * @param w The widget to be packed
     * @param e If the widget should use the whole size allocated to it
     * @param f If the widget should be sized to fill the whole space allocated to it (only makes sense with Expand=TRUE)
     * @param p Padding that should be used as the borders in each side of the widget
     */
    int packStart(QWidget *w, bool e=FALSE, bool f=FALSE,int p=1);
    /**
     * Pack one widget to the end of the container after the previously packed on end widgets
     * @param w The widget to be packed
     * @param e If the widget should use the whole size allocated to it
     * @param f If the widget should be sized to fill the whole space allocated to it (only makes sense with Expand=TRUE)
     * @param p Padding that should be used as the borders in each side of the widget
     */
    int packEnd(QWidget *w, bool e=FALSE, bool f=FALSE,int p=1);
    /**
     * Sets the orientation of the container, one of KContainerLayout::Horizontal or KContainer::Vertical
     */
    void setOrientation(int i);
    /**
     * Sets the container to use the same size to each widget he contains (TRUE) or not (FALSE)
     * When homogeneous is true all widgets will be packed as if they had the Expand set to TRUE @see KContainerLayout#packStart @see KContainer#packEnd
     */
    void setHomogeneos(bool b);
    /*
     * Sets the space to be used between each widget and between the first/last widget and the container borders
     */
    void setSpacing(int i);
    /**
     * Sets the starting offset for this container @see _startOffset
     */
    void setStartOffset(int i);
    /**
     * Sets the ending offset for this container @see _endOffset
     */
    void setEndOffset(int i);
    /**
     * Returns the current orientation of the container @see KContainerLayout#setOrientation
     */
    const int orientation() const	{ return _orientation; }
    /**
     * Returns the current homogeneous state of the container @see KContainerLayout#setHomogeneous
     */
    const bool homogeneos() const	{ return _homogeneos; }
    /**
     * Returns the current spacing of the container @see KContainerLayout#setSpacing
     */
    const int spacing() const		{ return _spacing; }
    /**
     * Returns the starting offset for this container @see _startOffset
     */
    const int startOffset() const	{ return _startOffset; }
    /**
     * Returns the ending offset for this container @see _endOffset
     */
    const int endOffset() const		{ return _endOffset; }
    /**
     * Resizes the container to be as small as necessary to display all widgets
     */
    void sizeToFit();
protected:
    /**
     * Calculates the size necessary to display all widgets
     */
    void recalcLayout();
    /**
     * Returns the size necessary for the widget represented by this KContainerLayoutItem
     */
    QSize widgetSize(KContainerLayoutItem *item)
    {
	QSize sz = item->widget()->sizeHint();
	if (!sz.isValid())
	   // well, some widgets will not return sizeHint()
	    sz = QSize(50,25); 
	return sz;
    }
    /**
     * Reposition all widgets on the container.
     */
    void repositionWidgets();
    /**
     * Returns the number of widgets that share the extra space on the container.
     */
    int numberOfWidgetsWithExpand();
    /**
     * Calculate our size hint based on the sizeHint() of all out widgets,
     * on our properties - expand and homogeneous, and on the KContainerLayoutItem 
     * properties.
     * @see KContainerLayoutItem @see packStart @see packEnd
     */
    void calculateSizeHint();
    /**
     * Return the size necessary by the largest widget on the container.
     */
    QSize sizeOfLargerWidget();
    /**
     * Returns the ideal size for the widget represented by this KContainerLayoutItem.
     */
    QSize idealSizeOfWidget(KContainerLayoutItem *item);
    /**
     * Return TRUE if this is an horizontal container.
     */
    const bool horizontal() const 	
	{ return (_orientation == KContainerLayout::Horizontal); }
    /**
     * Resizes the widget and repositions all widgets.
     */
    virtual void resizeEvent(QResizeEvent *ev);
    /**
     * Used to filter resize events from our parent if it isn't a KContainerLayout.
     */
    virtual bool eventFilter(QObject *, QEvent *ev);
    /**
     * Returns our size hint. The size necessary to display this container.
     */
    virtual QSize sizeHint() const;
    /**
     * Keeps the orientation of the container one of
     * KContainerLayout::Horizontal or KContainer::Vertical
     */
    int _orientation;
    /**
     * Should we split our size in equal parts by all the widgets?
     */ 
    bool _homogeneos;
    /**
     * Space to be used between widgets and between the first/last widget and
     * the container borders.
     */
    int _spacing;
    /**
     * Space between the starting border and the first widget
     */
    int _startOffset;
    /**
     * Space between the last widget and ending border
     */
    int _endOffset;
    /**
     * The list of all widgets packed on the start
     */
    QList<KContainerLayoutItem> _startWidgets;
    /**
     * The list of all widgets packed at the end
     */
    QList<KContainerLayoutItem> _endWidgets;
    /**
     * width or height we have for each widget
     */
    int _sizeForEach;	
    /**
     * our sizeHint that we will return on our implementation of sizeHint()
     */
    QSize _sizeHint;
};

#endif // __KCONTAINER_H__

--- NEW FILE: kcolorbtn.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Martin Jones (mjones at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qpainter.h>
#include <qdrawutil.h>
#include "kcolordlg.h"
#include "kcolorbtn.h"

#include "kcolorbtn.h"

KColorButton::KColorButton( QWidget *parent, const char *name )
	: QPushButton( parent, name )
{
	connect( this, SIGNAL( clicked() ), SLOT( slotClicked() ) );
}

KColorButton::KColorButton( const QColor &c, QWidget *parent, const char *name )
	: QPushButton( parent, name )
{
	connect( this, SIGNAL( clicked() ), SLOT( slotClicked() ) );
	col = c;
}

void KColorButton::setColor( const QColor &c )
{
	col = c;
	repaint( false );
}

void KColorButton::slotClicked()
{
	if ( KColorDialog::getColor( col ) == QDialog::Rejected )
		return;

	repaint( false );

	emit changed( col );
}

void KColorButton::drawButtonLabel( QPainter *painter )
{
	int w = ( style() == WindowsStyle ) ? 11 : 10;
	
	QColor lnCol = colorGroup().text();
	QColor fillCol = isEnabled() ? col : backgroundColor();

	if ( style() == WindowsStyle && isDown() )
	{
		qDrawPlainRect( painter, w/2+1, w/2+1, width()-w, height()-w,
		    lnCol, 1, 0 );
		w += 2;
		painter->fillRect( w/2+1, w/2+1, width()-w, height()-w, fillCol );
	}
	else
	{
		qDrawPlainRect( painter, w/2, w/2, width()-w, height()-w,
		    lnCol, 1, 0 );
		w += 2;
		painter->fillRect( w/2, w/2, width() - w, height() - w, fillCol );
	}
		
}

#include "kcolorbtn.moc"

--- NEW FILE: kfontdialog.h ---
/*
    $Id: kfontdialog.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $

    Requires the Qt widget libraries, available at no cost at 
    http://www.troll.no
       
    Copyright (C) 1997 Bernd Johannes Wuebben   
                       wuebben at math.cornell.edu

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
  
    $Log: kfontdialog.h,v $
    Revision 1.1  2006-10-03 11:26:31  dslinux_amadeus
    adding pristine copy of pixil to HEAD so I can branch from it

    Revision 1.1  2003/09/08 19:42:09  jasonk
    Addition of packages directory and associated files.

    Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
    Initial import of PIXIL into new cvs repository.

    Revision 1.1.1.1  2003/06/23 22:04:23  jasonk


    Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
    Initial import of ViewML

    Revision 1.14  1998/11/30 19:31:33  lavikka
    Now kfontdialog uses QLayout instead of hardcoded widget coordinates.
    Command buttons are aligned correctly as well. Looks good and behaves well.

    Revision 1.13  1998/09/01 20:21:54  kulow
    I renamed all old qt header files to the new versions. I think, this looks
    nicer (and gives the change in configure a sense :)

    Revision 1.12  1998/08/31 12:43:25  esken
    GPL -> LGPL

    Revision 1.11  1998/06/01 09:13:35  kalle
    Added static getFontAndText()

    Revision 1.10  1998/06/01 08:42:42  kalle
    KFontDialog:
    - you can now enter your own example string
    - new static method getXLFD() that converts a QFont() to a X Logical Font Description

    KIntegerLine:
    - new signal valueChanged( int )

    Revision 1.9  1998/01/21 15:07:00  jacek
    Added real KCharsets support

    Revision 1.7  1997/11/09 22:56:12  wuebben
    Bernd: colorscheme related changes

    Revision 1.6  1997/11/09 03:45:57  wuebben
    *** empty log message ***

    Revision 1.5  1997/10/21 20:45:01  kulow
    removed all NULLs and replaced it with 0L or "".
    There are some left in mediatool, but this is not C++

    Revision 1.4  1997/10/16 11:15:22  torben
    Kalle: Copyright headers
    kdoctoolbar removed

    Revision 1.3  1997/10/05 18:25:55  ssk
    Added short descriptions for documentation index.

    Revision 1.2  1997/05/02 16:46:39  kalle
    Kalle: You may now override how KApplication reacts to external changes
    KButton uses the widget default palette
    new kfontdialog version 0,5
    new kpanner by Paul Kendall
    new: KIconLoader

    Revision 1.6  1997/04/29 03:11:18  wuebben
    Added more comments

    Revision 1.5  1997/04/29 02:44:24  wuebben

    added support for ~/.kde/config/kdefonts
    and X server fontlist lookup

    Revision 1.4  1997/04/27 01:50:49  wuebben

    Revision 1.3  1997/04/20 14:59:45  wuebben
    fixed a minor bug which caused the last font in the font list to not
    be displayed

    Revision 1.1  1997/04/20 00:18:15  wuebben
    Initial revision

    Revision 1.2  1997/03/02 22:40:59  wuebben

    Revision 1.1  1997/01/04 17:36:44  wuebben
    Initial revision


*/


#ifndef _K_FONT_DIALOG_H_
#define _K_FONT_DIALOG_H_

#include <qmessagebox.h>
#include <qpixmap.h>
#include <qapplication.h>
#include <qframe.h> 
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qframe.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qlistbox.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qscrollbar.h>
#include <qtooltip.h>
#include <kbuttonbox.h>

#include <qstring.h>
#include <qfont.h>

/**
* Dialog for interactive font selection.
* @author Bernd Wuebben (wuebben at kde.org)
* @version $Id: kfontdialog.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
*/
class KFontDialog : public QDialog {

    Q_OBJECT

      // Usage of the KFontDialog Class:
      //
      // Case 1) The pointer fontlist is null ( Recommended Usage !!)
      // 
      // In this case KFontDialog will first search
      // for ~/.kde/config/kdefonts. If kdefonts if available
      // it will insert the fonts listed there into the family combo.
      // 
      // Note: ~/.kde/config/kdefonts is managed by kfontmanager. 
      // ~/.kde/config/kdefonts is a newline separated list of font names.
      // Such as: time\nhelvetica\nfixed\n etc.You should however not 
      // manipulate that list -- that is the job of kfontmanager.
      // 
      // If ~/.kde/config/kdefonts doesn't exist, KFontDialog will query
      // the X server and insert all availabe fonts.
      //
      // Case 2) The pointer fontlist is non null. In this cae KFontDialog 
      // will insert the strings of that QStrList into the family combo.
      // 
      // Note: Due to a bug in Qt 1.2 you must 
      // supply at this point at least two fonts in the QStrList that
      // fontlist points to. The bug has been reported and will hopefully
      // be fixed in Qt.1.3. 


public:
    KFontDialog( QWidget *parent = 0L, const char *name = 0L,
			bool modal = FALSE, const QStrList* fontlist = 0L );

    void setFont( const QFont &font );
    QFont font()	{  return selFont; }

    /*
     * This is probably the function you are looking for.
     * Just call this to pop up a dialog to get the selected font.
     * returns result().
     */

    static int getFont( QFont &theFont );

  /*
   * When you are not only interested in the font selected, but also
   * in the example string typed in, you can call this method.
   */
  static int getFontAndText( QFont &theFont, QString &theString );

  /*
   * This function converts a QFont into the corresponding X Logical Font 
   * Description.
   */
  static QString getXLFD( const QFont &theFont );

signals:
	/*
	 * connect to this to monitor the font as it as selected if you are
	 * not running modal.
	 */
	void fontSelected( const QFont &font );

private slots:

      void 	family_chosen_slot(const char* );
      void      size_chosen_slot(const char* );
      void      weight_chosen_slot(const char*);
      void      style_chosen_slot(const char*);
      void      display_example(const QFont &font);
      void      charset_chosen_slot(const char *);
      void      setColors();
private:

    bool loadKDEInstalledFonts();
    void fill_family_combo();
    void setCombos();


    QVBoxLayout  *layout;
    QGroupBox	 *box1;
    QGroupBox	 *box2;
    KButtonBox   *bbox;
    QGridLayout  *box1layout;
    QGridLayout  *box2layout;

    // pointer to an optinally supplied list of fonts to 
    // inserted into the fontdialog font-family combo-box
    QStrList     *fontlist; 

    QLabel	 *family_label;
    QLabel	 *size_label;
    QLabel       *weight_label;
    QLabel       *style_label;
    QLabel	 *charset_label;

    QLabel	 *actual_family_label;
    QLabel	 *actual_size_label;
    QLabel       *actual_weight_label;
    QLabel       *actual_style_label;
    QLabel	 *actual_charset_label;


    QLabel	 *actual_family_label_data;
    QLabel	 *actual_size_label_data;
    QLabel       *actual_weight_label_data;
    QLabel       *actual_style_label_data;
    QLabel	 *actual_charset_label_data;
    QComboBox    *family_combo;
    QComboBox    *size_combo;
    QComboBox    *weight_combo;
    QComboBox    *style_combo;
    QComboBox	 *charset_combo;    

    QLineEdit       *example_edit;
    QFont         selFont;

};


#endif

--- NEW FILE: krestrictedline.h ---
/**********************************************************************
**
** $Id: krestrictedline.h,v 1.1 2006-10-03 11:26:32 dslinux_amadeus Exp $
**
** Definition of KRestrictedLine
**
** Copyright (C) 1997 Michael Wiedmann, <mw at miwie.in-berlin.de>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the Free
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
**
*****************************************************************************/

#ifndef KRESTRICTEDLINE_H
#define KRESTRICTEDLINE_H

#include "qlineedit.h"

/** Restricted Editline: Only selected Characters are valid input. 
    All other characters will be discarded and the signal invalidChar() 
    will be emitted for each of them. Valid characters can be passed 
    through a pointer to the constructor or call of a public method.
    The default key binding of QLineEdit is still in effect.

    @author Michael Wiedmann <mw at miwie.in-berlin.de>
    @version 0.0.1
  */
class KRestrictedLine : public QLineEdit
{
  Q_OBJECT
  
public:
  /**@name methods */
  //@{
      
  /** Constructor: This contructor takes three - optional - arguments.
	  The first two parameters are simply passed on to QLineEdit.
	  @param parent   pointer to the parent widget
	  @param name     pointer to the name of this widget
	  @param valid    pointer to set of valid characters 
  */
  KRestrictedLine( QWidget *parent=0, const char *name=0, const char *valid=0 );

  /// Destructor
  ~KRestrictedLine();

  /** All characters in *valid are treated as valid characters
	*/
  void	setValidChars(const char *valid);
  //@}
  
  signals:
  /** This signal is emitted, if an invalid character was typed
	*/
  void	invalidChar(int);

protected:
  /// Handles the special keys
  void	keyPressEvent( QKeyEvent *e );

private:
  /// QString of valid characters for this line
  QString	qsValidChars;
};

#endif // KRESTRICTEDLINE_H




--- NEW FILE: kcolordlg.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Martin Jones (mjones at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
// KDE color selection dialog.

// layout managment added Oct 1997 by Mario Weilguni 
// <mweilguni at sime.com>

#ifndef __KCOLORDLG_H__
#define __KCOLORDLG_H__

#include <qdialog.h>
#include <qtableview.h>
#include <qframe.h>
#include <qrangecontrol.h>
#include <qlineedit.h>
#include <qpixmap.h>
#include <qcombobox.h>
#include "kselect.h"

//-----------------------------------------------------------------------------

class KHSSelector : public KXYSelector
{
  Q_OBJECT
public:
  KHSSelector( QWidget *parent );

private:
  void drawPalette();

protected:
  virtual void resizeEvent( QResizeEvent * );
  virtual void drawContents( QPainter *painter );

protected:
  QPixmap pixmap;
};

//-----------------------------------------------------------------------------

class KValueSelector : public KSelector
{
  Q_OBJECT
public:
  KValueSelector( QWidget *parent );

  void setHue( int h )	{	hue = h; }
  void setSaturation( int s )	{	sat = s; }

  void drawPalette();

protected:
  virtual void resizeEvent( QResizeEvent * );
  virtual void drawContents( QPainter *painter );

protected:
  int hue;
  int sat;
  QPixmap pixmap;
};

//-----------------------------------------------------------------------------

class KColorCells : public QTableView
{
  Q_OBJECT
public:
  KColorCells( QWidget *parent, int rows, int cols );
  ~KColorCells();

  void setColor( int colNum, const QColor &col );
  QColor color( int indx )
  {	return colors[indx]; }
  int numCells()
  {	return numRows() * numCols(); }
	
  int getSelected()
  {	return selected; }

  signals:
  void colorSelected( int col );

protected:
  virtual void paintCell( QPainter *painter, int row, int col );
  virtual void resizeEvent( QResizeEvent * );
  virtual void mouseReleaseEvent( QMouseEvent * );

  QColor *colors;
  int	selected;
};

//-----------------------------------------------------------------------------

class KColorPatch : public QFrame
{
  Q_OBJECT
public:
  KColorPatch( QWidget *parent );
  virtual ~KColorPatch();

  void setColor( const QColor &col );

protected:
  virtual void drawContents( QPainter *painter );

private:
  QColor color;
  uint pixel;
  int colContext;
};

//-----------------------------------------------------------------------------

/// KDE Color Selection dialog
/** KDE Color Selection dialog
Features:

Colour selection from a standard system palette.
Colour selection from a Palette of H vs S and V selectors (similar to windoze).
Direct input of HSV or RGB values.
Saving of custom colors

simplest use:
QColor myColor;
int result = KColorDialog::getColor( myColor );

 */
class KColorDialog : public QDialog
{
  Q_OBJECT
public:
  /// Constructor
  /** Construct a KColorDialog */
  KColorDialog( QWidget *parent = 0L, const char *name = 0L,
				bool modal = FALSE );

  /// Preselect a color
  /** Preselect a color */
  void setColor( const QColor &col );

  /// Retrieve the currently selected color.
  /** Retrieve the currently selected color. */
  QColor color()	{	return selColor; }
  
  /**
	This is probably the function you are looking for.
	Just call this to pop up dialog get the selected color.
	returns result().
	*/
  static int getColor( QColor &theColor );

 public slots:
 void slotOkPressed();

  signals:
 /// Notify when a color is selected.
 /**
   connect to this to monitor the color as it as selected if you are
   not running modal.
   */
 void colorSelected( const QColor &col );

 private slots:
 void slotRGBChanged();
  void slotHSVChanged();
  void slotHSChanged( int, int );
  void slotVChanged( int );
  void slotSysColorSelected( int );
  void slotCustColorSelected( int );
  void slotAddToCustom();
  void getHelp();

private:
  void readSettings();
  void writeSettings();
  void setRgbEdit();
  void setHsvEdit();

private:
  KColorCells *sysColorCells;
  KColorCells *custColorCells;
  QLineEdit *hedit;
  QLineEdit *sedit;
  QLineEdit *vedit;
  QLineEdit *redit;
  QLineEdit *gedit;
  QLineEdit *bedit;
  KColorPatch *patch;
  KHSSelector *palette;
  KValueSelector *valuePal;
  QColor selColor;
};

//----------------------------------------------------------------------------

class KColorCombo : public QComboBox
{
	Q_OBJECT
public:
	KColorCombo( QWidget *parent, const char *name = 0L );

	void setColor( const QColor &col );

public slots:
	void slotActivated( int index );
	void slotHighlighted( int index );

signals:
	void activated( const QColor &col );
	void highlighted( const QColor &col );

protected:
	virtual void resizeEvent( QResizeEvent *re );

private:
	void addColors();
	QColor customColor;
	QColor color;
};

#endif		// __KCOLORDLG_H__


--- NEW FILE: kprogress.cpp ---
/*
 * KProgress -- a progress indicator widget for KDE. 
 * (c) 1996 Martynas Kunigelis
 */
 
#include "kprogress.h"
#include "kprogress.h"

#include <qpainter.h>
#include <qstring.h>
#include <qpixmap.h>
#include <kapp.h>

KProgress::KProgress(QWidget *parent, const char *name)
	: QFrame(parent, name),
	QRangeControl(0, 100, 1, 10, 0),
	orient(Horizontal)
{
	initialize();
}

KProgress::KProgress(Orientation orientation, QWidget *parent, const char *name)
	: QFrame(parent, name),
	QRangeControl(0, 100, 1, 10, 0),
	orient(orientation)
{
	initialize();
}

KProgress::KProgress(int minValue, int maxValue, int value, 
					Orientation orientation, QWidget *parent, const char *name)
	: QFrame(parent, name),
	QRangeControl(minValue, maxValue, 1, 10, value),
	orient(orientation)
{
	initialize();
}

KProgress::~KProgress()
{
}

void KProgress::advance(int offset)
{
	setValue(value() + offset);
}

void KProgress::initialize()
{
	//setFrameStyle(QFrame::Panel | QFrame::Sunken);
	//setLineWidth(2);
	//setMidLineWidth(2);
	bar_pixmap = 0;
	bar_style = Solid;
	bar_color = kapp->selectColor;
	bar_text_color = kapp->selectTextColor;
	text_color = kapp->textColor;
	setBackgroundColor( kapp->windowColor );
	setFont(QFont("helvetica", 12, QFont::Bold));
	text_enabled = TRUE;
	adjustStyle();
}


void KProgress::setBarPixmap(const QPixmap &pixmap)
{
	if (pixmap.isNull())
		return;
	if (bar_pixmap)
		delete bar_pixmap;
		
	bar_pixmap = new QPixmap(pixmap);
}

void KProgress::setBarColor(const QColor &color)
{
	bar_color = color;
	if (bar_pixmap) {
		delete bar_pixmap;
		bar_pixmap = 0;
	}
}

void KProgress::setBarStyle(BarStyle style)
{
	if (bar_style != style) {
		bar_style = style;
		update();
	}
}

void KProgress::setOrientation(Orientation orientation)
{
	if (orient != orientation) {
		orient = orientation;
		update();
	}
}
 
void KProgress::setValue(int value)
{
	QRangeControl::setValue(value);
}

void KProgress::setTextEnabled(bool enable)
{
	text_enabled = enable;
}

const QColor & KProgress::barColor() const
{
	return bar_color;
}

const QPixmap * KProgress::barPixmap() const
{
	return bar_pixmap;
}

bool KProgress::textEnabled() const
{
	return text_enabled;
}

QSize KProgress::sizeHint() const
{
  QSize s( size() );

  if(orientation() == KProgress::Vertical) {
    s.setWidth(24);
  } else {
    s.setHeight(24);
  }

  return s;
}


KProgress::Orientation KProgress::orientation() const
{
	return orient;
}

KProgress::BarStyle KProgress::barStyle() const
{
	return bar_style;
}

int KProgress::recalcValue(int range)
{
	int abs_value = value() - minValue();
	int abs_range = maxValue() - minValue();
	return range * abs_value / abs_range;
}

void KProgress::valueChange()
{
	repaint(contentsRect(), FALSE);
	emit percentageChanged(recalcValue(100));
}

void KProgress::rangeChange()
{
	repaint(contentsRect(), FALSE);
	emit percentageChanged(recalcValue(100));
}

void KProgress::styleChange(GUIStyle)
{
	adjustStyle();
}

void KProgress::adjustStyle()
{
	switch (style()) {
		case WindowsStyle:
			setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
			break;
		case MotifStyle:
		default:
			setFrameStyle(QFrame::Panel | QFrame::Sunken);
			setLineWidth( 2 );
			break;
	}
	update();
}

void KProgress::paletteChange( const QPalette & )
{
	bar_color = kapp->selectColor;
	bar_text_color = kapp->selectTextColor;
	text_color = kapp->textColor;
	setBackgroundColor( kapp->windowColor );
}
		
void KProgress::drawText(QPainter *p)
{
	QRect r(contentsRect());
	//QColor c(bar_color.rgb() ^ backgroundColor().rgb());
	QString s;
	
	s.sprintf("%i%%", recalcValue(100));
	p->setPen(text_color);
	//p->setRasterOp(XorROP);
	p->drawText(r, AlignCenter, s);
	p->setClipRegion( fr );
	p->setPen(bar_text_color);
	p->drawText(r, AlignCenter, s);
	
}

void KProgress::drawContents(QPainter *p)
{
	QRect cr = contentsRect(), er = cr;
	fr = cr;
	QBrush fb(bar_color), eb(backgroundColor());

	if (bar_pixmap)
		fb.setPixmap(*bar_pixmap);

	if (backgroundPixmap())
		eb.setPixmap(*backgroundPixmap());

	switch (bar_style) {
		case Solid:
			if (orient == Horizontal) {
				fr.setWidth(recalcValue(cr.width()));
				er.setLeft(fr.right() + 1);
			} else {
				fr.setTop(cr.bottom() - recalcValue(cr.height()));
				er.setBottom(fr.top() - 1);
			}
				
			p->setBrushOrigin(cr.topLeft());
			p->fillRect(fr, fb);
			p->fillRect(er, eb);
			
			break;
			
		case Blocked:
			const int margin = 2;
			int max, num, dx, dy;
			if (orient == Horizontal) {
				fr.setHeight(cr.height() - 2 * margin);
				fr.setWidth((int)(0.67 * fr.height()));
				fr.moveTopLeft(QPoint(cr.left() + margin, cr.top() + margin));
				dx = fr.width() + margin;
				dy = 0;
				max = (cr.width() - margin) / (fr.width() + margin) + 1;
				num = recalcValue(max);
			} else {
				fr.setWidth(cr.width() - 2 * margin);
				fr.setHeight((int)(0.67 * fr.width()));
				fr.moveBottomLeft(QPoint(cr.left() + margin, cr.bottom() - margin));
				dx = 0;
				dy = - (fr.height() + margin);
				max = (cr.height() - margin) / (fr.height() + margin) + 1;
				num = recalcValue(max);
			}
			p->setClipRect(cr.x() + margin, cr.y() + margin, 
						   cr.width() - margin, cr.height() - margin);
			for (int i = 0; i < num; i++) {
				p->setBrushOrigin(fr.topLeft());
				p->fillRect(fr, fb);
				fr.moveBy(dx, dy);
			}
			
			if (num != max) {
				if (orient == Horizontal) 
					er.setLeft(fr.right() + 1);
				else
					er.setBottom(fr.bottom() + 1);
				if (!er.isNull()) {
					p->setBrushOrigin(cr.topLeft());
					p->fillRect(er, eb);
				}
			}
			
			break;
	}	
				
	if (text_enabled && bar_style != Blocked)
		drawText(p);
		
}			
#include "kprogress.moc"

--- NEW FILE: kmsgbox.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Alexander Sanda (alex at darkstar.ping.at)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/*                                                    cd source
 * $Id: kmsgbox.cpp,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
 *
 * $Log: kmsgbox.cpp,v $
 * Revision 1.1  2006-10-03 11:26:31  dslinux_amadeus
 * adding pristine copy of pixil to HEAD so I can branch from it
 *
 * Revision 1.1  2003/09/08 19:42:09  jasonk
 * Addition of packages directory and associated files.
 *
 * Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
 * Initial import of PIXIL into new cvs repository.
 *
 * Revision 1.1.1.1  2003/06/23 22:04:23  jasonk
 *
 *
 * Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
 * Initial import of ViewML
 *
 * Revision 1.14  1999/01/18 10:56:50  kulow
 * .moc files are back in kdelibs. Built fine here using automake 1.3
 *
 * Revision 1.13  1999/01/15 09:31:09  kulow
 * it's official - kdelibs builds with srcdir != builddir. For this I
 * automocifized it, the generated rules are easier to maintain than
 * selfwritten rules. I have to fight with some bugs of this tool, but
 * generally it's better than keeping them updated by hand.
 *
 * Revision 1.12  1998/08/03 15:24:22  ssk
 * Wrote documentation.
 * Eliminated dead and commented-out code.
 *
 * Revision 1.11  1998/03/15 13:05:14  mario
 * Mario: fixed kb60
 *
 * Revision 1.10  1998/02/24 15:54:35  kulow
 * replaced some hard coded paths with the kapp->kde_ methodes.
 * I'm not sure, if kde_datadir() is optimal for /share/apps ;)
 *
 * Revision 1.9  1998/01/03 19:47:28  kulow
 * changed the defaults for yesNo and co. It's no longer "Yes" and co, but
 * 0 to enable translation in case.
 * This is source and binary compatible. It's just, that it will behave
 * differently after recompiling (as far I understood the C++ language ;)
 *
 * Revision 1.8  1997/11/16 20:46:51  mark
 * MD: Reworked look of KMessageBox dialogs.
 *   Originally I was going to make KMessageBox a wrapper for
 *   QMessageBox. However, the classes are too different. I
 *   settled for a reworking the look of KMessageBox to make it
 *   conpatible with QMessageBox.
 *   Also fixed a possible bug in KButtonBox to do with the
 *   calculation of the size of Motif default buttons. This
 *   calculation depends on the undocumented behaviour of
 *   QButton::sizeHint so I suppose it could change from version to
 *   version of Qt. The fix is clearly marked should it need to
 *   be revoked.
 *
 * Revision 1.7  1997/10/21 20:45:02  kulow
 * removed all NULLs and replaced it with 0L or "".
 * There are some left in mediatool, but this is not C++
 *
 * Revision 1.6  1997/10/16 11:15:26  torben
 * Kalle: Copyright headers
 * kdoctoolbar removed
 *
 * Revision 1.5  1997/09/10 12:07:48  kdecvs
 * Kalle: fixed large meomry leak (bug reported by Joerg Habenicht)
 *
 * Revision 1.4  1997/09/10 09:04:17  kdecvs
 * Coolo: Torben's wish is my command ;)
 *
 * Revision 1.3  1997/09/04 22:36:26  kdecvs
 * Coolo: put the icons in share/icons, I hope, this is right ;)
 *
 * Revision 1.2  1997/05/08 22:53:20  kalle
 * Kalle:
 * KPixmap gone for good
 * Eliminated static objects from KApplication and HTML-Widget
 *
 * Revision 1.1.1.1  1997/04/13 14:42:42  cvsuser
 * Source imported
 *
 * Revision 1.1.1.1  1997/04/09 00:28:09  cvsuser
 * Sources imported
 *
 * Revision 1.1  1997/03/15 22:41:21  kalle
 * Initial revision
 *
 * Revision 1.3.2.1  1997/01/10 19:48:32  alex
 * public release 0.1
 *
 * Revision 1.3  1997/01/10 19:44:33  alex
 * *** empty log message ***
 *
 * Revision 1.2.4.1  1997/01/10 16:46:33  alex
 * rel 0.1a, not public
 *
 * Revision 1.2  1997/01/10 13:05:52  alex
 * *** empty log message ***
 *
 * Revision 1.1.1.1  1997/01/10 13:05:21  alex
 * imported
 *
 */

#include <stdlib.h>

#include <qpixmap.h>
#include <qlayout.h>

#include <kapp.h>
#include <kbuttonbox.h>

#include "kmsgbox.h"
#include "kmsgbox.h"

KMsgBox::KMsgBox( QWidget *parent, const char *caption,
	const char *message, int type,
	const char *b1text, const char *b2text,
	const char *b3text, const char *b4text )
	: QDialog ( parent, caption, TRUE, 0 ),
	msg( 0L ), picture( 0L ),
	b1( 0L ), b2( 0L ), b3( 0L ), b4( 0L ),
	f1( 0L )
{
    int icon;
    static int icons_initialized = 0;
    static QPixmap icons[4];

    if( !icons_initialized ) {
    	QString ipath = kapp->kde_datadir() + "/kde/pics/";
        QString ifile = ipath + "info.xpm";
        icons[0].load( ifile );
        icons[1].load( ipath + "exclamation.xpm" );
        icons[2].load( ipath + "stopsign.xpm" );
        icons[3].load( ipath + "question.xpm" );
        icons_initialized = 1;
    }

    int icon_index = type & 0x0000000f;   // mask the lower 4 bits (icon style)
    
	if( icon_index <= 4 )
        icon = icon_index >> 1;
    else
        icon = 3;
	
	setCaption( caption );
	
	int border = 8;
	int vertSpacing = 0;
	
	QBoxLayout *topLayout = new QVBoxLayout( this, border );
	
	QBoxLayout *labels = new QHBoxLayout( border );
	topLayout->addLayout( labels );
	
	topLayout->addSpacing( vertSpacing );
	
	// CREATE THE ICON AND MESSAGE LABELS
	
	picture = new QLabel( this, "_pict" );
    //picture->setAutoResize( TRUE );
    picture->setPixmap( icons[icon] );
	picture->adjustSize();
	picture->setFixedSize( picture->size() );
	
	msg = new QLabel( message, this, "_msg" );
    //msg->setAlignment( AlignCenter );
    msg->adjustSize();
	msg->setFixedSize( msg->size().width()+10, msg->size().height() );
	
	// Add the labels to their layout manager
	
	labels->addWidget( picture );
	labels->addWidget( msg );

	topLayout->addStretch( 10 );
	
	// CREATE BUTTONS
	
	nr_buttons = 0;
    b1 = b2 = b3 = b4 = 0;
	
	KButtonBox *bbox = new KButtonBox( this );
	bbox->addStretch( 10 );
	
    if( b1text ) {
		b1 = bbox->addButton( b1text );
		connect( b1, SIGNAL( clicked() ), this, SLOT( b1Pressed() ) );
        nr_buttons++;
    }

    if( b2text ) {
	
        b2 = bbox->addButton( b2text );
		connect( b2, SIGNAL( clicked() ), this, SLOT( b2Pressed() ) );
        nr_buttons++;
    }

    if( b3text ) {
		b3 = bbox->addButton( b3text );
		connect( b3, SIGNAL( clicked() ), this, SLOT( b3Pressed() ) );
        nr_buttons++;
    }

    if( b4text ) {
		b4 = bbox->addButton( b4text );
		connect( b4, SIGNAL( clicked() ), this, SLOT( b4Pressed() ) );
        nr_buttons++;
    }
	
	bbox->addStretch( 10 );
	
	//
	// Check, if we have a default button
	// If not, set the left button to default
	//

	if( !(type & 0x000000f0) )
		type |= DB_FIRST;
	if( b1 )
		b1->setDefault( type & DB_FIRST );
	if( b2 )
		b2->setDefault( type & DB_SECOND );
	if( b3 )
		b3->setDefault( type & DB_THIRD );
	if( b4 )
		b4->setDefault( type & DB_FOURTH );

	bbox->layout();
	topLayout->addWidget( bbox );
	
    topLayout->freeze();
}

KMsgBox::~KMsgBox() 
{
	delete f1;
	delete picture;
	delete msg;
	
	if( b1 )
		delete b1;
	if( b2 )
		delete b2;
	if( b3 )
		delete b3;
	if( b4 )
		delete b4;
}

void KMsgBox::calcOptimalSize()
{
    int text_width = picture->width() + 10 + msg->width() + 30;  // label width + margins

    int button_width = (nr_buttons * 80) + 20 + (nr_buttons - 1) * B_SPACING;

    w = button_width > text_width ? button_width : text_width;
    
    h1 = msg->height() > picture->height() ? msg->height() : picture->height();

    h = h1 + 25 + 40;

    text_offset = 15 + picture->width() + 10;
}

void KMsgBox::b1Pressed() { done(1); }
void KMsgBox::b2Pressed() { done(2); }
void KMsgBox::b3Pressed() { done(3); }
void KMsgBox::b4Pressed() { done(4); }

/*
 * now, the common functions. They may be used for easy creation and usage of
 * some general message boxes
 */

int KMsgBox::message(QWidget *parent, const char *caption, 
	const char *message, int type, const char *btext)

{
    if (!btext)
	btext = klocale->translate("OK");

    KMsgBox *mb = new KMsgBox(parent, caption, message, type, btext);

    int retcode = mb->exec();
    delete mb;
    return retcode;
}


int KMsgBox::yesNo(QWidget *parent, const char *caption, 
	const char *message, int type, 
	const char *yes, const char *no )
{
    if (!no)
	no = klocale->translate("No");
    if (!yes)
	yes = klocale->translate("Yes");

    KMsgBox *mb = new KMsgBox(parent, caption, message, type, yes, no);

    int retcode = mb->exec();
    delete mb;
    return retcode;
}

int KMsgBox::yesNoCancel(QWidget *parent, const char *caption, 
	const char *message, int type, const char *yes, 
	const char *no, const char *cancel)
{
    if (!no)
	no = klocale->translate("No");
    if (!yes)
	yes = klocale->translate("Yes");
    if (!cancel)
	cancel = klocale->translate("Cancel");
    
    KMsgBox *mb = new KMsgBox(parent, caption, message, type, 
    	yes, no, cancel);

    int retcode = mb->exec();
    delete mb;
    return retcode;
}
#include "kmsgbox.moc"

--- NEW FILE: kpanner.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Alexander Sanda (alex at darkstar.ping.at)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/*****************************************************************************
*                                                                            *
*  KPanner -- panner widget for KDE by Alexander Sanda                       *
*             modifications by Paul Kendall for absolute pixel positions     *
*                                                                            *
*                                                                            *
*****************************************************************************/

#ifndef _KPANNER_H
#define _KPANNER_H

#include <qwidget.h>
#include <qframe.h>

/// KPanner - resizeable screen regions
/** Kpanner is a simple widget, very similar to Motifs XmPanedWindow.
  Basically, KPanner creates two child widgets, separated by a dragable
  bar. The user can now resize the window areas by repositioning this bar.

How to use:
-----------

The class name is KPanner.

KPanner *p = new KPanner(parent, name, flags, i_size);

flags can be a combination of the following (or zero):

KPanner::O_VERTICAL (default)
KPanner::O_HORIZONTAL
KPanner::U_PERCENT (default)
KPanner::U_ABSOLUTE


i_size is the location of the separator.

The flag O_VERTICAL specifies that the separator is vertical and you
therefore have a left and right pane.  The O_HORIZONTAL flag means that
you have an upper and a lower pane.

U_ABSOLUTE specifies that the location is in pixels and U_PERCENT means
the location is measured in percent of full widget size, e.g. if you
specify a value of 50, the client widgets will have exactly the same size.  

To obtain the panners child widgets (which is necessary, because they
will act as parents for the widgets to manage), KPanner provides two
class methods:

QWidget *child0()  returns the leftmost (or topmost for horizontal
                   panners) child.

QWidget *child1()  returns the rightmost (or bottom for horizontal
                   panners) child */   
class KPanner : public QWidget  {
  Q_OBJECT
public:
  /// some flags
  /** some flags */
  enum {O_VERTICAL = 0, O_HORIZONTAL = 1, U_PERCENT = 0, U_ABSOLUTE = 2};
    
  KPanner(QWidget *parent = 0, const char *name = 0, unsigned flags = 0, int i_size = 0);

  ~KPanner();
  QWidget      *child0(), *child1();

  /// Set window division.
  /**
	(0 <= int <= 100)
	
	set the separator, so that it will divide the clients at i_size percent
	of full widget size. For vertical panners, this is measured from the
	left edge, and for horizontal panners it is measured from the top edge.
	
	If the value for i_size is invalid (less than 0 or greater than 100), it
	will be set to 50.
	
	This also applies to the value of i_size used with the constructor.
	*/
  void         setSeparator(int);

  /// Set panner to an absoulte pixel value.
  /**
	Same as setSeparator(), but i_size is interpreted as an absolute (pixel)
	value. The i_size parameter must be greater than current l_limit and less
	than current u_limit.
	*/
  void         setAbsSeparator(int);

  /// Set the range in which the panner may be moved.
  /**
	Set lower and upper limits as a range for the divider widget. The
	divider cannot be moved outside of these limits. The values are pixel
	values. The lower limit (l_limit) must be a positive integer between 0
	and the maximum width (height) of the panner. The upper limit (u_limit)
	may be either positive (if you want to measure it from the left (upper)
	edge), or negative (if you want to measure it from the right (lower)
	edge).  If the panner was created in U_PERCENT mode, use values 0 to 100
    also negatives for u_limit from right edge.
    To clear the limits, set both l_limit and u_limit to zero.
	*/
  void         setLimits(int, int);

  /// Get the maximum pixel value that the panner can be moved to.
  /**
    Get the maximum pixel value that the separator bar can be moved to.
	*/
  int          getMaxValue();
    
  /// Returns the current position of the separator as a percentage.
  /**
    Get the current position of the separator bar as a percentage.
    This can be used to save the position to the config file so the panner
    can be reset back to a save state.  Or if the panner is turned off &
    on again, the previous setting can be restored.
	*/
  int          getSeparator();
    
  /// Returns the current pixel position of the separator.
  /**
    Get the current pixel position of the separator bar.
    This can be used to save the position to the config file so the panner
    can be reset back to a save state.  Or if the panner is turned off &
    on again, the previous setting can be restored.
	*/
  int          getAbsSeparator();
    
private:
  enum {P_ORIENTATION = 1, P_UNITS = 2};
  virtual void resizeEvent(QResizeEvent *);
  bool         eventFilter(QObject *, QEvent *);
  void         setDividerGeometry(int);
  bool         checkRange(int &);
  int          u_coord, delta, old_coord;
  unsigned     u_flags;
  QWidget      *cw0, *cw1;
  QFrame       *divider;
  int          l_limit, u_limit, pos;
    
  signals:
  void positionChanged();
};

/*
 * $Id: kpanner.h,v 1.1 2006-10-03 11:26:32 dslinux_amadeus Exp $
 *
 * $Log: kpanner.h,v $
 * Revision 1.1  2006-10-03 11:26:32  dslinux_amadeus
 * adding pristine copy of pixil to HEAD so I can branch from it
 *
 * Revision 1.1  2003/09/08 19:42:10  jasonk
 * Addition of packages directory and associated files.
 *
 * Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
 * Initial import of PIXIL into new cvs repository.
 *
 * Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
 *
 *
 * Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
 * Initial import of ViewML
 *
 * Revision 1.3  1997/10/16 11:15:28  torben
 * Kalle: Copyright headers
 * kdoctoolbar removed
 *
 * Revision 1.2  1997/05/02 16:46:41  kalle
 * Kalle: You may now override how KApplication reacts to external changes
 * KButton uses the widget default palette
 * new kfontdialog version 0,5
 * new kpanner by Paul Kendall
 * new: KIconLoader
 *
 * Revision 1.1.1.1  1997/04/13 14:42:43  cvsuser
 * Source imported
 *
 * Revision 1.1.1.1  1997/04/09 00:28:09  cvsuser
 * Sources imported
 *
 * Revision 1.3  1997/03/09 17:17:25  kalle
 * Umformatiert
 *
 * Revision 1.2  1997/03/09 16:47:45  kalle
 * Documentation added
 *
 * Revision 1.1  1997/03/09 16:41:58  kalle
 * Initial revision
 *
 */

#endif


--- NEW FILE: ktreelist.h ---
/* qktstreelist.h
-------------------------------------------------------------------
$Revision: 1.1 $
$Date: 2006-10-03 11:26:33 $
  
KTreeList class declaration

Copyright (C) 1996 Keith Brown and KtSoft

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. You should have received a
copy of the GNU Library General Public License along with this program; if
not, write to the Free Software Foundation, Inc, 675 Mass Ave, 
Cambridge, MA 02139, USA.

-------------------------------------------------------------------
*/

#ifndef KTREE_LIST_H
#define KTREE_LIST_H

#include <qapplication.h>       // used for QApplication::closingDown()
#include <qkeycode.h>           // used for keyboard interface
#include <qpainter.h>		// used to paint items
#include <qpixmap.h>		// used in items
#include <qstack.h>		// used to specify tree paths
#include <qstring.h>		// used in items
#include <qtableview.h>		// base class for widget

// use stack of strings to represent path information
typedef QStack<QString> KPath;

class KTreeList;		// forward declaration

/** Items for the KTreeList widget */
class KTreeListItem
{
public:
  /**
    Item constructor. While text defaults to a null pointer, and the item
    can be constructed this way, the text has to be non-null when the
    item is added to the tree, or it will not be inserted.
    */
  KTreeListItem(const char *theText = 0, 
				const QPixmap *thePixmap = 0); // text can not be null when added to the list!

  virtual ~KTreeListItem();

  void appendChild(KTreeListItem *newChild);

  virtual QRect boundingRect(const QFontMetrics& fm) const;

  /**
	Returns a pointer to the child item at the given index in this item's
	sub tree, or 0 if not found.
	*/	
  KTreeListItem *childAt(int index);

  /**
	Returns the number of child items in this item's sub tree.
	*/
  uint childCount() const;

  /**
	Returns the index in this items sub tree of the given item or -1 if
	not found.
	*/
  int childIndex(KTreeListItem *child);

  bool drawExpandButton() const;

  bool drawText() const;

  bool drawTree() const;

  bool expandButtonClicked(const QPoint& coord) const;

  int getBranch() const;

  /**
	Returns a pointer to the first child item in this item's sub tree, or
	0 if none.
	*/
  KTreeListItem *getChild();

  int getIndent() const;

  /**
	Returns a pointer to the parent of this item, or 0 if none.
	*/
  KTreeListItem *getParent();

  /**
	Returns a pointer to this item's pixmap. If there is no pixmap
	associated with this item, it will return a pointer to a valid, null
	QPixmap.
	*/
  const QPixmap *getPixmap() const;

  /**
	Returns a pointer to the next item in the same branch below this one,
	or 0 if none.
	*/
  KTreeListItem *getSibling();

  /**
	Returns a pointer to this item's text.
	*/
  const char *getText() const;

  /**
	Indicates whether this item has any children.
	*/
  bool hasChild() const;

  /**
	Indicates whether this item has a parent.
	*/
  bool hasParent() const;

  /**
	Indicates whether this item has an item in the same branch below it.
	*/
  bool hasSibling() const;

  virtual int height(const KTreeList *theOwner) const;

  void insertChild(int index,
				   KTreeListItem *newItem);

  bool isExpanded() const;

  virtual void paint(QPainter *p, 
					 const QColorGroup& cg, 
					 bool highlighted);

  void removeChild(KTreeListItem *child);

  void setBranch(int level);

  void setChild(KTreeListItem *newChild);

  void setDrawExpandButton(bool doit);

  void setDrawText(bool doit);

  void setDrawTree(bool doit);

  void setExpanded(bool is);

  void setIndent(int value);

  void setParent(KTreeListItem *newParent);

  /**
	Sets the item pixmap to the given pixmap.
	*/
  void setPixmap(const QPixmap *pm);

  void setSibling(KTreeListItem *newSibling);

  /**
	Sets the item text to the given item.
	*/
  void setText(const char *t);

  virtual QRect textBoundingRect(const QFontMetrics& fm) const;

  virtual QRect itemBoundingRect(const QFontMetrics& fm) const;

  virtual int width(const KTreeList *theOwner) const;

protected:
  virtual int itemHeight(const QFontMetrics& fm) const;
  virtual int itemWidth(const QFontMetrics& fm) const;
private:
  int branch;
  int indent;
  int numChildren;
  bool doExpandButton;
  bool expanded;
  bool doTree;
  bool doText;
  QRect expandButton;
  KTreeListItem *child;
  KTreeListItem *parent;
  KTreeListItem *sibling;
  QPixmap pixmap;
  QString text;
};

// easier declarations of function prototypes for forEvery type functions
typedef bool (KTreeList::*KForEveryM)
  (KTreeListItem *, void *);
typedef bool (*KForEvery)
  (KTreeListItem *, void *);

struct KItemSearchInfo {
  int count;
  int index;
  KTreeListItem *foundItem;
  KItemSearchInfo() : count(0), index(0), foundItem(0) {}
};

/** 
  A collapsible treelist widget.

  1. Introduction
  2. Features
  3. Installation
  4. Public interface

  1. Introduction
  ================================================================================

  KTreeList is a class inherited from QTableView in the Qt user interface
  library. It provides a way to display hierarchical data in a single-inheritance
  tree, similar to tree controls in Microsoft Windows and other GUI's. It is most
  suitable for directory trees or outlines, but I'm sure other uses will come to
  mind. Frankly, it was designed mostly with the above two functions in mind, but
  I have tried to make it as flexible as I know how to make it easy to adapt to
  other uses. 

  In case of problems, I encourage you to read all of the other documentation
  files in this package before contacting me  as you may find the answer to your
  question in one of them. Also read the source code if you have time. I have
  tried to comment it adequately and make the source understandable.

  2. Features
  ================================================================================

  * Displays both text and optional pixmap supplied by the programmer. A support
  class, KTreeListItem, can be inherited and modified to draw items as needed
  by the programmer.

  * The list items can be returned by index or logical path and the tree
  navigated by parent, child or sibling references contained in them. Also,
  item information such as text, pixmap, branch level can be obtained.
  
  * Items can be inserted, changed and removed either by index in the visible
  structure, or by logical paths through the tree hierarchy. 

  * The logical path through the tree for any item can be obtained with the index
  of the item.

  * Tree structure display and expanding/collapsing of sub-trees is handled with
  no intervention from the programmer.
  
  * entire tree can be expanded or collapsed to a specified sub-level (handy for
  outline views)
  
  * Configuration as follows:

  enable/disable item text display (if you only want to display pixmaps)
  
  enable/disable drawing of expand/collapse button
  
  enable/disable drawing of tree structure
  
  * Keyboard support as follows:

  up/down arrows move the highlight appropriately and scroll the list an item at
  a time, if necessary
  
  pgup/pgdn move the highlight a 'page' up or down as applicable and scroll the
  view
  
  +/- keys expand/collapse the highlighted item if it appropriate
  
  enter key selects the highlighted item
  
  * Mouse support as follows:

  left click on item highlights it
  
  left click on an item "hot button" expands or collapses its sub-tree, as
  applicable
  
  double click on item selects it
  
  normal scrolling functions in conjunction with scrollbars if present

  2nd scrolling with the middle mouse button: pressing MMB inserts a
  rubberband, showing which part of the whole tree is currently visible.
  moving the mouse will scroll the visible part
  
  * Signals/Slots

  signal void highlighted(int) - emitted when an item in the tree is
  highlighted; sends the index of the item
  
  signal void selected(int) - emitted when an item in the tree is
  selected; sends the index of the item
  
  signal void expanded(int) - emitted when an item in the tree is expanded;
  sends the index of the item
  
  signal void collpased(int) - emitted when an item in the tree is collapsed;
  sends the index of the item
  */
class KTreeList : public QTableView
{
  Q_OBJECT
public:
  /**
	Widget contructor. Passes all parameters on to base QTableView, and
	does not use them directly. Does internal initialization, sets the
	current item to -1, and sets default values for scroll bars (both
	auto) and grid snap (snap to grid vertically).
	*/
  KTreeList(QWidget *parent = 0, 
			const char *name = 0,
			WFlags f = 0);

  virtual ~KTreeList();

  /**
	Adds a new item to the tree with the given text and pixmap as a child
	of the item currently at the given index. If the current item already
	has children, the new item is appended below them.
	*/
  void addChildItem(const char *theText,
					const QPixmap *thePixmap,
					int index);

  /**
	Same as above except parent item is specified by path.
	*/
  void addChildItem(const char *theText,
					const QPixmap *thePixmap,
					const KPath *thePath); 

  /**
	Adds the given item as a child of the item currently at the given
	index. If the current item already has children, the new item is
	appended below them.
	*/
  void addChildItem(KTreeListItem *newItem,
					int index);

  /**
	Same as above except parent item is specified by path.
	*/
  void addChildItem(KTreeListItem *newItem,
					const KPath *thePath);                                                             
  /**
	Returns a bool value indicating whether the list will display a
	horizontal scrollbar if one of the displayed items is wider than can
	be displayed at the current width of the view.
	*/
  bool autoBottomScrollBar() const;

  /**
	Returns a bool value indicating whether the list will display a
	vertical scrollbar if the number of displayed items is more than can
	be displayed at the current height of the view.
	*/
  bool autoScrollBar() const;

  /**
	Returns a bool value indicating whether the list will update
	immediately on changing the state of the widget in some way.
	*/
  bool autoUpdate() const;

  /**
	Returns a bool value indicating whether the list has currently has a
	horizontal scroll bar.
	*/
  bool bottomScrollBar() const;

  /**
	Changes the text and/or pixmap of the given item at the specified
	index to the given values and updates the display if auto update
	enabled. If changing only the text or pixmap, set the other parameter
	to 0.
	*/
  void changeItem(const char *newText, 
				  const QPixmap *newPixmap, 
				  int index);

  /**
	Same as above function, except item to change is specified by a path
	through the tree.
	*/
  void changeItem(const char *newText,
				  const QPixmap *newPixmap,
				  const KPath *thePath);

  /**
	Removes all items from the tree.

	*/
  void clear();

  /**
	Returns the total number of items in the tree, whether visible
	(expanded sub-trees) or not (collapsed).
	*/
  uint count();

  /**
	Returns the index of the current (highlighted) item. If no current
	item, returns -1.
	*/
  int currentItem() const;

  /**
	Collapses the sub-tree at the specified index. 
	*/
  void collapseItem(int index);

  /**
	Expands the sub-tree at the specified index. 
	*/
  void expandItem(int index);

  /**
	Returns the depth to which all parent items are automatically
	expanded.
	*/
  int expandLevel() const;

  /**
	Same as above functions combined into one. If sub-tree is expanded,
	collapses it, if it is collapsed, it expands it.
	*/
  void expandOrCollapseItem(int index);

  /**
	Iterates every item in the tree, visible or not, and applies the
	function func with a pointer to each item and user data
	supplied as parameters. KForEveryFunc is defined as:
          
	typedef void (*KForEveryFunc)(KTreeListItem *, void *); 
          
	That is, a function that returns void and takes a pointer to a
	KTreeListItem and pointer to void as parameters. 
	*/
  void forEveryItem(KForEvery func, 
					void *user);

  /**
	Same as above, but only iterates visible items, in order.			    
	*/
  void forEveryVisibleItem(KForEvery func, 
						   void *user);

  /**
	Returns a pointer to the current item if there is one, or 0.
	*/
  KTreeListItem *getCurrentItem();

  /**
	Returns the number of pixels an item is indented for each level.
	*/
  int indentSpacing();

  /**
	Inserts an item into the tree with the given text and pixmap either
	before or after the item currently at the given index, depending on
	the value of prefix. The new item is added to the same branch as the
	reference item. If index is -1, the item is simply appended to the
	tree at the root level. The item text must not be null.
	*/
  void insertItem(const char *theText,
				  const QPixmap *thePixmap,
				  int index = -1,
				  bool prefix = TRUE);

  /**
	Same as above, but uses a path through the tree to reference the
	insert position.
	*/
  void insertItem(const char *theText,
				  const QPixmap *thePixmap,
				  const KPath *thePath,
				  bool prefix = TRUE);

  /**
	Inserts the given item into the tree either before or after the item
	currently at the given index, depending on the value of prefix. The
	new item is add to the same branch as the reference item. If index is
	-1, the item is simply appended to the tree at the root level. The
	item text must not be null.
	*/
  void insertItem(KTreeListItem *newItem, 
				  int index = -1,
				  bool prefix = TRUE); 

  /**
	Same as above, but uses a path through the tree to reference the
	insert position.
	*/
  void insertItem(KTreeListItem *newItem,
				  const KPath *thePath,
				  bool prefix = TRUE);

  /**
	Returns a pointer to the item at index.
	*/
  KTreeListItem *itemAt(int index);

  /**
	Returns a pointer ot the item at the end of thePath.
	*/
  KTreeListItem *itemAt(const KPath *path);

  /**
	Returns the index of the given item in the visible tree or -1 if not
	found.			 
	*/
  int itemIndex(KTreeListItem *item);

  /**
	Returns a pointer to the logical path to the item at the specified
	index. The return KPath object must be deleted by the caller.
	Any strings still contained in the stack will be automatically
	deleted, but any popped from the path must also be deleted by the
	caller.
	*/
  KPath *itemPath(int index);

  /**
	Outdents the item at the given index one level so that it becomes a
	sibling of its parent.
	*/
  void join(int index);

  /**
   */
  void join(const KPath *path);

  /**
	Moves the item at the specified index down one slot in its current
	branch.
	*/
  void lowerItem(int index);

  /**
	Same as above but uses a path to specify the item.                              
	*/
  void lowerItem(const KPath *path);

  /**
	Moves the item at the specified index up one slot in its current
	branch. 
	*/
  void raiseItem(int index);

  /**
	Same as above but uses a path to specify the item.                  

	*/
  void raiseItem(const KPath *path);

  /**
	Removes the item at the specified index. 
	*/
  void removeItem(int index);

  /**
	Same as above except uses path through the tree to find the item.
	*/
  void removeItem(const KPath *thePath);

  /**
	Returns bool value indicating whether the list currently displays a
	vertical scroll bar.
	*/
  bool scrollBar() const;

  /**
	If enable is TRUE (default), enables auto update, else disables it.
	*/
  void setAutoUpdate(bool enable);

  /**
	If enable is TRUE, displays a horizontal scroll bar, else hides it.
	*/
  void setBottomScrollBar(bool enable);

  /**
	Makes the item at index current and highlights it.
	*/
  void setCurrentItem(int index);

  void setExpandButtonDrawing(bool enable);

  void setExpandLevel(int level);

  void setIndentSpacing(int spacing);

  /**
	If enable is TRUE, displays a vertical scroll bar, else hides it.                                        
	*/
  void setScrollBar(bool enable);

  /**
	If enable is TRUE (default), item text will be displayed, otherwise 
	it will not, and no highlight will be shown in the default widget.
	*/
  void setShowItemText(bool enable);

  /**
	If enable is TRUE, enables smooth scrolling, else disables 
	it (default).
	*/
  void setSmoothScrolling(bool enable);

  /**
	If enable is TRUE (default), lines depicting the structure of the
	tree will be drawn, otherwise they will not.
	*/
  void setTreeDrawing(bool enable);

  /**
	Indicates whether item text is displayed.
	*/
  bool showItemText() const;

  /**
	Returns a bool value indicating whether smooth scrolling is enabled.
	*/
  bool smoothScrolling() const;

  /**
	Indents the item at the specified index, creating a new branch.
	*/
  void split(int index);

  /**
	Same as above but uses a path to specify the item.                    
	*/
  void split(const KPath *path);

  /**
	Removes the item at the given index from the tree, but does not
	delete it, returning a pointer to the removed item.
	*/
  KTreeListItem *takeItem(int index);

  /**
	Same as above but uses a path to specify the item to take.
	*/
  KTreeListItem *takeItem(const KPath *path);

  /**
	Indicates whether the tree structure is drawn.
	*/
  bool treeDrawing() const;

  /**
	Returns the number of items that are visible (their parents are
	expanded).                   
	*/
  int visibleCount();

  signals:
  void collapsed(int index);
  void expanded(int index);
  void highlighted(int index);
  void selected(int index);
  void singleSelected(int index); //ettrich
protected:
  void paletteChange(const QPalette &);
  void addChildItem(KTreeListItem *theParent,
					KTreeListItem *theChild);
  virtual int cellHeight(int row);
  void changeItem(KTreeListItem *toChange,
				  int itemIndex,
				  const char *newText,
				  const QPixmap *newPixmap);
  bool checkItemPath(const KPath *path) const;
  bool checkItemText(const char *text) const;
  void collapseSubTree(KTreeListItem *subRoot);
  bool countItem(KTreeListItem *item,
				 void *total);
  void expandOrCollapse(KTreeListItem *parentItem);
  void expandSubTree(KTreeListItem *subRoot);
  bool findItemAt(KTreeListItem *item,
				  void *user);
  void fixChildBranches(KTreeListItem *parentItem);
  virtual void focusInEvent(QFocusEvent *e);
  void forEveryItem(KForEveryM func, 
					void *user);
  void forEveryVisibleItem(KForEveryM func,
						   void *user);
  bool getItemIndex(KTreeListItem *item,
					void *user);
  bool getMaxItemWidth(KTreeListItem *item,
					   void *user);
  void insertItem(KTreeListItem *referenceItem,
				  KTreeListItem *newItem,
				  bool prefix);
  void join(KTreeListItem *item);
  virtual void keyPressEvent(QKeyEvent *e);
  void lowerItem(KTreeListItem *item);
  virtual void mouseDoubleClickEvent(QMouseEvent *e);
  virtual void mouseMoveEvent(QMouseEvent *e);
  virtual void mousePressEvent(QMouseEvent *e);
  virtual void mouseReleaseEvent(QMouseEvent *e);
  virtual void paintCell(QPainter *p, int row, int col);
  virtual void paintHighlight(QPainter *p, 
							  KTreeListItem *item);
  virtual void paintItem(QPainter *p, KTreeListItem *item, 
						 bool highlighted);
  void raiseItem(KTreeListItem *item);
  KTreeListItem *recursiveFind(KTreeListItem *subRoot,
							   KPath *path);
  bool setItemExpanded(KTreeListItem *item, void *);
  bool setItemExpandButtonDrawing(KTreeListItem *item, void *);
  bool setItemIndent(KTreeListItem *item, void *);
  bool setItemShowText(KTreeListItem *item, void *);
  bool setItemTreeDrawing(KTreeListItem *item, void *);
  void split(KTreeListItem *item);
  void takeItem(KTreeListItem *item);
  virtual void updateCellWidth();
  KTreeListItem *treeRoot;
  bool clearing;
  int current;
  bool drawExpandButton;
  bool drawTree;
  int expansion;
  bool goingDown;
  int indent;
  int maxItemWidth;
  bool showText;

  // Rainer Bawidamann: move window in "rubberband" mode
  bool rubberband_mode;             // true if in "rubberband_mode"
  QPoint rubber_startMouse;         // where the user pressed the MMB
  int rubber_height, rubber_width,  // the size if the rubberband rect
	rubber_startX, rubber_startY; // the x/yOffset() when the MMB was pressed
  void draw_rubberband();
  void start_rubberband(const QPoint& where);
  void end_rubberband();
  void move_rubberband(const QPoint& where);
};

#endif // KTREE_LIST_H

--- NEW FILE: error.xpm ---
/* XPM */
static char *magick[] = {
/* columns rows colors chars-per-pixel */
"48 48 5 1",
"  c #000000",
". c #a0a0a4",
"X c #c0c0c0",
"o c #ffffff",
"O c None",
/* pixels */
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOO        OOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOO            OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOO                OOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO                  OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOO                    .OOOOOOOOOOOOOO",
"OOOOOOOOOOOO                      .OOOOOOOOOOOOO",
"OOOOOOOOOOO                        .OOOOOOOOOOOO",
"OOOOOOOOOO       o          o       .OOOOOOOOOOO",
"OOOOOOOOOO      ooo        ooo      .OOOOOOOOOOO",
"OOOOOOOOO      ooooo      ooooo      .OOOOOOOOOO",
"OOOOOOOOO       ooooo    ooooo       .OOOOOOOOOO",
"OOOOOOOO         ooooo  ooooo         .OOOOOOOOO",
"OOOOOOOO          oooooooooo          .OOOOOOOOO",
"OOOOOOOO           oooooooo           ..OOOOOOOO",
"OOOOOOOO            oooooo            ..OOOOOOOO",
"OOOOOOOO            oooooo            ..OOOOOOOO",
"OOOOOOOO           oooooooo           ..OOOOOOOO",
"OOOOOOOO          oooooooooo          ..OOOOOOOO",
"OOOOOOOO         ooooo  ooooo         ..OOOOOOOO",
"OOOOOOOOO       ooooo    ooooo       ..OOOOOOOOO",
"OOOOOOOOO      ooooo      ooooo      ..OOOOOOOOO",
"OOOOOOOOOO      ooo        ooo      ...OOOOOOOOO",
"OOOOOOOOOO       o          o       ..OOOOOOOOOO",
"OOOOOOOOOOO                        ...OOOOOOOOOO",
"OOOOOOOOOOOO                      ...OOOOOOOOOOO",
"OOOOOOOOOOOO.                    ...OOOOOOOOOOOO",
"OOOOOOOOOOOOO.                  ...OOOOOOOOOOOOO",
"OOOOOOOOOOOOOO.                ...OOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOO..            ....OOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOO..        .....OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOO...........OOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOO.......OOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
};

--- NEW FILE: kspinbox.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Andre Fornacon (afc at fh-zwickau.de)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
// KSpinBox.cpp - cycle through a list of values
// started: 970506 afo

// @TODO:
// - disable boxs at (min,max) and/or wraparound ?
// - other layouts (vert,horiz)

#include <stdlib.h>
#include <stdio.h>

#include <qapplication.h>	     // for beep()

#include "kspinbox.h"
#include "kspinbox.h"

#if 0
#define DBG(s)		s
#else
#define DBG(s)
#endif


///////////////////////////////////////////////////////////////////////////
///
///                         KSpinBox
///
///////////////////////////////////////////////////////////////////////////

// timeout for autocounting after pressing the mousebox
static const int timerInterval=150;

// make these user settable ?!
static const char *STR_INCR="+";
static const char *STR_DECR="-";


// QLineEdit doesn't support non editable text fields
// and setEnabled(FALSE) doesn't look nice enough
// thats why i switch between an label and an lineedit widget
// the following macros should make it easier to deal with this situation
#define GET_VALUE()		(_editable ? _edit->text() : _label->text())
#define SET_VALUE(s)	(_editable ? _edit->setText(s) : _label->setText(s))


KSpinBox::KSpinBox(QWidget *parent,const char *name,int align)
  : QWidget(parent,name)
{
  // create the widgets
  _label=new QLabel(this,"_label");
//  _label->setBackgroundColor(white);
  _label->setFrameStyle(QFrame::WinPanel|QFrame::Sunken);
	
  _edit=new QLineEdit(this,"_edit");
	
  _decr=new QPushButton(this,"_decr");
  _decr->setText(STR_DECR);

  _incr=new QPushButton(this,"_incr");
  _incr->setText(STR_INCR);

  // create the timer objects and connect the signals
	
  _incrTimer=new QTimer(this,"_incrTimer");
  _decrTimer=new QTimer(this,"_decrTimer");

  connect(_incrTimer,SIGNAL(timeout()), this,SLOT(slotIncrease()) );
  connect(_decrTimer,SIGNAL(timeout()), this,SLOT(slotDecrease()) );

  connect(_incr,SIGNAL(pressed()), this,SLOT(slotStartIncr()) );
  connect(_incr,SIGNAL(released()), this,SLOT(slotStopIncr()) );

  connect(_decr,SIGNAL(pressed()), this,SLOT(slotStartDecr()) );
  connect(_decr,SIGNAL(released()), this,SLOT(slotStopDecr()) );

	// set initial state
  _align=align;
  setEditable(FALSE);
}

KSpinBox::~KSpinBox()
{
  delete _edit;
  delete _label;

  delete _incr;
  delete _decr;

  delete _incrTimer;
  delete _decrTimer;
}

const char *KSpinBox::getValue()
{
  return GET_VALUE();
}


QSize KSpinBox::sizeHint()
{
  QSize hint = _edit->sizeHint();
  hint.setWidth( hint.width() + ( 2 * hint.height() ) );
  return hint;
}


void KSpinBox::setValue(const char *value)
{
  //	SET_VALUE(value);
  _edit->setText(value);
  _label->setText(value);
}

bool KSpinBox::isEditable()
{
  return _editable;
}

void KSpinBox::setEditable(bool flag)
{
  _editable=flag;

  if(_editable)
	{
	  _label->hide();
	  _edit->show();
	}
  else
	{
	  _edit->hide();
	  _label->show();
	}
}

void KSpinBox::setAlign(int align)
{
  if(align == AlignCenter || align == AlignLeft || align == AlignRight)
	{
	  _align=align;
	  resizeEvent(0);
	}
}

int KSpinBox::getAlign()
{
  return _align;
}


void KSpinBox::resizeEvent(QResizeEvent *)
{
  int w=width();
  int h=height();
  int h2=h/2;
	
  switch(_align)
	{
	case AlignCenter:		// horizontal, text centered
	  _edit->setGeometry(h,0,w-2*h,h);
	  _label->setGeometry(h,0,w-2*h,h);
	  _decr->setGeometry(0,0,h,h);
	  _incr->setGeometry(w-h,0,h,h);
	  break;

	case AlignRight:		// horizontal, text right
	  _edit->setGeometry(h2,0,w-h2,h);
	  _label->setGeometry(h2,0,w-h2,h);
	  _incr->setGeometry(0,0,h2,h2);
	  _decr->setGeometry(0,h2,h2,h2);
	  break;
		
	case AlignLeft:		// horizontal, text left
	  _edit->setGeometry(0,0,w-h2,h);
	  _label->setGeometry(0,0,w-h2,h);
	  _incr->setGeometry(w-h2,0,h2,h2);
	  _decr->setGeometry(w-h2,h2,h2,h2);
	  break;
	}
}


/////////////////////////////// slots //////////////////////////////////


void KSpinBox::slotIncrease()
{
  DBG(puts("Incr()"));

  emit valueIncreased();	
}

void KSpinBox::slotDecrease()
{
  DBG(puts("Decr()"));

  emit valueDecreased();
}


void KSpinBox::slotStartIncr()
{
  DBG(puts("startIncr()"));
	
  if(!_incrTimer->isActive())
	{
	  _incrTimer->start(timerInterval);
	  slotIncrease();
	}
}


void KSpinBox::slotStopIncr()
{
  DBG(puts("stopIncr()"));

  //	if(_incrTimer->isActive())
  _incrTimer->stop();
}

void KSpinBox::slotStartDecr()
{
  DBG(puts("startDecr()"));

  if(!_decrTimer->isActive())
	{
	  _decrTimer->start(timerInterval);
	  slotDecrease();
	}
}

void KSpinBox::slotStopDecr()
{
  DBG(puts("stopDecr()"));

  //	if(_decrTimer->isActive())
  _decrTimer->stop();
}


///////////////////////////////////////////////////////////////////////////
///
///                     KNumericSpinBox
///
///////////////////////////////////////////////////////////////////////////


KNumericSpinBox::KNumericSpinBox(QWidget *parent,const char *name,int align)
  : KSpinBox(parent,name,align)
{
  // set default values
  _min=1;
  _max=10;
  _step=1;
  setValue(1);
  //	setEditable(TRUE);

	// overwrite parents slots
  connect(this,SIGNAL(valueIncreased()), SLOT(slotIncrease()) );
  connect(this,SIGNAL(valueDecreased()), SLOT(slotDecrease()) );

}


KNumericSpinBox::~KNumericSpinBox()
{
	
}


int KNumericSpinBox::getValue()
{
  return atoi(KSpinBox::getValue());
}


void KNumericSpinBox::setValue(int value)
{
  //  DBG(printf("numSet(%d): %d .. %d\n",value,_min,_max));
	
  if(_min <= value && value <= _max)
	{
	  char buf[20];
	  sprintf(buf,"%d",value);
	  KSpinBox::setValue(buf);
	}
  else	
	qApp->beep();	// wrap around instead ?
}


int KNumericSpinBox::getStep()
{
  return _step;
}

void KNumericSpinBox::setStep(int step)
{
  _step=step;
}

void KNumericSpinBox::getRange(int &min, int &max)
{
  min = _min;
  max = _max;
}


void KNumericSpinBox::setRange(int min, int max)
{
  if(min < max)
	{
	  _min=min;
	  _max=max;
	}
}

void KNumericSpinBox::slotIncrease()
{
  DBG(puts("numIncr()"));

  setValue(getValue()+_step);	
}

void KNumericSpinBox::slotDecrease()
{
  DBG(puts("numDecr()"));

  setValue(getValue()-_step);	
}


///////////////////////////////////////////////////////////////////////////
///
///                     KListSpinBox
///
///////////////////////////////////////////////////////////////////////////


KListSpinBox::KListSpinBox(QStrList *list,QWidget *parent,const char *name,int align)
  : KSpinBox(parent,name,align)
{
  // set default values

  // overwrite parents slots
  connect(this,SIGNAL(valueIncreased()), SLOT(slotIncrease()) );
  connect(this,SIGNAL(valueDecreased()), SLOT(slotDecrease()) );

  _list=list;
  setIndex(_index=0);
}


KListSpinBox::~KListSpinBox()
{
	
}

void KListSpinBox::slotIncrease()
{
  DBG(puts("listIncr()"));

  _index=(_index < _list->count()-1 ? _index + 1 : 0);
  setValue(_list->at(_index));
}

void KListSpinBox::slotDecrease()
{
  DBG(puts("listDecr()"));

  _index=(_index > 0 ? _index : _list->count()) - 1;
  setValue(_list->at(_index));
}

void KListSpinBox::setIndex(unsigned int index)
{
  if(index < _list->count())
	setValue(_list->at(_index=index));
}

unsigned int KListSpinBox::getIndex()
{
  return _index;
}
#include "kspinbox.moc"

--- NEW FILE: kcolorbtn.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Martin Jones (mjones at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#ifndef __COLBTN_H__
#define __COLBTN_H__

#include <qpushbutton.h>

/**
* This widget can be used to display or allow user selection of a colour.
*
* @see KColorDialog
*
* @short A pushbutton to display or allow user selection of a colour.
* @version $Id: kcolorbtn.h,v 1.1 2006-10-03 11:26:29 dslinux_amadeus Exp $
*/
class KColorButton : public QPushButton
{
	Q_OBJECT
public:
	/**
	* Constructor. Create a KColorButton.
	*/
	KColorButton( QWidget *parent, const char *name = 0L );
	/**
	* Constructor. Create a KColorButton.
	* @param c	The initial colour of the button.
	*/
	KColorButton( const QColor &c, QWidget *parent, const char *name = 0L );
	/**
	* Destructor.
	*/
	virtual ~KColorButton() {}

	/**
	* The current colour.
	* @return The current colour.
	*/
	const QColor color() const
		{	return col; }
	/**
	* Set the current colour.
	*
	* @param c	The colour to set.
	*/
	void setColor( const QColor &c );

signals:
	/**
	* This signal will be emitted when the colour of the widget
	* is changed, either with @ref #setColor or via user selection.
	*/
	void changed( const QColor &newColor );

protected slots:
	/**
	*/
	void slotClicked();

protected:
	/**
	*/
	virtual void drawButtonLabel( QPainter *p );

private:
	QColor col;
};

#endif


--- NEW FILE: kcursor.h ---
/* This file is part of the KDE libraries
   Copyright (C) 1998 Kurt Granroth (granroth at kde.org)

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/
/*
 * $Id: kcursor.h,v 1.1 2006-10-03 11:26:30 dslinux_amadeus Exp $
 *
 * $Log: kcursor.h,v $
 * Revision 1.1  2006-10-03 11:26:30  dslinux_amadeus
 * adding pristine copy of pixil to HEAD so I can branch from it
 *
 * Revision 1.1  2003/09/08 19:42:08  jasonk
 * Addition of packages directory and associated files.
 *
 * Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
 * Initial import of PIXIL into new cvs repository.
 *
 * Revision 1.1.1.1  2003/06/23 22:04:23  jasonk
 *
 *
 * Revision 1.1.1.1  2000/07/07 16:10:59  jasonk
 * Initial import of ViewML
 *
 * Revision 1.2  1998/11/30 00:12:56  granroth
 * Updated KCursor to mimic all of Qt's cursors.  It would be a good idea
 * for all apps to start using, say "KCursor::arrowCursor" instead of just
 * "arrowCursor" so that when we have themes, the code won't have to change.
 *
 * Revision 1.1  1998/11/28 06:30:59  granroth
 * Added KCursor -- a simple wrapper around QCursor allowing for "themable"
 * cursors.  Currently, it only supports a 'handCursor'.
 *
 */
#ifndef _KCURSOR_H
#define _KCURSOR_H

class QCursor;

/**
 * A wrapper around QCursor that allows for "themed" cursors.
 *
 * Currently, the only themed cursor is a 'hand' cursor.
 *
 * A typical usage would be
 * <PRE>
 * 	setCursor(KCursor::handCursor());
 * </PRE>
 *
 * @short A QCursor wrapper allowing "themed" cursors.
 * @author Kurt Granroth <granroth at kde.org>
 */
class KCursor
{
public:
	/**
	 * Constructor.  Does not do anything so far
	 */
	KCursor();

	/**
	 * Static function returning the proper hand cursor according to
	 * the current GUI style.
	 */
	static QCursor handCursor();

	/**
	 * Static function returning the proper arrow cursor according to
	 * the current GUI style.
	 */
	static QCursor arrowCursor();

	/**
	 * Static function returning the proper up arrow cursor according to
	 * the current GUI style.
	 */
	static QCursor upArrowCursor();

	/**
	 * Static function returning the proper cross-hair cursor according to
	 * the current GUI style.
	 */
	static QCursor crossCursor();

	/**
	 * Static function returning the proper hourglass cursor according to
	 * the current GUI style.
	 */
	static QCursor waitCursor();

	/**
	 * Static function returning the proper text cursor according to
	 * the current GUI style.
	 */
	static QCursor ibeamCursor();

	/**
	 * Static function returning the proper vertical resize cursor
	 * according to the current GUI style.
	 */
	static QCursor sizeVerCursor();

	/**
	 * Static function returning the proper horizontal resize cursor
	 * according to the current GUI style.
	 */
	static QCursor sizeHorCursor();

	/**
	 * Static function returning the proper diagonal resize (/) cursor
	 * according to the current GUI style.
	 */
	static QCursor sizeBDiagCursor();

	/**
	 * Static function returning the proper diagonal resize (\) cursor
	 * according to the current GUI style.
	 */
	static QCursor sizeFDiagCursor();

	/**
	 * Static function returning the proper all directions resize cursor
	 * according to the current GUI style.
	 */
	static QCursor sizeAllCursor();

	/**
	 * Static function returning a blank or invisible cursor
	 */
	static QCursor blankCursor();
};
#endif // _KCURSOR_H

--- NEW FILE: kurllabel.h ---
/* This file is part of the KDE libraries
   Copyright (C) 1998 Kurt Granroth (granroth at kde.org)

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/
/*
 * $Id: kurllabel.h,v 1.1 2006-10-03 11:26:33 dslinux_amadeus Exp $
 *
 * $Log: kurllabel.h,v $
 * Revision 1.1  2006-10-03 11:26:33  dslinux_amadeus
 * adding pristine copy of pixil to HEAD so I can branch from it
 *
 * Revision 1.1  2003/09/08 19:42:12  jasonk
 * Addition of packages directory and associated files.
 *
 * Revision 1.1.1.1  2003/08/07 21:18:33  jasonk
 * Initial import of PIXIL into new cvs repository.
 *
 * Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
 *
 *
 * Revision 1.1.1.1  2000/07/07 16:11:01  jasonk
 * Initial import of ViewML
 *
 * Revision 1.4  1998/11/28 06:32:28  granroth
 * Got rid of built-in hand cursor and used KCursor
 *
 * Revision 1.3  1998/11/22 20:23:15  mirko
 * I added the possibility to use KURLLabel on top of a (parent) widget that
 * uses a background pattern, like kab's main view.
 *
 * Revision 1.2  1998/09/15 00:58:24  granroth
 * Changed method so that it compiles under egcs.  'moc' doesn't like default
 * args in declarations and generates invalid code if it encounters more than
 * one in any given function.
 *
 * Revision 1.1  1998/07/28 01:09:28  granroth
 * Added KURLLabel class
 *
 */
#ifndef _KURLLABEL_H
#define _KURLLABEL_H

#include <qpalette.h>
#include <qlabel.h>
#include <qstring.h>
#include <qpixmap.h>
#include <qmovie.h>
#include <qpainter.h>
#include <qbitmap.h>

typedef enum
{
	Bottom,
	Left,
	Top,
	Right
} TextAlignment;

/**
 * A label class that supports displaying hyperlinks
 *
 * KURLLabel is a drop-in replacement for QLabel that handles text
 * in a fashion similar to how an HTML widget handles hyperlinks.  The
 * text can be underlined (or not) and set to different colors.  It
 * can also "glow" (cycle colors) when the mouse passes over it.
 *
 * KURLLabel also provides signals for several events, including
 * the mouse leaving and entering the text area and all forms of
 * mouse clicking.
 *
 * A typical usage would be something like so:
 *
 * <PRE>
 *     KURLLabel *address = new KURLLabel(this);
 *     address->setText("My homepage");
 *     address->setURL("http://www.home.com/~me");
 *     connect(address, SIGNAL(leftClickedURL(const char*)),
 *                      SLOT(processMyURL(const char*)));
 * </PRE>
 *
 * In this example, the text "My homepage" would be displayed
 * as blue, underlined text.  When the mouse passed over it, 
 * it would "glow" red.  When the user clicks on the text, the
 * signal leftClickedURL() would be emitted with "http://www.home.com/~me"
 * as its argument.
 *
 * @short A drop-in replacement for QLabel that displays hyperlinks.
 * @author Kurt Granroth <granroth at kde.org>
 * @version 0.5.3
 */
class KURLLabel : public QLabel
{
	Q_OBJECT
public:
	/**
	 * Constructor.  Use this exactly like you would QLabel.
	 */
	KURLLabel(QWidget *parent=0, const char* name=0, WFlags f=0);

	/**
	 * Destructor.
	 */
	virtual ~KURLLabel();

	/**
	 * Returns the URL.  This will be the same as <CODE>text()</CODE> if 
	 * @ref #setURL is not used.
	 *
	 * @return the URL.
	 */
	const char* url() const;

	/**
	 * Returns the current text.
	 *
	 * @see #setText
	 *
	 * @return the current text.
	 */
	const char* text() const;

	/**
	 * Returns the current pixmap.
	 *
	 * @see #setPixmap
	 *
	 * @return the current pixmap.
	 */
	const QPixmap* pixmap() const;

	/**
	 * Returns the recommended size for this label
	 */
	QSize sizeHint() const;
  
        /**
	 * Enables or disables "transparent mode". If transparent mode 
	 * is enabled, the label copies its own background from its 
	 * parent widget so that it seems to be transparent.
	 * Transparent mode is disabled by default.
	 * Please note that the method does not repaint the widget, 
	 * changes take effect on the next repainting.
	 * Transparent widgets do (currently) not work if there is another 
	 * widget (a frame, for example) layered between this widget and its
	 * parent in Z-order.
	 */
         void setTransparentMode(bool state);
public slots:
	/**
	 * Turn on or off the "glow" feature.  When this is on, the
	 * text will switch to the selected color whenever the mouse
	 * passes over it.  By default, it is <EM>on</EM>.
	 */
	void setGlow(bool glow = true);

	/**
	 * Turn on or off the "float" feature.  This feature is very
	 * similar to the "glow" feature in that the color of the
	 * label switches to the selected color when the cursor passes
	 * over it.  In addition, underlining is turned on for as
	 * long as the mouse is overhead.  Note that if "glow" and
	 * underlining are both already turned on, this feature
	 * will have no visible effect.  By default, it is <EM>off</EM>.
	 */
	void setFloat(bool do_float = true);

	/**
	 * Turn on or off the custom cursor feature.  When this is on, the
	 * cursor will change to a custom cursor (default is a "pointing
	 * hand") whenever the cursor passes over the label.  By default,
	 * it is <EM>on</EM>
	 */
	void setUseCursor(bool use_cursor, const QCursor* cursor = 0);

	/**
	 * Turn on or off the tool tip feature.  When this is on, the
	 * URL will be displayed as a tooltip whenever the mouse passes
	 * passes over it.  By default, it is <EM>off</EM>.
	 */
	void setUseTips(bool tips = true);

	/**
	 * Specifies what text to display when tooltips are turned on.
	 * If this is not used, the tip will default to the URL.
	 *
	 * @see #setUseTips
	 */
	void setTipText(const char* tip);

	/**
	 * Set the text alignment
	 */
	void setTextAlignment(TextAlignment align);

	/**
	 * Turn on or off the underlining.  When this is on, the
	 * text will be underlined.  By default, it is <EM>on</EM>
	 */
	void setUnderline(bool underline = true);

	/**
	 * Set the highlight color.  This is the default foreground
	 * color (non-selected).  By default, it is <EM>blue</EM>.
	 */
	void setHighlightedColor(const QColor& highcolor);

	/**
	 * This is an overloaded version for convenience.
	 *
	 * @see #setHighlightedColor
	 */
	void setHighlightedColor(const char* highcolor);
	
	/**
	 * Set the selected color.  This is the color the text will change
	 * to when either a mouse passes over it and "glow" mode is on or
	 * when it is selected (clicked).  By default, it is <EM>read</EM>
	 */
	void setSelectedColor(const QColor& selcolor);

	/**
	 * This is an overloaded version for convenience.
	 *
	 * @see #setSelectedColor
	 */
	void setSelectedColor(const char* selcolor);
	
	/**
	 * Set the background color.  By default, it is set to the
	 * KDE background color.
	 */
	void setBackgroundColor(const QColor& bgcolor);

	/**
	 * This is an overloaded version for convenience.
	 *
	 * @see #setBackgroundColor
	 */
	void setBackgroundColor(const char* bgcolor);

	/**
	 * Sets the font for the label.
	 */
	void setFont(const QFont& font);

	/**
	 * Sets the label contents to <EM>text</EM>
	 *
	 * @see #text
	 */
	void setText(const char* text);

	/**
	 * Sets the pixmap.  Unlike QLabel, this can co-exist with 
	 * @ref #setText.  It cannot be used along with @ref #setMovie,
	 * however.
	 *
	 * @see #pixmap
	 */
	void setPixmap(const QPixmap& pixmap);

	/**
	 * Sets the "alt" pixmap.  This pixmap will be displayed when the
	 * cursor passes over the label.  The effect is similar to the
	 * trick done with 'onMouseOver' with javascript.
	 *
	 * @see #altPixmap
	 */
	void setAltPixmap(const QPixmap& pixmap);

	/**
	 * Sets the movie.  Cannot be used with @ref #setPixmap 
	 *
	 * @see #movie
	 */
	void setMovie(const QMovie& movie);

	/**
	 * Sets the URL for this label to <EM>url</EM>
	 *
	 * @see #url
	 */
	void setURL(const char* url);

signals:
	/**
	 * The mouse has passed over the label.
	 *
	 * @param url The URL for this label.
	 */ 
	void enteredURL(const char* url);

	/**
	 * The mouse has passed over the label.
	 */ 
	void enteredURL();

	/**
	 * The mouse is no longer over the label.
	 *
	 * @param url The URL for this label.
	 */ 
	void leftURL(const char* url);

	/**
	 * The mouse is no longer over the label.
	 */ 
	void leftURL();

	/**
	 * The user clicked the left mouse button on this label.
	 *
	 * @param url The URL for this label.
	 */ 
	void leftClickedURL(const char* url);

	/**
	 * The user clicked the left mouse button on this label.
	 */ 
	void leftClickedURL();

	/**
	 * The user clicked the right mouse button on this label.
	 *
	 * @param url The URL for this label.
	 */ 
	void rightClickedURL(const char* url);

	/**
	 * The user clicked the left mouse button on this label.
	 */ 
	void rightClickedURL();

	/**
	 * The user clicked the middle mouse button on this label.
	 *
	 * @param url The URL for this label.
	 */ 
	void middleClickedURL(const char* url);

	/**
	 * The user clicked the left mouse button on this label.
	 */ 
	void middleClickedURL();

protected:			
	/**
	 * Draws the text, pixmap, and/or movie
	 */
	void drawContents(QPainter *);

	/**
	 * Used to "glow" the text when it is selected.
	 */
	void timerEvent(QTimerEvent *);

	/**
	 * <CODE>emit</CODE>s the @ref #enteredURL signal.  If glow is
	 * on, it sets the selected color. 
	 */
	void m_enterEvent();

	/**
	 * <CODE>emit</CODE>s the @ref #leftURL signal.  If glow is
	 * on, it sets the normal color. 
	 */
	void m_leaveEvent();

	/**
	 * Processes "true" leave events since @ref #mouseMoveEvent cannot
	 */
	void leaveEvent(QEvent *event);

	/**
	 * Tracks if the cursor is above the text as well as the mouse state.
	 * It <CODE>emit</CODE>s either the @ref #enteredURL, @ref #leftURL,
	 * @ref #leftClickedURL, @ref #middleClickedURL, or @ref #rightClickedURL
	 * as appropriate.
	 */
	void mouseMoveEvent(QMouseEvent *);

	/**
	 * <CODE>emit</CODE>s either the @ref #leftClickedURL,
	 * @ref #rightClickedURL, or @ref #middleClickedURL signal depending
	 * on which one the user clicked.  Changes the color to selected
	 * to indicate that it was selected.  Starts a timer to deselect
	 * it.
	 */
	void mousePressEvent(QMouseEvent *);

        /**
	 * An overloaded repaint event that handles the background in 
	 * transparent mode. It sets a background pixmap that is obtained 
	 * from the widgets parent and calls the QLabel repaint handler 
	 * after that.
	 */
         void paintEvent(QPaintEvent*);

private:
	QRect m_textRect() const;
	QRect m_pixmapRect() const;
	void  m_resetPalette();

	TextAlignment m_textAlign;

	const char* m_url;
	const char* m_tipText;

	QPixmap m_altPixmap;
	QPixmap m_origPixmap;
	QPixmap m_unselPixmap;
	QPixmap m_pixmap;

	QString m_text;
	QMovie  m_movie;

	QCursor m_customCursor;

	QColor m_hc;
	QColor m_bc;
	QColor m_sc;
	QPalette m_nsp;
	QPalette m_sp;

	bool m_float;
	bool m_tips;
	bool m_glow;
	bool m_underline;
	bool m_inRegion;
	bool m_haveCursor;
	bool m_transparent; // true when transparent mode is enabled
};

#endif // _KURLLABEL_H

--- NEW FILE: kseparator.cpp ---
/*
 *   Copyright (C) 1997  Michael Roth <mroth at wirlweb.de>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */


#include "kseparator.h"


KSeparator::KSeparator(QWidget* parent, const char* name, WFlags f)
   : QFrame(parent, name, f)
{
   this->setLineWidth(1);
   this->setMidLineWidth(0);
   setOrientation( HLine );
}



KSeparator::KSeparator(int orientation, QWidget* parent, const char* name, WFlags f)
   : QFrame(parent, name, f)
{
   setLineWidth(1);
   setMidLineWidth(0);
   setOrientation( orientation );
}



void KSeparator::setOrientation(int orientation)
{
   switch(orientation)
   {
      case VLine:
         setFrameStyle( QFrame::VLine | QFrame::Sunken );
         setMinimumSize(2, 0);
         break;
      
      default:
         warning("KSeparator::setOrientation(): invalid orientation, using default orientation HLine");
         
      case HLine:
         setFrameStyle( QFrame::HLine | QFrame::Sunken );
         setMinimumSize(0, 2);
         break;
   }
}



int KSeparator::orientation() const
{
   if ( frameStyle() & VLine )
      return VLine;
   
   if ( frameStyle() & HLine )
      return HLine;
   
   return 0;
}



QSize KSeparator::sizeHint() const
{
   if ( frameStyle() & VLine )
      return QSize(2, 0);
   
   if ( frameStyle() & HLine )
      return QSize(0, 2);
   
   return QSize(-1, -1);
}






--- NEW FILE: arrow_up.xbm ---
#define arrow_up_width 16
#define arrow_up_height 16
static char arrow_up_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
   0xf8, 0x1f, 0xfc, 0x3f, 0xfc, 0x3f, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03,
   0xc0, 0x03, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00};

--- NEW FILE: kpanner.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Alexander Sanda (alex at darkstar.ping.at)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/*
 * $Id: kpanner.cpp,v 1.1 2006-10-03 11:26:32 dslinux_amadeus Exp $
 *
 * $Log: kpanner.cpp,v $
 * Revision 1.1  2006-10-03 11:26:32  dslinux_amadeus
 * adding pristine copy of pixil to HEAD so I can branch from it
 *
 * Revision 1.1  2003/09/08 19:42:09  jasonk
 * Addition of packages directory and associated files.
 *
 * Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
 * Initial import of PIXIL into new cvs repository.
 *
 * Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
 *
 *
 * Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
 * Initial import of ViewML
 *
 * Revision 1.9  1999/01/18 10:56:54  kulow
 * .moc files are back in kdelibs. Built fine here using automake 1.3
 *
 * Revision 1.8  1999/01/15 09:31:13  kulow
 * it's official - kdelibs builds with srcdir != builddir. For this I
 * automocifized it, the generated rules are easier to maintain than
 * selfwritten rules. I have to fight with some bugs of this tool, but
 * generally it's better than keeping them updated by hand.
 *
 * Revision 1.7  1997/10/16 11:15:27  torben
 * Kalle: Copyright headers
 * kdoctoolbar removed
 *
 * Revision 1.6  1997/05/17 20:38:23  kalle
 * Kalle:
 * - Bugfix for KPanner (from Paul Kendall)
 * - Better colors with kdisplay schemes (from Bernd Wuebben)
 * - new behavior in KApplication::invokeHTMLHelp(): if the first
 *   argument (the filename) is empty, the filename is defaulted to
 * 	$KDEDIR/doc/HTML/<appname>/<appname>.html
 * - KApplication::getCaption for Matthias added (breaks binary compatibility!)
 *
 * Revision 1.5  1997/05/09 15:10:12  kulow
 * Coolo: patched ltconfig for FreeBSD
 * removed some stupid warnings
 *
 * Revision 1.4  1997/05/02 19:33:49  kulow
 * Coolo: corrected some CVS related problems with Kalle's last commit
 * updated khtmlw to 0.5.4
 *
 * Revision 1.3  1997/05/02 16:46:40  kalle
 * Kalle: You may now override how KApplication reacts to external changes
 * KButton uses the widget default palette
 * new kfontdialog version 0,5
 * new kpanner by Paul Kendall
 * new: KIconLoader
 *
 * Revision 1.2  1997/04/30 22:28:37  kulow
 * Coolo: updated KWidget classes (out of kghostview)
 * patched kbutton (from Taj)
 * BTW: Do you like the new look of the toolbar? (I'm not)
 *
 * Revision 1.1.1.1  1997/04/13 14:42:43  cvsuser
 * Source imported
 *
 * Revision 1.1.1.1  1997/04/09 00:28:08  cvsuser
 * Sources imported
 *
 * Revision 1.1  1997/03/09 16:41:56  kalle
 * Initial revision
 *
 */

#include <qpainter.h>
#include <qcursor.h>
#include <qframe.h>
#include <kpanner.h>
#include "kpanner.h"

KPanner::KPanner(QWidget *parent, const char *name, unsigned flags, int d)
    : QWidget(parent, name)
{
    u_flags = flags;

    /*
     * create the child widgets and the divider widget
     */
    cw0 = new QWidget(this, "_pchild0");
    cw1 = new QWidget(this, "_pchild1");
    divider = new QFrame(this, "_pdivider", 0, TRUE);
    divider->setFrameStyle(QFrame::Panel | QFrame::Raised);
    divider->setLineWidth(1);

  
    /*
     * set the cursor shape
     */
    if((u_flags & P_ORIENTATION) == O_HORIZONTAL)
        divider->setCursor(QCursor(sizeVerCursor));
    else // O_VERTICAL
        divider->setCursor(QCursor(sizeHorCursor));

    u_limit = 0;
    l_limit = 0;

    pos = d;
    checkRange(pos);
    divider->installEventFilter(this);
}

KPanner::~KPanner() {
    delete cw0;
    delete cw1;
    delete divider;
}

/*
 * resize the panner.
 * this calculates the new geometry information for the client widgets
 * and the separator widget
 */

void KPanner::resizeEvent(QResizeEvent*)
{
    int abs_coord = pos;

    if((u_flags & P_UNITS) == U_PERCENT)
        abs_coord = (int)(pos / 100.0 * getMaxValue());
    
    if((u_flags & P_ORIENTATION) == O_HORIZONTAL) {
        cw0->setGeometry(0, 0, width(), abs_coord);
        cw1->setGeometry(0, abs_coord+4, width(), height()-abs_coord-4);
    }
    else { // O_VERTICAL
        cw0->setGeometry(0, 0, abs_coord, height());
        cw1->setGeometry(abs_coord+4, 0, width()-abs_coord-4, height());
    }
        
    setDividerGeometry(pos);
}

void KPanner::setDividerGeometry(int pos)
{
    int abs_coord = pos;
    
    if((u_flags & P_UNITS) == U_PERCENT)
        abs_coord = (int)(pos / 100.0 * getMaxValue());
    
    if((u_flags & P_ORIENTATION) == O_HORIZONTAL)
        divider->setGeometry(0, abs_coord, width(), 4);
    else // O_VERTICAL
        divider->setGeometry(abs_coord, 0, 4, height());
}

/*
 * dragging the mouse on the separator initiates the drag action. It does
 * not check for any mouse button (yet).
 */

bool KPanner::eventFilter(QObject *obj, QEvent *ev)
{
    /*
     * initiate divider drag action. record current position
     */
    
    if(ev->type() == Event_MouseButtonPress) {
        if((u_flags & P_ORIENTATION) == O_HORIZONTAL)
            old_coord = divider->y();
        else // O_VERTICAL
            old_coord = divider->x();
    }
    
    if(ev->type() == Event_MouseMove) {

        if(obj == (QObject *)divider) {
            QMouseEvent *mev = (QMouseEvent *)ev;

            /*
             * get the new coordinate, depending on our orientation.
             */
            if((u_flags & P_ORIENTATION) == O_HORIZONTAL)
                delta = mev->pos().y();
            else // O_VERTICAL
                delta = mev->pos().x();
            old_coord += delta;

            /*
             * check for limits
             */
            checkRange( old_coord );
            
            if((u_flags & P_ORIENTATION) == O_HORIZONTAL)
                divider->move(0, old_coord);
            else // O_VERTICAL
                divider->move(old_coord, 0);

            return TRUE;
        }
    }

    if(ev->type() == Event_MouseButtonRelease) {
        int max_value = getMaxValue();
    
        if((u_flags & P_UNITS) == U_PERCENT)
            pos = (int)((old_coord * 100.0) / max_value);
        else
            pos = old_coord;
        setDividerGeometry(pos);
        resizeEvent(0);
        emit(positionChanged());
        return TRUE;
    }
    
    return FALSE;
}

QWidget *KPanner::child0()
{
    return cw0;
}

QWidget *KPanner::child1()
{
    return cw1;
}

void KPanner::setSeparator(int size)
{
    if((u_flags & P_UNITS) == U_PERCENT)
        pos = size;
    else
        pos = (int)(size / 100.0 * getMaxValue());
    
    checkRange(pos);
    resizeEvent(0);
    emit(positionChanged());
}

void KPanner::setAbsSeparator(int size)
{
    if((u_flags & P_UNITS) == U_PERCENT)
        pos = (int)(size * 100.0 / getMaxValue());
    else
        pos = size;
    
    checkRange(pos);
    resizeEvent(0);
    emit(positionChanged());
}

void KPanner::setLimits(int l, int u)
{
    l_limit = (l < 0 ? 0 : l);
    if((u_flags & P_UNITS) == U_PERCENT) {
        if(u < 0 && u >= -100)
            u_limit = -100;
        else if(u >= 100)
            u_limit = 100;
        else
            u_limit = u;
    }
    else {
        int m = getMaxValue();
        
        if(u < 0 && u >= -m)
            u_limit = -m;
        else if(u >= m)
            u_limit = m;
        else
            u_limit = u;
    }
    
    if(l_limit >= u_limit) {
        l_limit = 0;
        u_limit = 0;
    }

    if(checkRange(pos)) {
        resizeEvent(0);
    }
}

int KPanner::getMaxValue()
{
    if(u_flags & O_HORIZONTAL) {
        return height() - 4;
    }
    else { // O_VERTICAL
        return width() - 4;
    }
   return 0;
}

bool KPanner::checkRange(int & value)
{
    int max_value = getMaxValue();
    
    if((u_flags & P_UNITS) == U_PERCENT) {
        float percent;

        percent = value * 100.0 / max_value;
        if( percent < l_limit )
            percent = l_limit;
        else if( u_limit > 0 && percent > u_limit )
            percent = u_limit;
        else if( u_limit <= 0 && percent > 100+u_limit )
            percent = 100+u_limit;
        else
            return FALSE;
        value = (int)(percent / 100.0 * max_value);
    }
    else {
        if( value < l_limit )
            value = l_limit;
        else if( u_limit > 0 && value > u_limit )
            value = u_limit;
        else if( u_limit <= 0 && value > max_value+u_limit )
            value = max_value+u_limit;
        else
            return FALSE;
    }
    return TRUE;
}

int KPanner::getSeparator() 
{
    if((u_flags & P_UNITS) == U_PERCENT)
        return pos;
    else
        return (int)(pos / 100.0 * getMaxValue());
}

int KPanner::getAbsSeparator() 
{
    if((u_flags & P_UNITS) == U_PERCENT)
        return (int)(pos * 100.0 / getMaxValue());
    else
        return pos;
}
#include "kpanner.moc"

--- NEW FILE: kdbtn.cpp ---
/*  This file is part of the KDE Libraries
    Copyright (C) 1998 Thomas Tanghus (tanghus at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/  

#include <kapp.h>
#include <qbutton.h>
#include <qpainter.h>
#include <qpen.h>
#include <qpointarray.h>
#include <qdrawutil.h>


#include "kdbtn.h"

KDirectionButton::KDirectionButton(QWidget *parent, const char *name)
 : QButton(parent, name)
{
  initMetaObject();
  direct = RightArrow;
}

KDirectionButton::KDirectionButton(ArrowType d, QWidget *parent, const char *name)
 : QButton(parent, name)
{
  initMetaObject();
  direct = d;
}

KDirectionButton::~KDirectionButton()
{
  //debug("KTabButton - destructor");

  //debug("KTabBar - destructor done");
}

void KDirectionButton::drawButton( QPainter *p)
{
  // I abandoned qDrawArrow(...) 'cause the result was totally unpredictable :-(

  int style = kapp->applicationStyle;
  int wm = width()/2, hm = height()/2;
  QColorGroup g = QWidget::colorGroup();
  QPen lightPen, darkPen;
  QColor lightColor, darkColor;

  if(isEnabled())
  {
    lightColor = g.midlight();
    darkColor = g.dark();
  }
  else
  {
    lightColor = g.midlight();
    darkColor = g.mid();
  }

  lightPen.setColor(lightColor);
  darkPen.setColor(darkColor);

  switch (direct)
  {
    case LeftArrow:
      if(style == MotifStyle)
      {
        if(isDown())
        {
          p->setPen(darkPen);
          p->drawLine(2, hm, (2*wm)-4, 2);
          p->setPen(lightPen);
          p->drawLine((2*wm)-4, 2, (2*wm)-4, (2*hm)-4);
          p->drawLine((2*wm)-4, (2*hm)-4, 2, hm);
        }
        else
        {
          p->setPen(lightPen);
          p->drawLine(2, hm, (2*wm)-4, 2);
          p->setPen(darkPen);
          p->drawLine((2*wm)-4, 2, (2*wm)-4, (2*hm)-4);
          p->drawLine((2*wm)-4, (2*hm)-4, 2, hm);
        }
      }
      else
      {
        p->setBrush(darkColor);
        p->setPen(darkPen);
        QPointArray a(3);
        if(isDown())
        {
          a.setPoint(0, (2*wm)-2, 2);
          a.setPoint(1, (2*wm)-2, (2*hm)-4);
          a.setPoint(2, 4, hm);
          p->drawPolygon(a);
        }
        else
        {
          a.setPoint(0, (2*wm)-4, 2);
          a.setPoint(1, (2*wm)-4, (2*hm)-4);
          a.setPoint(2, 2, hm);
          p->drawPolygon(a);
        }
      }
      break;

    case RightArrow:
      if(style == MotifStyle)
      {
        if(isDown())
        {
          p->setPen(darkPen);
          p->drawLine(2, (2*hm)-4, 2, 2);
          p->drawLine(2, 2, (2*wm)-4, hm);
          p->setPen(lightPen);
          p->drawLine((2*wm)-4, hm, 2, (2*hm)-4);
        }
        else
        {
          p->setPen(lightPen);
          p->drawLine(2, (2*hm)-4, 2, 2);
          p->drawLine(2, 2, (2*wm)-4, hm);
          p->setPen(darkPen);
          p->drawLine((2*wm)-4, hm, 2, (2*hm)-4);
        }
      }
      else
      {
        p->setBrush(darkColor);
        p->setPen(darkPen);
        QPointArray a(3);
        if(isDown())
        {
          a.setPoint(0, 0, 2);
          a.setPoint(1, 0, (2*hm)-4);
          a.setPoint(2, (2*wm)-6, hm);
          p->drawPolygon(a);
        }
        else
        {
          a.setPoint(0, 2, 2);
          a.setPoint(1, 2, (2*hm)-4);
          a.setPoint(2, (2*wm)-4, hm);
          p->drawPolygon(a);
        }
      }
      break;

    case UpArrow:
      if(style == MotifStyle)
      {
        if(isDown())
        {
          p->setPen(lightPen);
          p->drawLine(2, (2*hm)-4, (2*wm)-4, (2*hm)-4);
          p->drawLine((2*wm)-4, (2*hm)-4, wm, 2);
          p->setPen(darkPen);
          p->drawLine(wm, 2, 2, (2*hm)-4);
        }
        else
        {
          p->setPen(darkPen);
          p->drawLine(2, (2*hm)-4, (2*wm)-4, (2*hm)-4);
          p->drawLine((2*wm)-4, (2*hm)-4, wm, 2);
          p->setPen(lightPen);
          p->drawLine(wm, 2, 2, (2*hm)-4);
        }
      }
      else
      {
        p->setBrush(darkColor);
        p->setPen(darkPen);
        QPointArray a(3);
        if(isDown())
        {
          a.setPoint(0, 2, (2*hm)-2);
          a.setPoint(1, (2*wm)-4, (2*hm)-2);
          a.setPoint(2, wm, 4);
          p->drawPolygon(a);
        }
        else
        {
          a.setPoint(0, 2, (2*hm)-4);
          a.setPoint(1, (2*wm)-4, (2*hm)-4);
          a.setPoint(2, wm, 2);
          p->drawPolygon(a);
        }
      }
      break;

    case DownArrow:
      if(style == MotifStyle)
      {
        if(isDown())
        {
          p->setPen(darkPen);
          p->drawLine(wm, (2*hm)-4, 2, 2);
          p->drawLine(2, 2, (2*wm)-4, 2);
          p->setPen(lightPen);
          p->drawLine((2*wm)-4, 2, wm, (2*hm)-4);
        }
        else
        {
          p->setPen(lightPen);
          p->drawLine(wm, (2*hm)-4, 2, 2);
          p->drawLine(2, 2, (2*wm)-4, 2);
          p->setPen(darkPen);
          p->drawLine((2*wm)-4, 2, wm, (2*hm)-4);
        }
      }
      else
      {
        p->setBrush(darkColor);
        p->setPen(darkPen);
        QPointArray a(3);
        if(isDown())
        {
          a.setPoint(0, 2, 0);
          a.setPoint(1, (2*wm)-4, 0);
          a.setPoint(2, wm, (2*hm)-6);
          p->drawPolygon(a);
        }
        else
        {
          a.setPoint(0, 2, 2);
          a.setPoint(1, (2*wm)-4, 2);
          a.setPoint(2, wm, (2*hm)-4);
          p->drawPolygon(a);
        }
      }
      break;

    default:
#if defined(CHECK_RANGE)
      warning( "KDirectionButton: Requested Arrow style not supported" );
#endif
      break;
  }
}

KTabButton::KTabButton(QWidget *parent, const char *name)
 : KDirectionButton(parent, name)
{
  initMetaObject();
}

KTabButton::KTabButton(ArrowType d, QWidget *parent, const char *name)
 : KDirectionButton(d, parent, name)
{
  initMetaObject();
}

void KTabButton::drawButton( QPainter *p)
{
  int h = height(), w = width();

  KDirectionButton::drawButton(p);

  QPen pen( white, 1 );
  p->setPen( pen );

  // left outer
  p->drawLine( 0, h, 0, 1);

  // top outer
  p->drawLine( 1, 0, w-1, 0);
  
  pen.setColor( black );
  p->setPen( pen );

  // right outer
  p->drawLine( w-1 , 1, w-1, h);
}


#include "kdbtn.moc"


--- NEW FILE: kledlamp.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Richard Moore (moorer at cs.man.ac.uk)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
// CDE style LED lamp widget for Qt
// Richard J. Moore 23.11.96
// Email: moorer at cs.man.ac.uk

#include <stdio.h>
#include <qpainter.h>
#include <qbrush.h>
#include <qpen.h>
#include <qcolor.h>
#include "kledlamp.h"
#include "kledlamp.h"

KLedLamp::KLedLamp(QWidget *parent) : QFrame(parent),
  width( 28 ), height( 7 ), dx( 4 )
{
  // Make sure we're in a sane state
  s= Off;

  // Set the frame style
  setFrameStyle(Sunken | Box);
  setGeometry(0,0,width,height);
}

void KLedLamp::drawContents(QPainter *painter)
{
  QBrush lightBrush(yellow);
  QBrush darkBrush(QColor(60,60,0));
  QPen pen(QColor(40,40,0));
  switch(s) {
  case On:
    painter->setBrush(lightBrush);
	painter->drawRect(1,1,QFrame::width()-2, QFrame::height()-2);
    break;
  case Off:
    painter->setBrush(darkBrush);
	painter->drawRect(1,1,QFrame::width()-2, QFrame::height()-2);
    painter->setPen(pen);
	painter->drawLine(2,2,QFrame::width()-2, 2);
	painter->drawLine(2,QFrame::height()-2,QFrame::width()-2,QFrame::height()-2);
	// Draw verticals
    int i;
	for (i= 2; i < QFrame::width()-1; i+= dx)
	   painter->drawLine(i,2,i,QFrame::height()-2);
    break;
	//  default:
	//    fprintf(stderr, "KLedLamp: INVALID State (%d)\n", s);
  }
}

#include "kledlamp.moc"


--- NEW FILE: question.xpm ---
/* XPM */
static char *magick[] = {
/* columns rows colors chars-per-pixel */
"48 48 5 1",
"  c #000000",
". c #a0a0a4",
"X c #c0c0c0",
"o c #ffffff",
"O c None",
/* pixels */
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOO........OOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOO...oooooooo...OOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO..oooooooooooooo..OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOO.oooooooooooooooooo.OOOOOOOOOOOOOOO",
"OOOOOOOOOOOO.oooooooo     ooooooo OOOOOOOOOOOOOO",
"OOOOOOOOOOO.oooooooo oooo  ooooooo OOOOOOOOOOOOO",
"OOOOOOOOOO.oooooooo   oooo  ooooooo OOOOOOOOOOOO",
"OOOOOOOOO.ooooooooo    ooo  oooooooo OOOOOOOOOOO",
"OOOOOOOOO.oooooooooo  ooo   oooooooo .OOOOOOOOOO",
"OOOOOOOO.ooooooooooooooo    ooooooooo .OOOOOOOOO",
"OOOOOOOO.oooooooooooooo    oooooooooo .OOOOOOOOO",
"OOOOOOOO.oooooooooooo      oooooooooo ..OOOOOOOO",
"OOOOOOOO.oooooooooooo     ooooooooooo ..OOOOOOOO",
"OOOOOOOO.oooooooooooo   ooooooooooooo ..OOOOOOOO",
"OOOOOOOO.oooooooooooo  oooooooooooooo ..OOOOOOOO",
"OOOOOOOO.oooooooooooo ooooooooooooooo ..OOOOOOOO",
"OOOOOOOOO.ooooooooooo oooooooooooooo ...OOOOOOOO",
"OOOOOOOOO.oooooooooooooooooooooooooo ...OOOOOOOO",
"OOOOOOOOOO.oooooooooo  oooooooooooo ...OOOOOOOOO",
"OOOOOOOOOOO oooooooo    oooooooooo ....OOOOOOOOO",
"OOOOOOOOOOOO oooooooo  oooooooooo ....OOOOOOOOOO",
"OOOOOOOOOOOOO oooooooooooooooooo ....OOOOOOOOOOO",
"OOOOOOOOOOOOOO  oooooooooooooo  ....OOOOOOOOOOOO",
"OOOOOOOOOOOOOOO.   oooooooo   .....OOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOO...   oooo .......OOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOO.... ooo .....OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOO. ooo ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOO oo ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOO o ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOO  ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOO...OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOO..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
};

--- NEW FILE: ktoolboxmgr.cpp ---
/*
    This file is part of the KDE libraries
    Copyright (C) 1998 Sven Radej <radej at kde.org>
              
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/


#include <qcursor.h>
#include <qobject.h>
#include <qapplication.h>

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <ktoolboxmgr.h>
#include <kwm.h>

 // $Id: ktoolboxmgr.cpp,v 1.1 2006-10-03 11:26:33 dslinux_amadeus Exp $
 // $Log: ktoolboxmgr.cpp,v $
 // Revision 1.1  2006-10-03 11:26:33  dslinux_amadeus
 // adding pristine copy of pixil to HEAD so I can branch from it
 //
 // Revision 1.1  2003/09/08 19:42:11  jasonk
 // Addition of packages directory and associated files.
 //
 // Revision 1.1.1.1  2003/08/07 21:18:33  jasonk
 // Initial import of PIXIL into new cvs repository.
 //
 // Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
 //
 //
 // Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
 // Initial import of ViewML
 //
 // Revision 1.15  1999/01/18 10:57:12  kulow
 // .moc files are back in kdelibs. Built fine here using automake 1.3
 //
 // Revision 1.14  1999/01/15 09:31:31  kulow
 // it's official - kdelibs builds with srcdir != builddir. For this I
 // automocifized it, the generated rules are easier to maintain than
 // selfwritten rules. I have to fight with some bugs of this tool, but
 // generally it's better than keeping them updated by hand.
 //
 // Revision 1.13  1998/11/06 15:45:43  radej
 // sven: added helper for addHotSpot
 //
 // Revision 1.12  1998/09/01 20:22:25  kulow
 // I renamed all old qt header files to the new versions. I think, this looks
 // nicer (and gives the change in configure a sense :)
 //
 // Revision 1.11  1998/08/10 13:33:54  radej
 // sven: Added X-only and Y-only resizing.
 //
 // Revision 1.10  1998/07/29 12:48:30  ssk
 // Removed more warnings, possible portability problems and ANSI violations.
 //
 // Revision 1.9  1998/06/18 09:15:01  radej
 // sven: made transparent resizer's lines thicker  (3.pts)
 //
 // Revision 1.8  1998/06/18 08:54:31  radej
 // sven: removed debug outpot before 1.0
 //
 // Revision 1.7  1998/05/07 16:50:06  radej
 // I caught that mouseRelease without blocking (Yeah!)
 //
 // Revision 1.6  1998/05/05 16:52:45  radej
 // Bugs...
 //
 // Revision 1.5  1998/05/05 10:03:50  radej
 // Improvement for opaque moving (steeling releaseEvent from widget)
 //
 // Revision 1.4  1998/05/04 16:39:12  radej
 // No more server locking + opaque sizing/moving
 //
 // Revision 1.3  1998/05/03 10:56:23  radej
 // Fixing the locked server bug; all grab ungrab is in one function now.
 // Screen is not locked any more across different QTimer steps
 //
 // Revision 1.2  1998/05/02 18:30:13  radej
 // Switched to KWM::geometry instead x() and y()
 //
 // Revision 1.1  1998/04/28 09:16:18  radej
 // Initial checkin
 //


KToolBoxManager::KToolBoxManager (QWidget *_widget, bool _transparent) : QObject ()
{
  XGCValues gv;

  working=false;
  noLast=true;
  widget = _widget;
  geometryChanged = false;
  mode = Nothing;
  
  transparent = _transparent;
  scr = qt_xscreen();
  root = qt_xrootwin();

  gv.function = GXxor;
  gv.line_width = 0;
  gv.foreground = WhitePixel(qt_xdisplay(), scr)^BlackPixel(qt_xdisplay(), scr);
  gv.subwindow_mode = IncludeInferiors;
  long mask = GCForeground | GCFunction | GCLineWidth | GCSubwindowMode;
  rootgc = XCreateGC(qt_xdisplay(), qt_xrootwin(), mask, &gv);

  hotspots.setAutoDelete(true);
  
  //driver for mover and resizer
  timer = new QTimer(this);

  yOnly = false;
  xOnly = false;

}

KToolBoxManager::~KToolBoxManager ()
{
  stop();
}

int KToolBoxManager::addHotSpot(int rx, int ry, int rw, int rh)
{
  QRect *r = new QRect (rx, ry, rw, rh);
  hotspots.append(r);
  return hotspots.at();
}

int KToolBoxManager::addHotSpot (const QRect& _r, bool mapToGlobal)
{
  QRect *r = new QRect (_r.x(), _r.y(), _r.width(), _r.height());
  if (mapToGlobal)
    r->moveTopLeft(widget->parentWidget()->mapToGlobal(r->topLeft()));
  hotspots.append(r);
  return hotspots.at();
}


void KToolBoxManager::removeHotSpot(int index)
{
  hotspots.remove (index);
}

void KToolBoxManager::doMove (bool hot_static, bool _dynamic, bool dontmove)
{
  if (working)
    return;

  Window wroot, wchild;
  int trash;
  
  //debug("Doing move...");

  working=true;
  mode = Moving;
  dynamic = _dynamic;
  dontmoveres=dontmove;
  hotspot_static = hot_static;
  
  QRect rr = KWM::geometry(widget->winId(), true);
  QPoint p(rr.topLeft());

  offX = QCursor::pos().x() - p.x();
  offY = QCursor::pos().y() - p.y();
  
  xp = p.x();
  yp = p.y();
  w = rr.width();
  h = rr.height();

  orig_x = p.x();
  orig_y = p.y();
  orig_w = w;
  orig_h = h;

  XQueryPointer( qt_xdisplay(), qt_xrootwin(), &wroot, &wchild,
                 &sx, &sy, &trash, &trash, &active_button);
  
  rx = sx;
  ry = sy;
  
  xp=sx-offX;
  yp=sy-offY;

  QApplication::setOverrideCursor(QCursor(sizeAllCursor));
  
  connect (timer, SIGNAL(timeout()), this, SLOT (doMoveInternal()));
  if (transparent)
    drawRectangle(xp, yp, w, h);

  timer->start(0);
  qApp->enter_loop();
}

void KToolBoxManager::doMoveInternal()
{
  bool onspot=false;
  bool changed=false;
  Window wroot, wchild;
  int trash;
  unsigned int buttons;

  XQueryPointer( qt_xdisplay(), qt_xrootwin(), &wroot, &wchild,
                 &rx, &ry, &trash, &trash, &buttons );
  
  if (buttons != active_button)
  {
    /*bool b = */ XCheckMaskEvent(qt_xdisplay(), ButtonReleaseMask, &ev);
    // if (b) debug ("KTBmgr: Got and removed mouseRelease");
    stop();  
    return;
  }
  
  if (rx == sx && ry == sy)
    return;
  /*
  if (geometryChanged)
  {
    offX = rx - xp;
    offY = ry - yp;
    geometryChanged = false;
  }
  */
  sx=rx;
  sy=ry;

  xp=rx-offX;
  yp=ry-offY;

  for (QRect *hsp = hotspots.first(); hsp; hsp = hotspots.next())
  {
    if (hsp->contains(QPoint(rx,ry)))
    {
      if (hsp != last_hsp)
      {
        last_hsp = hsp;
        emit onHotSpot (hotspots.at());
        changed=true;
      }
      onspot=true;
      deepSpace=false;
      break;
    }
  }
  // we re out of all hotspots;
  if (!deepSpace && !onspot)
  {
    emit onHotSpot (-1);
    deepSpace = true;
    last_hsp=0;
  }

  if (onspot && !changed && hotspot_static)
  {
    geometryChanged = true;
    return;
  }

  if (transparent)
  {
    deleteLastRectangle();
    drawRectangle(xp, yp, w, h);

    XFlush(qt_xdisplay());
  }
  else
  {
    QPoint p(xp, yp);
    if (widget->parentWidget() != 0)
      p=widget->parentWidget()->mapFromGlobal(p);

    XMoveWindow(qt_xdisplay(), widget->winId(), p.x(), p.y());
    //widget->move(p);
  }
  XSync(qt_xdisplay(), False);

  if (dynamic)
    emit posChanged(xp, yp);
}

void KToolBoxManager::doXResize (bool _dontresize, bool _dynamic)
{
  if (working)
    return;

  yOnly = false;
  xOnly = true;

  doResize(_dontresize, _dynamic);

  yOnly = false;
  xOnly = false;

}

void KToolBoxManager::doYResize (bool _dontresize, bool _dynamic)
{
  if (working)
    return;

  yOnly = true;
  xOnly = false;

  doResize(_dontresize, _dynamic);

  yOnly = false;
  xOnly = false;

}

void KToolBoxManager::doResize (bool dontresize, bool _dynamic)
{
  if (working)
    return;


  Window wroot, wchild;
  int trash;
  
  //debug("Doing resize...");

  working=true;
  dynamic = _dynamic;
  dontmoveres=dontresize;
  mode = Resizing;
  
  QRect rr = KWM::geometry(widget->winId(), true);
  QPoint p(rr.topLeft());

  offX = QCursor::pos().x() - p.x();
  offY = QCursor::pos().y() - p.y();
  
  xp = p.x();
  yp = p.y();
  w = rr.width();
  h = rr.height();

  orig_x = p.x();
  orig_y = p.y();
  orig_w = w;
  orig_h = h;

  XQueryPointer( qt_xdisplay(), qt_xrootwin(), &wroot, &wchild,
                 &sx, &sy, &trash, &trash, &active_button);
  
  rx = sx;
  ry = sy;

  QApplication::setOverrideCursor(QCursor(sizeFDiagCursor));
  
  connect (timer, SIGNAL(timeout()), this, SLOT (doResizeInternal()));

  if (transparent)
    drawRectangle(xp, yp, w, h);
  
  timer->start(0);
  qApp->enter_loop();
}

void KToolBoxManager::doResizeInternal ()
{
  Window wroot, wchild;
  int trash;
  unsigned int buttons;

  XQueryPointer( qt_xdisplay(), qt_xrootwin(), &wroot, &wchild,
                 &rx, &ry, &trash, &trash, &buttons );
  
  if (buttons != active_button)
  {
    /*bool b = */ XCheckMaskEvent(qt_xdisplay(), ButtonReleaseMask, &ev);
    // if (b) debug ("KTBmgr: Got and removed mouseRelease");
    stop();
    return;
  }


  if (xOnly)
    ry=sy;
  else if (yOnly)
    rx=sx;

  if (rx == sx && ry == sy) return;
  
  w += rx-sx;
  h += ry-sy;

  sx=rx;
  sy=ry;

  if (transparent)
  {
    deleteLastRectangle();
    drawRectangle(xp, yp, w, h);
    XFlush(qt_xdisplay());
  }
  else
    widget->resize(w, h);
//    XResizeWindow (qt_xdisplay(), widget->winId(), w, h);

  XSync(qt_xdisplay(), False);

  if (dynamic)
    emit sizeChanged(w, h);
}


void KToolBoxManager::stop ()
{
  if (!working)
    return;
  
  timer->stop();
  disconnect (timer, SIGNAL(timeout()));

  QApplication::restoreOverrideCursor();

  if (transparent)
    deleteLastRectangle();

  XFlush(qt_xdisplay());

  if (dontmoveres) // do not move or resize caller'll do it himself
  {
    if (!transparent)
      if (mode==Moving)
      {
        QPoint p(orig_x, orig_y);
        if (widget->parent() != 0)
          p=widget->parentWidget()->mapFromGlobal(p);

        widget->move(p);
      }
      else if (mode == Resizing)
        widget->resize(orig_w, orig_h);
  }
  else // do move or resize, even children
  {
    if (transparent) // else if opaque: already moved/sized
      if (mode==Moving)
      {
        QPoint p(xp, yp);
        if (widget->parent() != 0)
          p=widget->parentWidget()->mapFromGlobal(p);

        widget->move(p);
      }
      else if (mode == Resizing)
        widget->resize(w, h);
  }
  
  working = false;
  mode=Nothing;

  qApp->exit_loop();
  //debug ("stopped");
}

void KToolBoxManager::setGeometry (int index)
{
  if (index == -1)
    return;
  QRect *r = hotspots.at(index);
  if (r)
    setGeometry(r->x(), r->y(), r->width(), r->height());
}

void KToolBoxManager::setGeometry (int _x, int _y, int _w, int _h)
{
  if (!working)
    return;

  xp=_x;
  yp=_y;
  w=_w;
  h=_h;
  if (transparent)
    deleteLastRectangle();
  else
    widget->resize(w, h);
  geometryChanged=true;
}


void KToolBoxManager::drawRectangle(int _x, int _y, int _w, int _h)
{
  ox = _x;
  oy = _y;
  ow = _w;
  oh = _h;

  XDrawRectangle(qt_xdisplay(), root, rootgc, _x, _y, _w, _h);
  if (_w > 2)
    _w -= 2;
  if (_h > 2)
    _h -= 2;
  XDrawRectangle(qt_xdisplay(), root, rootgc, _x+1, _y+1, _w, _h);
  if (_w > 2)
    _w -= 2;
  if (_h > 2)
    _h -= 2;
  XDrawRectangle(qt_xdisplay(), root, rootgc, _x+2, _y+2, _w, _h);
  
  noLast = false;
}

void KToolBoxManager::deleteLastRectangle()
{
  if (noLast)
    return;
  
  XDrawRectangle(qt_xdisplay(), root, rootgc, ox, oy, ow, oh);
  if (ow > 2)
    ow -= 2;
  if (oh > 2)
    oh -= 2;
  XDrawRectangle(qt_xdisplay(), root, rootgc, ox+1, oy+1, ow, oh);
  if (ow > 2)
    ow -= 2;
  if (oh > 2)
    oh -= 2;
  XDrawRectangle(qt_xdisplay(), root, rootgc, ox+2, oy+2, ow, oh);

  noLast = true;
}

#include "ktoolboxmgr.moc"


--- NEW FILE: ktabctl.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Alexander Sanda (alex at darkstar.ping.at)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/*
 * $Id: ktabctl.h,v 1.1 2006-10-03 11:26:33 dslinux_amadeus Exp $
 *
 * $Log: ktabctl.h,v $
 * Revision 1.1  2006-10-03 11:26:33  dslinux_amadeus
 * adding pristine copy of pixil to HEAD so I can branch from it
 *
 * Revision 1.1  2003/09/08 19:42:10  jasonk
 * Addition of packages directory and associated files.
 *
 * Revision 1.1.1.1  2003/08/07 21:18:33  jasonk
 * Initial import of PIXIL into new cvs repository.
 *
 * Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
 *
 *
 * Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
 * Initial import of ViewML
 *
 * Revision 1.5.4.1  1999/06/22 18:32:14  gehrmab
 * Removed unwanted html tags from kdocumentation
 *
 * Revision 1.5  1998/07/23 08:34:10  garbanzo
 * Repeat after me: private members are bad, private members are bad, private
 * members are the bane of reusable code.
 *
 * Ronald Reagan -- America's favorite placebo.
 *
 * Revision 1.4  1998/06/16 21:23:15  hoss
 * *** empty log message ***
 *
 * Revision 1.3  1997/10/16 11:15:54  torben
 * Kalle: Copyright headers
 * kdoctoolbar removed
 *
 * Revision 1.2  1997/07/24 21:06:08  kalle
 * Kalle:
 * KToolBar upgraded to newtoolbar 0.6
 * KTreeList has rubberbanding now
 * Patches for SGI
 *
 * Revision 1.1.1.1  1997/04/13 14:42:43  cvsuser
 * Source imported
 *
 * Revision 1.1.1.1  1997/04/09 00:28:10  cvsuser
 * Sources imported
 *
 * Revision 1.1  1997/03/15 22:40:57  kalle
 * Initial revision
 *
 * Revision 1.2.2.1  1997/01/07 14:41:57  alex
 * release 0.1
 *
 * Revision 1.2  1997/01/07 13:47:09  alex
 * first working release
 *
 * Revision 1.1.1.1  1997/01/07 13:44:53  alex
 * imported
 *
 */

#ifndef KTABCTL_H
#define KTABCTL_H

#include "qwidget.h"
#include "qtabbar.h"
#include "qarray.h"

/// KTabCtl, simple widget for the creation of tabbed window layouts.
/** KTabCtl is very similar to QTabDialog, with the following differences:
 To avoid confusion, the API is almost identical with QTabDialog.
  
  * does not create any button, therefore KTabCtl is not limited to dialog
	boxes. You can use it whereever you want.
	 
 * emits the signal tabSelected(int pagenumber) when the user selects one
   of the tabs. This gives you the chance to update the widget contents
 of a single page. The signal is emitted _before_ the page is shown.
   Very important, if the contents of some widgets on page (a) depend on
	 the contents of some other widgets on page (b).
*/
class KTabCtl : public QWidget
{
    Q_OBJECT

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

    void show();
    void setFont(const QFont & font);
    void setTabFont( const QFont &font );

    void addTab(QWidget *, const char *);
    bool isTabEnabled(const char * );
    void setTabEnabled(const char *, bool);
    void setBorder(bool);
    void setShape( QTabBar::Shape shape );

protected:
    void paintEvent(QPaintEvent *);
    void resizeEvent(QResizeEvent *);

signals:
    void tabSelected(int);
    
protected slots:
    void showTab(int i);

protected:
    void setSizes();
    QRect getChildRect() const;

    QTabBar * tabs;
    QArrayT<QWidget *> pages;
    int bh;
    bool blBorder;
};
#endif

--- NEW FILE: CHANGES.kdatepicker ---
This file records changes made to the KDatePicker and KDateTable class.
It is maintained by Mirko Sucker (mirko at kde.org).

February 25 1998:
The buttons that switch the month no more display "<--" and "-->" but 
arrow bitmaps that look much nicer.

March 17 1998:
I added the two methods setDate(QDate) and QSize sizeHint() to 
KDatePicker.

March 27 1998:
I added some documentation to the both header files and cleaned up 
some code. No functional changes.

April 13 1998:
No changes, but Preston Brown tested the sources in korganizer without
problems. I will send them to Kalle to check it in.

May 28 1998:
I got a patch from Andreas "highstick" Hochsteger, he added yearwise up 
and down buttons. I was very happy as I intended to do the same, and 
now he did. It looks good.

Aug 21 1998:
Added the method for setting the font size.

last change: May 28 1998			Mirko Sucker.


--- NEW FILE: ktabbar.h ---
/*  This file is part of the KDE Libraries
    Copyright (C) 1998 Thomas Tanghus (tanghus at earthling.net)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/  

#ifndef __KTABBAR_H__
#define __KTABBAR_H__

#include <kapp.h>
#include <kwizard.h>
#include <qtabbar.h>
#include <kdbtn.h>

struct KTabBarProtected;

#define JUMP 30

/**
* KTabBar is very similar to QTabBar. The only difference is that if the tab bar
* needs more space it provides left and right buttons used to scroll the tab bar.
* @short KTabBar
* @author Thomas Tanghus <tanghus at earthling.net>
* @version 0.1
*/
class KTabBar : public QWidget
{
    Q_OBJECT

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

    QTabBar *getQTab();
    QSize sizeHint();
    int addTab( QTab *tab );
    void setTabEnabled( int tab, bool enable );
    bool isTabEnabled( int tab );
    int currentTab();
    QTab *tab( int tab );
    int keyboardFocusTab();

public slots:
    void setCurrentTab( int tab );
    void setCurrentTab( QTab *tab );

signals:
    void selected( int );
    void scrolled( ArrowType );

protected slots:
    void leftClicked();
    void rightClicked();
    void emitSelected(int);

protected:
    void init();
    void setSizes();
    void resizeEvent ( QResizeEvent * );
    void paintEvent ( QPaintEvent * );

    KTabBarProtected *ptab;
};


#endif // __KTABBAR_H__




--- NEW FILE: kcontrol.cpp ---
/*
  kcontrol - Base for KDE Control Applications

  written 1997 by Matthias Hoelzer

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/


#include <klocale.h>


#include "kcontrol.h"
#include "kcontrol.h"

static int minimum_width_;

KControlDialog::KControlDialog()
  : QTabDialog(0, 0, FALSE)
{
  // Create help button
  helpBtn = new QPushButton(klocale->translate("Help"), this);
  helpBtn->resize(helpBtn->sizeHint());
  helpBtn->move(7, height() - helpBtn->height() - 6);


  // Create default button
  defaultBtn = new QPushButton(klocale->translate("Default"), this);
  defaultBtn->resize(defaultBtn->sizeHint());
  defaultBtn->move(helpBtn->width()+16, height() - defaultBtn->height() - 6);

  // set the default buttons
  setOKButton(klocale->translate("OK"));
  setApplyButton(klocale->translate("Apply"));
  setCancelButton(klocale->translate("Cancel"));

  //geometry hack.
  defaultBtn->setText(klocale->translate("OK"));
  int w = defaultBtn->sizeHint().width();
  defaultBtn->setText(klocale->translate("Apply"));
  w  = QMAX(w, defaultBtn->sizeHint().width());
  defaultBtn->setText(klocale->translate("Cancel"));
  w  = QMAX(w, defaultBtn->sizeHint().width());

  defaultBtn->setText(klocale->translate("Default"));


  minimum_width_ = w*3+20+ defaultBtn->width() + 30 + helpBtn->width();
}

void KControlDialog::done(int result)
{
  hide();
  setResult(result);
  kapp->quit();
}


void KControlDialog::resizeEvent(QResizeEvent *event)
{
  QTabDialog::resizeEvent(event);

  if (helpBtn)
    helpBtn->move(7, height() - helpBtn->height() - 6);
  if (defaultBtn)
    defaultBtn->move(16+helpBtn->width(), height() - helpBtn->height() - 6);
}


KControlApplication::KControlApplication(int &argc, char **argv, const char *name)
  : KApplication(argc, argv, name)
{
  dialog = 0;
  pages = 0;

  // called to initialize?
  if (argc == 2 && strcmp("-init", argv[1]) == 0)
    {
      init();
      justInit = TRUE;
      return;
    }

  // run the setup dialog
  justInit = FALSE;

  // create setup dialog
  dialog = new KControlDialog();
  if (!dialog)
    return;
  // Stephan: this is not possible (or better: not practical)
  // dialog->setCaption(klocale->translate(title));

  // connect the buttons
  connect(dialog, SIGNAL(applyButtonPressed()), this, SLOT(apply()));
  connect(dialog->helpBtn, SIGNAL(pressed()), this, SLOT(help()));
  connect(dialog->defaultBtn, SIGNAL(pressed()), this, SLOT(defaultValues()));

  // set dialog as main widget
  setMainWidget(dialog);

  // detect, if swallowing
  int start=1;
  if (argc >= 3 && strcmp(argv[1],"-swallow") == 0)
    {
      swallowCaption = argv[2];
      start = 3;
    }

  dialog->setCaption( swallowCaption );
  
  // parse the command line parameters, if any
  if (argc > start)
    {
      pages = new QStrList();
      if (pages)
	{
	  for (int i=start; i<argc; i++)
	    pages->append(argv[i]);
	}
    }

}


void KControlApplication::setTitle(const char *title)
{
  if (dialog && swallowCaption.isEmpty())
      dialog->setCaption(title);
}

KControlApplication::~KControlApplication()
{
  if (dialog)
    delete dialog;
  if (pages)
    delete pages;
}


void KControlApplication::addPage(QWidget *page, const QString &name, const QString &help_name)
{
  if (dialog)
    {
      dialog->addTab(page, name);
      helpNames.append(help_name.data());
      // set the default size
      dialog->resize(QMAX(dialog->sizeHint().width(), minimum_width_), dialog->height());
    }
}


void KControlApplication::help()
{
  QString name("index.html");

  if (dialog)
    name = helpNames.at(dialog->tabBar()->currentTab());

  kapp->invokeHTMLHelp(QString("kcontrol/")+kapp->appName()+"/"+name, "");
}
#include "kcontrol.moc"

--- NEW FILE: ktopwidget.h ---
#ifndef _KTOPWIDGET_H
#define _KTOPWIDGET_H

#include <ktmainwindow.h>

/**
 * This was top level widget. It inherits KTMainWindow completely now.
 * You can still use is under this name, if you are so nostalgic.
 * You shouldn't use this widget it might be removed from libraries
 * in future.
 * @see KTMainWindow
 * @short Old KDE top level window
 * @author Stephan Kulow (coolo at kde.org), was maintained by Sven Radej (radej at kde.org)
 */

class KTopLevelWidget : public KTMainWindow {
    Q_OBJECT

     friend class KToolBar;

public:
    /**
     * Constructor.
     */
    KTopLevelWidget( const char *name = 0L );
    /**
     * Destructor. 
     */
    ~KTopLevelWidget();

protected:
    /**
     * This is called when the widget is closed.
     * The default implementation jut calls accepts the event.
     * This method is only difference from KTMainWindow. Old
     * applications reimplement closeEvent, new should use 
     * @ref KTMainWindow and reimplement some of special handlers
     * there.
     */
    virtual void closeEvent ( QCloseEvent *);

};

#endif
//Eh!!!

--- NEW FILE: knotebook.cpp ---
/*  This file is part of the KDE Libraries
    Copyright (C) 1998 Thomas Tanghus (tanghus at earthling.net)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/  

#include "knotebook.h"

struct KNoteBookProtected
{
  KWizard     *currentwiz;
  QPushButton *cancel;
  QPushButton *ok;
  QPushButton *def;
  QPushButton *help;
  KTabBar     *tabbar;
  QWidget     *main;
  QPopupMenu  *menu;
  int         current;
  int         numtabs;
  int         currentmenu;
  bool        enablepopupmenu;
  bool        enablearrowbuttons;
  bool        directionsreflectspage;
};


KNoteBook::KNoteBook(QWidget *parent, const char *name, bool modal, WFlags f)
 : KDialog(parent, name, modal, f)
{
  initMetaObject();
  init();
}

KNoteBook::~KNoteBook()
{
  //debug("KNoteBook - destructor");
  delete pnote;
  delete sections;
  //debug("KNoteBook - destructor done");
}

void KNoteBook::init()
{
  //debug("KNoteBook::init");
  sections = new QList<KWizard>;
  sections->setAutoDelete(true);
  pnote = new KNoteBookProtected;
  pnote->directionsreflectspage = pnote->enablepopupmenu = pnote->enablearrowbuttons = false;
  pnote->current = -1;
  pnote->numtabs = 0;
  pnote->currentwiz = 0L;
  pnote->ok = pnote->cancel = pnote->def = pnote->help = 0L;
  pnote->tabbar = new KTabBar(this);
  connect( pnote->tabbar, SIGNAL(selected(int)), SLOT( showSection(int)) );
  connect( pnote->tabbar, SIGNAL(scrolled(ArrowType)),
                   SLOT( tabScroll(ArrowType)) );
  //debug("tabbar");
  pnote->menu = new QPopupMenu();
  connect( pnote->menu, SIGNAL(highlighted(int)), SLOT( menuChoice(int)) );
  connect( pnote->menu, SIGNAL(activatedRedirect(int)), SLOT( menuChoiceRedirect(int)) );

  //debug("init - done");
}

void KNoteBook::menuChoice(int c)
{
  //debug("Activated: %d", c);
  pnote->currentmenu = c;
}

void KNoteBook::tabScroll( ArrowType )
{
  //debug("KNoteBook::tabScroll");
  // fake a resize event to trigger child widget moves
  //QResizeEvent r( size(), size() );
  //resizeEvent( &r );
  //repaint(true);
}

void KNoteBook::menuChoiceRedirect(int c)
{
  //debug("ActivatedRedirect: %d", c);
  if(pnote->tabbar->isTabEnabled(pnote->currentmenu) && 
      sections->at(pnote->currentmenu)->isPageEnabled(c))
  {
    gotoTab(pnote->currentmenu);
    pnote->currentwiz->gotoPage(c);  
  }
}

int KNoteBook::addTab(QTab *tab, KWizardPage *p)
{
  //debug("addTab");
  int id = 0;
  KWizard *wiz = new KWizard(this, 0, false); // non-modal wizard
  wiz->setDirectionsReflectsPage(pnote->directionsreflectspage);
  wiz->setEnableArrowButtons(pnote->enablearrowbuttons);
  wiz->hide();
  //debug("KWizard created");
  sections->append(wiz);
  if(!pnote->numtabs) // the first tab
  {
    pnote->current = 0;
    pnote->currentwiz = wiz;
  }
  pnote->numtabs++;
  connect( wiz, SIGNAL(popup(QPoint)), SLOT(popupMenu(QPoint)) );
  connect( wiz, SIGNAL(nomorepages(bool, bool)), SLOT(directionButton(bool, bool)) );

  //tab->id = pnote->numtabs;
  //debug("Before adding to tabbar");
  id = pnote->tabbar->addTab(tab);
  pnote->menu->insertItem(tab->label, wiz->getMenu(), id);
  pnote->menu->setItemEnabled(id, tab->enabled);
  //debug("After adding to tabbar");

  if(p)
    wiz->addPage(p);

  setSizes();

  //debug("addTab - done");

  return id;
}

int KNoteBook::addPage(KWizardPage *p)
{
  if(!pnote->numtabs)
  {
    debug(klocale->translate("Trying to add page when no KWizards are added!"));
    return -1;
  }
  KWizard *wiz = sections->at(pnote->numtabs-1);
  CHECK_PTR(wiz);

  return (wiz->addPage(p));
}

void KNoteBook::gotoTab(int t)
{
  int i = 0;
  if(t < 0 || t >= pnote->numtabs || t == pnote->current)
    return;
  else if(t > pnote->current)
    for(i = t; i < pnote->numtabs; i++)
    {
      if(pnote->tabbar->isTabEnabled(i))
        break;
    }
  else
    for(i = t; i >= 0; i--)
    {
      if(pnote->tabbar->isTabEnabled(i))
        break;
    }
  //debug("gototab: %d", i);
  if(pnote->tabbar->isTabEnabled(i))
    pnote->tabbar->setCurrentTab(i);
}

void KNoteBook::setCancelButton()
{
  setCancelButton(klocale->translate("&Cancel"));
}

void KNoteBook::setCancelButton(const char *name)
{
  if(!pnote->cancel)
  {
    pnote->cancel = new QPushButton(name, this);
    pnote->cancel->show();
    connect( pnote->cancel, SIGNAL(clicked()), SLOT(cancelClicked()));
  }
  else
    pnote->cancel->setText(name);
  setSizes();
}

QButton *KNoteBook::getCancelButton()
{
  return pnote->cancel;
}

void KNoteBook::setDefaultButton()
{
  setDefaultButton(klocale->translate("&Default"));
}

void KNoteBook::setDefaultButton(const char *name)
{
  if(!pnote->def)
  {
    pnote->def = new QPushButton(name, this);
    pnote->def->show();
    connect( pnote->def, SIGNAL(clicked()), SLOT(defaultClicked()));
  }
  else
    pnote->def->setText(name);
  setSizes();
}

QButton *KNoteBook::getDefaultButton()
{
  return pnote->def;
}

void KNoteBook::setHelpButton()
{
  setHelpButton(klocale->translate("&Help"));
}

void KNoteBook::setHelpButton(const char *name)
{
  if(!pnote->help)
  {
    pnote->help = new QPushButton(name, this);
    pnote->help->show();
    connect( pnote->help, SIGNAL(clicked()), SLOT(helpClicked()));
  }
  else
    pnote->help->setText(name);
  setSizes();
}

QButton *KNoteBook::getHelpButton()
{
  return pnote->help;
}

void KNoteBook::setOkButton()
{
  setOkButton(klocale->translate("&OK"));
}

void KNoteBook::setOkButton(const char *name)
{
  if(!pnote->ok)
  {
    pnote->ok = new QPushButton(name, this);
    pnote->ok->show();
    connect( pnote->ok, SIGNAL(clicked()), SLOT(okClicked()));
  }
  else
    pnote->ok->setText(name);
  setSizes();
}

QButton *KNoteBook::getOkButton()
{
  return pnote->ok;
}

void KNoteBook::okClicked()
{
  emit okclicked();
}

void KNoteBook::cancelClicked()
{
  emit cancelclicked();
}

void KNoteBook::defaultClicked()
{
  emit defaultclicked(pnote->current);
}

void KNoteBook::helpClicked()
{
  emit helpclicked(pnote->current);
}

void KNoteBook::showSection(int s)
{
  //debug("showSection: %d", s);
  pnote->current = s;
  pnote->currentwiz->hide();
  pnote->currentwiz = sections->at(s);
  pnote->currentwiz->gotoPage(0);
  pnote->currentwiz->adjustSize();
  // fake a resize event to trigger child widget moves
  QResizeEvent r( size(), size() );
  resizeEvent( &r );
  pnote->currentwiz->show();
}

void KNoteBook::popupMenu(QPoint pos)
{
  if(pnote->enablepopupmenu)
  {
    pnote->menu->popup(pos);
  }
}

QSize KNoteBook::childSize()
{
  //debug("Calculating sizes");
  QSize size(0,0);
  //int x = 0, y = 0;
  for(int i = 0; i < pnote->numtabs; i++)
  {
    QSize csize = sections->at(i)->sizeHint();
    if(csize.isNull())
      csize = sections->at(i)->size();
    if(size.height() < csize.height())
      size.setHeight(csize.height());
    if(size.width() < csize.width())
      size.setWidth(csize.width());
    //debug("Child size: %d x %d", size.width(), size.height());
  }

  return size;
}

void KNoteBook::setEnableArrowButtons(bool state)
{
  pnote->enablearrowbuttons = state;
  for(int i = 0; i < pnote->numtabs; i++)
    sections->at(i)->setEnableArrowButtons(state);
}

bool KNoteBook::enableArrowButtons()
{
  return pnote->enablearrowbuttons;
}

void KNoteBook::setDirectionsReflectsPage(bool state)
{
  pnote->directionsreflectspage = state;
  for(int i = 0; i < pnote->numtabs; i++)
    sections->at(i)->setDirectionsReflectsPage(state);
  setSizes();
}

bool KNoteBook::directionsReflectsPage()
{
  return pnote->directionsreflectspage;
}

void KNoteBook::setEnablePopupMenu(bool state)
{
  pnote->enablepopupmenu = state;
}

bool KNoteBook::enablePopupMenu()
{
  return pnote->enablepopupmenu;
}

QPopupMenu *KNoteBook::getMenu()
{
  return pnote->menu;
}

KTabBar *KNoteBook::getTabBar()
{
  return pnote->tabbar;
}

void KNoteBook::setTabEnabled(int tab, bool state)
{
  pnote->tabbar->setTabEnabled( tab, state );
  pnote->menu->setItemEnabled( tab, state );
}

void KNoteBook::setPageEnabled(int tab, int page, bool state)
{
  sections->at(tab)->setPageEnabled( page, state );
}

bool KNoteBook::isTabEnabled(int tab)
{
  return pnote->tabbar->isTabEnabled(tab);
}

bool KNoteBook::isPageEnabled(int tab, int page)
{
  return sections->at(tab)->isPageEnabled(page);
}

int KNoteBook::numTabs()
{
  return pnote->numtabs;
}

void KNoteBook::directionButton(bool changetab, bool forward)
{
  //debug("directionButton");
  QButton *button, *arrow;
  QString str;

  if(changetab)
  {
    if(forward)
    {
      //debug("changing to tab: %d", current+1);
      gotoTab(pnote->current+1);
      button = pnote->currentwiz->getPreviousButton();
      arrow = pnote->currentwiz->getLeftArrow();
      if(pnote->directionsreflectspage)
      {
        str = "<< ";
        str += sections->at(pnote->current-1)->getTitle(sections->at(pnote->current-1)->numPages()-1);
        button->setText(str.data());
      }
      else
        button->setText(PREV);
      //debug("Setting previous to: %s", str.data());
      button->show();
      if(pnote->enablearrowbuttons)
        arrow->show();
    }
    else
    {
      //debug("changing to tab: %d", pnote->current-1);
      gotoTab(pnote->current-1);
      pnote->currentwiz->gotoPage(pnote->currentwiz->numPages()-1);
      button = pnote->currentwiz->getNextButton();
      arrow = pnote->currentwiz->getRightArrow();
      if(pnote->directionsreflectspage)
      {
        str = sections->at(pnote->current+1)->getTitle(0);
        str += " >>";
        button->setText(str.data());
      }
      else
        button->setText(NEXT);
      //debug("Setting next to: %s", str.data());
      button->show();
      if(pnote->enablearrowbuttons)
        arrow->show();
    }
  }
  else
  {
    //debug("dont change tab");
    if(forward)
    {
      button = pnote->currentwiz->getNextButton();
      arrow = pnote->currentwiz->getRightArrow();
      if((pnote->current+1) >= pnote->numtabs)
      {
        button->hide();
        if(pnote->enablearrowbuttons)
          arrow->hide();
      }
      else
      {
        str = sections->at(pnote->current+1)->getTitle(0);
        str += " >>";
        //debug("Setting next to: %s", str.data());
        button->setText(str.data());
        button->show();
        if(pnote->enablearrowbuttons)
          arrow->show();
      }
    }
    else
    {
      button = pnote->currentwiz->getPreviousButton();
      arrow = pnote->currentwiz->getLeftArrow();
      if((pnote->current) == 0)
      {
        button->hide();
        if(pnote->enablearrowbuttons)
          arrow->hide();
      }
      else
      {
        str = "<< ";
        str += sections->at(pnote->current-1)->getTitle(sections->at(pnote->current-1)->numPages()-1);
        //debug("Setting previous to: %s", str.data());
        button->setText(str.data());
        button->show();
        if(pnote->enablearrowbuttons)
          arrow->show();
      }
    }
  }
}

void KNoteBook::setSizes()
{
  //debug("setSizes");
  QSize childsize = childSize();

  int extra = 16;
  bool f = false;
  if(pnote->ok)
  {
    pnote->ok->adjustSize();
    f = true;
    extra += pnote->ok->height();
  }
  if(pnote->cancel)
  {
    pnote->cancel->adjustSize();
    if(!f)
    {
      f = true;
      extra += pnote->cancel->height();
    }
  }
  if(pnote->def)
  {
    pnote->def->adjustSize();
    if(!f)
    {
      f = true;
      extra += pnote->def->height();
    }
  }
  if(pnote->help)
  {
    pnote->help->adjustSize();
    if(!f)
      extra += pnote->help->height();
  }

  pnote->tabbar->adjustSize();
  int y = pnote->tabbar->height() + childsize.height() + extra;
  int x = 16 + childsize.width();
  setMinimumSize(x, y);
  resize(x, y);
  //debug("setSizes - done");
}

void KNoteBook::resizeEvent(QResizeEvent *)
{
  //debug("KNote, resizing");

  pnote->tabbar->setGeometry( 2, 2, width()-3, pnote->tabbar->sizeHint().height());

  // Check to see if there are any buttons.
  QPushButton *tmp = 0L;
  int x = 8, y = pnote->tabbar->height() + 7;
  int cx = width() - 14, cy = height()-(pnote->tabbar->height()+14);
  if( pnote->ok && pnote->ok->isVisible() )
    tmp = pnote->ok;
  else if(pnote->cancel && pnote->cancel->isVisible())
    tmp = pnote->cancel;
  else if(pnote->def && pnote->def->isVisible())
    tmp = pnote->def;
  else if(pnote->help && pnote->help->isVisible())
    tmp = pnote->help;
  if(tmp)
    cy -= (tmp->height());

  if(pnote->currentwiz)
    pnote->currentwiz->setGeometry( x, y, cx, cy );

  int offs = 2;
  if(pnote->ok && pnote->ok->isVisible())
  {
    pnote->ok->setGeometry(offs, height()-(pnote->ok->height()+2),
                           pnote->ok->width(), pnote->ok->height());
    offs += 5 + pnote->ok->width();
  }
  if(pnote->cancel && pnote->cancel->isVisible())
  {
    pnote->cancel->setGeometry(offs, height()-(pnote->cancel->height()+2),
                           pnote->cancel->width(), pnote->cancel->height());
    offs += 5 + pnote->cancel->width();
  }
  if(pnote->def && pnote->def->isVisible())
    pnote->def->setGeometry(offs, height()-(pnote->def->height()+2),
                           pnote->def->width(), pnote->def->height());
  if(pnote->help && pnote->help->isVisible())
    pnote->help->setGeometry(width()-(pnote->help->width()+1),
                             height()-(pnote->help->height()+2),
                             pnote->help->width(), pnote->help->height());

  //debug("KNote, resize - done");
}

void KNoteBook::paintEvent(QPaintEvent *)
{
  //debug("KNoteBook::paintEvent");
  // Check to see if there are any buttons.
  QPushButton *tmp = 0L;
  int w = width(), h = height(), s = 2;
  int tw = pnote->tabbar->width();
  int boffs = 4, toffs = pnote->tabbar->height() + 1;
  if( pnote->ok && pnote->ok->isVisible() )
    tmp = pnote->ok;
  else if(pnote->cancel && pnote->cancel->isVisible())
    tmp = pnote->cancel;
  else if(pnote->def && pnote->def->isVisible())
    tmp = pnote->def;
  else if(pnote->help && pnote->help->isVisible())
    tmp = pnote->help;
  if(tmp)
    boffs = tmp->height() + 4;

  // start painting widget
  QPainter paint;
  paint.begin( this );
  QPen pen( white, 1 );
  paint.setPen( pen );

  // left outer
  paint.drawLine( s, h-(boffs), s, toffs-1);

  // top outer
  paint.drawLine( tw+s , toffs, w-s, toffs);
  
  // right inner
  paint.drawLine( w-(s*3) , toffs+(s*2)+1, w-(s*3), h-(boffs+(s+1)));

  // bottom inner
  paint.drawLine( (s*3)+1 , h-(boffs+(s*2)-1), w-(s*3), h-(boffs+(s*2)-1));

  pen.setColor( black );
  paint.setPen( pen );

  // right outer
  paint.drawLine( w-s , toffs+1, w-s, h-(boffs));

  // bottom outer
  paint.drawLine( w-s , h-(boffs), s+1, h-(boffs));

  // left inner
  paint.drawLine( s*3 , h-(boffs+(s+1)), s*3, toffs+((s*2)+1) );

  // top inner
  paint.drawLine( (s*3)+1, toffs+(s*2), w-(s*3), toffs+(s*2));

  paint.end();
}
/*
// Grab QDialogs keypresses if non-modal
bool KNoteBook::eventFilter( QObject *obj, QEvent *e )
{
  if ( e->type() == Event_KeyPress && obj == this && !testWFlags(WType_Modal))
  {
    QKeyEvent *k = (QKeyEvent*)e;
    if(k->key() == Key_Escape || k->key() == Key_Return || k->key() == Key_Enter)
      return true;
  }

  return false;
}
*/

#include "knotebook.moc"

--- NEW FILE: kruler.h ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: keditcl2.cpp ---
 /*

  $Id: keditcl2.cpp,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
 
  kedit, a simple text editor for the KDE project
  
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
  
  KEdit, simple editor class, hacked version of the original by 

 
  */

#include "keditcl.h"
#include <klocale.h>
#include <kapp.h>




//////////////////////////////////////////////////////////////////////////
//
// Find Methods
//
 
void KEdit::Search(){

  if (replace_dialog)
	if (replace_dialog->isVisible())
		replace_dialog->hide();
  

  if(!srchdialog){
    srchdialog = new KEdSrch(0, "searchdialog");
    connect(srchdialog,SIGNAL(search_signal()),this,SLOT(search_slot()));
    connect(srchdialog,SIGNAL(search_done_signal()),this,SLOT(searchdone_slot()));
  }

  // If we already searched / replaced something before make sure it shows
  // up in the find dialog line-edit.

  QString string;
  string = srchdialog->getText();
  if(string.isEmpty())
    srchdialog->setText(pattern);

  this->deselect();
  last_search = NONE;

  this->clearFocus();

  QPoint point = this->mapToGlobal (QPoint (0,0));

  QRect pos = this->geometry();
  srchdialog->setGeometry(point.x() + pos.width()/2  - srchdialog->width()/2,
			   point.y() + pos.height()/2 - srchdialog->height()/2, 
			   srchdialog->width(),
			   srchdialog->height());
   
  srchdialog->show();
  srchdialog->result();
}


void KEdit::search_slot(){

  int line, col;

  if (!srchdialog)
    return;

  QString to_find_string = srchdialog->getText();
  getCursorPosition(&line,&col);
  
  // srchdialog->get_direction() is true if searching backward

  if (last_search != NONE && srchdialog->get_direction()){
    col = col  - pattern.length() - 1 ;
  }

again:
  int  result = doSearch(to_find_string, srchdialog->case_sensitive(),
			 FALSE, (!srchdialog->get_direction()),line,col);
    
  if(result == 0){
    if(!srchdialog->get_direction()){ // forward search
    
      int query = QMessageBox::information(
					   srchdialog,
					   klocale->translate("Find"), 
					   klocale->translate("End of document reached.\n"\
							      "Continue from the beginning?"), 
					   klocale->translate("Yes"),
					   klocale->translate("No"),
					   "",
					   0,1);
      if (query == 0){
	line = 0;
	col = 0;
	goto again;
      }
    }
    else{ //backward search
      
      int query = QMessageBox::information(
					   srchdialog,
					   klocale->translate("Find"), 
					   klocale->translate("Beginning of document reached.\n"\
							      "Continue from the end?"), 
					   klocale->translate("Yes"),
					   klocale->translate("No"),
					   "",
					   0,1);
      if (query == 0){
	QString string = textLine( numLines() - 1 );
	line = numLines() - 1;
	col  = string.length();
	last_search = BACKWARD;
	goto again;
      }
    }
  }
  else{
    emit CursorPositionChanged(); 
  }
}



void KEdit::searchdone_slot(){

  if (!srchdialog)
    return;

  srchdialog->hide();
  this->setFocus();
  last_search = NONE;

}

int KEdit::doSearch(QString s_pattern, bool case_sensitive, 
		    bool wildcard, bool forward, int line, int col){

  (void) wildcard; // reserved for possible extension to regex


  int i, length;  
  int pos = -1;

  if(forward){

    QString string;

    for(i = line; i < numLines(); i++) {

      string = textLine(i);

      pos = string.find(s_pattern, i == line ? col : 0, case_sensitive);
      
      if( pos != -1){
      
	length = s_pattern.length();

	setCursorPosition(i,pos,FALSE);
      
	for(int l = 0 ; l < length; l++){
	  cursorRight(TRUE);
	}
      
	setCursorPosition( i , pos + length, TRUE );
	pattern = s_pattern;
	last_search = FORWARD;

	return 1;
      }
    }
  }
  else{ // searching backwards

    QString string;
    
    for(i = line; i >= 0; i--) {

      string = textLine(i);
      int line_length = string.length();

      pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive);

      if (pos != -1){

	length = s_pattern.length();

	if( ! (line == i && pos > col ) ){

	  setCursorPosition(i ,pos ,FALSE );
      
	  for(int l = 0 ; l < length; l++){
	    cursorRight(TRUE);
	  }	
      
	  setCursorPosition(i ,pos + length ,TRUE );
	  pattern = s_pattern;
	  last_search = BACKWARD;
	  return 1;

	}
      }

    }
  }
  
  return 0;

}



int KEdit::repeatSearch() {
  
  if(!srchdialog)
      return 0;


  if(pattern.isEmpty()) // there wasn't a previous search
    return 0;

  search_slot();

  this->setFocus();
  return 1;

}


//////////////////////////////////////////////////////////////////////////
//
// Replace Methods
//


void KEdit::Replace(){

  if (srchdialog)
	if (srchdialog->isVisible())
		srchdialog->hide();
  

  if (!replace_dialog){
    
    replace_dialog = new KEdReplace(0, "replace_dialog");
    connect(replace_dialog,SIGNAL(find_signal()),this,SLOT(replace_search_slot()));
    connect(replace_dialog,SIGNAL(replace_signal()),this,SLOT(replace_slot()));
    connect(replace_dialog,SIGNAL(replace_all_signal()),this,SLOT(replace_all_slot()));
    connect(replace_dialog,SIGNAL(replace_done_signal()),this,SLOT(replacedone_slot()));
  
  }

  QString string = replace_dialog->getText();

  if(string.isEmpty())
    replace_dialog->setText(pattern);


  this->deselect();
  last_replace = NONE;

  this->clearFocus();

  QPoint point = this->mapToGlobal (QPoint (0,0));

  QRect pos = this->geometry();
  replace_dialog->setGeometry(point.x() + pos.width()/2  - replace_dialog->width()/2,
			   point.y() + pos.height()/2 - replace_dialog->height()/2, 
			   replace_dialog->width(),
			   replace_dialog->height());
  replace_dialog->show();
  replace_dialog->result();
}


void KEdit::replace_slot(){

  if (!replace_dialog)
    return;

  if(!can_replace){
    QApplication::beep();
    return;
  }

  int line,col, length;

  QString string = replace_dialog->getReplaceText();
  length = string.length();

  this->cut();

  getCursorPosition(&line,&col);

  insertAt(string,line,col);
  setModified();
  can_replace = FALSE;

  setCursorPosition(line,col);
  for( int k = 0; k < length; k++){
    cursorRight(TRUE);
  }

}

void KEdit::replace_all_slot(){

  if (!replace_dialog)
    return;

  QString to_find_string = replace_dialog->getText();
  getCursorPosition(&replace_all_line,&replace_all_col);
  
  // replace_dialog->get_direction() is true if searching backward

  if (last_replace != NONE && replace_dialog->get_direction()){
    replace_all_col = replace_all_col  - pattern.length() - 1 ;
  }
  
  deselect();

again:

  setAutoUpdate(FALSE);
  int result = 1;

  while(result){

    result = doReplace(to_find_string, replace_dialog->case_sensitive(),
		       FALSE, (!replace_dialog->get_direction()),
		       replace_all_line,replace_all_col,TRUE);

  }

  setAutoUpdate(TRUE);
  update();
    
  if(!replace_dialog->get_direction()){ // forward search
    
    int query = QMessageBox::information(
				   replace_dialog,
				   klocale->translate("Find"), 
				   klocale->translate("End of document reached.\n"\
						      "Continue from the beginning?"), 
				   klocale->translate("Yes"),
				   klocale->translate("No"),
				   "",
				   0,1);
    if (query == 0){
      replace_all_line = 0;
      replace_all_col = 0;
      goto again;
    }
  }
  else{ //backward search
    
    int query = QMessageBox::information(
				   replace_dialog,
				   klocale->translate("Find"), 
				   klocale->translate("Beginning of document reached.\n"\
						      "Continue from the end?"), 
				   klocale->translate("Yes"),
				   klocale->translate("No"),
				   "",
				   0,1);
    if (query == 0){
      QString string = textLine( numLines() - 1 );
      replace_all_line = numLines() - 1;
      replace_all_col  = string.length();
      last_replace = BACKWARD;
      goto again;
    }
  }

  emit CursorPositionChanged(); 

}


void KEdit::replace_search_slot(){

  int line, col;

  if (!replace_dialog)
    return;

  QString to_find_string = replace_dialog->getText();
  getCursorPosition(&line,&col);
  
  // replace_dialog->get_direction() is true if searching backward

  //printf("col %d length %d\n",col, pattern.length());

  if (last_replace != NONE && replace_dialog->get_direction()){
    col = col  - pattern.length() -1;
    if (col < 0 ) {
      if(line !=0){
	col = strlen(textLine(line - 1));
	line --;
      }
      else{

	int query = QMessageBox::information(
			 replace_dialog,
			 klocale->translate("Replace"), 
			 klocale->translate("Beginning of document reached.\n"\
					    "Continue from the end?"), 
			 klocale->translate("Yes"),
			 klocale->translate("No"),
			 "",
			 0,1);

	if (query == 0){
	  QString string = textLine( numLines() - 1 );
	  line = numLines() - 1;
	  col  = string.length();
	  last_replace = BACKWARD;
	}
      }
    }
  }

again:

  //  printf("Col %d \n",col);

  int  result = doReplace(to_find_string, replace_dialog->case_sensitive(),
			 FALSE, (!replace_dialog->get_direction()), line, col, FALSE );
    
  if(result == 0){
    if(!replace_dialog->get_direction()){ // forward search
    
      int query = QMessageBox::information(
				     replace_dialog,
				     klocale->translate("Replace"), 
				     klocale->translate("End of document reached.\n"\
							"Continue from the beginning?"), 
				     klocale->translate("Yes"),
				     klocale->translate("No"),
				     "",
				     0,1);
      if (query == 0){
	line = 0;
	col = 0;
	goto again;
      }
    }
    else{ //backward search
      
      int query = QMessageBox::information(
					   replace_dialog,
					   klocale->translate("Replace"), 
					   klocale->translate("Beginning of document reached.\n"\
							      "Continue from the end?"), 
					   klocale->translate("Yes"),
					   klocale->translate("No"),
					   "",
					   0,1);
      if (query == 0){
	QString string = textLine( numLines() - 1 );
	line = numLines() - 1;
	col  = string.length();
	last_replace = BACKWARD;
	goto again;
      }
    }
  }
  else{

    emit CursorPositionChanged(); 
  }
}



void KEdit::replacedone_slot(){

  if (!replace_dialog)
    return;
  
  replace_dialog->hide();
  //  replace_dialog->clearFocus();

  this->setFocus();

  last_replace = NONE;
  can_replace  = FALSE;

}



int KEdit::doReplace(QString s_pattern, bool case_sensitive, 
	   bool wildcard, bool forward, int line, int col, bool replace_all){


  (void) wildcard; // reserved for possible extension to regex

  int line_counter, length;  
  int pos = -1;

  QString string;
  QString stringnew;
  QString replacement;
  
  replacement = replace_dialog->getReplaceText();
  line_counter = line;
  replace_all_col = col;

  if(forward){

    int num_lines = numLines();

    while (line_counter < num_lines){
      
      string = "";
      string = textLine(line_counter);

      if (replace_all){
	pos = string.find(s_pattern, replace_all_col, case_sensitive);
      }
      else{
	pos = string.find(s_pattern, line_counter == line ? col : 0, case_sensitive);
      }

      if (pos == -1 ){
	line_counter ++;
	replace_all_col = 0;
	replace_all_line = line_counter;
      }

      if( pos != -1){

	length = s_pattern.length();
	
	if(replace_all){ // automatic

	  stringnew = string.copy();
	  stringnew.replace(pos,length,replacement);

	  removeLine(line_counter);
	  insertLine(stringnew.data(),line_counter);

	  replace_all_col = replace_all_col + replacement.length();
	  replace_all_line = line_counter;

	  setModified();
	}
	else{ // interactive

	  setCursorPosition( line_counter , pos, FALSE );

	  for(int l = 0 ; l < length; l++){
	    cursorRight(TRUE);
	  }

	  setCursorPosition( line_counter , pos + length, TRUE );
	  pattern = s_pattern;
	  last_replace = FORWARD;
	  can_replace = TRUE;

	  return 1;

	}
	
      }
    }
  }
  else{ // searching backwards

    while(line_counter >= 0){

      string = "";
      string = textLine(line_counter);

      int line_length = string.length();

      if( replace_all ){
      	pos = string.findRev(s_pattern, replace_all_col , case_sensitive);
      }
      else{
	pos = string.findRev(s_pattern, 
			   line == line_counter ? col : line_length , case_sensitive);
      }

      if (pos == -1 ){
	line_counter --;

	if(line_counter >= 0){
	  string = "";
	  string = textLine(line_counter);
	  replace_all_col = string.length();
	  
	}
	replace_all_line = line_counter;
      }


      if (pos != -1){
	length = s_pattern.length();

	if(replace_all){ // automatic

	  stringnew = string.copy();
	  stringnew.replace(pos,length,replacement);

	  removeLine(line_counter);
	  insertLine(stringnew.data(),line_counter);

	  replace_all_col = replace_all_col - replacement.length();
	  replace_all_line = line_counter;

	  setModified();

	}
	else{ // interactive

	  //	  printf("line_counter %d pos %d col %d\n",line_counter, pos,col);
	  if( ! (line == line_counter && pos > col ) ){

	    setCursorPosition(line_counter ,pos ,FALSE );
      
	    for(int l = 0 ; l < length; l++){
	      cursorRight(TRUE);
	    }	
	
	    setCursorPosition(line_counter ,pos + length ,TRUE );
	    pattern = s_pattern;

	    last_replace = BACKWARD;
	    can_replace = TRUE;

	    return 1;
	  }
	}
      }
    }
  }
  
  return 0;

}





////////////////////////////////////////////////////////////////////
//
// Find Dialog
//


KEdSrch::KEdSrch(QWidget *parent, const char *name)
    : QDialog(parent, name,FALSE){

    this->setFocusPolicy(QWidget::StrongFocus);
    frame1 = new QGroupBox(klocale->translate("Find"), this, "frame1");

    value = new QLineEdit( this, "value");
    value->setFocus();
    connect(value, SIGNAL(returnPressed()), this, SLOT(ok_slot()));

    sensitive = new QCheckBox(klocale->translate("Case Sensitive"), this, "case");
    direction = new QCheckBox(klocale->translate("Find Backwards"), this, "direction");

    ok = new QPushButton(klocale->translate("Find"), this, "find");
    connect(ok, SIGNAL(clicked()), this, SLOT(ok_slot()));

    cancel = new QPushButton(klocale->translate("Done"), this, "cancel");
    connect(cancel, SIGNAL(clicked()), this, SLOT(done_slot()));
    //    connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));

    setFixedSize(330, 130);

}

void KEdSrch::focusInEvent( QFocusEvent *)
{
    value->setFocus();
    //value->selectAll();
}

QString KEdSrch::getText() { return value->text(); }

void KEdSrch::setText(QString string){

  value->setText(string);

}

void KEdSrch::done_slot(){

  emit search_done_signal();

}


bool KEdSrch::case_sensitive(){

  return sensitive->isChecked();

}

bool KEdSrch::get_direction(){

  return direction->isChecked();

}


void KEdSrch::ok_slot(){

  QString text;

  text = value->text();

  if (!text.isEmpty())
    emit search_signal();

}


void KEdSrch::resizeEvent(QResizeEvent *){


    frame1->setGeometry(5, 5, width() - 10, 80);
    cancel->setGeometry(width() - 80, height() - 30, 70, 25);
    ok->setGeometry(10, height() - 30, 70, 25);
    value->setGeometry(20, 25, width() - 40, 25);
    sensitive->setGeometry(20, 55, 110, 25);
    direction->setGeometry(width()- 20 - 130, 55, 130, 25);

}



////////////////////////////////////////////////////////////////////
//
//  Replace Dialog
//


KEdReplace::KEdReplace(QWidget *parent, const char *name)
    : QDialog(parent, name,FALSE){


    this->setFocusPolicy(QWidget::StrongFocus);

    frame1 = new QGroupBox(klocale->translate("Find:"), this, "frame1");

    value = new QLineEdit( this, "value");
    value->setFocus();
    connect(value, SIGNAL(returnPressed()), this, SLOT(ok_slot()));

    replace_value = new QLineEdit( this, "replac_value");
    connect(replace_value, SIGNAL(returnPressed()), this, SLOT(ok_slot()));

    label = new QLabel(this,"Rlabel");
    label->setText(klocale->translate("Replace with:"));

    sensitive = new QCheckBox(klocale->translate("Case Sensitive"), this, "case");
    sensitive->setChecked(TRUE);

    direction = new QCheckBox(klocale->translate("Find Backwards")
			      , this, "direction");
    
    ok = new QPushButton(klocale->translate("Find"), this, "find");
    connect(ok, SIGNAL(clicked()), this, SLOT(ok_slot()));

    replace = new QPushButton(klocale->translate("Replace"), this, "rep");
    connect(replace, SIGNAL(clicked()), this, SLOT(replace_slot()));

    replace_all = new QPushButton(klocale->translate("Replace All"), this, "repall");
    connect(replace_all, SIGNAL(clicked()), this, SLOT(replace_all_slot()));

    cancel = new QPushButton(klocale->translate("Done"), this, "cancel");
    connect(cancel, SIGNAL(clicked()), this, SLOT(done_slot()));

    setFixedSize(330, 180);

}


void KEdReplace::focusInEvent( QFocusEvent *){

    value->setFocus();
    // value->selectAll();
}

QString KEdReplace::getText() { return value->text(); }

QString KEdReplace::getReplaceText() { return replace_value->text(); }

void KEdReplace::setText(QString string) { 

  value->setText(string); 

}

void KEdReplace::done_slot(){

  emit replace_done_signal();

}


void KEdReplace::replace_slot(){

  emit replace_signal();

}

void KEdReplace::replace_all_slot(){

  emit replace_all_signal();

}


bool KEdReplace::case_sensitive(){

  return sensitive->isChecked();

}


bool KEdReplace::get_direction(){

  return direction->isChecked();

}


void KEdReplace::ok_slot(){

  QString text;
  text = value->text();

  if (!text.isEmpty())
    emit find_signal();

}


void KEdReplace::resizeEvent(QResizeEvent *){

    frame1->setGeometry(5, 5, width() - 10, 135);

    cancel->setGeometry(width() - 80, height() - 30, 70, 25);
    ok->setGeometry(10, height() - 30, 70, 25);
    replace->setGeometry(85, height() - 30, 70, 25);
    replace_all->setGeometry(160, height() - 30, 85, 25);

    value->setGeometry(20, 25, width() - 40, 25);
    replace_value->setGeometry(20, 80, width() - 40, 25);
    
    label->setGeometry(20,55,80,20);
    sensitive->setGeometry(20, 110, 110, 25);
    direction->setGeometry(width()- 20 - 130, 110, 130, 25);

}





KEdGotoLine::KEdGotoLine( QWidget *parent, const char *name)
	: QDialog( parent, name, TRUE )
{
	frame = new QGroupBox( klocale->translate("Goto Line"), this );
	lineNum = new KIntLineEdit( this );
	this->setFocusPolicy( QWidget::StrongFocus );
	connect(lineNum, SIGNAL(returnPressed()), this, SLOT(accept()));

	ok = new QPushButton(klocale->translate("Go"), this );
	cancel = new QPushButton(klocale->translate("Cancel"), this ); 

	connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
	connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
	resize(300, 120); 

}

void KEdGotoLine::selected(int)
{
	accept();
}

void KEdGotoLine::resizeEvent(QResizeEvent *)
{
    frame->setGeometry(5, 5, width() - 10, 80);
    cancel->setGeometry(width() - 80, height() - 30, 70, 25);
    ok->setGeometry(10, height() - 30, 70, 25);
    lineNum->setGeometry(20, 35, width() - 40, 25);
}

void KEdGotoLine::focusInEvent( QFocusEvent *)
{
    lineNum->setFocus();
    lineNum->selectAll();
}

int KEdGotoLine::getLineNumber()
{
	return lineNum->getValue();
}

--- NEW FILE: klined.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Sven Radej (sven.radej at iname.com)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
// This was taken from filentry.h
// fileentry.h is part of KFM II, by Torben Weis



#ifndef _KLINED_H
#define _KLINED_H
#include <qlineedit.h>

/**
 * This widget has the same behaviour as QLineEditor, but emits
 * signals for two more key-events: @ref completion when Ctrl-D is
 * pressed and  @ref rotation when Ctrl-S is pressed. This
 * class is inspired by Torben Weis' fileentry.cpp for KFM II
 * @short KDE Line input widget
 */

class KLined : public QLineEdit
{
  Q_OBJECT
        
public:
  KLined ( QWidget *parent=0, const char *name=0 );
  ~KLined ();

  /**
    * This puts cursor at and of string. When using out of toolbar,
    * call this in your slot connected to signal completion.
    */
  void cursorAtEnd();

  signals:

  /**
	* Connect to this signal to receive Ctrl-D
	*/
  void completion ();
    
  /**
	* Connect to this signal to receive Ctrl-S
	*/
  void rotation ();
    
 protected:
     bool eventFilter (QObject *, QEvent *);
 };

#endif

--- NEW FILE: kdatetbl.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Tim D. Gilman (tdgilman at best.org)
              (C) 1998, 1999 Mirko Sucker (mirko at kde.org)
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/////////////////// KDateTable widget class //////////////////////
//
// Copyright (C) 1997 Tim D. Gilman
//           (C) 1998, 1999 Mirko Sucker
// Original header from Tim:
// Written using Qt (http://www.troll.no) for the
// KDE project (http://www.kde.org)
//
// This is a support class for the KDatePicker class.  It just
// draws the calender table without titles, but could theoretically
// be used as a standalone.
//
// When a date is selected by the user, it emits a signal: 
//      dateSelected(QDate)


#include <qpainter.h>
#include <qstring.h>
#include <kapp.h>

#include "kdatetbl.h"
#include "kdatetbl.h"

KDateTable::KDateTable(QWidget *parent, QDate date, 
		       const char *name, WFlags f) 
  : QTableView(parent, name, f),
    fontsize(10)
{
  initMetaObject();
  // Mirko, March 17 1998: translate day names
  Days[0]=i18n("Sun"); Days[1]=i18n("Mon"); Days[2]=i18n("Tue"); 
  Days[3]=i18n("Wed"); Days[4]=i18n("Thu"); Days[5]=i18n("Fri"); 
  Days[6]=i18n("Sat");
  // ^^^^^^^^^^^^^^^^^^^^^^^^^
  setBackgroundColor(white);

  setNumRows(7);
  setNumCols(7);
  setTableFlags(Tbl_clipCellPainting);

  QRect rec = contentsRect();
  setCellWidth(rec.width()/7);
  setCellHeight(rec.height()/7);
   
  m_oldRow = m_oldCol = 0;
  m_selRow = m_selCol = 0;
  m_bSelection = FALSE;

  setFocusPolicy(StrongFocus);

  // initialize date
  m_date = date;

  // get the day of the week on the first day
  QDate dayone(m_date.year(), m_date.month(), 1);
  m_firstDayOfWeek = dayone.dayOfWeek();

  // determine number of days in previous month
  QDate prvmonth;
  getPrevMonth(m_date, prvmonth);   
  m_daysInPrevMonth = prvmonth.daysInMonth();
}

KDateTable::~KDateTable()
{
}

void KDateTable::paintCell( QPainter *p, int row, int col )
{
  const int w = cellWidth();
  const int h = cellHeight();
  bool bSelected = FALSE;

  if (row==0) 
    { // paint headline
      p->setPen(darkBlue);
      p->setFont(QFont("Arial", fontsize, QFont::Bold, false));
      p->drawText(0, 0, w, h, AlignCenter, Days[col]);
      p->setPen(black);
      p->moveTo(0, h-1);
      p->lineTo(w-1, h-1);
    } else { // paint day cell
      int nDay = dayNum(row, col);
      p->setFont(QFont("Arial", fontsize));
      /* Will be implemented the next time: the preset date
       * will be drawn with a gray background to give feedback 
       * to the user. --Mirko
       {
       int x, y; 
       // calculate row & column of current date:
       // this is missing
       // test if we are displaying the right year and month:
       // this is missing
       // draw the current date with a gray background:
       if(row==y && col==x)
       {
       p->setPen(lightGray);
       p->setBrush(lightGray);
       p->drawRect(0, 0, w, h);
       }
       }
      */
      if (m_bSelection && row==m_selRow && col==m_selCol) 
	{  // item is selected
	  bSelected = TRUE;
	  p->setBrush(darkBlue);
	  p->setPen(red);
	  p->drawEllipse(4,h/2-(w-8)/3,w-8,2*(w-8)/3); // think of better way
	}
      QString day;
      day.sprintf("%i", nDay);
      p->setPen(bSelected? white : black);
      if (nDay > 0 && nDay <= m_date.daysInMonth()) 
	{
	  p->drawText(0, 0, w, h, AlignCenter, day);
	} else if (nDay <= 0) 
	  {
	    int nDayPrv = m_daysInPrevMonth + nDay;
	    day.sprintf("%i", nDayPrv);
	    p->setPen(bSelected? white : gray);
	    p->drawText(0, 0, w, h, AlignCenter, day);
	  } else {
	    int nDayNext = nDay - m_date.daysInMonth();
	    day.sprintf("%i", nDayNext);
	    p->setPen(bSelected? white : gray);
	    p->drawText(0, 0, w, h, AlignCenter, day);
	  }
      if (bSelected && hasFocus()) 
	{
	  if ( style() == WindowsStyle)
	    {
	      p->drawWinFocusRect(1, 1, w-2, h-2);
	    } else {
	      QColorGroup g = colorGroup();
	      p->setPen( black );
	      p->setBrush( NoBrush );
	      p->drawRect(0, 0, w, h
			  /*1, 1, w-2, h-2 */);
	    }
	}
      //      m_bSelected = FALSE;
    }
}

void KDateTable::mousePressEvent(QMouseEvent *e)
{
  if (e->type() != Event_MouseButtonPress)
    return;
   
  int row, col;
   
  QPoint mouseCoord = e->pos();
  row = findRow(mouseCoord.y());
  col = findCol(mouseCoord.x());

  if (row > 0)
    setSelection(row, col);
   
}

void KDateTable::setSelection(int row, int col)
{
  int nDay = dayNum(row, col);
  bool bDayInMonth =  
    (row > 0 && nDay > 0 && nDay <= m_date.daysInMonth()) 
    ? TRUE : FALSE;
  // -----
  if(bDayInMonth)
    {
      m_selRow = row;
      m_selCol = col;
      // if we clicked on a valid day for the current 
      // month and there is something already
      // selected, then update it
      if (m_bSelection) 
	{ // if something already selected
	  updateCell(m_oldRow, m_oldCol);
	}
      // update new selection
      m_bSelection = TRUE;  // validating selection
      m_date.setYMD(m_date.year(),m_date.month(),nDay);
      updateCell(row, col);
      emit dateSelected(m_date);
      // remember last selected location
      m_oldRow = row;
      m_oldCol = col; 
    } // else .. do nothing
}

void KDateTable::resizeEvent( QResizeEvent *)
{
  QRect rec = contentsRect();
  setCellWidth(rec.width()/7);
  setCellHeight(rec.height()/7);
}

void KDateTable::goForward()
{
  // remember old number of days in month
  m_daysInPrevMonth = m_date.daysInMonth();
   
   // get next month and set new date and first day of the week
  QDate dtnext;
  getNextMonth(m_date, dtnext);
  m_date = dtnext;
  m_firstDayOfWeek = m_date.dayOfWeek();
   
  m_bSelection = FALSE;
   
  emit monthChanged(m_date);
  update();
}

void KDateTable::goBackward()
{
  // get previous month and set new date and first day of the week
  QDate dtprev;
  getPrevMonth(m_date, dtprev);
  m_date = dtprev;
  m_firstDayOfWeek = m_date.dayOfWeek();
   
  // now get the month previous to that and find out number of days
  getPrevMonth(m_date, dtprev);
  m_daysInPrevMonth = dtprev.daysInMonth();
   
  m_bSelection = FALSE;
   
  emit monthChanged(m_date);
  update();
}

// gets a date on the first day of the previous month
void KDateTable::getPrevMonth(QDate dtnow, QDate &dtprv)
{
  int month = dtnow.month() > 1 ? dtnow.month()-1 : 12;
  int year = dtnow.month() > 1 ? dtnow.year() : dtnow.year()-1;
  dtprv = QDate(year, month, 1);
}

// gets a date on the first day of the next month
void KDateTable::getNextMonth(QDate dtnow, QDate &dtnxt)
{
  int month = dtnow.month() < 12 ? dtnow.month()+1 : 1;
  int year = dtnow.month() < 12 ? dtnow.year() : dtnow.year()+1;
  dtnxt = QDate(year, month, 1);
}

int KDateTable::dayNum(int row, int col)
{
  return 7*row - 7 + 1 + col - m_firstDayOfWeek;
}

/* Mirko: Implementation of sizeHint and setDate methods.
 * March 17 1998
 */

QSize KDateTable::sizeHint() const 
{
  const int Spacing=2; // pixels
  int x=0;
  int y, count, temp;
  for(count=0; count<7; count++)
    {
      temp=fontMetrics().width(Days[count]);
      if(temp>x) x=temp;
    }
  x=7*x+8*Spacing;
  y=7*fontMetrics().height()+7*Spacing;
  debug("KDateTable::sizeHint: recommending %ix%i "
	"pixels.\n", x, y);
  // the widget has 7 rows and 7 columns
  return QSize(x, y);
}

void KDateTable::setDate(QDate date)
{
  if(date.isValid())
    {
      m_date=date; 
      emit dateSelected(m_date);
      repaint(false);
    } else {
      debug("KDateTable::setDate: "
	    "date is invalid, not set.\n");
    }
}

// end of new methods from March 17 1998
/**********************************************************/

// highstick: added May 13 1998
void KDateTable::goDown()
{
  // remember old number of days in month
  m_daysInPrevMonth = m_date.daysInMonth();

	// get next month and set new date and first day of the week
  QDate dtnext;
  getNextYear(m_date, dtnext);
  m_date = dtnext;
  m_firstDayOfWeek = m_date.dayOfWeek();

  m_bSelection = FALSE;

  emit(yearChanged(m_date));
  update();
}

// highstick: added May 13 1998
void KDateTable::goUp()
{
  // get previous month and set new date and first day of the week
  QDate dtprev;
  getPrevYear(m_date, dtprev);
  m_date = dtprev;
  m_firstDayOfWeek = m_date.dayOfWeek();

  // now get the month previous to that and find out number of days
  getPrevYear(m_date, dtprev);
  m_daysInPrevMonth = dtprev.daysInMonth();

  m_bSelection = FALSE;

  emit(yearChanged(m_date));
  update();
}

// highstick: added May 13 1998
// gets a date on the first day of the previous month
void KDateTable::getPrevYear(QDate dtnow, QDate &dtprv)
{
  dtprv = QDate(dtnow.year()-1, dtnow.month(), 1);
}

// highstick: added May 13 1998
// gets a date on the first day of the next month
void KDateTable::getNextYear(QDate dtnow, QDate &dtnxt)
{
  dtnxt = QDate(dtnow.year()+1, dtnow.month(), 1);
}
// end of new methods from May 13 1998 by highstick

/* Mirko: Aug 21 1998 */
void KDateTable::setFontSize(int size)
{
  if(size>0)
    {
      fontsize=size;
    }
}


/**********************************************************/


#include "kdatetbl.moc"


--- NEW FILE: arrow_right.xbm ---
#define arrow_right_width 16
#define arrow_right_height 16
static char arrow_right_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x03, 0x80, 0x07, 0x80, 0x0f,
   0xfe, 0x1f, 0xfe, 0x3f, 0xfe, 0x3f, 0xfe, 0x1f, 0x80, 0x0f, 0x80, 0x07,
   0x80, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00};

--- NEW FILE: kpopmenu.h ---
#ifndef _KPOPUP_H
#define _KPOPUP_H

#include <qpopupmenu.h>


/// Popup menus with a title bar
/**
Here's a popup menu widget for KDE apps. It differs from Qt popup menu in
that it has a title -- thus it is *not* to be used in a menu bar. Only two
new methods are added -- setTitle(char *) and title() and a new constructor,
taking the title as a first argument. The main API difference from Qt's
QPopupMenu is that you should *not* expect the first item you insert into
KPopupMenu to have index (an ID) 0! So the following is wrong:
	
<pre>
	KPopupMenu menu("Window operations");
	menu->insertItem("Move");
	menu->insertItem("Minimize");
	menu->insertItem("Close");

	menu->connectItem(0, this, SLOT(moveWindow()));		// WRONG!!!
	menu->connectItem(1, this, SLOT(minimizeWindow()));	// WRONG!!!
	menu->connectItem(2, this, SLOT(closeWindow()));	// WRONG!!!
</pre>

The reason is that the title and a double line (actually, two separators) are
stored as menu items too, so the first item you insert has index 3. There's
a constant KPM_FirstItem so use one of those approaches instead of the above:

<pre>
[1] int move_item = menu->insertItem("Move");
    ...
    menu->connectItem(menu_item, this, SLOT(moveWindow()));

[2] menu->insertItem("Move");
    ...
    menu->connectItem(KPM_FirstItem+0, this, SLOT(moveWindow()));

[3] The best one!
     menu->insertItem("Move", this, SLOT(moveWindow()));
</pre>

* @short Popup menu with title.
* @version $Id: kpopmenu.h,v 1.1 2006-10-03 11:26:32 dslinux_amadeus Exp $
*/
class KPopupMenu : public QPopupMenu {
    Q_OBJECT
public:
    KPopupMenu(QWidget *parent=0, const char *name=0);
    KPopupMenu(const char *title, QWidget *parent=0, const char *name=0);
    ~KPopupMenu();
    
    void setTitle(const char *);
    const char *title() const;
    
private:
    void paintCell(QPainter *, int, int);
    void initialize(const char *);

};         

const int KPM_FirstItem = 3;


#endif

--- NEW FILE: kbutton.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Torben Weis (weis at kde.org)
              (C) 1997 Matthias Ettrich (ettrich at kde.org)
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef KBUTTON_H
#define KBUTTON_H

#include <qpixmap.h>
#include <qbutton.h>

/**
* Provides active-raise/lower buttons.
* @version $Id: kbutton.h,v 1.1 2006-10-03 11:26:29 dslinux_amadeus Exp $
*/
class KButton : public QButton
{
    Q_OBJECT
public:
    KButton( QWidget *_parent = 0L, const char *name = 0L );
    ~KButton();

protected:
    virtual void leaveEvent( QEvent *_ev );
    virtual void enterEvent( QEvent *_ev );
        
    virtual void drawButton( QPainter *_painter );
    virtual void drawButtonLabel( QPainter *_painter );

    void paint( QPainter *_painter );

 private:    
    bool raised;    
};

#endif

--- NEW FILE: kslider.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Martin Jones (mjones at kde.org)
              (C) 1997-1999 Christian Esken (esken at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
// Slider control V2.2
// (C) 1997-1999 Christian Esken (esken at kde.org)
// V1.0 Copyright (C) Martin R. Jones 1997

#ifndef __KSLIDER_H__
#define __KSLIDER_H__

// undef Above+Below because of Qt <-> X11 collision. Grr, I hate X11 headers
#undef Above
#undef Below
#include <qslider.h>

/**
KSlider is a control for selecting a value from using a sliding pointer.
It is similar to QSlider but it always looks like Windows style and
additionaly it provides a pageStep(). 

This makes it an ideal widget for position indiicators, especially in
multimedia applications. Please note that currently tick marks cannot
be switched off.

The interface is identical to QSlider, please see the Qt documentation for
more information. The pageStep is not being used in QSlider, you can set
this by calling setSteps( line, page ).
*/
class KSlider : public QSlider
{
  Q_OBJECT
    public:

  KSlider( QWidget *parent = 0L, const char *name = 0L );
  KSlider( Orientation o, QWidget *parent = 0L, const char *name = 0L );
  KSlider( int _minValue, int _maxValue, int _Step, int _value,
	   Orientation o, QWidget *parent = 0L, const char *name = 0L );

  virtual QSize sizeHint() const;

signals:
  void valueChanged( int value );
  void sliderPressed();
  void sliderMoved( int value );
  void sliderReleased();

protected:
  virtual void valueChange();
  virtual void rangeChange();
  virtual void paletteChange(const QPalette &);
  virtual void paintSlider(QPainter *painter, const QRect &rect );
  virtual void backgroundColorChange(const QPalette &);
  virtual void focusInEvent( QFocusEvent * );
  virtual void focusOutEvent( QFocusEvent * );

private:
  QPoint calcArrowPos( int val );
  void moveArrow( const QPoint &pos );
  void drawArrow( QPainter *painter, bool show, const QPoint &pos );
  void drawShadeLine( QPainter *painter );
  void drawTickMarks( QPainter *painter );
  void drawTicks( QPainter * p, int d, int w, int i=1 );
  void drawWinGroove(class QPainter *, short int);
  void drawFocusBar(QPainter *painter, const QRect & );
  virtual void paintEvent( QPaintEvent * );

  int checkWidth();
  bool isFocussed;
};

//-----------------------------------------------------------------------------

#endif


--- NEW FILE: kselect.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Martin Jones (mjones at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
// Selector widgets for KDE Color Selector, but probably useful for other
// stuff also.

#ifndef __KSELECT_H__
#define __KSELECT_H__

#include <qdialog.h>
#include <qframe.h>
#include <qrangecontrol.h>
#include <qlineedit.h>
#include <qpixmap.h>

/// 2D value selector.
/** 2D value selector.
  The contents of the selector are drawn by derived class.
  */
class KXYSelector : public QWidget
{
  Q_OBJECT
public:
  KXYSelector( QWidget *parent = 0L, const char *name = 0L );

  void setValues( int _xPos, int _yPos );
  void setRange( int _minX, int _minY, int _maxX, int _maxY );

  int xValue()	{	return xPos; }
  int yValue()	{	return yPos; }

  QRect contentsRect();

  signals:
  void valueChanged( int _x, int _y );

protected:
  virtual void paintEvent( QPaintEvent *e );

  /// Draw contents
  /** Override this function to draw the contents of the widget.
	Draw within contentsRect() only
	*/
  virtual void drawContents( QPainter * ) {}

  virtual void mousePressEvent( QMouseEvent *e );
  virtual void mouseMoveEvent( QMouseEvent *e );

private:
  void setPosition( int xp, int yp );
  void drawCursor( QPainter &painter, int xp, int yp );

protected:
  int px;
  int py;
  int xPos;
  int yPos;
  int minX;
  int maxX;
  int minY;
  int maxY;
  QPixmap store;
};

/// 1D value selector
/** 1D value selector with contents drawn by derived class.
  See KColorDialog for example.
 */
class KSelector : public QWidget, public QRangeControl
{
  Q_OBJECT
public:
  enum Orientation { Horizontal, Vertical };

  KSelector( Orientation o, QWidget *parent = 0L, const char *name = 0L );

  Orientation orientation() const
  {	return _orientation; }

  QRect contentsRect();

  void setIndent( bool i )
  {	_indent = i; }
  bool indent() const
  {	return _indent; }

  signals:
  void valueChanged( int value );

protected:
  /**
	Override this function to draw the contents of the control.
	Draw only within contentsRect().
	*/
  virtual void drawContents( QPainter * ) {}

  virtual void valueChange();
  virtual void drawArrow( QPainter &painter, bool show, const QPoint &pos );

private:
  QPoint calcArrowPos( int val );
  void moveArrow( const QPoint &pos );

  virtual void paintEvent( QPaintEvent * );
  virtual void mousePressEvent( QMouseEvent *e );
  virtual void mouseMoveEvent( QMouseEvent *e );

protected:
  Orientation _orientation;
  bool _indent;
};

//-----------------------------------------------------------------------------

class KGradientSelector : public KSelector
{
  Q_OBJECT
public:
  KGradientSelector( Orientation o, QWidget *parent = 0L,
					 const char *name = 0L );

  void setColors( const QColor &col1, const QColor &col2 )
  {	color1 = col1; color2 = col2; }
  void setText( const char *t1, const char *t2 )
  {	text1 = t1; text2 = t2; }

protected:
  virtual void drawContents( QPainter * );

protected:
  QColor color1, color2;
  QString text1, text2;
};

#endif		// __KSELECT_H__


--- NEW FILE: kdatepik.h ---
/*  -*- C++ -*-
    This file is part of the KDE libraries
    Copyright (C) 1997 Tim D. Gilman (tdgilman at best.org)
              (C) 1998, 1999 Mirko Sucker (mirko at kde.org)
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef _KDATEPIK_H
#define _KDATEPIK_H

/////////////////// KDatePicker widget class //////////////////////
//
// Copyright (C) 1997 Tim D. Gilman
//           (C) 1998, 1999 Mirko Sucker
// I also documented protected members as this is a library 
// reference.
// Original header from Tim:
// This version of the class is the first release.  Please
// send comments/suggestions/bug reports to <tdgilman at best.com>
//
// Written using Qt (http://www.troll.no) for the 
// KDE project (http://www.kde.org)
//
//
// Use this class to make a date picker widget
// When a date is selected by the user, it emits a signal: 
//    dateSelected(QDate)
//
// Required header for use:
//    kdatepik.h
// 
// Required files for compilation:
//
//    kdatepik.h kdatepik.cpp kdatetbl.h kdatetbl.cpp


#include <qframe.h>
#include <qdatetime.h>
#include <qsize.h>

class KDateTable;
class QLabel;
class QPushButton;
class QDate;

/** Use this class to make a date picker widget.
  *
  * When a date is selected by the user, it emits a signal: 
  *    dateSelected(QDate)
  *
  * @short A widget for selecting dates.
  * @author Mirko Sucker (mirko.sucker at unibw-hamburg.de)
  * @version $Id: kdatepik.h,v 1.1 2006-10-03 11:26:30 dslinux_amadeus Exp $
  */

class KDatePicker : public QFrame {
  Q_OBJECT
public:
  /** The usual constructor, the given date will be displayed 
    * initially.
    */
  KDatePicker(QWidget *parent=0, 
	      QDate=QDate::currentDate(), 
	      const char *name=0);
  // Mirko, Mar 17 1998:
  /** Returns a recommended size for the widget.
    * The recommended size is calculated so that the widget "looks good", 
    * that means everything fits in it and there is some additional space
    * between the rows. Also the buttons and every (!) month name 
    * fit in the headline.
    */
  QSize sizeHint() const;
  // Mirko, Aug 21 1998:
  /** Set the size of the contents of the datepicker widget using 
    * setFontSize.
    * The days are displayed with the font size, the headline gets a size
    * of fontsize + 2 by default. The default is 12pt.
    * Important: this changes the headline size, so adjust it later!

    */
  void setFontSize(int size);
  int fontSize(); // return it
  /** Set the font size of the headline, independent from the rest of the widget.
    * The default size is fontsize + 2.
    */
  void setHeadlineSize(int size);
  int headlineSize();
  // ^^^^^^^^^^^^^^^^^^^
private:
  KDateTable *m_tbl;
  QLabel *m_header;
  QLabel *m_footer;
  QPushButton *m_back;
  QPushButton *m_forward;
  // highstick: added May 13 1998
  QPushButton *m_up;
  QPushButton *m_down;
  // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
protected:
  void resizeEvent(QResizeEvent *);
  void sizeElements();
  /// The size that lets the button look best.
  static const int PreferredButtonSize;
  /// The minimum space between the button and the border.
  static const int MinimumFrameAroundButtons;
  /// The number of month in a year, usually 12 I suppose :-).
  static const int NoOfMonth;
  /// The names of the 12 month translated to the user language.
  const char* Month[12];
  int fontsize;
signals:
  /** This signal is emmitted when the user picked a date.
    */
  void dateSelected(QDate);
private slots:
public slots:
  void updateHeader(QDate dt);
  // Mirko, Mar 17 1998:
  void setDate(QDate);
  // ^^^^^^^^^^^^^^^^^^^
};

#endif // _KDATEPIK_H

--- NEW FILE: kquickhelp.cpp ---
// ---------------------------------------------------------------------------
//
//   QuickHelp: an improved mini-help system for KDE
//
// ---------------------------------------------------------------------------
//
//   This file is part of the KDE libraries
//
//   Copyright (C) 1997 Mario Weilguni <mweilguni at kde.org>
//
//   This library is free software; you can redistribute it and/or
//   modify it under the terms of the GNU Library General Public
//   License as published by the Free Software Foundation; either
//   version 2 of the License, or (at your option) any later version.
//
//   This library is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//   Library General Public License for more details.
//
//   You should have received a copy of the GNU Library General Public License
//   along with this library; see the file COPYING.LIB.  If not, write to
//   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
//   Boston, MA 02111-1307, USA.
//
// ---------------------------------------------------------------------------

#include "kquickhelp.h"
#include <qpainter.h>
#include <qpixmap.h>
#include <stdio.h>
#include <kapp.h>
#include <qpopupmenu.h>
#include <qbitmap.h>
#include <qregexp.h>

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

// this selects wheter we want shapes or not
#define QH_SHAPE
#ifdef QH_SHAPE
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
  #include <X11/Xos.h>
  #include <X11/extensions/shape.h>
  #define X_SHADOW 6
  #define Y_SHADOW 6
#else
  #define X_SHADOW 0
  #define Y_SHADOW 0
#endif

// text attribute flags
#define F_BOLD 1
#define F_ITALIC 2
#define F_UNDERLINE 4

// predefined border and shadow width
#define X_BORDER 10
#define Y_BORDER 6

// numeric representation of allowed tokens
const int TOK_BOLD_ON = 1;
const int TOK_BOLD_OFF = 2;
const int TOK_ITALIC_ON = 3;
const int TOK_ITALIC_OFF = 4;
const int TOK_UNDERLINE_ON = 5;
const int TOK_UNDERLINE_OFF = 6;
const int TOK_FONTSIZE_PLUS = 7;
const int TOK_FONTSIZE_MINUS = 8;
const int TOK_COLOR_BY_RGB = 9;
const int TOK_COLOR_RED = 10;
const int TOK_COLOR_GREEN = 11;
const int TOK_COLOR_BLUE = 12;
const int TOK_COLOR_WHITE = 13;
const int TOK_COLOR_YELLOW = 14;
const int TOK_COLOR_BLACK = 15;
const int TOK_COLOR_BROWN = 16;
const int TOK_COLOR_MAGENTA = 17;
const int TOK_COLOR_CYAN = 18;
const int TOK_FONT_DEFAULT = 19;
const int TOK_FONT_FIXED = 20;
const int TOK_INDENT_PLUS = 21;
const int TOK_INDENT_MINUS = 22;
const int TOK_NEWLINE = 23;
const int TOK_LINK = 24;
const int TOK_ENDLINK = 25;


QPopupMenu *KQuickHelp::menu = 0;
KQuickHelp *KQuickHelp::instance = 0;
QList<KQuickTip> *KQuickHelp::tips;
KQuickHelpWindow *KQuickHelp::window = 0;


// the standard colors
QColor KQuickHelpWindow::stdColors[] = {
  red,
  green,
  blue,
  white,
  yellow,
  black,
  QColor(165, 42, 42),
  magenta,
  cyan
};


KQuickHelp_Token KQuickHelpWindow::tokens[] = {
  // font attributes
  {"<b>", TOK_BOLD_ON},
  {"</b>", TOK_BOLD_OFF},
  {"<i>", TOK_ITALIC_ON},
  {"</i>", TOK_ITALIC_OFF},
  {"<u>", TOK_UNDERLINE_ON},
  {"</u>", TOK_UNDERLINE_OFF},

  // font attributes (long)
  {"<bold>", TOK_BOLD_ON},
  {"</bold>", TOK_BOLD_OFF},
  {"<italic>", TOK_ITALIC_ON},
  {"</italic>", TOK_ITALIC_OFF},
  {"<underline>", TOK_UNDERLINE_ON},
  {"</underline>", TOK_UNDERLINE_OFF},

  // font size
  {"<FONT SIZE +>", TOK_FONTSIZE_PLUS},
  {"<FONT SIZE ->", TOK_FONTSIZE_MINUS},
  {"<+>", TOK_FONTSIZE_PLUS},
  {"<->", TOK_FONTSIZE_MINUS},

  // indentation
  {"<INDENT +>", TOK_INDENT_PLUS},
  {"<INDENT ->", TOK_INDENT_MINUS},
  {"<i+>", TOK_INDENT_PLUS},
  {"<i->", TOK_INDENT_MINUS},

  // color selection by RGB value
  {"<COLOR #", TOK_COLOR_BY_RGB},

  // color selection by color name
  {"<COLOR RED>", TOK_COLOR_RED},
  {"<COLOR GREEN>", TOK_COLOR_GREEN},
  {"<COLOR BLUE>", TOK_COLOR_BLUE},
  {"<COLOR WHITE>", TOK_COLOR_WHITE},
  {"<COLOR YELLOW>", TOK_COLOR_YELLOW},
  {"<COLOR BLACK>", TOK_COLOR_BLACK},
  {"<COLOR BROWN>", TOK_COLOR_BROWN},
  {"<COLOR MAGENTA>", TOK_COLOR_MAGENTA},
  {"<COLOR CYAN>", TOK_COLOR_CYAN},

  // color selection by color name (short form)
  {"<RED>", TOK_COLOR_RED},
  {"<GREEN>", TOK_COLOR_GREEN},
  {"<BLUE>", TOK_COLOR_BLUE},
  {"<WHITE>", TOK_COLOR_WHITE},
  {"<YELLOW>", TOK_COLOR_YELLOW},
  {"<BLACK>", TOK_COLOR_BLACK},
  {"<BROWN>", TOK_COLOR_BROWN},
  {"<MAGENTA>", TOK_COLOR_MAGENTA},
  {"<CYAN>", TOK_COLOR_CYAN},

  // font selection
  {"<FONT DEFAULT>", TOK_FONT_DEFAULT},
  {"<FONT FIXED>", TOK_FONT_FIXED},
  {"<DEFAULT>", TOK_FONT_DEFAULT},
  {"<FIXED>", TOK_FONT_FIXED},

  // newline
  {"<br>", TOK_NEWLINE},

  // hyperlinks
  {"<link ", TOK_LINK},
  {"</link>", TOK_ENDLINK},
  
  // token table terminator
  {0, 0}
};


KQuickHelp::KQuickHelp() : QObject(0) {
}


const char *KQuickHelp::add(QWidget *w, const char *s) {
  if(!s)
    return 0;

  if(w != 0) {
    // make sure we have  a class instance running
    if(instance == 0) {
      tips = new QList<KQuickTip>;
      instance = new KQuickHelp();
      window = new KQuickHelpWindow();
      menu = new QPopupMenu;
      menu->insertItem(i18n("Quickhelp"));
      connect(menu, SIGNAL(activated(int)),
	      instance, SLOT(getKQuickHelp(int)));
      connect(window, SIGNAL(hyperlink(QString)),
	      instance, SLOT(hyperlinkRequested(QString)));
      tips->setAutoDelete(true);
    }

    KQuickTip *qt = new KQuickTip;
    qt->widget = w;
    qt->txt = s;
    tips->append(qt);
    connect(w, SIGNAL(destroyed()),
	    instance, SLOT(widgetDestroyed()));

    w->installEventFilter(instance);
  }

  return s;
}


void KQuickHelp::hyperlinkRequested(QString link) {
  // check protocol
  if(strncasecmp("http:", link.data(), 5) == 0 ||
     strncasecmp("info:", link.data(), 5) == 0 ||
     strncasecmp("ftp:", link.data(), 4) == 0 ||
     strncasecmp("file:", link.data(), 5) == 0 ||
     strncasecmp("mailto:", link.data(), 7) == 0)
    {
      // lets give this URL to kfm, he knows better what
      // to do with it
      if(fork() > 0) {
	// drop setuid, setgid
	setgid(getgid());
	setuid(getuid());
	
	QString s = "kfmclient exec " + link + " &";
	execlp("kfmclient", "kfmclient", "exec", link.data(), 0);
	_exit(0);
      }
    } else {
      // hmm, seems I have to do it myself :-(
      QString fname = "", anchor = "";
      int idx;

      if((idx = link.find('#')) == -1)
	fname = link;
      else {
	if(*link.data() == '#') {
	  anchor = link.mid(1, 255);
	  fname = kapp->appName() + ".html";
	} else {
	  fname = link.left(idx);
	  anchor = link.mid(idx+1, 1024);
	}
      }
      
      kapp->invokeHTMLHelp((kapp->appName() +  "/" + fname), anchor);
    }
}


void KQuickHelp::remove(QWidget *w) {
  for(unsigned i = 0; i < tips->count(); i++)
    if(tips->at(i)->widget == w) {
      tips->remove(i);
      return;
    }      
}


void KQuickHelp::widgetDestroyed() {
  remove((QWidget *)sender());
}


bool KQuickHelp::eventFilter(QObject *o, QEvent *e) {
  if(e->type() == Event_MouseButtonPress && ((QMouseEvent *)e)->button() == RightButton) {
    for(unsigned i = 0; i < tips->count(); i++) {
      if(tips->at(i)->widget == (QWidget *)o) {
	current = tips->at(i)->widget;
	currentText = tips->at(i)->txt;
	currentPos = QCursor::pos();
	menu->popup(currentPos);
	return true;
      }
    }
  }
  
  return false;
}


void KQuickHelp::getKQuickHelp(int) {
  window->popup(currentText, currentPos.x(), currentPos.y());
}


KQuickHelpWindow::KQuickHelpWindow() : QFrame(0, 0, WStyle_Customize|WStyle_Tool) {
  setBackgroundColor(QColor(255, 255, 225));
  defaultCursor = cursor();
  linkAreas.setAutoDelete(true);
}


void KQuickHelpWindow::newText() {
  QPixmap pm(1, 1);
  QPainter p;
  p.begin(&pm);

  int w = 0, h = 0;
  paint(&p, w, h);
  p.end();

  // HACK: there may have been link-areas defined. Remove them
  linkAreas.clear();

  // resize to appropr. size
  resize(w, h);
}


void KQuickHelpWindow::mousePressEvent(QMouseEvent *e) {
  if(e->button() == LeftButton && activeLink.length())
    emit hyperlink(activeLink);
  hide();
}


void KQuickHelpWindow::mouseMoveEvent(QMouseEvent *e) {
  QPoint p = e->pos();

  for(uint i = 0; i < linkAreas.count(); i++)
    if(linkAreas.at(i)->area.contains(p)) {
      setCursor(upArrowCursor);
      activeLink = linkAreas.at(i)->link.copy();      
      return;
    } 

  activeLink = "";
  setCursor(defaultCursor);
}


void KQuickHelpWindow::keyPressEvent(QKeyEvent *e) {
  e->accept();
  hide();
}


void KQuickHelpWindow::show() {
  QFrame::show();
  grabMouse();
  grabKeyboard();
  setMouseTracking(true);
}


void KQuickHelpWindow::hide() {
  QFrame::hide();
  releaseMouse();
  releaseKeyboard();
  setMouseTracking(false);

  // clean up
  activeLink = "";
  linkAreas.clear();
}


void KQuickHelpWindow::popup(QString text, int x, int y) {
  txt = text.copy();
  newText();

  if(x + width() > QApplication::desktop()->width() - 8)
    x = QApplication::desktop()->width() - 8 - width();
  if(y + height() > QApplication::desktop()->height() - 4)
    y = QApplication::desktop()->height() - 4 - height();
  move(x, y);
  show();
}
  
  
void KQuickHelpWindow::paintEvent(QPaintEvent *) {
  QPainter p;

  p.begin(this);
  int x, y;
  paint(&p, x, y);
  p.end();

#ifdef QH_SHAPE
  // repaint, so we can apply the Shape (don't know if necessary)
  // kapp->flushX();

  QBitmap bm(width(), height());
  p.begin(&bm);
  p.setPen(color0);
  bm.fill(color1);
  
  p.fillRect(X_SHADOW, height() - Y_SHADOW,
	     width() - X_SHADOW, Y_SHADOW, Dense4Pattern);
  p.fillRect(width()-X_SHADOW, Y_SHADOW,
	     X_SHADOW, height()-Y_SHADOW, Dense4Pattern);
  p.fillRect(width()-X_SHADOW, 0,
	     X_SHADOW, Y_SHADOW, SolidPattern);
  p.fillRect(0, height()-Y_SHADOW,
	     X_SHADOW, Y_SHADOW, SolidPattern);
  p.end();
  
  XShapeCombineMask( x11Display(), winId(), ShapeBounding, 0, 0, bm.handle(), ShapeSet );
#endif
}


QString KQuickHelpWindow::token() {
  QString t = "";
  bool  backslash = false;

  while(tokIndex < (int)txt.length()) {
    char c = txt[tokIndex++];

    if(backslash) {
      backslash = false;
      t += c;
    } else {
      switch(c) {
      case '\\':
	backslash = true;
	break;

      case '\n':
	if(t.length() == 0)
	  t = "<br>";
	else
	  tokIndex--;
	return t;

      case '<':
	if(t.length() == 0)
	  t += c;
	else {
	  tokIndex--;
	  return t;
	}
	break;

      case '>':
	if(t.left(1) == "<") // bad token
	  t += c;
	return t;

      default:
	t += c;
      }
    }
  }

  return t;
}


void KQuickHelpWindow::paint(QPainter *p, int &w, int &h) {
  int posx = X_BORDER, posy = Y_BORDER;
  int maxy = 0, maxx = 0, idx;
  int indent = 0;
  QFont f;
  QColor txtColor = black;
  QColor savedColor;
  int txtFlags = 0;
  bool wasUnderline = false;

  QString link;

  int pointsize = p->font().pointSize();
  p->setPen(black);

  tokIndex = 0;
  while(tokIndex < (int)txt.length()) {
    QString t = token();
    if(t.left(1) == "<") { // a token      
      // find token
      int tokenID = -1;
      t = t.simplifyWhiteSpace();

      for(int i = 0; tokens[i].token != 0; i++)
	if(strncasecmp(t.data(), tokens[i].token, strlen(tokens[i].token)) == 0) {
	  tokenID = tokens[i].tokenID;
	  break;
	}
      
      switch(tokenID) {
      case -1:
	// ignore
	fprintf(stderr, "KQuickHelp: ignoring unknown token \"%s\"!\n", t.data());
	break;

	// font attributes
      case TOK_BOLD_ON:
	txtFlags |= F_BOLD;
	break;
      case TOK_BOLD_OFF:
	txtFlags &= ~F_BOLD;
	break;
      case TOK_ITALIC_ON:
	txtFlags |= F_ITALIC;
	break;
      case TOK_ITALIC_OFF:
	txtFlags &= ~F_ITALIC;
	break;
      case TOK_UNDERLINE_ON:
	txtFlags |= F_UNDERLINE;
	break;
      case TOK_UNDERLINE_OFF:
	txtFlags &= ~F_UNDERLINE;
	break;
	
	// font size
      case TOK_FONTSIZE_PLUS:
	f = p->font();
	while(QFontInfo(f).pointSize() == pointsize)
	  f.setPointSize(f.pointSize() + 1);
	pointsize = QFontInfo(f).pointSize();
	break;
      case TOK_FONTSIZE_MINUS:
	f = p->font();
	while(QFontInfo(f).pointSize() == pointsize)
	  f.setPointSize(f.pointSize() - 1);
	pointsize = QFontInfo(f).pointSize();
	break;

	// indentation
      case TOK_INDENT_PLUS:
	posx += fontMetrics().width('H') * 2;
	indent += fontMetrics().width('H') * 2;
	break;
      case TOK_INDENT_MINUS:
	if(indent > 0)
	  indent -= fontMetrics().width('H') * 2;
	break;

	// color by RGB value
      case TOK_COLOR_BY_RGB:
	idx = t.find(QRegExp("#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]"));
	if(idx != -1) {
	  int cval, r, g, b;
	  sscanf(t.data() + idx + 1, "%x", &cval);
	  r = cval >> 16;
	  g = (cval >> 8) & 0xff;
	  b = cval & 0xff;
	  txtColor = QColor(r, g, b);
	}
	break;
      
	// newline
      case TOK_NEWLINE:
	posx = X_BORDER + indent;
	posy += maxy;
	maxy = 10;
	break;

	// standard colors
      case TOK_COLOR_RED:
      case TOK_COLOR_GREEN:
      case TOK_COLOR_BLUE:
      case TOK_COLOR_WHITE:
      case TOK_COLOR_YELLOW:
      case TOK_COLOR_BLACK:
      case TOK_COLOR_BROWN:
      case TOK_COLOR_MAGENTA:
      case TOK_COLOR_CYAN:
	txtColor = stdColors[tokenID-TOK_COLOR_RED];
	break;

	// hyperlinks
      case TOK_LINK:
	idx = t.find(QRegExp(" .*>", false));
	if(idx != -1) {
	  link = t.mid(idx+1, t.length()-idx-2);
	  savedColor = txtColor;
	  wasUnderline = (txtFlags & F_UNDERLINE) != 0;
	  txtColor = blue;
	  txtFlags |= F_UNDERLINE;
	}
	break;

      case TOK_ENDLINK:
	txtColor = savedColor;
	if(!wasUnderline)
	  txtFlags &= ~F_UNDERLINE;
	link = "";
	break;

      default:
	printf("TOKEN: \"%s\", ID=%d\n", t.data(), tokenID);
      }
    } else { // plain text
      p->setPen(txtColor);
      QFont f = font();
      f.setPointSize(pointsize);
      f.setBold((txtFlags & F_BOLD) != 0);
      f.setItalic((txtFlags & F_ITALIC) != 0);
      f.setUnderline((txtFlags & F_UNDERLINE) != 0);
      p->setFont(f);

      QRect r;
      p->drawText(posx, posy, 1024, 1024, AlignLeft|AlignTop, t.data(), -1, &r, 0);
      if(link.length() > 0) {
	KQuickHelp_Link *l = new KQuickHelp_Link;
	l->area = r;
	l->link = link;
	linkAreas.append(l);
      }
      posx += r.width();
      maxy = QMAX(maxy, p->fontMetrics().lineSpacing());
      maxx = QMAX(maxx, r.right());
    }
  }

  w = maxx + X_BORDER + X_SHADOW;
  h = posy + maxy + Y_BORDER + Y_SHADOW;

  // draw frame
  p->setPen(QPen(black, 1));
  p->drawRect(0, 0, w - X_SHADOW, h - Y_SHADOW);
  p->fillRect(0, h - Y_SHADOW, w, h, QBrush(QColor(black)));
  p->fillRect(w - X_SHADOW, 0, w, h, QBrush(QColor(black)));
}
#include "kquickhelp.moc"


--- NEW FILE: kdatepik.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Tim D. Gilman (tdgilman at best.org)
              (C) 1998, 1999 Mirko Sucker (mirko at kde.org)
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

/////////////////// KDatePicker widget class //////////////////////
//
// Copyright (C) 1997 Tim D. Gilman
//           (C) 1998, 1999 Mirko Sucker
// Original header from Tim:
// This version of the class is the first release.  Please
// send comments/suggestions/bug reports to <tdgilman at best.com>
//
// Written using Qt (http://www.troll.no) for the
// KDE project (http://www.kde.org)
//
//
// Use this class to make a date picker widget
// When a date is selected by the user, it emits a signal: 
//    dateSelected(QDate)
//
// Required header for use:
//    kdatepik.h
//
// Required files for compilation:
//
//    kdatepik.h kdatepik.cpp kdatetbl.h kdatetbl.cpp
// ------------------------------------------------------------

#include <qpushbutton.h>
#include <qlabel.h>
#include <qfont.h>
#include <qdatetime.h>

#include "kdatepik.h"
#include "kdatepik.h"

#include "kdatetbl.h"

// Mirko, Feb 25 1998:
extern "C" {
#include "arrow_left.xbm"
#include "arrow_right.xbm"
  // highstick: added May 13 1998
#include "arrow_up.xbm"
#include "arrow_down.xbm"
  // ^^^^^^^^^^^^^^^^^^^
	   }
#include <qbitmap.h>
#include <kapp.h>

// Mirko, March 17 1998:
const int KDatePicker::PreferredButtonSize=22;
const int KDatePicker::MinimumFrameAroundButtons=2;
const int KDatePicker::NoOfMonth=12;
// ----- taken from kapp.h:
#ifndef i18n
#define i18n(X) KApplication::getKApplication()->getLocale()->translate(X)
#endif
// ^^^^^^^^^^^^^^^^^^^


KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name)
  : QFrame(parent,name),
    fontsize(10)
{
  // Mirko: added Feb 25 1998
  QBitmap left // a left arrow, 32 Bytes
    (arrow_left_width, arrow_left_height, 
     (const unsigned char*)arrow_left_bits, true);
  QBitmap right // a right arrow, 32 Bytes
    (arrow_right_width, arrow_right_height, 
     (const unsigned char*)arrow_right_bits, true);
  // highstick: added May 13 1998
  QBitmap up
    (arrow_up_width, arrow_up_height,
     (const unsigned char*)arrow_up_bits, true);
  QBitmap down
    (arrow_down_width, arrow_down_height,
     (const unsigned char*)arrow_down_bits, true);
  // Mirko: added March 17 1998
  /* I added the names literally to force that they are
   * included into the translation templates.
   * I did not make it static to allow different languages,
   * altough I do not know if this is possible inside the
   * same process with locale.
   */
  Month[0]=i18n("January"); Month[1]=i18n("February"); 
  Month[2]=i18n("March"); Month[3]=i18n("April"); 
  Month[4]=i18n("May"); Month[5]=i18n("June");
  Month[6]=i18n("July"); Month[7]=i18n("August"); 
  Month[8]=i18n("September"); Month[9]=i18n("October"); 
  Month[10]=i18n("November"); Month[11]=i18n("December");
  // ^^^^^^^^^^^^^^^^^^^^^^^^
  initMetaObject();
   
  QDate dNow = QDate::currentDate();
  QString sNow;
  sNow.sprintf("Today: %i/%i/%i", 
	       dNow.month(),dNow.day(),dNow.year());
   
  m_header = new QLabel(this);
  updateHeader(dt);
   
  m_tbl = new KDateTable(this, dt);
  m_footer = new QLabel((const char*)sNow, this);
  // Mirko: changed Feb 25 1998
  m_back = new QPushButton(this);
  m_back->setPixmap(left);
  m_forward = new QPushButton(this);
  m_forward->setPixmap(right);
  // highstick: added May 13 1998
  m_up = new QPushButton(this);
  m_up->setPixmap(up);
  m_down = new QPushButton(this);
  m_down->setPixmap(down);
  // ^^^^^^^^^^^^^^^^^^^^^^^^^^

  switch(style()) {
  case WindowsStyle:
  case MotifStyle:
    setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
    break;
  default:
    setFrameStyle(QFrame::Panel | QFrame::Plain);
    setLineWidth(1);
  }

  sizeElements();

  connect(m_forward, SIGNAL(clicked()), m_tbl, SLOT(goForward()));
  connect(m_back, SIGNAL(clicked()), m_tbl, SLOT(goBackward()));   
  connect(m_tbl, SIGNAL(monthChanged(QDate)), SLOT(updateHeader(QDate)));
  connect(m_tbl, SIGNAL(dateSelected(QDate)), SIGNAL(dateSelected(QDate)));
  // highstick: added May 13 1998
  connect(m_down, SIGNAL(clicked()), m_tbl, SLOT(goDown()));
  connect(m_up, SIGNAL(clicked()), m_tbl, SLOT(goUp()));   
  connect(m_tbl, SIGNAL(yearChanged(QDate)), SLOT(updateHeader(QDate)));
  connect(m_tbl, SIGNAL(dateSelected(QDate)), SIGNAL(dateSelected(QDate)));
  // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
  m_header->setAlignment(AlignCenter);
  m_footer->setAlignment(AlignCenter);
   
  m_footer->setBackgroundColor(white);
   
  QColorGroup old_cg = m_header->colorGroup();
  QColorGroup new_cg(old_cg.foreground(), 
		     darkBlue,   // blue background
		     old_cg.light(), old_cg.dark(), old_cg.mid(),
		     white,      // white text
		     old_cg.base());
  m_header->setPalette(QPalette(new_cg,new_cg,new_cg));
   
  m_footer->setFont(QFont("Arial", fontsize, QFont::Bold));
  m_header->setFont(QFont("Times", fontsize+2/*, QFont::Bold*/));   
}


void KDatePicker::resizeEvent(QResizeEvent *)
{
  sizeElements();
}

void KDatePicker::sizeElements()
{
  QRect rec = contentsRect();
   
  // table height
  int th = rec.height()/10;
   
  m_header->setGeometry(rec.x(),
			rec.y(),
			rec.width(),
			2*th);
  m_footer->setGeometry(rec.x(),
			rec.bottom()-(th-1),
			rec.width(),
			th);
  m_tbl->setGeometry(rec.x(),
		     rec.y()+2*th,
		     rec.width(),
		     rec.height()-3*th);
  /* Mirko: changed Feb 25 1998
   * - assumes that both bitmaps have equal height
   *   buttons are set to a max height and width of 22, 
   *   that is the height of the arrow 
   *   plus 3 pixels in x and y direction
   */
  int buttonSize;
  int spacing;
  const int roomLeft=2*th-2*MinimumFrameAroundButtons;
  if(roomLeft>PreferredButtonSize)
    {
      spacing=(2*th-PreferredButtonSize)/2;
      buttonSize=PreferredButtonSize;
    } else { // the widget is smaller -> ugly buttons
      spacing=2; 
      /* This way the buttons might get very small,
       * but it is the task of the programmer to 
       * take care of the size hint.
       */
      buttonSize=2*th-2*MinimumFrameAroundButtons;
    }
  m_back->setGeometry(rec.x()+2*spacing+buttonSize,
		      rec.y()+spacing,
		      buttonSize,
		      buttonSize);
  m_forward->setGeometry(rec.right()-2*spacing-2*buttonSize,
			 rec.y()+spacing,
			 buttonSize,
			 buttonSize);
  // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // highstick: added May 13 1998
  m_up->setGeometry(rec.x() + spacing,
		    rec.y() + spacing,
		    buttonSize,
		    buttonSize);
  m_down->setGeometry(rec.right() - spacing - buttonSize,
		      rec.y() + spacing,
		      buttonSize,
		      buttonSize);
  // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

void KDatePicker::updateHeader(QDate dt)
{
  QString sHeader;
  const char* month;
  if(dt.month()>0 && dt.month()<13)
    {
      month=Month[dt.month()-1];
    } else {
      month=i18n("(invalid)");
    }
  CHECK_PTR(month);
  sHeader.sprintf("%s %i", 
		  month,
		  // (const char*)dt.monthName(dt.month()), 
		  dt.year());
  m_header->setText((const char*)sHeader);
}

/* Mirko: Implementation of sizeHint and setDate methods.
 * March 17 1998
 */

QSize KDatePicker::sizeHint() const 
{
  int count, temp, x, y;
  QSize table, header, footer;
  CHECK_PTR(m_tbl); CHECK_PTR(m_footer);
  // ----- find recommended size for month table:
  table=m_tbl->sizeHint();
  // ----- find recommended size for headline:
  header=m_header->sizeHint();
  header.setWidth(0);
  for(count=0; count<NoOfMonth; count++)
    { // find the width of the widest month name
      temp=m_header->fontMetrics().width(Month[count]);
      if(temp>header.width())
	{ //  ^^^ this depends on the font set!
	  header.setWidth(temp);
	}
    }
  header.setWidth(header.width()
		  +m_header->fontMetrics().width(" 2984 ")+10
		  +6*MinimumFrameAroundButtons
		  +4*PreferredButtonSize);
  // ----- find recommended size for bottom label:
  // let us assume that the footer label is smaller than 
  // header label
  footer=m_footer->sizeHint();
  // ----- construct size hint from values:
  x=table.width(); 
  if(x<header.width())
    { // footer skipped
      x=header.width();
    }
  y=header.height()+table.height()+footer.height();
  debug("KDatePicker::sizeHint: "
	"recommending %ix%i pixels.\n", x, y);
  // -----
  return QSize(x, y);
}

void KDatePicker::setDate(QDate date)
{
  if(date.isValid())
    {
      m_tbl->setDate(date);
      updateHeader(date);
    } else {
      debug("KDatePicker::setDate: "
	    "date is invalid, not set.\n");
    }
}

// end of new methods from March 17 1998

/* Mirko: Aug 19 1998 */
void KDatePicker::setFontSize(int size)
{
  if(size>0)
    {
      fontsize=size;
      m_tbl->setFontSize(size);
      setHeadlineSize(size+2);
      repaint();
    }
}

int KDatePicker::fontSize()
{
  return fontsize;
}

void KDatePicker::setHeadlineSize(int size)
{
  QFont font=m_header->font();
  if(size>0)
    {
      font.setPointSize(size);
      m_header->setFont(font);
      m_header->repaint();
    }
}

int KDatePicker::headlineSize()
{
  return m_header->fontInfo().pointSize();
}

// end of new methods from Aug 19 1998

/**********************************************************/
#include "kdatepik.moc"

--- NEW FILE: ChangeLog ---
1999-03-29  Harri Porten  <porten at kde.org>

	* keditcl1.cpp: i18n'ed "Untitled" (Save As ... bug)
	* keditcl2.cpp: gave QMessageBox'es more appropriate parents

1999-03-04  Harri Porten  <porten at kde.org>

	* kquickhelp.*: changed 'tips' to be a pointer instead of an object.
	This fixes the segfaults on HP/UX and probably the ones on NetBSD.
	* kquickhelp.*: use setuid()/setgid() instead of the not-so-portable
	seteuid()/setegid() pair. Reversed the order, too.

1998-11-09  Alex Zepeda  <garbanzo at hooked.net>

	* kmenubar.h: Fix up some of the comments so they're gramatically
	correct and make a bit more sense.  Make private members protected, 
	in the spirit of reusable code.


--- NEW FILE: exclamation.xpm ---
/* XPM */
static char *magick[] = {
/* columns rows colors chars-per-pixel */
"51 50 5 1",
"  c #000000",
". c #a0a0a4",
"X c #c0c0c0",
"o c #ffffff",
"O c None",
/* pixels */
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOO   OOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOO ooo OOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOO ooooo .OOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOO ooooo ..OOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOO ooooooo ..OOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOO ooooooo ..OOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOO ooooooooo ..OOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOO ooooooooo ..OOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOO ooooooooooo ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOO oooo   oooo ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOO oooo     oooo ..OOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOO oooo     oooo ..OOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOO ooooo     ooooo ..OOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOO ooooo     ooooo ..OOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO oooooo     oooooo ..OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO oooooo     oooooo ..OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOO oooooooo   oooooooo ..OOOOOOOOOOOOOOO",
"OOOOOOOOOOOOO oooooooo   oooooooo ..OOOOOOOOOOOOOOO",
"OOOOOOOOOOOO ooooooooo   ooooooooo ..OOOOOOOOOOOOOO",
"OOOOOOOOOOOO oooooooooo oooooooooo ..OOOOOOOOOOOOOO",
"OOOOOOOOOOO ooooooooooo ooooooooooo ..OOOOOOOOOOOOO",
"OOOOOOOOOOO ooooooooooooooooooooooo ..OOOOOOOOOOOOO",
"OOOOOOOOOO oooooooooooo  ooooooooooo ..OOOOOOOOOOOO",
"OOOOOOOOOO ooooooooooo    oooooooooo ..OOOOOOOOOOOO",
"OOOOOOOOO oooooooooooo    ooooooooooo ..OOOOOOOOOOO",
"OOOOOOOOO ooooooooooooo  oooooooooooo ..OOOOOOOOOOO",
"OOOOOOOOO ooooooooooooooooooooooooooo ...OOOOOOOOOO",
"OOOOOOOOO ooooooooooooooooooooooooooo ...OOOOOOOOOO",
"OOOOOOOOOO ooooooooooooooooooooooooo ....OOOOOOOOOO",
"OOOOOOOOOOO                         .....OOOOOOOOOO",
"OOOOOOOOOOOOO...........................OOOOOOOOOOO",
"OOOOOOOOOOOOOO.........................OOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
};

--- NEW FILE: ktoolboxmgr.h ---
/*
    This file is part of the KDE libraries
    Copyright (C) 1998 Sven Radej (radej at kde.org)
              
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#ifndef K_OWN_WM
#define K_OWN_WM

#include <qwindowdefs.h>
#include <qwidget.h>
#include <qtimer.h>
#include <qlist.h>
#include <qrect.h>

#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

 // $Id: ktoolboxmgr.h,v 1.1 2006-10-03 11:26:33 dslinux_amadeus Exp $
 // $Log: ktoolboxmgr.h,v $
 // Revision 1.1  2006-10-03 11:26:33  dslinux_amadeus
 // adding pristine copy of pixil to HEAD so I can branch from it
 //
 // Revision 1.1  2003/09/08 19:42:11  jasonk
 // Addition of packages directory and associated files.
 //
 // Revision 1.1.1.1  2003/08/07 21:18:33  jasonk
 // Initial import of PIXIL into new cvs repository.
 //
 // Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
 //
 //
 // Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
 // Initial import of ViewML
 //
 // Revision 1.7  1998/11/06 15:45:44  radej
 // sven: added helper for addHotSpot
 //
 // Revision 1.6  1998/09/01 20:22:26  kulow
 // I renamed all old qt header files to the new versions. I think, this looks
 // nicer (and gives the change in configure a sense :)
 //
 // Revision 1.5  1998/08/10 13:33:55  radej
 // sven: Added X-only and Y-only resizing.
 //
 // Revision 1.4  1998/07/29 12:48:31  ssk
 // Removed more warnings, possible portability problems and ANSI violations.
 //
 // Revision 1.3  1998/05/07 16:50:42  radej
 // Docs update: you don't get mouseRelease
 //
 // Revision 1.2  1998/05/04 16:39:34  radej
 // Docs update.
 //
 // Revision 1.1  1998/04/28 09:16:41  radej
 // Initial checkin
 //

 /**
  * KToolBoxManager is a class for self management of small windows.
  * Windows can be resized or moved. During move/resize it will emit
  * all changes and you can recompute and accept or discard new geometry.
  * You can define hot spots on the screen, and you will receive signal
  * when your widget enters it. KToolBoxManager doesn't draw any decoration.
  *
  * You will call (after constructing KToolBoxManager instance) doMove or
  * doResize when mouse presses some handle point of your widget. Then,
  * KToolBoxManager will move (or resize) hollow rectangle (or actual widget)
  * on the screen. Moving/resizing is finished on mouse release event or
  * by calling stop() function.
  * Provided that your widget is top-level, the simplest use is like this:
  * <pre>
  * mousePressevent(QMouseEvent *)
  * {
  *  KToolBoxManager *mgr = new KToolBoxManager(this);
  *  doMove();
  * }
  * </pre>
  * Moving/resizing can be transparent or opaque. In transparent mode, word
  * "resizer" refers to hollow rectangle which is actually resized or moved.
  * In opaque mode it refers to actual widget.
  *
  * Moving child widgets in opaque mode will move the widget only inside your
  * parent widget. You can drag it outside, but you won't see it, neither
  * during drag nor after. You should reparent it in that case.
  *
  * Functions doMove and doResize do not return untill mouse is released or
  * stop() function is called. However, this is QTimer driven so you will
  * receive signals, and Qt-engine will operate normally. Halting does not
  * hog CPU (it's not an empty for(;;) loop).
  *
  * You will not receive mouseRelease event when mouse is released. (uh.)
  *
  * @short Class for own window management.
  * @author Sven Radej <radej at kde.org>
  *
  */
class KToolBoxManager : public QObject
{
  Q_OBJECT
    
public:
  /**
   * Constructor. widget is the widget to be managed. It can be any custom
   * widget with QWidget as a base class.
   * If transparent is true (default) moving and resizing is transparent.
   * @ref #doMove or @ref #doResize won't return till mouseRelease, or
   * @ref #stop . Qt will run normaly, because this thing is QTimer driven.
   * You can get position and size calling @ref #x , @ref #y , @ref #width and
   * @ref #height
   */
  KToolBoxManager (QWidget *widget, bool transparent=true);

  /**
   * Destructor. If resizer is working, it will stop working,
   * and move/resize the widget (i.e. will call @ref #stop) before it's death.
   */
  ~KToolBoxManager ();

  /**
   * Starts moving. If dynamic is true signal @ref #posChanged
   * will be emitted whenever position changes. If dynamic is false no signals
   * are emitted except @ref #onHotSpot when resizer enters a hot spot area.
   * Function will not return till end of drag. You
   * can call @ref #setGeometry and resizer will adapt to it whenever you want.
   * If dontmove is false, widget is moved to resizer's position when dragging
   * If dontmove is false, no move is done you have to do it. Beware, moving
   * of child widgets often isn't what you want. Still it is possible.
   * If KToolBoxManager already moves or resizes widget when you
   * call this function, it will return and do nothing.<br>
   * When dynamic is true, signal @ref #posChanged is emitted when resizer
   * changes position.<br>
   * When in_hotspot_static is true, resizer is not moved while in hotspot;
   * only mouse moves, and  @ref #posChanged is not emitted.
   * Hint: Call this function with dynamic=false and define hot spots.
   * @see #x
   * @see #y
   * @see #width
   * @see #height
   */
  void doMove(bool in_hotspot_static=false, bool dynamic = false, bool dontmove=false);

  /**
   * Starts resizing. If dynamic is true (default) signal @ref #sizeChanged
   * will be emitted whenever size changes. If dynamic is false, no signals
   * are emitted. Function will not return until
   * button mouse is released or @ref #stop function is called. You can call
   * @ref #setGeometry and resizer will adapt to it whenever you want.
   * If dontresize is false, widget is resized to resizer's size on the end.
   * If dontresize is true, widget is not resized, you have to do it. If
   * KToolBoxManager already
   * moves or resizes widget when you  call this function, it will return
   * and do nothing.  When dynamic is true, signal @ref #sizeChanged is
   * emitted only when resizers changes size. You can resize the resizer
   * with @ref #setGeometry or @ref #resize .
   * Note that (for know) KTBM can only resize on the right/bottom side of
   * the widget.
   *
   * @see #x
   * @see #y
   * @see #width
   * @see #height
   */
  void doResize(bool dynamic = false, bool dontresize=false);
  /**
   * Starts vertical only resizing. Arguments and behaviour are the same as
   * in @ref #doMove .
   */
  void doXResize(bool dynamic = false, bool dontresize=false);

  /**
   * Starts horizontal only resizing. Arguments and behaviour are the same as
   * in @ref #doMove .
   */
  void doYResize(bool dynamic = false, bool dontresize=false);
  
  /**
   * Adds region x, y, w, h to the lists of hot spots, and returns
   * index of that hot spot. When resizer enters that hot spot, signal
   * @ref #onHotSpot will be emitted. Only first hotspot is reported
   * That mean if you have overlaping hotspots the one with the lower index
   * will be reported. There is a special hotspot with index -1; exterior
   * of all hotspots(the whole screen minus defined hotspots). When resizer
   * leaves defined all hotspots @ref #onHotSpot (-1) will be emitted.
   *
   * Note that x and y must be global screen coordinates.
   * @see #removeHotSpot
   */
  int addHotSpot(int x, int y, int w, int h);

  /**
   * This is an overloaded function which takes rectangle as parameter.
   * if mapToGlobal = true, rect will be converted to global coords.
   */
  int addHotSpot(const QRect &r, bool mapToGlobal=false);

  /**
   * Removes hot spot index.
   * @see #addHotSpot
   */
  void removeHotSpot(int index);

    /**
   * Sets geometry of resizer. Does nothing if manager is not working (i.e.
   * if @ref #doMove or @ref #doResize were not called first). This function
   * will not emit signals @ref #sizeChanged ,  @ref #posChanged or
   * @ref #onHotSpot . Call this after you received some of those signals,
   * and you have to change geometry. For example, toolbar will change
   * geometry if dragged on hot spots - to tell user that it will -  if left
   * on that place -  re-embed itself into parent window. Note that x and y
   * must be global screen coordinates.
   */
  void setGeometry(int x, int y, int w, int h);

  /**
   * Sets geometry of resizer to geometry of hotspot index. This is
   * provided for conevenience. Does nothing is index is false.
   */
  void setGeometry(int index);

  /**
   * Resizes the resizer. rw is width and rh is height
   */
  void resize(int rw, int rh) {setGeometry(xp, yp, rw, rh);};

  /**
   * Returns global x coordinate of a mouse.
   */
   int mouseX() {return rx;};

  /**
   * Returns global y coordinate of a mouse.
   */
  int mouseY() {return ry;};
  
  /**
   * Returns global x coordinate of resizer.
   */
  int x() {return xp;};

  /**
   * Returns global y coordinate of resizer.
   */
  int y() {return yp;};

  /**
   * Returns width of resizer.
   */
  int width() {return w;};

  /**
   * Returns height resizer.
   */
  int height() {return h;};

  
public slots:

  /**
   * Calling this slot will stop the process of moving or resizing. It is
   * equal as if user releases the mouse button.
   */
  void stop ();

protected:

  /**
   * Internal - draws rectangle on the screen
   */
  void drawRectangle (int x, int y, int w, int h);

  /**
   * Internal - deletes last rectangle, if there is one.
   */
  void deleteLastRectangle ();

  /**
   * Internal - mode.
   */
  enum Mode {Nothing=0, Moving=1, Resizing=2};
  

protected slots:
  /**
   * Internal, QTimer driven mover.
   */
  void doMoveInternal();

  /**
   * Internal, QTimer driven sizer.
   */
  void doResizeInternal();
  
private:
  int xp, yp, w, h;
  int ox, oy, ow, oh;
  int orig_x, orig_y, orig_w, orig_h;
  bool noLast;
  bool working;
  bool dynamic;
  bool geometryChanged;
  bool transparent;;
  bool dontmoveres;
  bool deepSpace;
  bool hotspot_static;
  Mode mode;
  
  QWidget *widget;
  QTimer *timer;

  QList<QRect> hotspots;
  QRect *last_hsp;
  
  int rx, ry, sx, sy;
  int offX, offY;

  bool xOnly; // flags for only horizontal or... 
  bool yOnly; //...only vertical resize
  
  /* X-stuff */

  Window root;
  GC rootgc;
  int scr;
  XEvent ev;
  unsigned int active_button;
  
signals:
    
    /**
     * This signal is emitted when resizer changes position. Note:
     * x and y are global screen coordinates
     */
    void posChanged (int x, int y);

    /**
     * This signal is emitted when resizer changes size.
     */
    void sizeChanged (int w, int h);

    /**
     * This signal is emitted when resizer enter hot spot index.
     * It is also emited with index = -1 in the moment when resizer
     * leaves a hot spot but doesn't enter another hotspot. That is,
     * when it goes to "free space".
     */
    void onHotSpot (int id);

};

#endif


--- NEW FILE: krestrictedline.cpp ---
/**********************************************************************
**
** $Id: krestrictedline.cpp,v 1.1 2006-10-03 11:26:32 dslinux_amadeus Exp $
**
** Implementation of KRestrictedLine
**
** Copyright (C) 1997 Michael Wiedmann, <mw at miwie.in-berlin.de>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the Free
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
**
*****************************************************************************/

#include "krestrictedline.h"
#include "qkeycode.h"

#include "krestrictedline.h"


KRestrictedLine::KRestrictedLine( QWidget *parent, 
								  const char *name,
								  const char *valid )
  : QLineEdit( parent, name )
{
  qsValidChars = valid;
}

KRestrictedLine::~KRestrictedLine()
{
  ;
}


void KRestrictedLine::keyPressEvent( QKeyEvent *e )
{
  if (e->key() == Key_Enter || e->key() == Key_Return)
    {
      emit returnPressed();
      return;
    }

  // let QLineEdit process "special" keys
  // so that we still can use the default key binding
  if (e->ascii() < 32)
    {
      QLineEdit::keyPressEvent(e);
      return;
    }

  // do we have a list of valid chars &&
  // is the pressed key in the list of valid chars?
  if (!qsValidChars.isEmpty() && !qsValidChars.contains((char)e->ascii()))
    {
      // invalid char, emit signal and return
      emit (invalidChar(e->key()));
      return;
    }
  else
	// valid char: let QLineEdit process this key as usual
	QLineEdit::keyPressEvent(e);

  return;
}


void KRestrictedLine::setValidChars( const char *valid)
{
  qsValidChars = valid;
}

#include "krestrictedline.moc"

--- NEW FILE: AUTHORS ---
Matthias Kalle Dalheimer <kalle at kde.org>:
classes KApplication, KConfig, KTextStream, KColorSet, 
automake, autoconf, maintenance

Richard Moore <moorer at cs.man.ac.uk>:
KLedLamp class, KNewPanner class.

Martynas Kunigelis <algikun at santaka.ktu.lt>:
KProgress class

Steffen Hansen <stefh at dit.ou.dk>:
KURL class

Torben Weis <weis at stud.uni-frankfurt.de>
DnD stuff, KSocket and KServerSocket classes, KPixmap

Alexander Sanda <alex at darkstar.ping.at>
Read and write numerical config entries, KPanner, KTabControl,
KPopupMenu, KMessageBox, KEdit widgets. 

Martin Jones <mjones at powerup.com.au>
Bugfixes in KPixmap and KURL, KColorDialog, KSelector
KColorButton

Keith Brown <kbrown at pdq.net>
KTreeList class

Bernd Johannes Wuebben <wuebben at math.cornell.edu>
KFontDialog class

Tim D. Gilman <tdgilman at best.com>
KDatePicker, KDateTable class

Nicolas Hadacek <hadacek at via.ecp.fr>
Key configuration classes, bug fixes

Christoph Neerfeld <Christoph.Neerfeld at mail.bonn.netsurf.de>
KIconLoader class

Sven Radej <sven.radej at iname.com>
KLineEdit, KCombo, KToolbar, KStatusBar

Rainer Bawidamann <Rainer.Bawidamann at wohnheim.uni-ulm.de>
Rubberbanding in KTreeList

Andre Fornacon <afo at fh-zwickau.de>
KSpinBox

Michael Wiedmann <mw at miwie.in-berlin.de>
KRestrictedLine, KIntegerLine

Matthias Ettrich <ettrich at kde.org> 
KWMModuleApplication, tearing/docking of ktoolbar and kmenubar, heavy
modifications to kbutton

Stephan Kulow <coolo at kde.org>
first versions of KTopLevelWidget and KToolBar, heavy modifications to
automake and autoconf

Joerg Habenicht <j.habenicht at europemail.com>
KLed class

Thomas Tanghus <tanghus at earthling.net>
Classes KNotebook and KWizard

Jorge Monteiro <jomo at casema.net>
KContainerLayout class

Kurt Granroth <granroth at kde.org>
KURLLabel class

Jörg Habenicht <habenich at kbs.uni-hannover.de>
KRuler class

--- NEW FILE: kbutton.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Torben Weis (weis at kde.org)
	              1997 Matthias Ettrich (ettrich at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#include "kbutton.h"

#include <qpainter.h>
#include <qdrawutil.h>

KButton::KButton( QWidget *_parent, const char *name )
    : QButton( _parent , name)
{
  raised = FALSE;
  setFocusPolicy( NoFocus );
}

void KButton::enterEvent( QEvent* )
{
  if ( isEnabled() )
    {
      raised = TRUE;
      repaint(FALSE);
    }
}

void KButton::leaveEvent( QEvent * )
{
  if( raised != FALSE )
    {
      raised = FALSE;
      repaint();
    }
}
    
void KButton::drawButton( QPainter *_painter )
{
  paint( _painter );
}

void KButton::drawButtonLabel( QPainter *_painter )
{
  paint( _painter );
}

void KButton::paint( QPainter *painter )
{
  if ( isDown() || isOn() )
    {
      if ( style() == WindowsStyle )
	qDrawWinButton( painter, 0, 0, width(), 
			height(), colorGroup(), TRUE );
      else
	qDrawShadePanel( painter, 0, 0, width(), 
			 height(), colorGroup(), TRUE, 2, 0L );
    }
  else if ( raised )
    {
      if ( style() == WindowsStyle )
	qDrawWinButton( painter, 0, 0, width(), height(), 
			colorGroup(), FALSE );
      else
	qDrawShadePanel( painter, 0, 0, width(), height(), 
			 colorGroup(), FALSE, 2, 0L );
    }
  
  if ( pixmap() )
    {
      int dx = ( width() - pixmap()->width() ) / 2;
      int dy = ( height() - pixmap()->height() ) / 2;
      if ( isDown() && style() == WindowsStyle ) {
       ++dx;
       ++dy;
      }
      painter->drawPixmap( dx, dy, *pixmap() );
    }
}


KButton::~KButton()
{
}

#include "kbutton.moc"


--- NEW FILE: kcontainer.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1998 Jorge Monteiro <jomo at casema.net>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include "kcontainer.h"

KContainerLayout::KContainerLayout(QWidget * parent, const char * name, 
			int orientation, bool homogeneos,
			int spacing, WFlags f, bool allowLines)
    : QFrame(parent,name,f,allowLines)
{
    _spacing = spacing;
    _homogeneos = homogeneos;
    _orientation = orientation;
    _startOffset = 0;
    _endOffset = 0;
    //setFrameStyle(QFrame::WinPanel|QFrame::Raised);
    if (parent && !parent->inherits("KContainerLayout"))
    {
	// Install handle for parent resize, this will allow us to 
	// resize ourselves
	parent->installEventFilter(this);
    }
}

KContainerLayout::~KContainerLayout()
{
}

int KContainerLayout::packStart(QWidget *w, bool e, bool f,int p)
{
    _startWidgets.append(new KContainerLayoutItem(w,e,f,p));
    recalcLayout();
    return 0;
}

int KContainerLayout::packEnd(QWidget *w, bool e, bool f,int p)
{
    _endWidgets.append(new KContainerLayoutItem(w,e,f,p));
    recalcLayout();
    return 0;
}

void KContainerLayout::setOrientation(int i)
{
    _orientation = i;
    recalcLayout();
}

void KContainerLayout::setHomogeneos(bool b)
{
    _homogeneos = b;
    recalcLayout();
}

void KContainerLayout::setSpacing(int i)
{
    _spacing = i;
    recalcLayout();
}

void KContainerLayout::setStartOffset(int i)
{
    _startOffset = i;
    recalcLayout();
}

void KContainerLayout::setEndOffset(int i)
{
    _endOffset = i;
    recalcLayout();
}

void KContainerLayout::recalcLayout()
{
    // Calculate our hint
    QSize sz = sizeHint();
    // if our size is not enough, resize us
    if (size().width() < sz.width() || size().height() < sz.height())
	resize(sz);
    repositionWidgets();
}

void KContainerLayout::sizeToFit()
{
    if (parent()!=0L && !parent()->inherits("KContainerLayout") && parent()->inherits("QWidget"))
	((QWidget*)parent())->resize(_sizeHint);
    resize(_sizeHint);
}

int KContainerLayout::getNumberOfWidgets() const
{
   return (_startWidgets.count() + _endWidgets.count());
}

void KContainerLayout::repositionWidgets()
{
    int x,y;

    if (horizontal())
    {
	y = 0;
	x = _spacing + _startOffset;
	if (_homogeneos)
	{
	    int nr_widgets = getNumberOfWidgets();
	    int each_width=0;
	    if (nr_widgets)
		each_width = (((size().width()-_startOffset-_endOffset) - (_spacing*(nr_widgets+1)))) / nr_widgets;
	    KContainerLayoutItem *item;
	    // Now reposition one each time
	    for ( item=_startWidgets.first(); item != 0; item=_startWidgets.next() )
	    {
		int w = idealSizeOfWidget(item).width();
		int gap = each_width - w;
		if (item->fill())
		    item->widget()->setGeometry(x+item->padding(),y,
			    	each_width-item->padding()*2,size().height());
		else
		    item->widget()->setGeometry(x+item->padding()+gap/2,y,
				each_width-item->padding()*2-gap,size().height());
		x += (each_width+_spacing);
	    }
	    // ... from the end
	    warning("homo");
	    x = size().width() - _endOffset;
	    for ( item=_endWidgets.first(); item != 0; item=_endWidgets.next() )
	    {
		int w = idealSizeOfWidget(item).width();
		int gap = each_width - w;
		x -= (each_width+_spacing);
		if (item->fill())
		    item->widget()->setGeometry(x+item->padding(),y,
			    	each_width-item->padding()*2,size().height());
		else
		    item->widget()->setGeometry(x+item->padding()+gap/2,y,
				each_width-item->padding()*2-gap,size().height());
	    }
	}
	else
	{
	    int nr_expand = numberOfWidgetsWithExpand();
	    int extra_width=0;
	    if (nr_expand)
		extra_width = (size().width() - _sizeHint.width()) / nr_expand;
	    KContainerLayoutItem *item;
	    // Now reposition one each time
	    for ( item=_startWidgets.first(); item != 0; item=_startWidgets.next() )
	    {
		int w = idealSizeOfWidget(item).width();
		if (item->expand())
		{
		    w += extra_width;
		    if (item->fill())
			item->widget()->setGeometry(x+item->padding(),y,w-item->padding()*2,size().height());
		    else
			item->widget()->setGeometry(x+item->padding()+extra_width/2,y,
				w-item->padding()*2-extra_width,size().height());
		}
		else
		    item->widget()->setGeometry(x+item->padding(),y,w-item->padding()*2,size().height());
		x += (w+_spacing);
	    }
	    // ... from end
	    warning("non-homo");
	    x = size().width() - _endOffset;
	    for ( item=_endWidgets.first(); item != 0; item=_endWidgets.next() )
	    {
		int w = idealSizeOfWidget(item).width();
		if (item->expand())
		    w += extra_width;
		x -= (w+_spacing);
		if (item->expand())
		{
		    if (item->fill())
			item->widget()->setGeometry(x+item->padding(),y,w-item->padding()*2,size().height());
		    else
			item->widget()->setGeometry(x+item->padding()+extra_width/2,y,
				w-item->padding()*2-extra_width,size().height());
		}
		else
		    item->widget()->setGeometry(x+item->padding(),y,w-item->padding()*2,size().height());
	    }

	}
    }
    else
    {
	y = _spacing + _startOffset;
	x = 0;
	if (_homogeneos)
	{
	    int nr_widgets = getNumberOfWidgets();
	    int each_height=0;
	    if (nr_widgets)
		each_height = (((size().height()-_startOffset-_endOffset) - (_spacing*(nr_widgets+1)))) / nr_widgets;
	    KContainerLayoutItem *item;
	    // Now reposition one each time
	    for ( item=_startWidgets.first(); item != 0; item=_startWidgets.next() )
	    {
		int h = idealSizeOfWidget(item).height();
		int gap = each_height - h;
		if (item->fill())
		    item->widget()->setGeometry(x,y+item->padding(),
			    	size().width(),each_height-item->padding()*2);
		else
		    item->widget()->setGeometry(x,y+item->padding()+gap/2,
				size().width(),each_height-item->padding()*2-gap);
		y += (each_height+_spacing);
	    }
	    // Now reposition one each time
	    y = size().height() - _endOffset;
	    for ( item=_endWidgets.first(); item != 0; item=_endWidgets.next() )
	    {
		int h = idealSizeOfWidget(item).height();
		int gap = each_height - h;
		y -= (each_height+_spacing);
		if (item->fill())
		    item->widget()->setGeometry(x,y+item->padding(),
			    	size().width(),each_height-item->padding()*2);
		else
		    item->widget()->setGeometry(x,y+item->padding()+gap/2,
				size().width(),each_height-item->padding()*2-gap);
	    }
	}
	else
	{
	    int nr_expand = numberOfWidgetsWithExpand();
	    int extra_height=0;
	    if (nr_expand)
		extra_height = (size().height() - _sizeHint.height()) / nr_expand;
	    KContainerLayoutItem *item;
	    // Now reposition one each time
	    for ( item=_startWidgets.first(); item != 0; item=_startWidgets.next() )
	    {
		int h = idealSizeOfWidget(item).height();
		if (item->expand())
		{
		    h += extra_height;
		    if (item->fill())
			item->widget()->setGeometry(x,y+item->padding(),size().width(),h-item->padding()*2);
		    else
			item->widget()->setGeometry(x,y+item->padding()+extra_height/2,
				size().width(),h-item->padding()*2-extra_height);
		}
		else
		    item->widget()->setGeometry(x,y+item->padding(),size().width(),h-item->padding()*2);
		y += (h+_spacing);
	    }
	    // ... and the end
	    y = size().height() - _endOffset;
	    for ( item=_endWidgets.first(); item != 0; item=_endWidgets.next() )
	    {
		int h = idealSizeOfWidget(item).height();
		if (item->expand())
		    h += extra_height;
		y -= (h+_spacing);
		if (item->expand())
		{
		    if (item->fill())
			item->widget()->setGeometry(x,y+item->padding(),size().width(),h-item->padding()*2);
		    else
			item->widget()->setGeometry(x,y+item->padding()+extra_height/2,
				size().width(),h-item->padding()*2-extra_height);
		}
		else
		    item->widget()->setGeometry(x,y+item->padding(),size().width(),h-item->padding()*2);
	    }
	}
    }
}

int KContainerLayout::numberOfWidgetsWithExpand()
{
    int i = 0;
    KContainerLayoutItem *item;
    for ( item=_startWidgets.first(); item != 0; item=_startWidgets.next() )
	i += (item->expand())?1:0;
    for ( item=_endWidgets.first(); item != 0; item=_endWidgets.next() )
	i += (item->expand())?1:0;
    return i;
}

void KContainerLayout::calculateSizeHint()
{
    int nr_widgets = getNumberOfWidgets();
    if (nr_widgets == 0)
    {
	if (horizontal())
	    _sizeHint = QSize(_startOffset + _endOffset,0);
	else
	    _sizeHint = QSize(0,_startOffset + _endOffset);
	_sizeForEach = -1;
	return;
    }
    
    if (_homogeneos)
    {
	// this is easy
	QSize sz = sizeOfLargerWidget();
	// Ok, the size of each box will be the size
	// of the bigger widget plus the spacing
	if (horizontal())
	{
	    _sizeForEach = sz.width();
	    int w = (sz.width()*nr_widgets)+(_spacing * (nr_widgets + 1));
	    sz.setWidth(w+_startOffset+_endOffset);
	}
	else
	{
	    _sizeForEach = sz.height();
	    int h = (sz.height()*nr_widgets)+(_spacing * (nr_widgets + 1));
	    sz.setHeight(h+_startOffset+_endOffset);
	}
	_sizeHint = sz;
    }
    else
    {
	// We have to calculate the size based on each widget
	int w = 0, h = 0;
	KContainerLayoutItem *item;
	// First on the start widgets...
	for ( item=_startWidgets.first(); item != 0; item=_startWidgets.next() )
	{
	    QSize widgetSz = idealSizeOfWidget(item);
	    
	    if (horizontal())
	    {
		w += widgetSz.width();
		h = (widgetSz.height()>h)?widgetSz.height():h;
	    }
	    else
	    {
		h += widgetSz.height();
		w = (widgetSz.width()>h)?widgetSz.width():w;
	    }
	}
	// ...now the end widgets
	for ( item=_endWidgets.first(); item != 0; item=_endWidgets.next() )
	{
	    QSize widgetSz = idealSizeOfWidget(item);
	    
	    if (horizontal())
	    {
		w += widgetSz.width();
		h = (widgetSz.height()>h)?widgetSz.height():h;
	    }
	    else
	    {
		h += widgetSz.height();
		w = (widgetSz.width()>h)?widgetSz.width():w;
	    }
	}
	if (horizontal())
	    w += ((nr_widgets+1)*_spacing) + _startOffset + _endOffset;
	else
	    h += ((nr_widgets+1)*_spacing) + _startOffset + _endOffset;
	_sizeHint = QSize(w,h);
	_sizeForEach = -1;
    }
    if (parent()!=0L && !parent()->inherits("KContainerLayout") && parent()->inherits("QWidget"))
    {
	warning("setting minimum size for parent widget (%i,%i)",_sizeHint.width(),_sizeHint.height());
	((QWidget*)parent())->setMinimumSize(_sizeHint);
    }
    warning("minimum size (%i,%i)",_sizeHint.width(),_sizeHint.height());
    setMinimumSize(_sizeHint);
}

QSize KContainerLayout::sizeOfLargerWidget()
{
    QSize sz;
    int maxW=0,maxH=0;
    KContainerLayoutItem *item;
    // start widgets
    for ( item=_startWidgets.first(); item != 0; item=_startWidgets.next() )
    {
	sz = idealSizeOfWidget(item);
	if (sz.width()>maxW)
	    maxW = sz.width();
	if (sz.height()>maxH)
	    maxH = sz.height();	
    }
    // ent widgets
    for ( item=_endWidgets.first(); item != 0; item=_endWidgets.next() )
    {
	sz = idealSizeOfWidget(item);
	if (sz.width()>maxW)
	    maxW = sz.width();
	if (sz.height()>maxH)
	    maxH = sz.height();	
    }
    return QSize(maxW,maxH);
}

QSize KContainerLayout::idealSizeOfWidget(KContainerLayoutItem *item)
{
   // Calculate the size for the widget this will make use of 
   // sizeHint() - the widget must return a valid value here
   QSize sz = widgetSize(item);
   if (horizontal())
	sz.setWidth(sz.width()+item->padding()*2);
   else
	sz.setHeight(sz.height()+item->padding()*2);
   return sz;
}

void KContainerLayout::resizeEvent(QResizeEvent *ev)
{
    QFrame::resizeEvent(ev);

    repositionWidgets();
}

bool KContainerLayout::eventFilter(QObject *, QEvent *ev)
{
    if (ev->type() == Event_Resize)
    {
	// resize ourselves
	resize(((QResizeEvent*)ev)->size());
	// let parent resize normally
	return false;
    }
    else
	return false;
}

QSize KContainerLayout::sizeHint() const
{
    KContainerLayout *p = (KContainerLayout*)this;
    p->calculateSizeHint();
    return _sizeHint;
}

#include "kcontainer.moc"


--- NEW FILE: kbuttonbox.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Mario Weilguni (mweilguni at sime.com)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/* 
 * KButtonBox class
 *
 * A container widget for buttons. Uses Qt layout control to place the
 * buttons, can handle both vertical and horizontal button placement.
 * The default border is now 0 (easier to deal with layouts). The space
 * between buttons is now more Motif compliant
 */

#ifndef __KBUTTONBOX__H__
#define __KBUTTONBOX__H__

#include <qwidget.h>
#include <qpushbutton.h>
#include <qlist.h>

/**
  * This class is used internally.
  */
class KButtonBoxItem {
public:
  QPushButton *button;
  bool noexpand;
  int stretch;
  int actual_size;
};


class KButtonBox : public QWidget {
  Q_OBJECT
public:
  enum { VERTICAL = 1, HORIZONTAL = 2 };

  /**
    * Creates an empty container for buttons. If _orientation is 
    * KButtonBox::VERTICAL, the buttons inserted with @see addButton
    * are layouted from top to bottom, otherwise they are layouted 
    * from left to right.
    */
  KButtonBox(QWidget *parent, int _orientation = HORIZONTAL, 
	     int border = 0, int _autoborder = 6);

  /**
    * The destructor is needed, otherwise gcc 2.7.2.1 may report an 
    * internal compiler error. It does nothing.
    */
  ~KButtonBox();

  /**
    * @return the minimum size needed to fit all buttons. This size is
    * calculated by the with/height of all buttons plus border/autoborder
    */
  virtual QSize sizeHint() const;

  virtual void resizeEvent(QResizeEvent *);

  /**
    * adds a new @see QPushButton and @return a pointer to the newly 
    * created button. If noexpand is FALSE, the width of the button is
    * adjusted to fit the other buttons (the maximum of all buttons is
    * taken). If noexpand is TRUE, the width of this button will be
    * set to the minimum width needed for the given text).
    */
  QPushButton *addButton(const char *text, bool noexpand = FALSE);

  /**
    * This adds a stretch to the buttonbox. @see QBoxLayout for details.
    * Can be used to separate buttons (i.e. if you add the buttons "OK",
    * "Cancel", add a stretch and then add the button "Help", "OK" and
    * "Cancel" will be left-aligned (or top-aligned for vertical) while
    * "Help" will be right-aligned (or bottom-aligned for vertical).
    */
  void addStretch(int scale = 1);

  /**
    * This function must be called ONCE after all buttons have been
    * inserted. It will start layout control.
    */
  void layout();

protected:
  /**
    * @return the best size for a button. Checks all buttons and takes
    * the maximum width/height.
    */
  QSize bestButtonSize() const;
  void  placeButtons();
  QSize buttonSizeHint(QPushButton *) const;

protected:
  int _border, _autoborder;
  int orientation;
  bool activated;
  QList<KButtonBoxItem> buttons;
};

#endif

--- NEW FILE: ktmainwindow.h ---
#ifndef _KWIDGET_H
#define _KWIDGET_H

#include <stdlib.h>
#include <qwidget.h>
#include <qlist.h>
#include <ktoolbar.h>
#include <kmenubar.h>
#include <kstatusbar.h>
#include <kconfig.h>

/**
 * Top level widget that provides toolbars, a status line and a frame.
 * It should be used as a toplevel (parent-less) widget and
 * manages the geometry for all its children, including your
 * main widget.
 *
 * Normally, you will inherit from KTMainWindow (known also as KTMW).
 * Then you must construct (or use some existing) widget that will be
 * your main view. You can set only one main view.
 *
 * You can add as many toolbar(s) as you like. There can be only one menubar
 * and only one statusbar.
 *
 * Toolbars, Menubar, and Statusbar can be generated by the KTMainWindow and - unlike
 * old KTopLevelWidget - may, but do not have to be deleted by you. KTMainWindow will
 * handle that internaly.
 *
 * KTMainWindow maintaines the layout and resizing of all elements
 * (toolbars, statusbar, main widget, etc).  KTMainWindow now handles fixed-size
 * and Y-fixed main views properly. Just set fixed size or
 * your main view. You can change it runtime, the changes will take effect
 * on next updateRects call. Do not set fixed size on window! You may set
 * minimum or maximum size on window, but only if main view is freely
 * resizable. Minimum width can also be set if main view is Y-fixed.
 *
 * KTMainWindow will set icon, mini icon and caption, which it gets
 * from KApplication. It provides full session management, and will save
 * its position, geometry and positions of toolbar(s) and menubar on
 * logout. If you want to save aditional data, overload saveProperties and
 * (to read them again on next login) readProperties. To save special
 * data about your data, overload saveData. To warn user
 * that application has unsaved data on logout, use setUnsavedData.
 *
 * There is also a macro RESTORE which can restore all your windows
 * on next login.
 *
 * This class is now merged with KTopLevelWidget (KTW). Biggest difference
 * is that KTMainWindow implements closeEvent and calls needed functios
 * in case when window is closed. By overloading these (virtual)
 * functions, you controll what happens in these cases.
 *
 * KTMainWindow might be replaced/extended in the future to
 * KMainWindow which will be a child of QMainWindow. Anyway,
 * the current interface  will be supported for compatibility
 * reasons.
 *
 * @see KApplication
 * @see KTopLevelWidget
 * @short KDE top level main window
   @author Stephan Kulow (coolo at kde.org), Matthias Ettrich (ettrich at kde.org), Sven Radej (radej at kde.org) .Maintained by Sven Radej (radej at kde.org)

 */

class KTMainWindow : public QWidget {
    Q_OBJECT

        friend class KToolBar;

public:
    /**
     * Constructor.
     * Note that for session management to work, KTMainWindow widget
     * must be created with 'new'.
     */
    KTMainWindow( const char *name = 0L );
    /**
     * Destructor. Will also destroy the toolbars, and menubar if
     * needed.
     */
    ~KTMainWindow();

    /** Deletes all KTMainWindows. This is a good thing to call before
      * an applications wants to exit via kapp->quit(). Rationale: The
      * destructors of main windows may want to delete other widgets
      * as well. Now, if an application calls kapp->quit() then Qt
      * will destroy all widgets in a somewhat random order which may
      * result in double-free'ed memory (=segfault). Since not every
      * program checks for QApplication::closingDown() before deleting
      * a widget, calling KTMainWindow::deleteAll() before is a good
      * and proper solution.
     */
  static void deleteAll();

    /**
     * Add a toolbar to the widget.
     * A toolbar added to this widget will be automatically laid out
     * by it.
     *
     * The toolbar must have been created with this instance of
     * KTMainWindow as its parent.
     *
     * Usually you do not need this function. Just refer to a toolbar
     * with @ref #toolBar (index) instead and the KTMainWindow will
     * create it for you. Anyway addToolBar() is usefull if you want
     * to pass additional arguments to the toolbar's constructor.
     * (Matthias)
     */
    int addToolBar( KToolBar *toolbar, int index = -1 );

    /**
     * Set the main client widget.
     * This is the main widget for your application; it's geometry
     * will be automatically managed by KTMainWindow to fit the
     * client area, constrained by the positions of the menu, toolbars
     * and status bar. It can be fixed-width or Y-fixed.
     *
     * Only one client widget can be handled at a time; multiple calls
     * of setView will cause only the last widget to be added to be
     * properly handled.
     *
     * The widget must have been created with this instance of
     * KTMainWindow as its parent.
     */
    void setView( QWidget *view, bool show_frame = TRUE );


    /**
     *Enable or disable the status bar.
     */
    void enableStatusBar( KStatusBar::BarStatus stat = KStatusBar::Toggle );

    /**
     * Enable or disable the toolbar with the ID specified.
     * If no ID is specified, the default ID is 0.
     */
    void enableToolBar( KToolBar::BarStatus stat = KToolBar::Toggle,
                        int ID = 0 );

    /**
     * Set the width of the view frame.
     * If you request a frame around your view with @ref #setView (...,TRUE),
     * you can use this function to set the border width of the frame.
     * The default is 1 pixel. You should call this function before
     * @ref #setView ().
     */
    void setFrameBorderWidth( int );

    /**
     * Returns a pointer to the toolbar with the specified ID.
     * If there is no such tool bar yet, it will be generated
     */
    KToolBar *toolBar( int ID = 0 );

    /**
     * Returns a pointer to the menu bar. If there is no
     * menu bar yet, it will be generated
     */
    KMenuBar *menuBar();

    /**
     * If you constructed menuBar yourself, you must set it with this
     * function. You can use it also if you want to replace old menu bar
     * with a new one. There can be only one menu bar at a time. After this
     * function, layout will be updated.
     * @see #menuBar
     */
    void setMenu (KMenuBar *menuBar);

    /**
     * Returns a pointer to the status bar. If there is no
     * status bar yet, it will be generated
     */
    KStatusBar *statusBar();

    /**
     * If you constructed statusBar yourself, you must set it with this
     * function. You can use it also if you want to replace old status bar
     * with a new one. There can be only one status bar at a time. After this
     * function layout will be updated.
     * @see #statusBar
     */
    void setStatusBar (KStatusBar *statusBar);

    /* You probably do not need this. Anyway, if you are porting code
     * which have been written for the former @ref KTopLevelWidget you may
     * find the following three boolean has-functions useful:
     *
     * This function returns wether the menubar is existing
     */
    bool hasMenuBar();
    /**
     * Returns wether the statusbar is existing
     */
    bool hasStatusBar();
    /**
     * Returns wether the specified toolbar  is existing
     */
    bool hasToolBar( int ID = 0);


    /**
     * Shows toplevel widget. Reimplemented from QWidget, and calls
     * @ref #updateRects (i.e. updates layout)
     */
    virtual void show ();

    /**
     * Distance from top of window to top of main view,
     * Computed in @ref #updateRects. Changing of this variable
     * has no effect.
     * Avoid using it, it might be removed in future.
     */
    int view_top;

    /**
     * Distance from top of window to bottom of main view.
     * Computed in @ref #updateRects. Changing of this variable
     * has no effect.
     * Avoid using it, it might be removed in future.
     */
    int view_bottom;

    /**
     * Distance from left edge of window to left border of main view.
     * Computed in @ref #updateRects. Changing of this variable
     * has no effect.
     * Avoid using it, it might be removed in future.
     */
    int view_left;

    /**
     * Distance from left edge of window to right edge of main view.
     * Computed in @ref #updateRects. Changing of this variable
     * has no effect.
     * Avoid using it, it might be removed in future.
     */
    int view_right;



  /**
   * This function tries to restore the toplevel widget as defined number (1..X)
   * If the session did not contain that high number, the configuration
   * is not changed and False returned.
   *
   * That means clients could simply do the following:
   * <pre>
   * if (kapp->isRestored()){
   *   int n = 1;
   *   while (KTMainWindow::canBeRestored(n)){
   *     (new childTLW)->restore(n);
   *     n++;
   *   }
   * } else {
   * // create default application as usual
   * }
   * </pre>
   * Note that "show()" is called implicit in restore.
   *
   * With this you can easily restore all toplevel windows of your
   * application.
   *
   * If your application uses different kinds of toplevel
   * windows, then you can use KTMainWindow::classNameOfToplevel(n)
   * to determine the exact type before calling the childTLW
   * constructor in the example from above.
   *
   * If your client has only one kind of toplevel widgets (which should
   * be pretty usual) then you should use the RESTORE-macro:
   *
   * <pre>
   * if (kapp->isRestored())
   *   RESTORE(childTLW)
   * else {
   * // create default application as usual
   * }
   * </pre>
   *
   * The macro expands to the term above but is easier to use and
   * less code to write.
   *
   * @see #restore
   * @see #classNameOfToplevel
   *
   *(Matthias)
   */
  static bool canBeRestored(int number);


  /**
   * Returns the className of the numberth toplevel window which
   * should be restored. This is only usefull if you application uses
   * different kinds of toplevel windows. (Matthias)
   */
  static const QString classNameOfToplevel(int number);

  /**
   * Restores the specified number. Returns "False" if this
   * fails, otherwise returns "True" and shows the window
   * You should call @ref canBeRestored first.
   */
  bool restore(int number);

  /**
    * Tells the session manager wether the window contains
    * unsaved data which cannot be stored in temporary files
    * during saveYourself. Note that this is somewhat bad style.
    * A really good KDE application should store everything in
    * temporary recover files. Kapplication has some nifty support
    * for that.
    *
    * Default is False == No unsaved data.
    * @see KApplication::tempSaveName
    */
  void setUnsavedData( bool );


protected:
   /**
    * Default implementation calls @ref #updateRects if main widget
    * is resizable. If mainWidget is not resizable it does
    * nothing. You shouldn't need to override this function.
    */
    virtual void resizeEvent( QResizeEvent *e);
    /**
     * Default implementation just calls repaint (FALSE); You may
     * reimplement this function if you want to.
     */
    virtual void focusInEvent ( QFocusEvent *);
    /**
     * Default implementation just calls repaint (FALSE); You may
     * reimplement this function if you want to.
     */
    virtual void focusOutEvent ( QFocusEvent *);

    /**
      * This is called when the widget is closed.
      * The default implementation will also destroy the
      * widget.(Matthias)
      */
    virtual void closeEvent ( QCloseEvent *);

   /**
    * KTMainWindow has the nice habbit that it will exit the
    * application when the very last KTMainWindow is
    * closed. Some applications may not want this default
    * behaviour, for example if the application wants to ask the user
    * wether he really wants to quit the application.  This can be
    * achived by overloading the @ref #queryExit () method.  The default
    * implementation simply returns TRUE, which means that the
    * application will be quitted. FALSE will cancel the exiting
    * process. (Matthias)
    * Note, if you cancel exiting, your application will live on without
    * windows (sven).
    * @see #queryClose
    */
    virtual bool queryExit();

    /**
     * Called before window is closed.
     * Reimplement this function if you want to ignore/accept close event.
     * Default implementation returns true. Returning false will ignore
     * closing. (sven)
     * @see #queryExit
     */
    virtual bool queryClose();

    
  /**
   * Save your instance-specific properties.
   * You MUST NOT change the group of the kconfig object,
   * since KTMainWindow uses one group for each window.
   * Please overload these function in childclasses.
   *
   * Note that any interaction or X calls are forbidden
   * in these functions!
   *
   * (Matthias)
   */
  virtual void saveProperties(KConfig*){};

  /**
  * Read your instance-specific properties.
  */
  virtual void readProperties(KConfig*){};
  /**
   * This method is called, when @ref KApplication emits signal saveYourself
   * and after KTMainWindow has verified that it is "main" top-level window.
   * So this method will be called only once and not in every widget.
   * Override it if you need to save other data about your documents on
   * session end. sessionConfig is a config to which that data should be
   * saved. Normaly, you don't need this function. But if you want to save
   * data about your documents that are not in opened windows you might need
   * it.
   *
   * Default implementation does nothing.
   */
  virtual void saveData(KConfig* sessionConfig);

protected slots:
    /**
     * Updates child window geometry. This is automatically called
     * when the window is created, new components are added or the
     * window is resized, or showd.
     * updateRects handles fixed-size widgets properly.
     *
     * Override it if you intend to manage the children yourself.
     * You normally do not need or want to do this.
     */
    virtual void updateRects();

 private slots:
  /**
   * React on the request of the session manager (Matthias)
   */
    void saveYourself();

    /**
     * Notices when toolbar is deleted.
     */
    void toolbarKilled();

    /**
     * Notices when menubar is killed.
     */
    void menubarKilled();


public:

  /**
   * List of members of KTMainWindow class
   */
  static QList<KTMainWindow>* memberList;

private:
    /**
     * List of toolbars.
     */
    QList <KToolBar> toolbars;

    /**
     * Main widget. If you want fixed-widget just call setFixedSize(w.h)
     * on your mainwidget.
     * You should not setFixedSize on KTMainWindow.
     */
    QWidget *kmainwidget;

    /**
     * Menubar.
     */
    KMenuBar *kmenubar;

    /**
     * Statusbar
     */
    KStatusBar *kstatusbar;

    /**
     * Frame around main widget
     */
    QFrame *kmainwidgetframe;

    /**
     * Stores the width of the view frame
     */
    int borderwidth;

    /**
     * True if toolbars are killed by this destructor.
     */
    bool localKill;


  // Matthias
protected:
  void savePropertiesInternal (KConfig*, int);
  bool readPropertiesInternal (KConfig*, int);
};


#define RESTORE(type) { int n = 1;\
    while (KTMainWindow::canBeRestored(n)){\
      (new type)->restore(n);\
      n++;}}

#endif

--- NEW FILE: kcolordlg.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Martin Jones (mjones at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
// KDE color selection dialog.

// layout managment added Oct 1997 by Mario Weilguni 
// <mweilguni at sime.com>

#include <stdlib.h>
#include <qimage.h>
#include <qpainter.h>
#include <qdrawutil.h>
#include <qevent.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <kconfig.h>
#include "kcolordlg.h"
#include "kcolordlg.h"

#include <dither.h>
#include <klocale.h>
#include <kapp.h>

#include <kbuttonbox.h>
#include <qlayout.h>
#include <kseparator.h>

#define HSV_X 305
#define RGB_X 385

static QColor *standardPalette = 0;

#define STANDARD_PAL_SIZE 17

void createStandardPalette()
{
    if ( standardPalette )
	return;

    standardPalette = new QColor [STANDARD_PAL_SIZE];

    int i = 0;

    standardPalette[i++] = red;
    standardPalette[i++] = green;
    standardPalette[i++] = blue;
    standardPalette[i++] = cyan;
    standardPalette[i++] = magenta;
    standardPalette[i++] = yellow;
    standardPalette[i++] = darkRed;
    standardPalette[i++] = darkGreen;
    standardPalette[i++] = darkBlue;
    standardPalette[i++] = darkCyan;
    standardPalette[i++] = darkMagenta;
    standardPalette[i++] = darkYellow;
    standardPalette[i++] = white;
    standardPalette[i++] = lightGray;
    standardPalette[i++] = gray;
    standardPalette[i++] = darkGray;
    standardPalette[i++] = black;
}

KHSSelector::KHSSelector( QWidget *parent )
	: KXYSelector( parent )
{
	setRange( 0, 0, 359, 255 );
}

void KHSSelector::resizeEvent( QResizeEvent * )
{
	drawPalette();
}

void KHSSelector::drawContents( QPainter *painter )
{
	painter->drawPixmap( contentsRect().x(), contentsRect().y(), pixmap );
}

void KHSSelector::drawPalette()
{
	int xSize = contentsRect().width(), ySize = contentsRect().height();
	QImage image( xSize, ySize, 32 );
	QColor col;
	int h, s;
	uint *p;

	for ( s = ySize-1; s >= 0; s-- )
	{
		p = (uint *) image.scanLine( ySize - s - 1 );
		for( h = 0; h < xSize; h++ )
		{
			col.setHsv( 359*h/(xSize-1), 255*s/(ySize-1), 192 );
			*p = col.rgb();
			p++;
		}
	}

	if ( QColor::numBitPlanes() <= 8 )
	{
		createStandardPalette();
		kFSDither dither( standardPalette, STANDARD_PAL_SIZE );
		QImage tImage = dither.dither( image );
		pixmap.convertFromImage( tImage );
	}
	else
		pixmap.convertFromImage( image );
}

//-----------------------------------------------------------------------------

KValueSelector::KValueSelector( QWidget *parent )
	: KSelector( KSelector::Vertical, parent )
{
	setRange( 0, 255 );
	pixmap.optimize( TRUE );
}

void KValueSelector::resizeEvent( QResizeEvent * )
{
	drawPalette();
}

void KValueSelector::drawContents( QPainter *painter )
{
	painter->drawPixmap( contentsRect().x(), contentsRect().y(), pixmap );
}

void KValueSelector::drawPalette()
{
	int xSize = contentsRect().width(), ySize = contentsRect().height();
	QImage image( xSize, ySize, 32 );
	QColor col;
	uint *p;
	QRgb rgb;

	for ( int v = 0; v < ySize; v++ )
	{
		p = (uint *) image.scanLine( ySize - v - 1 );
		col.setHsv( hue, sat, 255*v/(ySize-1) );
		rgb = col.rgb();
		for ( int i = 0; i < xSize; i++ )
			*p++ = rgb;
	}

	if ( QColor::numBitPlanes() <= 8 )
	{
		createStandardPalette();
		kFSDither dither( standardPalette, STANDARD_PAL_SIZE );
		QImage tImage = dither.dither( image );
		pixmap.convertFromImage( tImage );
	}
	else
		pixmap.convertFromImage( image );
}

//-----------------------------------------------------------------------------

KColorCells::KColorCells( QWidget *parent, int rows, int cols )
	: QTableView( parent )
{
	setNumRows( rows );
	setNumCols( cols );
	colors = new QColor [ rows * cols ];

	for ( int i = 0; i < rows * cols; i++ )
		colors[i] = backgroundColor();

	selected = 0;
}

KColorCells::~KColorCells()
{
	delete [] colors;
}

void KColorCells::setColor( int colNum, const QColor &col )
{
	colors[colNum] = col;
	updateCell( colNum/numCols(), colNum%numCols() );
}

void KColorCells::paintCell( QPainter *painter, int row, int col )
{
	QBrush brush;
	qDrawShadePanel( painter, 1, 1, cellWidth()-2, cellHeight()-2, colorGroup(),
	            TRUE, 1, &brush );
	painter->setPen( colors[ row * numCols() + col ] );
	painter->setBrush( QBrush( colors[ row * numCols() + col ] ) );
	painter->drawRect( 2, 2, cellWidth()-4, cellHeight()-4 );

	if ( row * numCols() + col == selected )
		painter->drawWinFocusRect( 2, 2, cellWidth()-4, cellHeight()-4 );
}

void KColorCells::resizeEvent( QResizeEvent * )
{
	setCellWidth( width() / numCols() );
	setCellHeight( height() / numRows() );
}

void KColorCells::mouseReleaseEvent( QMouseEvent *e )
{
	int row = e->pos().y() / cellHeight();
	int col = e->pos().x() / cellWidth();
	int cell = row * numCols() + col;

	if ( selected != cell )
	{
		int prevSel = selected;
		selected = cell;
		updateCell( prevSel/numCols(), prevSel%numCols(), FALSE );
		updateCell( row, col, FALSE );
	}

	emit colorSelected( cell );
}

//-----------------------------------------------------------------------------

KColorPatch::KColorPatch( QWidget *parent ) : QFrame( parent )
{
	setFrameStyle( QFrame::Panel | QFrame::Sunken );
	colContext = 0;
}

KColorPatch::~KColorPatch()
{
  if ( colContext )
    QColor::destroyAllocContext( colContext );
}

void KColorPatch::setColor( const QColor &col )
{
	if ( colContext )
		QColor::destroyAllocContext( colContext );
	colContext = QColor::enterAllocContext();
	color.setRgb( col.rgb() );
	color.alloc();
	QColor::leaveAllocContext();

	QPainter painter;

	painter.begin( this );
	drawContents( &painter );
	painter.end();
}

void KColorPatch::drawContents( QPainter *painter )
{
	painter->setPen( color );
	painter->setBrush( QBrush( color ) );
	painter->drawRect( contentsRect() );
}

//-----------------------------------------------------------------------------

KColorDialog::KColorDialog( QWidget *parent, const char *name, bool modal )
	: QDialog( parent, name, modal )
{
	QLabel *label;
	QPushButton *button;
	int h, s, v;
	
	selColor = darkCyan;
	selColor.hsv( &h, &s, &v );
	QString st;
	if(kapp->appName().length() > 0)
	  st = kapp->appName() + ": ";
	st =  klocale->translate("Select Color");
	setCaption( st.data() );
	
	// create a toplevel layout
	QGridLayout *tl_layout = new QGridLayout(this, 3, 3, 10);
	tl_layout->addColSpacing(1, 15);
	
	// add a layout for left-side (colors)
	QVBoxLayout *l_left = new QVBoxLayout;
	tl_layout->addLayout(l_left, 0, 0);
	
	// system colors
	label = new QLabel( klocale->translate("System Colors"), this );
	label->setFixedSize(label->sizeHint());
	l_left->addWidget(label, 0, AlignLeft);
	sysColorCells = new KColorCells( this, 3, 6 );
	sysColorCells->setMinimumSize(90, 60);
	sysColorCells->setGeometry( 15, 35, 180, 60 );
	sysColorCells->setColor( 0, red );
	sysColorCells->setColor( 1, green );
	sysColorCells->setColor( 2, blue );
	sysColorCells->setColor( 3, cyan );
	sysColorCells->setColor( 4, magenta );
	sysColorCells->setColor( 5, yellow );
	sysColorCells->setColor( 6, darkRed );
	sysColorCells->setColor( 7, darkGreen );
	sysColorCells->setColor( 8, darkBlue );
	sysColorCells->setColor( 9, darkCyan );
	sysColorCells->setColor( 10, darkMagenta );
	sysColorCells->setColor( 11, darkYellow );
	sysColorCells->setColor( 12, white );
	sysColorCells->setColor( 13, lightGray );
	sysColorCells->setColor( 14, gray );
	sysColorCells->setColor( 15, darkGray );
	sysColorCells->setColor( 16, black );
	connect( sysColorCells, SIGNAL( colorSelected( int ) ),
		 SLOT( slotSysColorSelected( int ) ) );
	l_left->addWidget(sysColorCells, 10);
	
	// a little space between
	l_left->addStretch(1);
	
	// add custom colors
	label = new QLabel( klocale->translate("Custom Colors"), this );
	label->setFixedSize(label->sizeHint());
	l_left->addWidget(label, 0, AlignLeft);
	custColorCells = new KColorCells( this, 3, 6 );
	custColorCells->setMinimumSize(90, 60);
	connect( custColorCells, SIGNAL( colorSelected( int ) ),
		 SLOT( slotCustColorSelected( int ) ) );
	l_left->addWidget(custColorCells, 10);
	
	// a little space between
	l_left->addStretch(1);
	
	// add buttom for adding colors
	button = new QPushButton( klocale->translate("Add to Custom Colors"),
				  this );
	button->setMinimumSize(button->sizeHint());
	l_left->addWidget(button, 0);
	connect( button, SIGNAL( clicked() ), 
		 SLOT( slotAddToCustom() ) );
	
	// the more complicated part: the right side
	// add a V-box
	QVBoxLayout *l_right = new QVBoxLayout();
	tl_layout->addLayout(l_right, 0, 2);
	
	// add a H-Box for the XY-Selector and a grid for the
	// entry fields
	QHBoxLayout *l_rtop = new QHBoxLayout();
	l_right->addLayout(l_rtop);
	QGridLayout *l_rbot = new QGridLayout(3, 6);
	l_right->addLayout(l_rbot);  
	
	// the palette and value selector go into the H-box
	palette = new KHSSelector( this );
	palette->setMinimumSize(140, 70);
	l_rtop->addWidget(palette, 8);  
	connect( palette, SIGNAL( valueChanged( int, int ) ),
		 SLOT( slotHSChanged( int, int ) ) );
	
	valuePal = new KValueSelector( this );
	valuePal->setHue( h );
	valuePal->setSaturation( s );
	valuePal->setMinimumSize(26, 70);
	l_rtop->addWidget(valuePal, 1);
	connect( valuePal, SIGNAL( valueChanged( int ) ),
		 SLOT( slotVChanged( int ) ) );
	
	// and now the entry fields and the patch
	patch = new KColorPatch( this );
	l_rbot->addMultiCellWidget(patch, 0, 2, 0, 0, AlignVCenter|AlignLeft);
	patch->setFixedSize(48, 48);
	patch->setColor( selColor );
	
	// add the HSV fields
	label = new QLabel( "H:", this );
	label->setMinimumSize(label->sizeHint());
	label->setAlignment(AlignRight | AlignVCenter);
	l_rbot->addWidget(label, 0, 2);
	hedit = new QLineEdit( this );
	hedit->setFixedHeight(hedit->sizeHint().height());
	l_rbot->addWidget(hedit, 0, 3);
	connect( hedit, SIGNAL( returnPressed() ),
		 SLOT( slotHSVChanged() ) );
	
	label = new QLabel( "S:", this );
	label->setMinimumSize(label->sizeHint());
	label->setAlignment(AlignRight | AlignVCenter);
	l_rbot->addWidget(label, 1, 2);
	sedit = new QLineEdit( this );
	sedit->setFixedHeight(sedit->sizeHint().height());
	l_rbot->addWidget(sedit, 1, 3);
	connect( sedit, SIGNAL( returnPressed() ),
		 SLOT( slotHSVChanged() ) );
	
	label = new QLabel( "V:", this );
	label->setMinimumSize(label->sizeHint());
	label->setAlignment(AlignRight | AlignVCenter);
	l_rbot->addWidget(label, 2, 2);
	vedit = new QLineEdit( this );
	vedit->setFixedHeight(vedit->sizeHint().height());
	l_rbot->addWidget(vedit, 2, 3);
	connect( vedit, SIGNAL( returnPressed() ),
		 SLOT( slotHSVChanged() ) );
	
	
	// add the RGB fields
	label = new QLabel( "R:", this );
	label->setMinimumSize(label->sizeHint());
	label->setAlignment(AlignRight | AlignVCenter);
	l_rbot->addWidget(label, 0, 4);
	redit = new QLineEdit( this );
	redit->setFixedHeight(redit->sizeHint().height());
	l_rbot->addWidget(redit, 0, 5);
	connect( redit, SIGNAL( returnPressed() ),
		 SLOT( slotRGBChanged() ) );
	
	label = new QLabel( "G:", this );
	label->setMinimumSize(label->sizeHint());
	label->setAlignment(AlignRight | AlignVCenter);
	l_rbot->addWidget(label, 1, 4);
	gedit = new QLineEdit( this );
	gedit->setFixedHeight(gedit->sizeHint().height());
	l_rbot->addWidget(gedit, 1, 5);
	connect( gedit, SIGNAL( returnPressed() ),
		 SLOT( slotRGBChanged() ) );
	
	label = new QLabel( "B:", this );
	label->setMinimumSize(label->sizeHint());
	label->setAlignment(AlignRight | AlignVCenter);
	l_rbot->addWidget(label, 2, 4);
	bedit = new QLineEdit( this );
	bedit->setFixedHeight(bedit->sizeHint().height());
	l_rbot->addWidget(bedit, 2, 5);
	connect( bedit, SIGNAL( returnPressed() ),
		 SLOT( slotRGBChanged() ) );
	
	// the entry fields should be wide enought to hold 88888
	int w = hedit->fontMetrics().boundingRect("88888").width();
	hedit->setMinimumWidth(w);
	redit->setMinimumWidth(w);
	
	// the label rows should not expand
	l_rbot->setColStretch(2, 0);
	l_rbot->setColStretch(4, 0);
	
	// the entry rows should expand
	l_rbot->setColStretch(3, 1);
	l_rbot->setColStretch(5, 1);
	
	// a little separator between
	KSeparator *sep = new KSeparator(this);
	tl_layout->addMultiCellWidget(sep, 1, 1, 0, 2);
	
	// the standard buttons
	KButtonBox *bbox = new KButtonBox(this);
        button  = bbox->addButton(klocale->translate("Help"));
          connect( button, SIGNAL(clicked()),
		                   SLOT(getHelp()));                              
        bbox->addStretch(1);
        button = bbox->addButton(klocale->translate("OK"));
	connect( button, SIGNAL( clicked() ), 
		 SLOT( slotOkPressed() ) );
	button = bbox->addButton(klocale->translate("Cancel"));

	connect( button, SIGNAL( clicked() ), 
		 SLOT( reject() ) );
	bbox->layout();
	bbox->setMinimumSize(bbox->sizeHint());

        tl_layout->addMultiCellWidget(bbox, 2, 2, 0, 2);
	tl_layout->setRowStretch(0, 1);
	tl_layout->setRowStretch(1, 0);
	tl_layout->setRowStretch(2, 0);
	tl_layout->activate();
	tl_layout->freeze();
	
	readSettings();
	
	setRgbEdit();
	setHsvEdit();
	
	palette->setValues( h, s );
	valuePal->setValue( v );
}

void KColorDialog::setColor( const QColor &col )
{
	selColor = col;

	setRgbEdit();
	setHsvEdit();

	int h, s, v;
	selColor.hsv( &h, &s, &v );
	palette->setValues( h, s );
	valuePal->setHue( h );
	valuePal->setSaturation( s );
	valuePal->drawPalette();
	valuePal->repaint( FALSE );
	valuePal->setValue( v );
	patch->setColor( selColor );
}

// static function to display dialog and return color
int KColorDialog::getColor( QColor &theColor )
{
	KColorDialog dlg( 0L, "Color Selector", TRUE );
	if ( theColor.isValid() )
		dlg.setColor( theColor );
	int result = dlg.exec();

	if ( result == Accepted )
		theColor = dlg.color();

	return result;
}

void KColorDialog::slotOkPressed()
{
	writeSettings();
	accept();
}

void KColorDialog::slotRGBChanged()
{
	int red = atoi( redit->text() );
	int grn = atoi( gedit->text() );
	int blu = atoi( bedit->text() );

	if ( red > 255 || red < 0 ) return;
	if ( grn > 255 || grn < 0 ) return;
	if ( blu > 255 || blu < 0 ) return;

	selColor.setRgb( red, grn, blu );
	patch->setColor( selColor );

	setRgbEdit();
	setHsvEdit();

	int h, s, v;
	selColor.hsv( &h, &s, &v );
	palette->setValues( h, s );
	valuePal->setHue( h );
	valuePal->setSaturation( s );
	valuePal->drawPalette();
	valuePal->repaint( FALSE );
	valuePal->setValue( v );

	emit colorSelected( selColor );
}

void KColorDialog::slotHSVChanged()
{
	int hue = atoi( hedit->text() );
	int sat = atoi( sedit->text() );
	int val = atoi( vedit->text() );

	if ( hue > 359 || hue < 0 ) return;
	if ( sat > 255 || sat < 0 ) return;
	if ( val > 255 || val < 0 ) return;

	selColor.setHsv( hue, sat, val );
	patch->setColor( selColor );

	setRgbEdit();
	setHsvEdit();

	palette->setValues( hue, sat );
	valuePal->setHue( hue );
	valuePal->setSaturation( sat );
	valuePal->drawPalette();
	valuePal->repaint( FALSE );
	valuePal->setValue( val );

	emit colorSelected( selColor );
}

void KColorDialog::slotHSChanged( int h, int s )
{
	selColor.setHsv( h, s, valuePal->value() );

	valuePal->setHue( h );
	valuePal->setSaturation( s );
	valuePal->drawPalette();
	valuePal->repaint( FALSE );

	patch->setColor( selColor );

	setRgbEdit();
	setHsvEdit();

	emit colorSelected( selColor );
}

void KColorDialog::slotVChanged( int v )
{
	selColor.setHsv( palette->xValue(), palette->yValue(), v );
	patch->setColor( selColor );

	setRgbEdit();
	setHsvEdit();

	emit colorSelected( selColor );
}

void KColorDialog::slotSysColorSelected( int col )
{
	selColor = sysColorCells->color( col );

	patch->setColor( selColor );

	setRgbEdit();
	setHsvEdit();

	int h, s, v;
	selColor.hsv( &h, &s, &v );
	palette->setValues( h, s );
	valuePal->setHue( h );
	valuePal->setSaturation( s );
	valuePal->drawPalette();
	valuePal->repaint( FALSE );
	valuePal->setValue( v );

	emit colorSelected( selColor );
}

void KColorDialog::slotCustColorSelected( int col )
{
	QColor color = custColorCells->color( col );

	// if a color has not been assigned to this cell, don't change current col
	if ( color == lightGray )
		return;

	selColor = color;

	patch->setColor( selColor );

	setRgbEdit();
	setHsvEdit();

	int h, s, v;
	selColor.hsv( &h, &s, &v );
	palette->setValues( h, s );
	valuePal->setHue( h );
	valuePal->setSaturation( s );
	valuePal->drawPalette();
	valuePal->repaint( FALSE );
	valuePal->setValue( v );

	emit colorSelected( selColor );
}

void KColorDialog::slotAddToCustom()
{
	custColorCells->setColor( custColorCells->getSelected(), selColor );
}

void KColorDialog::readSettings()
{
	QColor col;
	QString key;

	KConfig* config = kapp->getConfig();

	QString oldgroup = config->group();
	config->setGroup( "Custom Colors");

	for ( int i = 0; i < custColorCells->numCells(); i++ )
	{
		key.sprintf( "Color%d", i );
		col = config->readColorEntry( key, &lightGray );
		custColorCells->setColor( i, col );
	}
	config->setGroup( oldgroup );
}

void KColorDialog::writeSettings()
{
	QColor color;
	QString key;

	KConfig* config = kapp->getConfig();

	QString oldgroup = config->group();
	config->setGroup( "Custom Colors");

	for ( int i = 0; i < custColorCells->numCells(); i++ )
	{
		color = custColorCells->color( i );
		key.sprintf( "Color%d", i );
		config->writeEntry( key, color, true, true );
	}

	config->setGroup( oldgroup );
}

void KColorDialog::setRgbEdit()
{
	int r, g, b;
	selColor.rgb( &r, &g, &b );
	QString num;

	num.setNum( r );
	redit->setText( num );
	num.setNum( g );
	gedit->setText( num );
	num.setNum( b );
	bedit->setText( num );
}

void KColorDialog::setHsvEdit()
{
	int h, s, v;
	selColor.hsv( &h, &s, &v );
	QString num;

	num.setNum( h );
	hedit->setText( num );
	num.setNum( s );
	sedit->setText( num );
	num.setNum( v );
	vedit->setText( num );
}

void KColorDialog::getHelp() {
  if(kapp != 0)
    kapp->invokeHTMLHelp("kcolordialog.html", "");
}

//----------------------------------------------------------------------------

KColorCombo::KColorCombo( QWidget *parent, const char *name )
	: QComboBox( parent, name )
{
	customColor.setRgb( 255, 255, 255 );
	color.setRgb( 255, 255, 255 );

	createStandardPalette();

	addColors();

	connect( this, SIGNAL( activated(int) ), SLOT( slotActivated(int) ) );
	connect( this, SIGNAL( highlighted(int) ), SLOT( slotHighlighted(int) ) );
}

void KColorCombo::setColor( const QColor &col )
{
	color = col;

	addColors();
}

void KColorCombo::resizeEvent( QResizeEvent *re )
{
	QComboBox::resizeEvent( re );

	addColors();
}

void KColorCombo::slotActivated( int index )
{
	if ( index == 0 )
	{
	    if ( KColorDialog::getColor( customColor ) == QDialog::Accepted )
		{
			QRect rect( 0, 0, width(), 20 );
			QPixmap pixmap( rect.width(), rect.height() );
			QPainter painter;
			QPen pen;

			if ( qGray( customColor.rgb() ) < 128 )
				pen.setColor( white );
			else
				pen.setColor( black );

			painter.begin( &pixmap );
			QBrush brush( customColor );
			painter.fillRect( rect, brush );
			painter.setPen( pen );
			painter.drawText( 2, 18, 
					  klocale->translate("Custom...") );
			painter.end();

			changeItem( pixmap, 0 );
			pixmap.detach();
		}

		color = customColor;
	}
	else
		color = standardPalette[ index - 1 ];

	emit activated( color );
}

void KColorCombo::slotHighlighted( int index )
{
	if ( index == 0 )
		color = customColor;
	else
		color = standardPalette[ index - 1 ];

	emit highlighted( color );
}

void KColorCombo::addColors()
{
	QRect rect( 0, 0, width(), 20 );
	QPixmap pixmap( rect.width(), rect.height() );
	QPainter painter;
	QPen pen;
	int i;

	clear();

	createStandardPalette();

	for ( i = 0; i < STANDARD_PAL_SIZE; i++ )
		if ( standardPalette[i] == color ) break;

	if ( i == STANDARD_PAL_SIZE )
		customColor = color;

	if ( qGray( customColor.rgb() ) < 128 )
		pen.setColor( white );
	else
		pen.setColor( black );

	painter.begin( &pixmap );
	QBrush brush( customColor );
	painter.fillRect( rect, brush );
	painter.setPen( pen );
	painter.drawText( 2, 18, klocale->translate("Custom...") );
	painter.end();

	insertItem( pixmap );
	pixmap.detach();
	
	for ( i = 0; i < STANDARD_PAL_SIZE; i++ )
	{
		painter.begin( &pixmap );
		QBrush brush( standardPalette[i] );
		painter.fillRect( rect, brush );
		painter.end();

		insertItem( pixmap );
		pixmap.detach();

		if ( standardPalette[i] == color )
			setCurrentItem( i + 1 );
	}
}
#include "kcolordlg.moc"


--- NEW FILE: kseparator.h ---
/*
 *   Copyright (C) 1997  Michael Roth <mroth at wirlweb.de>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#ifndef __KSEPARATOR_H__
#define __KSEPARATOR_H__

#include <qframe.h>

/// Horizontal and vertical lines
/**
'kseparator' is a small class to provide a identically look of horizontal or
vertical lines in all KDE applications.
*/
class KSeparator : public QFrame
{
   public:
      KSeparator(QWidget* parent=0, const char* name=0, WFlags f=0);
      KSeparator(int orientation, QWidget* parent=0, const char* name=0, WFlags f=0);
      
      int orientation() const;
      void setOrientation(int);
      
      virtual QSize sizeHint() const;
};


#endif // __KSEPARATOR_H__

--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am

# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

#	This file is part of the KDE libraries
#    Copyright (C) 1997 Matthias Kalle Dalheimer (kalle at kde.org)
#			  (C) 1997 Stephan Kulow (coolo at kde.org)

#    This library is free software; you can redistribute it and/or
#    modify it under the terms of the GNU Library General Public
#    License as published by the Free Software Foundation; either
#    version 2 of the License, or (at your option) any later version.

#    This library is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#    Library General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with this library; see the file COPYING.  If not, write to
#    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
#    Boston, MA 02111-1307, USA.


SHELL = @SHELL@

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include

DESTDIR =

pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@

top_builddir = ..

ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@

NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
GLINC = @GLINC@
GLLIB = @GLLIB@
GMSGFMT = @GMSGFMT@
IDL = @IDL@
KDE_EXTRA_RPATH = @KDE_EXTRA_RPATH@
KDE_INCLUDES = @KDE_INCLUDES@
KDE_LDFLAGS = @KDE_LDFLAGS@
KDE_RPATH = @KDE_RPATH@
LD = @LD@
LIBCOMPAT = @LIBCOMPAT@
LIBCRYPT = @LIBCRYPT@
LIBDL = @LIBDL@
LIBJPEG = @LIBJPEG@
LIBMICO = @LIBMICO@
LIBOBJS = @LIBOBJS@
LIBPNG = @LIBPNG@
LIBPTHREAD = @LIBPTHREAD@
LIBPYTHON = @LIBPYTHON@
LIBQIMGIO = @LIBQIMGIO@
LIBSOCKET = @LIBSOCKET@
LIBTIFF = @LIBTIFF@
LIBTOOL = @LIBTOOL@
LIBUCB = @LIBUCB@
LIBZ = @LIBZ@
LIB_KAB = @LIB_KAB@
LIB_KDECORE = @LIB_KDECORE@
LIB_KDEUI = @LIB_KDEUI@
LIB_KDEUTIL = @LIB_KDEUTIL@
LIB_KFILE = @LIB_KFILE@
LIB_KFM = @LIB_KFM@
LIB_KHTML = @LIB_KHTML@
LIB_KHTMLW = @LIB_KHTMLW@
LIB_KIMGIO = @LIB_KIMGIO@
LIB_KIO = @LIB_KIO@
LIB_MEDIATOOL = @LIB_MEDIATOOL@
LIB_QT = @LIB_QT@
LIB_X11 = @LIB_X11@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
MICO_INCLUDES = @MICO_INCLUDES@
MICO_LDFLAGS = @MICO_LDFLAGS@
MOC = @MOC@
MSGFMT = @MSGFMT@
NM = @NM@
PACKAGE = @PACKAGE@
PAMINC = @PAMINC@
PAMLIBPATHS = @PAMLIBPATHS@
PAMLIBS = @PAMLIBS@
PYTHONINC = @PYTHONINC@
PYTHONLIB = @PYTHONLIB@
QKEYCODE_H = @QKEYCODE_H@
QT_INCLUDES = @QT_INCLUDES@
QT_LDFLAGS = @QT_LDFLAGS@
RANLIB = @RANLIB@
TOPSUBDIRS = @TOPSUBDIRS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XPMINC = @XPMINC@
XPMLIB = @XPMLIB@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_INCLUDES = @X_INCLUDES@
X_LDFLAGS = @X_LDFLAGS@
all_includes = @all_includes@
all_libraries = @all_libraries@
install_root = @install_root@
kde_appsdir = @kde_appsdir@
kde_bindir = @kde_bindir@
kde_cgidir = @kde_cgidir@
kde_confdir = @kde_confdir@
kde_datadir = @kde_datadir@
kde_htmldir = @kde_htmldir@
kde_icondir = @kde_icondir@
kde_includes = @kde_includes@
kde_libraries = @kde_libraries@
kde_locale = @kde_locale@
kde_mimedir = @kde_mimedir@
kde_minidir = @kde_minidir@
kde_partsdir = @kde_partsdir@
kde_sounddir = @kde_sounddir@
kde_toolbardir = @kde_toolbardir@
kde_wallpaperdir = @kde_wallpaperdir@
qt_includes = @qt_includes@
qt_libraries = @qt_libraries@
topdir = @topdir@
x_includes = @x_includes@
x_libraries = @x_libraries@

INCLUDES = -I$(top_srcdir)/kdecore -I$(top_srcdir)/kfile $(QT_INCLUDES) $(X_INCLUDES) 
EXTRA_DIST = $(data_DATA) CHANGES.kdatepicker USERS.kdatepicker

lib_LTLIBRARIES = libkdeui.la
libkdeui_la_LDFLAGS = -version-info 2:0  

include_HEADERS = kledlamp.h kprogress.h kpanner.h kcolordlg.h kselect.h 		kdatepik.h kdatetbl.h 		kfontdialog.h kmsgbox.h kpopmenu.h ktabctl.h 		ktreelist.h kstatusbar.h ktopwidget.h ktmainwindow.h 		ktoolbar.h kmenubar.h kbutton.h kslider.h kseparator.h 		klined.h kcombo.h krestrictedline.h kintegerline.h			kspinbox.h kcolorbtn.h kiconloaderdialog.h 		kwmmapp.h kbuttonbox.h ktablistbox.h kcontainer.h 		knewpanner.h kcontrol.h keditcl.h ktoolboxmgr.h kled.h			kdbtn.h knotebook.h ktabbar.h kwizard.h kkeydialog.h 		kurllabel.h kruler.h kquickhelp.h kcursor.h


libkdeui_la_SOURCES = kledlamp.cpp kprogress.cpp kpanner.cpp kcolordlg.cpp 		kselect.cpp kdatepik.cpp kdatetbl.cpp 		kfontdialog.cpp kmsgbox.cpp kpopmenu.cpp ktabctl.cpp 		ktreelist.cpp kstatusbar.cpp ktopwidget.cpp ktmainwindow.cpp 		kmenubar.cpp ktoolbar.cpp kbutton.cpp kslider.cpp 		kseparator.cpp klined.cpp kcombo.cpp krestrictedline.cpp 		kintegerline.cpp kspinbox.cpp kcontrol.cpp 		kcolorbtn.cpp kiconloaderdialog.cpp kwmmapp.cpp			kbuttonbox.cpp ktablistbox.cpp knewpanner.cpp 		keditcl1.cpp keditcl2.cpp ktoolboxmgr.cpp kled.cpp			kdbtn.cpp knotebook.cpp ktabbar.cpp kwizard.cpp kcontainer.cpp 		kkeydialog.cpp kurllabel.cpp kruler.cpp kquickhelp.cpp kcursor.cpp


libkdeui_la_METASOURCES = kbutton.moc kbuttonbox.moc kcolorbtn.moc 	kcolordlg.moc kcombo.moc kcontainer.moc kcontrol.moc kdatepik.moc 	kdatetbl.moc kdbtn.moc keditcl.moc kfontdialog.moc 	kiconloaderdialog.moc kintegerline.moc kkeydialog.moc kled.moc 	kledlamp.moc klined.moc kmenubar.moc kmsgbox.moc knewpanner.moc 	knotebook.moc kpanner.moc kpopmenu.moc kprogress.moc 	kquickhelp.moc krestrictedline.moc kruler.moc kselect.moc 	kslider.moc kspinbox.moc kstatusbar.moc ktabbar.moc ktabctl.moc 	ktablistbox.moc ktmainwindow.moc ktoolbar.moc ktoolboxmgr.moc 	ktopwidget.moc ktreelist.moc kurllabel.moc kwizard.moc kwmmapp.moc


data_DATA = error.xpm exclamation.xpm info.xpm stopsign.xpm question.xpm 	arrow_up.xbm arrow_down.xbm arrow_left.xbm arrow_right.xbm	

datadir = $(kde_datadir)/kde/pics
mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES = 
LTLIBRARIES =  $(lib_LTLIBRARIES)


DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libkdeui_la_LIBADD = 
libkdeui_la_OBJECTS =  kledlamp.lo kprogress.lo kpanner.lo kcolordlg.lo \
kselect.lo kdatepik.lo kdatetbl.lo kfontdialog.lo kmsgbox.lo \
kpopmenu.lo ktabctl.lo ktreelist.lo kstatusbar.lo ktopwidget.lo \
ktmainwindow.lo kmenubar.lo ktoolbar.lo kbutton.lo kslider.lo \
kseparator.lo klined.lo kcombo.lo krestrictedline.lo kintegerline.lo \
kspinbox.lo kcontrol.lo kcolorbtn.lo kiconloaderdialog.lo kwmmapp.lo \
kbuttonbox.lo ktablistbox.lo knewpanner.lo keditcl1.lo keditcl2.lo \
ktoolboxmgr.lo kled.lo kdbtn.lo knotebook.lo ktabbar.lo kwizard.lo \
kcontainer.lo kkeydialog.lo kurllabel.lo kruler.lo kquickhelp.lo \
kcursor.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
DATA =  $(data_DATA)

HEADERS =  $(include_HEADERS)

DIST_COMMON =  AUTHORS ChangeLog Makefile.am Makefile.in


DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)

TAR = tar
GZIP_ENV = --best
SOURCES = $(libkdeui_la_SOURCES)
OBJECTS = $(libkdeui_la_OBJECTS)

all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cpp .lo .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
	cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps kdeui/Makefile
	cd $(top_srcdir) && perl admin/automoc kdeui/Makefile.in

Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
	cd $(top_builddir) \
	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status


mostlyclean-libLTLIBRARIES:

clean-libLTLIBRARIES:
	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)

distclean-libLTLIBRARIES:

maintainer-clean-libLTLIBRARIES:

install-libLTLIBRARIES: $(lib_LTLIBRARIES)
	@$(NORMAL_INSTALL)
	$(mkinstalldirs) $(DESTDIR)$(libdir)
	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
	  if test -f $$p; then \
	    echo "$(LIBTOOL)  --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
	    $(LIBTOOL)  --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
	  else :; fi; \
	done

uninstall-libLTLIBRARIES:
	@$(NORMAL_UNINSTALL)
	list='$(lib_LTLIBRARIES)'; for p in $$list; do \
	  $(LIBTOOL)  --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
	done

.c.o:
	$(COMPILE) -c $<

.s.o:
	$(COMPILE) -c $<

.S.o:
	$(COMPILE) -c $<

mostlyclean-compile:
	-rm -f *.o core *.core

clean-compile:

distclean-compile:
	-rm -f *.tab.c

maintainer-clean-compile:

.c.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

.s.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

.S.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

mostlyclean-libtool:
	-rm -f *.lo

clean-libtool:
	-rm -rf .libs _libs

distclean-libtool:

maintainer-clean-libtool:

libkdeui.la: $(libkdeui_la_OBJECTS) $(libkdeui_la_DEPENDENCIES)
	$(CXXLINK) -rpath $(libdir) $(libkdeui_la_LDFLAGS) $(libkdeui_la_OBJECTS) $(libkdeui_la_LIBADD) $(LIBS)
.cpp.o:
	$(CXXCOMPILE) -c $<
.cpp.lo:
	$(LTCXXCOMPILE) -c $<

install-dataDATA: $(data_DATA)
	@$(NORMAL_INSTALL)
	$(mkinstalldirs) $(DESTDIR)$(datadir)
	@list='$(data_DATA)'; for p in $$list; do \
	  if test -f $(srcdir)/$$p; then \
	    echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(datadir)/$$p"; \
	    $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(datadir)/$$p; \
	  else if test -f $$p; then \
	    echo " $(INSTALL_DATA) $$p $(DESTDIR)$(datadir)/$$p"; \
	    $(INSTALL_DATA) $$p $(DESTDIR)$(datadir)/$$p; \
	  fi; fi; \
	done

uninstall-dataDATA:
	@$(NORMAL_UNINSTALL)
	list='$(data_DATA)'; for p in $$list; do \
	  rm -f $(DESTDIR)$(datadir)/$$p; \
	done

install-includeHEADERS: $(include_HEADERS)
	@$(NORMAL_INSTALL)
	$(mkinstalldirs) $(DESTDIR)$(includedir)
	@list='$(include_HEADERS)'; for p in $$list; do \
	  if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
	  echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
	  $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
	done

uninstall-includeHEADERS:
	@$(NORMAL_UNINSTALL)
	list='$(include_HEADERS)'; for p in $$list; do \
	  rm -f $(DESTDIR)$(includedir)/$$p; \
	done

tags: TAGS

ID: $(HEADERS) $(SOURCES) $(LISP)
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	here=`pwd` && cd $(srcdir) \
	  && mkid -f$$here/ID $$unique $(LISP)

TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
	tags=; \
	here=`pwd`; \
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)

mostlyclean-tags:

clean-tags:

distclean-tags:
	-rm -f TAGS ID

maintainer-clean-tags:

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)

subdir = kdeui

distdir: $(DISTFILES)
	@for file in $(DISTFILES); do \
	  d=$(srcdir); \
	  if test -d $$d/$$file; then \
	    cp -pr $$/$$file $(distdir)/$$file; \
	  else \
	    test -f $(distdir)/$$file \
	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
	    || cp -p $$d/$$file $(distdir)/$$file || :; \
	  fi; \
	done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libLTLIBRARIES
install-exec: install-exec-am

install-data-am: install-dataDATA install-includeHEADERS
install-data: install-data-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libLTLIBRARIES uninstall-dataDATA \
		uninstall-includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
all-redirect: all-am
install-strip:
	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
	$(mkinstalldirs)  $(DESTDIR)$(libdir) $(DESTDIR)$(datadir) \
		$(DESTDIR)$(includedir)


mostlyclean-generic:

clean-generic:

distclean-generic:
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
	-rm -f config.cache config.log stamp-h stamp-h[0-9]*

maintainer-clean-generic:
mostlyclean-am:  mostlyclean-libLTLIBRARIES mostlyclean-compile \
		mostlyclean-libtool mostlyclean-tags \
		mostlyclean-generic

mostlyclean: mostlyclean-am

clean-am:  clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
		clean-generic mostlyclean-am

clean: clean-am

distclean-am:  distclean-libLTLIBRARIES distclean-compile \
		distclean-libtool distclean-tags distclean-generic \
		clean-am
	-rm -f libtool

distclean: distclean-metasources distclean-am

maintainer-clean-am:  maintainer-clean-libLTLIBRARIES \
		maintainer-clean-compile maintainer-clean-libtool \
		maintainer-clean-tags maintainer-clean-generic \
		distclean-am
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."

maintainer-clean: maintainer-clean-am

.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
distclean-compile clean-compile maintainer-clean-compile \
mostlyclean-libtool distclean-libtool clean-libtool \
maintainer-clean-libtool uninstall-dataDATA install-dataDATA \
uninstall-includeHEADERS install-includeHEADERS tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean


# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:


$(srcdir)/kbutton.cpp: kbutton.moc
kbutton.moc: $(srcdir)/kbutton.h
	$(MOC) $(srcdir)/kbutton.h -o kbutton.moc

$(srcdir)/kbuttonbox.cpp: kbuttonbox.moc
kbuttonbox.moc: $(srcdir)/kbuttonbox.h
	$(MOC) $(srcdir)/kbuttonbox.h -o kbuttonbox.moc

$(srcdir)/kcolorbtn.cpp: kcolorbtn.moc
kcolorbtn.moc: $(srcdir)/kcolorbtn.h
	$(MOC) $(srcdir)/kcolorbtn.h -o kcolorbtn.moc

$(srcdir)/kcolordlg.cpp: kcolordlg.moc
kcolordlg.moc: $(srcdir)/kcolordlg.h
	$(MOC) $(srcdir)/kcolordlg.h -o kcolordlg.moc

$(srcdir)/kcombo.cpp: kcombo.moc
kcombo.moc: $(srcdir)/kcombo.h
	$(MOC) $(srcdir)/kcombo.h -o kcombo.moc

$(srcdir)/kcontainer.cpp: kcontainer.moc
kcontainer.moc: $(srcdir)/kcontainer.h
	$(MOC) $(srcdir)/kcontainer.h -o kcontainer.moc

$(srcdir)/kcontrol.cpp: kcontrol.moc
kcontrol.moc: $(srcdir)/kcontrol.h
	$(MOC) $(srcdir)/kcontrol.h -o kcontrol.moc

$(srcdir)/kdatepik.cpp: kdatepik.moc
kdatepik.moc: $(srcdir)/kdatepik.h
	$(MOC) $(srcdir)/kdatepik.h -o kdatepik.moc

$(srcdir)/kdatetbl.cpp: kdatetbl.moc
kdatetbl.moc: $(srcdir)/kdatetbl.h
	$(MOC) $(srcdir)/kdatetbl.h -o kdatetbl.moc

$(srcdir)/kdbtn.cpp: kdbtn.moc
kdbtn.moc: $(srcdir)/kdbtn.h
	$(MOC) $(srcdir)/kdbtn.h -o kdbtn.moc

$(srcdir)/keditcl1.cpp: keditcl.moc
keditcl.moc: $(srcdir)/keditcl.h
	$(MOC) $(srcdir)/keditcl.h -o keditcl.moc

$(srcdir)/kfontdialog.cpp: kfontdialog.moc
kfontdialog.moc: $(srcdir)/kfontdialog.h
	$(MOC) $(srcdir)/kfontdialog.h -o kfontdialog.moc

$(srcdir)/kiconloaderdialog.cpp: kiconloaderdialog.moc
kiconloaderdialog.moc: $(srcdir)/kiconloaderdialog.h
	$(MOC) $(srcdir)/kiconloaderdialog.h -o kiconloaderdialog.moc

$(srcdir)/kintegerline.cpp: kintegerline.moc
kintegerline.moc: $(srcdir)/kintegerline.h
	$(MOC) $(srcdir)/kintegerline.h -o kintegerline.moc

$(srcdir)/kkeydialog.cpp: kkeydialog.moc
kkeydialog.moc: $(srcdir)/kkeydialog.h
	$(MOC) $(srcdir)/kkeydialog.h -o kkeydialog.moc

$(srcdir)/kled.cpp: kled.moc
kled.moc: $(srcdir)/kled.h
	$(MOC) $(srcdir)/kled.h -o kled.moc

$(srcdir)/kledlamp.cpp: kledlamp.moc
kledlamp.moc: $(srcdir)/kledlamp.h
	$(MOC) $(srcdir)/kledlamp.h -o kledlamp.moc

$(srcdir)/klined.cpp: klined.moc
klined.moc: $(srcdir)/klined.h
	$(MOC) $(srcdir)/klined.h -o klined.moc

$(srcdir)/kmenubar.cpp: kmenubar.moc
kmenubar.moc: $(srcdir)/kmenubar.h
	$(MOC) $(srcdir)/kmenubar.h -o kmenubar.moc

$(srcdir)/kmsgbox.cpp: kmsgbox.moc
kmsgbox.moc: $(srcdir)/kmsgbox.h
	$(MOC) $(srcdir)/kmsgbox.h -o kmsgbox.moc

$(srcdir)/knewpanner.cpp: knewpanner.moc
knewpanner.moc: $(srcdir)/knewpanner.h
	$(MOC) $(srcdir)/knewpanner.h -o knewpanner.moc

$(srcdir)/knotebook.cpp: knotebook.moc
knotebook.moc: $(srcdir)/knotebook.h
	$(MOC) $(srcdir)/knotebook.h -o knotebook.moc

$(srcdir)/kpanner.cpp: kpanner.moc
kpanner.moc: $(srcdir)/kpanner.h
	$(MOC) $(srcdir)/kpanner.h -o kpanner.moc

$(srcdir)/kpopmenu.cpp: kpopmenu.moc
kpopmenu.moc: $(srcdir)/kpopmenu.h
	$(MOC) $(srcdir)/kpopmenu.h -o kpopmenu.moc

$(srcdir)/kprogress.cpp: kprogress.moc
kprogress.moc: $(srcdir)/kprogress.h
	$(MOC) $(srcdir)/kprogress.h -o kprogress.moc

$(srcdir)/kquickhelp.cpp: kquickhelp.moc
kquickhelp.moc: $(srcdir)/kquickhelp.h
	$(MOC) $(srcdir)/kquickhelp.h -o kquickhelp.moc

$(srcdir)/krestrictedline.cpp: krestrictedline.moc
krestrictedline.moc: $(srcdir)/krestrictedline.h
	$(MOC) $(srcdir)/krestrictedline.h -o krestrictedline.moc

$(srcdir)/kruler.cpp: kruler.moc
kruler.moc: $(srcdir)/kruler.h
	$(MOC) $(srcdir)/kruler.h -o kruler.moc

$(srcdir)/kselect.cpp: kselect.moc
kselect.moc: $(srcdir)/kselect.h
	$(MOC) $(srcdir)/kselect.h -o kselect.moc

$(srcdir)/kslider.cpp: kslider.moc
kslider.moc: $(srcdir)/kslider.h
	$(MOC) $(srcdir)/kslider.h -o kslider.moc

$(srcdir)/kspinbox.cpp: kspinbox.moc
kspinbox.moc: $(srcdir)/kspinbox.h
	$(MOC) $(srcdir)/kspinbox.h -o kspinbox.moc

$(srcdir)/kstatusbar.cpp: kstatusbar.moc
kstatusbar.moc: $(srcdir)/kstatusbar.h
	$(MOC) $(srcdir)/kstatusbar.h -o kstatusbar.moc

$(srcdir)/ktabbar.cpp: ktabbar.moc
ktabbar.moc: $(srcdir)/ktabbar.h
	$(MOC) $(srcdir)/ktabbar.h -o ktabbar.moc

$(srcdir)/ktabctl.cpp: ktabctl.moc
ktabctl.moc: $(srcdir)/ktabctl.h
	$(MOC) $(srcdir)/ktabctl.h -o ktabctl.moc

$(srcdir)/ktablistbox.cpp: ktablistbox.moc
ktablistbox.moc: $(srcdir)/ktablistbox.h
	$(MOC) $(srcdir)/ktablistbox.h -o ktablistbox.moc

$(srcdir)/ktmainwindow.cpp: ktmainwindow.moc
ktmainwindow.moc: $(srcdir)/ktmainwindow.h
	$(MOC) $(srcdir)/ktmainwindow.h -o ktmainwindow.moc

$(srcdir)/ktoolbar.cpp: ktoolbar.moc
ktoolbar.moc: $(srcdir)/ktoolbar.h
	$(MOC) $(srcdir)/ktoolbar.h -o ktoolbar.moc

$(srcdir)/ktoolboxmgr.cpp: ktoolboxmgr.moc
ktoolboxmgr.moc: $(srcdir)/ktoolboxmgr.h
	$(MOC) $(srcdir)/ktoolboxmgr.h -o ktoolboxmgr.moc

$(srcdir)/ktopwidget.cpp: ktopwidget.moc
ktopwidget.moc: $(srcdir)/ktopwidget.h
	$(MOC) $(srcdir)/ktopwidget.h -o ktopwidget.moc

$(srcdir)/ktreelist.cpp: ktreelist.moc
ktreelist.moc: $(srcdir)/ktreelist.h
	$(MOC) $(srcdir)/ktreelist.h -o ktreelist.moc

$(srcdir)/kurllabel.cpp: kurllabel.moc
kurllabel.moc: $(srcdir)/kurllabel.h
	$(MOC) $(srcdir)/kurllabel.h -o kurllabel.moc

$(srcdir)/kwizard.cpp: kwizard.moc
kwizard.moc: $(srcdir)/kwizard.h
	$(MOC) $(srcdir)/kwizard.h -o kwizard.moc

$(srcdir)/kwmmapp.cpp: kwmmapp.moc
kwmmapp.moc: $(srcdir)/kwmmapp.h
	$(MOC) $(srcdir)/kwmmapp.h -o kwmmapp.moc

distclean-metasources:
	-rm -f kbutton.moc kbuttonbox.moc kcolorbtn.moc kcolordlg.moc kcombo.moc kcontainer.moc kcontrol.moc kdatepik.moc kdatetbl.moc kdbtn.moc keditcl.moc kfontdialog.moc kiconloaderdialog.moc kintegerline.moc kkeydialog.moc kled.moc kledlamp.moc klined.moc kmenubar.moc kmsgbox.moc knewpanner.moc knotebook.moc kpanner.moc kpopmenu.moc kprogress.moc kquickhelp.moc krestrictedline.moc kruler.moc kselect.moc kslider.moc kspinbox.moc kstatusbar.moc ktabbar.moc ktabctl.moc ktablistbox.moc ktmainwindow.moc ktoolbar.moc ktoolboxmgr.moc ktopwidget.moc ktreelist.moc kurllabel.moc kwizard.moc kwmmapp.moc 

# DO_NOT_USE_AUTOMOC

--- NEW FILE: ktablistbox.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 The KDE Team

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
//  Written by Stefan Taferner <taferner at kde.org>
[...1854 lines suppressed...]
  if ( raised )
    {
      QBrush   brush( white );
      qDrawShadeRect( &painter, 0, 0, width(), height(), colorGroup(),
                      TRUE, 1,1, &brush );
    }
  else
      qDrawShadeRect( &painter, 0, 0, width(), height(), colorGroup(),
                      TRUE, 1,1, 0L );
  int tf = AlignCenter;
  oldfont=painter.font();
  font=oldfont;
  font.setPointSize(height()-7);
  painter.setFont(font);
  painter.drawText(0, 0, width(), height(), tf, btext);
  painter.setFont(oldfont);
  painter.end();
}

#include "ktablistbox.moc"

--- NEW FILE: kruler.cpp ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: kprogress.h ---
/*****************************************************************************
*                                                                            *
*  KProgress -- progress indicator widget for KDE by Martynas Kunigelis      *
*                                                                            *
*****************************************************************************/

#ifndef _KPROGRES_H
#define _KPROGRES_H

#include <qframe.h>
#include <qrangecontrol.h>

/** 
* KProgress is derived from QFrame and QRangeControl, so you can use all 
* the methods from those classes. The only difference is that setValue(int) 
* is now made a slot, so you can connect stuff to it. 
*
* None of the constructors take line step and page step as arguments, 
* so by default they're set to 1 and 10 respectively.
*
* The Blocked style ignores the textEnabled() setting and displays
* no text, since it looks truly ugly and there are other reasons. Signal 
* percentageChanged(int) is emmitted whenever the value changes so you
* can setup a different widget to display percentage and connect the
* signal to it. 
*
* @short A Progress indicator widget
* @author Martynas Kunigelis
* @version $Id: kprogress.h,v 1.1 2006-10-03 11:26:32 dslinux_amadeus Exp $
*/
class KProgress : public QFrame, public QRangeControl {
	Q_OBJECT
public:
  /** 
  * Possible values for orientation 
  */
  enum Orientation { Horizontal, Vertical };

  /** 
  * Possible values for bar style. 
  *
  * Solid means one continuous progress bar, Blocked means a 
  * progress bar made up of several blocks. 
  */ 
  enum BarStyle { Solid, Blocked };

  /** 
  * Construct a default KProgress bar. Orientation is horizontal. 
  */
  KProgress(QWidget *parent=0, const char *name=0);

  /** 
  * Construct a KProgress bar with an orientation. 
  */
  KProgress(Orientation, QWidget *parent=0, const char *name=0);

  /** 
  * Construct a KProgress bar with minimum, maximum and initial value. 
  */
	KProgress(int minValue, int maxValue, int value, Orientation, 
				QWidget *parent=0, const char *name=0);
	
  /** 
  * Destructor 
  */
  ~KProgress();
	
  /** 
  * Set the progress bar style. Allowed values are Solid and Blocked. 
  */
  void setBarStyle(BarStyle style);  
	
  /** 
  * Set the color of the progress bar. 
  */
  void setBarColor(const QColor &); 
  
  /** 
  * Set a pixmap to be shown in the progress bar. 
  */
  void setBarPixmap(const QPixmap &);

  /** 
  * Set the orientation of the progress bar. 
  * Allowed values are Horizonzal and Vertical. 
  */
  void setOrientation(Orientation);

  /**
  * If this is set to TRUE, the progress text will be displayed.
  *
  */
  void setTextEnabled(bool);
	
  /** 
  * Retrieve the bar style. 
  */
  BarStyle barStyle() const;

  /** 
  * Retrieve the bar color. 
  */
  const QColor &barColor() const;

  /** 
  * Retrieve the bar pixmap. 
  */
  const QPixmap *barPixmap() const;

  /** 
  * Retrieve the orientation. 
  */
  Orientation orientation() const;

  /**
  * Returns TRUE if progress text will be displayed, FALSE otherwise.
  */
  bool textEnabled() const;

  /**
   * Returns the recommended width for vertical progress bars or
   * the recommended height for vertical progress bars
   */
  virtual QSize sizeHint() const;
	
		
public slots:
	void setValue(int);
	void advance(int);
	
signals:
	void percentageChanged(int);
	
protected:
	void valueChange();
	void rangeChange();
	void styleChange( GUIStyle );
	void paletteChange( const QPalette & );
	void drawContents( QPainter * );
	
private:
	QPixmap		*bar_pixmap;
	QColor		bar_color;
	QColor		bar_text_color;
	QColor		text_color;
	QRect fr;
	BarStyle	bar_style;
	Orientation orient;
	bool		text_enabled;
	void initialize();
	int recalcValue(int);
	void drawText(QPainter *);
	void adjustStyle();
};


#endif

--- NEW FILE: kfontdialog.cpp ---
/*
    $Id: kfontdialog.cpp,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $

    Requires the Qt widget libraries, available at no cost at 
    http://www.troll.no
       
    Copyright (C) 1996 Bernd Johannes Wuebben   
                       wuebben at math.cornell.edu

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
  
    $Log: kfontdialog.cpp,v $
    Revision 1.1  2006-10-03 11:26:31  dslinux_amadeus
    adding pristine copy of pixil to HEAD so I can branch from it

    Revision 1.1  2003/09/08 19:42:09  jasonk
    Addition of packages directory and associated files.

    Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
    Initial import of PIXIL into new cvs repository.

    Revision 1.1.1.1  2003/06/23 22:04:23  jasonk


    Revision 1.1.1.1  2000/07/07 16:10:59  jasonk
    Initial import of ViewML

    Revision 1.29  1999/01/18 10:56:41  kulow
    .moc files are back in kdelibs. Built fine here using automake 1.3

    Revision 1.28  1999/01/15 09:31:00  kulow
    it's official - kdelibs builds with srcdir != builddir. For this I
    automocifized it, the generated rules are easier to maintain than
    selfwritten rules. I have to fight with some bugs of this tool, but
    generally it's better than keeping them updated by hand.

    Revision 1.27  1998/11/30 19:31:32  lavikka
    Now kfontdialog uses QLayout instead of hardcoded widget coordinates.
    Command buttons are aligned correctly as well. Looks good and behaves well.

    Revision 1.26  1998/09/14 20:44:04  kulow
    I know, Ok is ok too, but OK is more OK some GUI guides say :)

    Revision 1.25  1998/09/01 20:21:53  kulow
    I renamed all old qt header files to the new versions. I think, this looks
    nicer (and gives the change in configure a sense :)

    Revision 1.24  1998/08/31 12:43:26  esken
    GPL -> LGPL

    Revision 1.23  1998/06/15 12:49:33  kulow
    applied patch to replace .kde with localkdedir()

    Revision 1.22  1998/06/10 18:23:37  schreter
    New klocale code had a little bug - it tried to find if there is "charsets"
    file in a locale dir instead of "charset" file, but then opened "charset"
    file. So I've fixed it. I've also fixed font dialog label sizes.

    Revision 1.21  1998/06/01 09:13:34  kalle
    Added static getFontAndText()

    Revision 1.20  1998/06/01 08:42:41  kalle
    KFontDialog:
    - you can now enter your own example string
    - new static method getXLFD() that converts a QFont() to a X Logical Font Description

    KIntegerLine:
    - new signal valueChanged( int )

    Revision 1.19  1998/05/27 20:38:48  schreter


    Fixed font dialog charset display problem - combo wouldn't load charsets
    for current font on invocation of the dialog.

    Revision 1.18  1998/04/12 08:56:13  jacek

    Small fix in setting charset combo

    Revision 1.17  1998/03/08 22:08:49  wuebben
    Bernd: adjusted the size of kfontdialog for localization

    Revision 1.16  1998/01/21 15:06:57  jacek
    Added real KCharsets support

    Revision 1.14  1997/11/20 22:36:48  kalle
    - Removed some more hardcoded colors
    - A patch from Bernd regarding KProgress

    Revision 1.13  1997/11/09 22:56:11  wuebben
    Bernd: colorscheme related changes

    Revision 1.12  1997/11/09 05:18:57  wuebben
    Bernd: fix

    Revision 1.11  1997/11/09 04:41:44  wuebben
    Bernd: fixed the broken kfontdialog ...

    Revision 1.10  1997/11/09 03:45:55  wuebben
    *** empty log message ***

    Revision 1.9  1997/10/21 20:45:00  kulow
    removed all NULLs and replaced it with 0L or "".
    There are some left in mediatool, but this is not C++

    Revision 1.8  1997/10/16 11:15:21  torben
    Kalle: Copyright headers
    kdoctoolbar removed

    Revision 1.7  1997/08/31 19:18:37  kdecvs
    Kalle:
    new usage of KLocale
    default string for KConfig::readEntry to const char*

    Revision 1.6  1997/08/24 20:40:40  kulow
    Coolo: translated the dialogs and others. I hope, noone minds.

    Revision 1.5  1997/07/24 21:06:04  kalle
    Kalle:
    KToolBar upgraded to newtoolbar 0.6
    KTreeList has rubberbanding now
    Patches for SGI

    Revision 1.4  1997/05/03 19:37:02  kulow
    Coolo: Again a little bug in acinclude
    included the moc file in kfontdialog

    Revision 1.3  1997/05/02 16:46:39  kalle
    Kalle: You may now override how KApplication reacts to external changes
    KButton uses the widget default palette
    new kfontdialog version 0,5
    new kpanner by Paul Kendall
    new: KIconLoader

    Revision 1.4  1997/04/29 02:44:24  wuebben
    *** empty log message ***

    Revision 1.3  1997/04/27 01:50:49  wuebben
    added ~/.kde/config/kdefonts support

    Revision 1.2  1997/04/20 14:59:44  wuebben
    fixed a minor bug which caused the last font in the font list to not
    be displayed

    Revision 1.1  1997/04/20 00:18:15  wuebben
    Initial revision

    Revision 1.1  1997/01/04 17:36:44  wuebben
    Initial revision


*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "kfontdialog.h"
#include "stdio.h"
#include "stdlib.h"
#include "qfile.h"
#include <qstrlist.h> 
#include <qfile.h>
#include <qtextstream.h> 
#include <qapplication.h>
#include <X11/Xlib.h>

#include <klocale.h>
#include <kcharsets.h>
#include <kapp.h>

#define MINSIZE(x) x->setMinimumSize(x->sizeHint());

KFontDialog::KFontDialog( QWidget *parent, const char *name, 
   bool modal, const QStrList* fontlist)  : QDialog( parent, name, modal )
{
  QPushButton *button;
  
  setCaption( klocale->translate("Select Font") );
  
  layout = new QVBoxLayout(this, 10);
  
  box1 = new QGroupBox(klocale->translate("Requested Font"), this);
  box2 = new QGroupBox(klocale->translate("Actual Font"), this);
  
  box1layout = new QGridLayout(box1, 5, 7, 7);
  box1layout->addColSpacing(0, 3);
  box1layout->addColSpacing(6, 3);
  box1layout->addRowSpacing(0, 13);
  box1layout->addRowSpacing(4, 3);
  box1layout->addColSpacing(3, 10);
  box1layout->setColStretch(2, 1);
  box1layout->setColStretch(5, 1);
  
  box2layout = new QGridLayout(box2, 7, 5, 7);
  box2layout->addColSpacing(0, 3);
  box2layout->addColSpacing(4, 3);
  box2layout->addRowSpacing(0, 13);
  box2layout->addRowSpacing(6, 3);
  box2layout->setColStretch(2, 1);
  box2layout->setColStretch(3, 2);
  
  family_label = new QLabel(box1,"family");
  family_label->setText( klocale->translate("Family:") );
  MINSIZE(family_label);
  box1layout->addWidget(family_label, 1, 1);
  
  actual_family_label = new QLabel(box2,"afamily");
  actual_family_label->setText(klocale->translate("Family:"));
  MINSIZE(actual_family_label);
  actual_family_label_data = new QLabel(box2,"afamilyd");
  box2layout->addWidget(actual_family_label, 2, 1);
  box2layout->addWidget(actual_family_label_data, 2, 2);
  
  charset_label = new QLabel(box1,"charset");
  charset_label->setText(klocale->translate("Charset:"));
  MINSIZE(charset_label);
  box1layout->addWidget(charset_label, 3, 1);
  
  actual_charset_label = new QLabel(box2,"acharset");
  actual_charset_label->setText(klocale->translate("Charset:"));
  MINSIZE(actual_charset_label);
  
  actual_charset_label_data = new QLabel(box2,"acharsetd");
  box2layout->addWidget(actual_charset_label, 1, 1);
  box2layout->addWidget(actual_charset_label_data, 1, 2);
  
  size_label = new QLabel(box1,"size");
  size_label->setText(klocale->translate("Size:"));
  MINSIZE(size_label);
  box1layout->addWidget(size_label, 1, 4);
  
  actual_size_label = new QLabel(box2,"asize");
  actual_size_label->setText(klocale->translate("Size:"));
  MINSIZE(actual_size_label);
  actual_size_label_data = new QLabel(box2,"asized");
  box2layout->addWidget(actual_size_label, 3, 1);
  box2layout->addWidget(actual_size_label_data, 3, 2);
  
  weight_label = new QLabel(box1,"weight");
  weight_label->setText(klocale->translate("Weight:"));
  MINSIZE(weight_label);
  box1layout->addWidget(weight_label, 2, 1);
  
  actual_weight_label = new QLabel(box2,"aweight");
  actual_weight_label->setText(klocale->translate("Weight:"));
  MINSIZE(actual_weight_label);
  actual_weight_label_data = new QLabel(box2,"aweightd");
  box2layout->addWidget(actual_weight_label, 4, 1);
  box2layout->addWidget(actual_weight_label_data, 4, 2);
  
  style_label = new QLabel(box1,"style");
  style_label->setText(klocale->translate("Style:"));
  MINSIZE(style_label);
  box1layout->addWidget(style_label, 2, 4);
  
  actual_style_label = new QLabel(box2,"astyle");
  actual_style_label->setText(klocale->translate("Style:"));
  MINSIZE(actual_style_label);
  actual_style_label_data = new QLabel(box2,"astyled");
  box2layout->addWidget(actual_style_label, 5, 1);
  box2layout->addWidget(actual_style_label_data, 5, 2);
  
  
  
  family_combo = new QComboBox(true, box1, "Family" );
  box1layout->addWidget(family_combo, 1, 2);
  family_combo->setInsertionPolicy(QComboBox::NoInsertion);
  
  connect( family_combo, SIGNAL(activated(const char *)),
	  SLOT(family_chosen_slot(const char *)) );
  
  if (fontlist != 0L){
    if(fontlist->count() !=0){
      family_combo->insertStrList(fontlist, -1);
      // this is a dirty fix due to a bug in Qt 1.2
      family_combo->setCurrentItem(1);
      family_combo->setCurrentItem(0);
    }
  }
  else{
    fill_family_combo();
  }
  MINSIZE(family_combo);
  
  size_combo = new QComboBox( true, box1, klocale->translate("Size") );
  box1layout->addWidget(size_combo, 1, 5);
  
  size_combo->insertItem( "4" );
  size_combo->insertItem( "5" );
  size_combo->insertItem( "6" );
  size_combo->insertItem( "7" );
  size_combo->insertItem( "8" );
  size_combo->insertItem( "9" );
  size_combo->insertItem( "10" );
  size_combo->insertItem( "11" );
  size_combo->insertItem( "12" );
  size_combo->insertItem( "13" );
  size_combo->insertItem( "14" );
  size_combo->insertItem( "15" );
  size_combo->insertItem( "16" );
  size_combo->insertItem( "17" );
  size_combo->insertItem( "18" );
  size_combo->insertItem( "19" );
  size_combo->insertItem( "20" );
  size_combo->insertItem( "22" );
  size_combo->insertItem( "24" );
  size_combo->insertItem( "26" );
  size_combo->insertItem( "28" );
  size_combo->insertItem( "32" );
  size_combo->insertItem( "48" );
  size_combo->insertItem( "64" );
  
  // we may want to allow the user to choose another size, since I
  // can really not presume to have listed all useful sizes.
  
  //  size_combo->setInsertionPolicy(QComboBox::NoInsertion);
  
  connect( size_combo, SIGNAL(activated(const char *)),
	  SLOT(size_chosen_slot(const char *)) );
  MINSIZE(size_combo);
  
  
  weight_combo = new QComboBox( TRUE, box1, klocale->translate("Weight") );
  box1layout->addWidget(weight_combo, 2, 2);
  
  weight_combo->insertItem( klocale->translate("normal") );
  weight_combo->insertItem( klocale->translate("bold") );
  
  weight_combo->setInsertionPolicy(QComboBox::NoInsertion);
  connect( weight_combo, SIGNAL(activated(const char *)),
	  SLOT(weight_chosen_slot(const char *)) );
  // QToolTip::add( weight_combo, "Select Font Weight" );
  
  MINSIZE(weight_combo);
  
  
  style_combo = new QComboBox( TRUE, box1, klocale->translate("Style") );
  box1layout->addWidget(style_combo, 2, 5);
  
  style_combo->insertItem( klocale->translate("roman") );
  style_combo->insertItem( klocale->translate("italic") );
  
  style_combo->setInsertionPolicy(QComboBox::NoInsertion);
  connect( style_combo, SIGNAL(activated(const char *)),
	  SLOT(style_chosen_slot(const char *)) );
  MINSIZE(style_combo);
  
  
  charset_combo = new QComboBox( TRUE, box1, klocale->translate("Charset") );
  box1layout->addWidget(charset_combo, 3, 2);
  
  charset_combo->setInsertionPolicy(QComboBox::NoInsertion);
  connect( charset_combo, SIGNAL(activated(const char *)),
	  SLOT(charset_chosen_slot(const char *)) );
  MINSIZE(charset_combo);
  
  
  example_edit = new QLineEdit(box2, "examples");
  
  box2layout->addMultiCellWidget(example_edit, 1, 5, 3, 3);
  
  example_edit->setFont(selFont);
  
  //  example_edit->setAlignment(AlignCenter);
  //  example_edit->setBackgroundColor(white);
  //  example_edit->setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
  //  example_edit->setLineWidth( 1 );
  example_edit->setText(klocale->translate("Dolor Ipse"));
  //  example_edit->setAutoResize(true);
  
  connect(this,SIGNAL(fontSelected( const QFont&  )),
	  this,SLOT(display_example( const QFont&)));
  MINSIZE(example_edit);
  
  // lets initialize the display if possible
  if(family_combo->count() != 0){
    this->setFont(QFont(family_combo->text(0),12,QFont::Normal)); 
  }
  
  // Create displayable charsets list
  KCharsets *charsets=KApplication::getKApplication()->getCharsets();
  QStrList lst=charsets->displayable(selFont.family());
  for(const char * chset=lst.first();chset;chset=lst.next())
    charset_combo->insertItem( chset );
  charset_combo->insertItem( "any" );
  
  setColors();
  connect(KApplication::getKApplication(),SIGNAL(kdisplayPaletteChanged()),
	  this,SLOT(setColors()));
  
  
  box1layout->activate();
  box2layout->activate();
  
  layout->addWidget(box1, 1);
  layout->addWidget(box2, 1);
  
  KButtonBox *bbox = new KButtonBox(this);
  
  bbox->addStretch(1);
  button = bbox->addButton(klocale->translate("OK"));
  connect( button, SIGNAL( clicked() ), 
	  SLOT( accept() ) );
  button = bbox->addButton(klocale->translate("Cancel"));
  connect( button, SIGNAL( clicked() ), 
	  SLOT( reject() ) );
  bbox->layout();
  bbox->setMinimumSize(bbox->sizeHint());
  
  layout->addWidget(bbox, 0);
  layout->activate();
}


void KFontDialog::charset_chosen_slot(const char *chset){

  KCharset(chset).setQFont(selFont);
  emit fontSelected(selFont);
}

int KFontDialog::getFont( QFont &theFont )
{
	KFontDialog dlg( 0L, "Font Selector", TRUE );
	dlg.setFont( theFont );
	int result = dlg.exec();

	if ( result == Accepted )
		theFont = dlg.font();

	return result;
}


int KFontDialog::getFontAndText( QFont &theFont, QString &theString )
{
  KFontDialog dlg( 0L, "Font and Text Selector", TRUE );
  dlg.setFont( theFont );
  int result = dlg.exec();

  if( result == Accepted ) {
	theFont = dlg.font();
	theString = dlg.example_edit->text();
  }

  return result;
}

void KFontDialog::setFont( const QFont& aFont){

  selFont = aFont;
  setCombos();
  display_example(selFont);
}  


void KFontDialog::family_chosen_slot(const char* family){

  selFont.setFamily(family);
 
  // Re-create displayable charsets list
  KCharsets *charsets=KApplication::getKApplication()->getCharsets();
  QStrList lst=charsets->displayable(selFont.family());
  charset_combo->clear();
  for(const char * chset=lst.first();chset;chset=lst.next())
      charset_combo->insertItem( chset );
  charset_combo->insertItem( "any" );
  
  //display_example();
  emit fontSelected(selFont);
}

void KFontDialog::size_chosen_slot(const char* size){
  
  QString size_string = size;

  selFont.setPointSize(size_string.toInt());
  //display_example();
  emit fontSelected(selFont);
}

void KFontDialog::weight_chosen_slot(const char* weight){

  QString weight_string = weight;

  if ( weight_string == QString(klocale->translate("normal")))
    selFont.setBold(false);
  if ( weight_string == QString(klocale->translate("bold")))
       selFont.setBold(true);
  // display_example();
  emit fontSelected(selFont);
}

void KFontDialog::style_chosen_slot(const char* style){


  QString style_string = style;

  if ( style_string == QString(klocale->translate("roman")))
    selFont.setItalic(false);
  if ( style_string == QString(klocale->translate("italic")))
    selFont.setItalic(true);
  //  display_example();
  emit fontSelected(selFont);
}
       

void KFontDialog::display_example(const QFont& font){

  QString string;

  example_edit->setFont(font);

  QFontInfo info = example_edit->fontInfo();
  actual_family_label_data->setText(info.family());
  
  string.setNum(info.pointSize());
  actual_size_label_data->setText(string);

  if (info.bold())
    actual_weight_label_data->setText(klocale->translate("Bold"));
  else
    actual_weight_label_data->setText(klocale->translate("Normal"));
 
  if (info.italic())
    actual_style_label_data->setText(klocale->translate("italic"));
  else
    actual_style_label_data->setText(klocale->translate("roman"));
  
  KCharsets *charsets=KApplication::getKApplication()->getCharsets();
  const char * charset=charsets->name(selFont);
  actual_charset_label_data->setText(charset);
}

void KFontDialog::setCombos(){

 QString string;
 QComboBox* combo;
 int number_of_entries, i=0; 
 bool found;

 number_of_entries =  family_combo->count(); 
 string = selFont.family();
 combo = family_combo; 
 found = false;

 for (i = 0;i < number_of_entries ; i++){
   //   printf("%s with %s\n",string.data(), ((QString) combo->text(i)).data());
   if ( string.lower() == ((QString) combo->text(i)).lower()){
     combo->setCurrentItem(i);
     //printf("Found Font %s\n",string.data());
     found = true;
     break;
   }
 }

 
 number_of_entries =  size_combo->count(); 
 string.setNum(selFont.pointSize());
 combo = size_combo; 
 found = false;

 for (i = 0;i < number_of_entries - 1; i++){
   if ( string == (QString) combo->text(i)){
     combo->setCurrentItem(i);
     found = true;
     // printf("Found Size %s setting to item %d\n",string.data(),i);
     break;
   }
 }

 if (selFont.bold()){
   //weight_combo->setCurrentItem(0);
   weight_combo->setCurrentItem(1);
 }else
   weight_combo->setCurrentItem(0);

  if (selFont.italic())
   style_combo->setCurrentItem(1);
 else
   style_combo->setCurrentItem(0);

 // Re-create displayable charsets list
 KCharsets *charsets=KApplication::getKApplication()->getCharsets();
 const char * charset=charsets->name(selFont);
 QStrList lst=charsets->displayable(selFont.family());
 charset_combo->clear();
 i = 0;
 for(const char * chset=lst.first();chset;chset=lst.next(),++i) {
     charset_combo->insertItem( chset );
     if (strcmp(chset, charset) == 0) charset_combo->setCurrentItem(i);
 }
 charset_combo->insertItem( "any" );
 
}

bool KFontDialog::loadKDEInstalledFonts(){

  QString fontfilename;

  //TODO replace by QDir::homePath();

  fontfilename = KApplication::localkdedir() + "/share/config/kdefonts";

  QFile fontfile(fontfilename);

  if (!fontfile.exists())
    return false;

  if(!fontfile.open(IO_ReadOnly)){
    return false;
  }

  if (!fontfile.isReadable())
    return false;
  
  
  QTextStream t(&fontfile);

  while ( !t.eof() ) {
    QString s = t.readLine();
    s = s.stripWhiteSpace();
    if(!s.isEmpty())
      family_combo->insertItem( s ,-1 );
  }

  fontfile.close();

  
  return true;

}


void KFontDialog::fill_family_combo(){

  int numFonts;
  Display *kde_display;
  char** fontNames;
  char** fontNames_copy;
  QString qfontname;


    
  QStrList fontlist(TRUE);
  
  kde_display = XOpenDisplay( 0L );

  // now try to load the KDE fonts

  bool have_installed = loadKDEInstalledFonts();
  
  // if available we are done, the kde fonts are now in the family_combo

  if (have_installed)
    return;

  fontNames = XListFonts(kde_display, "*", 32767, &numFonts);
  fontNames_copy = fontNames;

  for(int i = 0; i < numFonts; i++){
    
    if (**fontNames != '-'){ 
      
      // The font name doesn't start with a dash -- an alias
      // so we ignore it. It is debatable whether this is the right
      // behaviour so I leave the following snippet of code around.
      // Just uncomment it if you want those aliases to be inserted as well.
      
      /*
      qfontname = "";
      qfontname = *fontNames;
      if(fontlist.find(qfontname) == -1)
          fontlist.inSort(qfontname);
      */

      fontNames ++;
      continue;
    };
      
    qfontname = "";
    qfontname = *fontNames;
    int dash = qfontname.find ('-', 1, TRUE); // find next dash

    if (dash == -1) { // No such next dash -- this shouldn't happen.
                      // but what do I care -- lets skip it.
      fontNames ++;
      continue;
    }

    // the font name is between the second and third dash so:
    // let's find the third dash:

    int dash_two = qfontname.find ('-', dash + 1 , TRUE); 

    if (dash == -1) { // No such next dash -- this shouldn't happen.
                      // But what do I care -- lets skip it.
      fontNames ++;
      continue;
    }

    // fish the name of the font info string

    qfontname = qfontname.mid(dash +1, dash_two - dash -1);

    if( !qfontname.contains("open look", TRUE)){
      if(qfontname != "nil"){
	if(fontlist.find(qfontname) == -1)
	  fontlist.inSort(qfontname);
      }
    }
  

    fontNames ++;

  }

  for(fontlist.first(); fontlist.current(); fontlist.next())
      family_combo->insertItem(fontlist.current(),-1);

  XFreeFontNames(fontNames_copy);
  XCloseDisplay(kde_display);


}


void KFontDialog::setColors(){
 
  /* this is to the the backgound of a widget to white and the
     text color to black -- some lables such as the one of the
     font manager really shouldn't follow colorschemes The
     primary task of those label is to display the text clearly
     an visibly and not to look pretty ...*/

  QPalette mypalette = (example_edit->palette()).copy();

  QColorGroup cgrp = mypalette.normal();
  QColorGroup ncgrp(black,cgrp.background(),
		    cgrp.light(),cgrp.dark(),cgrp.mid(),black,white);

  mypalette.setNormal(ncgrp);
  mypalette.setDisabled(ncgrp);
  mypalette.setActive(ncgrp);

  example_edit->setPalette(mypalette);
  example_edit->setBackgroundColor(white);
 
}


QString KFontDialog::getXLFD( const QFont& font )
{
  QFontInfo fi( font );

  QString xlfd = "-*-"; // foundry
  xlfd += fi.family(); // family
  xlfd += "-";
  switch( fi.weight() ) { // weight
  case QFont::Light:
	xlfd += "light-";
	break;
  case QFont::Normal:
	xlfd += "normal-";
	break;
  case QFont::DemiBold:
	xlfd += "demi-";
	break;
  case QFont::Bold:
	xlfd += "bold-";
	break;
  case QFont::Black:
	xlfd += "black-";
	break;
  default:
	xlfd += "*-";
  }
  if( fi.italic() )
	xlfd += "i-"; // slant
  else
	xlfd += "r-"; // slant
  xlfd += "*-"; // set width
  xlfd += "*-"; // pixels (we cannot know portably, because this
                // depends on the screen resolution 
  xlfd += fi.pointSize()*10; // points
  xlfd += "-";
  xlfd += "*-"; // horz. resolution
  xlfd += "*-"; // vert. resolution
  if( fi.fixedPitch() )
	xlfd += "m-"; // spacing: monospaced
  else
	xlfd += "p-"; // spacing: proportional
  xlfd += "*-"; // average width
  // charset
  switch( fi.charSet() ) {
  case QFont::AnyCharSet:
	xlfd += "*";
	break;
  case QFont::Latin1:
	xlfd += "iso8859-1";
	break;
  case QFont::Latin2:
	xlfd += "iso8859-2";
	break;
  case QFont::Latin3:
	xlfd += "iso8859-3";
	break;
  case QFont::Latin4:
	xlfd += "iso8859-4";
	break;
  case QFont::Latin5:
	xlfd += "iso8859-5";
	break;
  case QFont::Latin6:
	xlfd += "iso8859-6";
	break;
  case QFont::Latin7:
	xlfd += "iso8859-7";
	break;
  case QFont::Latin8:
	xlfd += "iso8859-8";
	break;
  case QFont::Latin9:
	xlfd += "iso8859-9";
	break;
  default:
	xlfd += "*";
  }

  return xlfd;
}
#include "kfontdialog.moc"

--- NEW FILE: kdatetbl.h ---
/*  -*- C++ -*-
    This file is part of the KDE libraries
    Copyright (C) 1997 Tim D. Gilman (tdgilman at best.org)
              (C) 1998, 1999 Mirko Sucker (mirko at kde.org)
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef _KDATETBL_H 
#define _KDATETBL_H

/////////////////// KDateTable widget class //////////////////////
//
// Copyright (C) 1997 Tim D. Gilman
//           (C) 1998, 1999 Mirko Sucker
// Written using Qt (http://www.troll.no) for the
// KDE project (http://www.kde.org)
//
// This is a support class for the KDatePicker class.  It just
// draws the calender table without titles, but could theoretically
// be used as a standalone.
//
// When a date is selected by the user, it emits a signal: 
//      dateSelected(QDate)

#include <qtableview.h>
#include <qdatetime.h>
#include <qsize.h>

/**
  * Draws a calendar table.
  * @author Tim D. Gilman
  * @version $Id: kdatetbl.h,v 1.1 2006-10-03 11:26:30 dslinux_amadeus Exp $
  */

class KDateTable: public QTableView {
  Q_OBJECT
public:
  KDateTable(QWidget *parent=0, 
	     QDate date=QDate::currentDate(), 
	     const char *name=0, WFlags f=0);
  ~KDateTable();
  // Mirko, Mar 17 1998:
  /** Returns a recommended size for the widget.
    */
  QSize sizeHint() const;
  // Mirko, Aug 21 1998:
  void setFontSize(int size);
  // ^^^^^^^^^^^^^^^^^^^
public slots:
  void goForward();
  void goBackward();
  // highstick: added May 13 1998
  void goDown();
  void goUp();
  // Mirko, Mar 17 1998:
  /** Sets the currently selected date. The date is
    * only set if the given date is a valid one.
    */
  void setDate(QDate);
  // ^^^^^^^^^^^^^^^^^^^
signals:
  void monthChanged(QDate);
  void yearChanged(QDate);	// highstick: added May 13 1998
  void dateSelected(QDate);
protected:
  void paintCell( QPainter *p, int row, int col );
  void resizeEvent( QResizeEvent * );
  void mousePressEvent(QMouseEvent *e);
  const char* Days[7];
  int fontsize;
private:
  QDate m_date;
  int m_firstDayOfWeek;
  int m_daysInPrevMonth;
  int m_oldRow;
  int m_oldCol;
  bool m_bSelection;
  int m_selRow;
  int m_selCol;

  void setSelection(int row, int col);
  void getPrevMonth(QDate dtnow, QDate &dtprv);
  void getNextMonth(QDate dtnow, QDate &dtnxt);
  /** Returns the number of the day at position (row,col).
    * The number is a negative one if the day is in the 
    * previous month, and it is bigger than m_date.daysInMonth()
    * if the day is in the next month.
    */
  int dayNum(int row, int col);
  // highstick: added May 13 1998
  void getPrevYear(QDate dtnow, QDate &dtprv);
  void getNextYear(QDate dtnow, QDate &dtprv);
private:  // Disabled copy constructor and operator=
  KDateTable(const KDateTable & ) : QTableView() {}
  KDateTable &operator=(const KDateTable &) { return *this; }
};

#endif // _KDATETBL_H

--- NEW FILE: stopsign.xpm ---
/* XPM */
static char *magick[] = {
/* columns rows colors chars-per-pixel */
"48 48 5 1",
"  c #000000",
". c #a0a0a4",
"X c #c0c0c0",
"o c #ffffff",
"O c None",
/* pixels */
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOO        OOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOO            OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOO                OOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO                  OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOO                    .OOOOOOOOOOOOOO",
"OOOOOOOOOOOO                      .OOOOOOOOOOOOO",
"OOOOOOOOOOO                        .OOOOOOOOOOOO",
"OOOOOOOOOO       o          o       .OOOOOOOOOOO",
"OOOOOOOOOO      ooo        ooo      .OOOOOOOOOOO",
"OOOOOOOOO      ooooo      ooooo      .OOOOOOOOOO",
"OOOOOOOOO       ooooo    ooooo       .OOOOOOOOOO",
"OOOOOOOO         ooooo  ooooo         .OOOOOOOOO",
"OOOOOOOO          oooooooooo          .OOOOOOOOO",
"OOOOOOOO           oooooooo           ..OOOOOOOO",
"OOOOOOOO            oooooo            ..OOOOOOOO",
"OOOOOOOO            oooooo            ..OOOOOOOO",
"OOOOOOOO           oooooooo           ..OOOOOOOO",
"OOOOOOOO          oooooooooo          ..OOOOOOOO",
"OOOOOOOO         ooooo  ooooo         ..OOOOOOOO",
"OOOOOOOOO       ooooo    ooooo       ..OOOOOOOOO",
"OOOOOOOOO      ooooo      ooooo      ..OOOOOOOOO",
"OOOOOOOOOO      ooo        ooo      ...OOOOOOOOO",
"OOOOOOOOOO       o          o       ..OOOOOOOOOO",
"OOOOOOOOOOO                        ...OOOOOOOOOO",
"OOOOOOOOOOOO                      ...OOOOOOOOOOO",
"OOOOOOOOOOOO.                    ...OOOOOOOOOOOO",
"OOOOOOOOOOOOO.                  ...OOOOOOOOOOOOO",
"OOOOOOOOOOOOOO.                ...OOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOO..            ....OOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOO..        .....OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOO...........OOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOO.......OOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
};

--- NEW FILE: kmsgbox.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Alexander Sanda (alex at darkstar.ping.at)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/*
 * $Id: kmsgbox.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
 *
 * $Log: kmsgbox.h,v $
 * Revision 1.1  2006-10-03 11:26:31  dslinux_amadeus
 * adding pristine copy of pixil to HEAD so I can branch from it
 *
 * Revision 1.1  2003/09/08 19:42:09  jasonk
 * Addition of packages directory and associated files.
 *
 * Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
 * Initial import of PIXIL into new cvs repository.
 *
 * Revision 1.1.1.1  2003/06/23 22:04:23  jasonk
 *
 *
 * Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
 * Initial import of ViewML
 *
 * Revision 1.11  1998/10/31 15:25:01  porten
 * Harri: fixed documented return value of yesNo()
 *
 * Revision 1.10  1998/09/14 20:44:07  kulow
 * I know, Ok is ok too, but OK is more OK some GUI guides say :)
 *
 * Revision 1.9  1998/09/01 20:22:04  kulow
 * I renamed all old qt header files to the new versions. I think, this looks
 * nicer (and gives the change in configure a sense :)
 *
 * Revision 1.8  1998/08/03 15:24:24  ssk
 * Wrote documentation.
 * Eliminated dead and commented-out code.
 *
 * Revision 1.7  1998/01/03 19:47:30  kulow
 * changed the defaults for yesNo and co. It's no longer "Yes" and co, but
 * 0 to enable translation in case.
 * This is source and binary compatible. It's just, that it will behave
 * differently after recompiling (as far I understood the C++ language ;)
 *
 * Revision 1.6  1997/11/04 17:48:51  kulow
 * hmm, gcc accepts QPixmap & icon = 0, Sparc CC won't. So I made it .. = QPixmap()
 *
 * Revision 1.5  1997/10/21 20:45:03  kulow
 * removed all NULLs and replaced it with 0L or "".
 * There are some left in mediatool, but this is not C++
 *
 * Revision 1.4  1997/10/16 11:15:27  torben
 * Kalle: Copyright headers
 * kdoctoolbar removed
 *
 * Revision 1.3  1997/07/24 21:06:07  kalle
 * Kalle:
 * KToolBar upgraded to newtoolbar 0.6
 * KTreeList has rubberbanding now
 * Patches for SGI
 *
 * Revision 1.2  1997/05/08 22:53:20  kalle
 * Kalle:
 * KPixmap gone for good
 * Eliminated static objects from KApplication and HTML-Widget
 *
 * Revision 1.1.1.1  1997/04/13 14:42:42  cvsuser
 * Source imported
 *
 * Revision 1.1.1.1  1997/04/09 00:28:09  cvsuser
 * Sources imported
 *
 * Revision 1.1  1997/03/15 22:41:21  kalle
 * Initial revision
 *
 * Revision 1.3.2.1  1997/01/10 19:48:32  alex
 * public release 0.1
 *
 * Revision 1.3  1997/01/10 19:44:33  alex
 * *** empty log message ***
 *
 * Revision 1.2.4.1  1997/01/10 16:46:33  alex
 * rel 0.1a, not public
 *
 * Revision 1.2  1997/01/10 13:05:52  alex
 * *** empty log message ***
 *
 * Revision 1.1.1.1  1997/01/10 13:05:21  alex
 * imported
 *
 */

// kmsgbox.h

#ifndef _KMSGBOX_H_
#define _KMSGBOX_H_

#include <qdialog.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qframe.h>
#include <qpixmap.h>


 /** 
  * Enhanced MessageBox Dialog. 
  *
  * Provides a message box with icons and up to four configurable
  * buttons and internationalized button text.
  *
  * Several static functions that perform common message box functions
  * are also provided for convenience.
  *
  * @author Alexander Sanda (alex at darkstar.ping.at)
  * @version $Id: kmsgbox.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
  */
class KMsgBox : public QDialog
{
    Q_OBJECT

public:

    /**
    * Icon styles for message box customization. One of these should be
    * passed in the type parameter of the message box constructor
    * and static functions.
    *
    * @see KMsgBox::KMsgBox
    */
    enum IconStyle { INFORMATION = 1, EXCLAMATION = 2, 
		STOP = 4, QUESTION = 8 };

    /**
    * Possible options for the default button. The first button
    * is set to the default if no button is explicitly selected.
    *
    * @see KMsgBox::KMsgBox
    */
    enum DefaultButton { DB_FIRST = 16, DB_SECOND = 32, 
    		DB_THIRD = 64, DB_FOURTH = 128};
    
    /** 
     * The generic constructor for a KMsgBox widget. 
     *
     * @param parent 	Parent widget
     * @param caption	Message box title
     * @param message	Message string, center aligned by default. 
     *			May contain newlines.
     * @param type	Selects message box options. This value is 
     *			a constant from @ref ::DefaultButton and/or
     *			a constant from @ref ::IconStyle or-ed together.
     * @param b1text..	Button captions. Up to four may be specified, only
     *			specified buttons will be displayed.
     *
     * @see ::DefaultButton ::IconStyle
     */
    KMsgBox ( QWidget *parent = 0, const char *caption = 0, 
		    const char *message = 0, int type = INFORMATION,
		    const char *b1text = 0, const char *b2text = 0, 
		    const char *b3text = 0, const char *b4text = 0);

    /**
    * Destructor.
    */
    ~KMsgBox();

    /** 
     * Displays a modal yes/no message box. 
     * The icon is set to a question mark.
     *
     * @param parent 	the parent widget
     * @param caption	the message box title
     * @param message	the message in the dialog (eg the question the 
     *			user is to be asked)
     * @param type	Selects message box options. This value is 
     *			a constant from @ref ::DefaultButton and/or
     *			a constant from @ref ::IconStyle or-ed together.
     * @param yes	the text for the "Yes" button. defaults to "Yes", or
     *			its translation in the current user's locale if
     *			available.
     * @param no	the text for the "No" button. defaults to "No", or
     *			its translation in the current user's locale if
     *			available.
     *
     * @return 1 if yes is clicked, 2 otherwise.
     */
    static int yesNo( QWidget *parent = 0, const char *caption = 0, 
		    const char *message = 0, int type = 0,
		    const char *yes = 0, const char *no = 0);

    /** 
     * Displays a modal yes/no/cancel message box.
     * The icon is set to a question mark.
     *
     * @param parent 	the parent widget
     * @param caption	the message box title
     * @param message	the message in the dialog (eg the question the user is 
     *			to be asked)
     * @param type	Selects message box options. This value is 
     *			a constant from @ref ::DefaultButton and/or
     *			a constant from @ref ::IconStyle or-ed together.
     * @param yes	the text for the "Yes" button. defaults to "Yes", or
     *			its translation in the current user's locale if
     *			available.
     * @param no	the text for the "No" button. defaults to "No", or
     *			its translation in the current user's locale if
     *			available.
     * @param cancel	the text for the "Cancel" button. defaults to "Cancel", 
     *			or its translation in the current user's locale
     *			if available.
     *
     * @return 1, 2 or 3 if yes, no or cancel are clicked respectively.
     */
    static int yesNoCancel( QWidget *parent = 0, 
    		const char *caption = 0, const char *message = 0, 
		int type = 0, const char *yes = 0, const char *no = 0, 
		const char *cancel = 0);

    /** 
     * Displays a modal message box with one button. An "Information"
     * icon is displayed.
     *
     * @param parent 	the parent widget
     * @param caption	the message box title
     * @param message	the message in the dialog (eg the question the user is 
     *			to be asked)
     * @param type	Selects message box options. This value is 
     *			a constant from @ref ::DefaultButton and/or
     *			a constant from @ref ::IconStyle or-ed together.
     * @param btext	the text for the "OK" button. defaults to "Ok", or
     *			its translation in the current user's locale if
     *			available.
     * @return		1 if the Ok button is clicked
     */
    static int message( QWidget *parent = 0, const char *caption = 0, 
		    const char *message = 0, int type = 0,
		    const char *btext = 0);

private:

    enum {B_SPACING = 10, B_WIDTH = 80};

    QLabel      *msg, *picture;
    QPushButton *b1, *b2, *b3, *b4;
    QFrame      *f1;

    int		nr_buttons;
    int         w, h, h1, text_offset;

    void        calcOptimalSize();

public slots:

    void        b1Pressed();
    void        b2Pressed();
    void        b3Pressed();
    void        b4Pressed();
};

#endif


--- NEW FILE: kwizard.cpp ---
/*  This file is part of the KDE Libraries
    Copyright (C) 1998 Thomas Tanghus (tanghus at earthling.net)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/  


#include "kwizard.h"


struct KWizProtected
{
  QPopupMenu       *menu;
  QWidget          *currentwidget;
  KSeparator       *sep1;
  KSeparator       *sep2;
  KDirectionButton *left;
  KDirectionButton *right;
  QPushButton      *ok;
  QPushButton      *cancel;
  QPushButton      *def;
  QPushButton      *help;
  QPushButton      *next;
  QPushButton      *previous;
  QLabel           *title;
  QLabel           *pagina;
  bool             directionsreflectspage;
  bool             enablepopupmenu;
  bool             enablearrowbuttons;
  int              numpages;
  int              current;
  int              minheight;
  int              minwidth;
  
};

KDialog::KDialog(QWidget *parent, const char *name, bool modal, WFlags f)
  : QDialog(parent, name, modal, f)
{
  //debug("KDialog creation");

  initMetaObject();
  setFocusPolicy(QWidget::StrongFocus);

}

// Grab QDialogs keypresses if non-modal.
void KDialog::keyPressEvent(QKeyEvent *e)
{
  if ( e->state() == 0 )
  {
    switch ( e->key() )
    {
      case Key_Escape:
      case Key_Enter:
      case Key_Return:
      {
        if(testWFlags(WType_Modal))
          QDialog::keyPressEvent(e);
        else
        {
          //debug("KDialog - Eating keyevent");
  	  e->ignore();
        }
      }
      break;
      default:
	e->ignore();
	return;
    }
  }
  else
  {
    e->ignore();
  }
}

KWizard::KWizard(QWidget *parent, const char *name, bool modal, WFlags f)
  : KDialog(parent, name, modal, f)
//  : QWidget(parent, name, modal ? (f | WType_Modal) : f)
{
  //debug("KWizard creation");

  initMetaObject();

  pwiz = new KWizProtected;
  pages = new QList<KWizardPage>;
  pages->setAutoDelete(true);

  pwiz->menu = new QPopupMenu();
  connect( pwiz->menu, SIGNAL(activated(int)), SLOT(gotoPage(int)));

  pwiz->numpages = 0;
  pwiz->current = -1;
  pwiz->minwidth = 300;
  pwiz->minheight = 300;
  pwiz->currentwidget = 0L;
  pwiz->ok = pwiz->cancel = pwiz->def = pwiz->help = pwiz->next = pwiz->previous = 0L;
  pwiz->directionsreflectspage = pwiz->enablepopupmenu = pwiz->enablearrowbuttons = false;

  pwiz->title = new QLabel(this);
  pwiz->title->installEventFilter(this);
  pwiz->title->setAlignment(AlignLeft|AlignVCenter);

  pwiz->pagina = new QLabel("Page 1 of 1", this);
  pwiz->pagina->setAlignment(AlignLeft|AlignVCenter);

  pwiz->left = new KDirectionButton(LeftArrow, this);
  connect( pwiz->left, SIGNAL(clicked()), SLOT(previousPage()));
  pwiz->left->hide();
  pwiz->right = new KDirectionButton(RightArrow, this);
  connect( pwiz->right, SIGNAL(clicked()), SLOT(nextPage()));
  pwiz->right->hide();

  pwiz->sep1 = new KSeparator(this);
  //sep1->setFixedHeight(sep1->sizeHint().height());
  pwiz->sep2 = new KSeparator(this);
  //sep2->setFixedHeight(sep2->sizeHint().height());

  pwiz->previous = new QPushButton(PREV, this);
  pwiz->previous->hide();
  connect( pwiz->previous, SIGNAL(clicked()), SLOT(previousPage()));

  pwiz->next = new QPushButton(NEXT, this);
  pwiz->next->hide();
  connect( pwiz->next, SIGNAL(clicked()), SLOT(nextPage()));

  installEventFilter(this);

  //debug("KWizard created");
}

// Destructor
KWizard::~KWizard()
{
  //debug("KWizard - destructor");
  //if (menu) delete menu;
  //menu = 0L;
  delete pwiz;
  delete pages;
  //debug("KWizard - destructor done");
}

void KWizard::setCancelButton()
{
  setCancelButton(klocale->translate("&Cancel"));
}

void KWizard::setCancelButton(const char *name)
{
  if(!pwiz->cancel)
  {
    pwiz->cancel = new QPushButton(name, this);
    pwiz->cancel->show();
    connect( pwiz->cancel, SIGNAL(clicked()), SLOT(cancelClicked()));
  }
  else
    pwiz->cancel->setText(name);
  setSizes();
}

QButton *KWizard::getCancelButton()
{
  return pwiz->cancel;
}

void KWizard::setDefaultButton()
{
  setDefaultButton(klocale->translate("&Default"));
}

void KWizard::setDefaultButton(const char *name)
{
  if(!pwiz->def)
  {
    pwiz->def = new QPushButton(name, this);
    pwiz->def->show();
    connect( pwiz->def, SIGNAL(clicked()), SLOT(defaultClicked()));
  }
  else
    pwiz->def->setText(name);
  setSizes();
}

QButton *KWizard::getDefaultButton()
{
  return pwiz->def;
}

void KWizard::setHelpButton()
{
  setHelpButton(klocale->translate("&Help"));
}

void KWizard::setHelpButton(const char *name)
{
  if(!pwiz->help)
  {
    pwiz->help = new QPushButton(name, this);
    pwiz->help->show();
    connect( pwiz->help, SIGNAL(clicked()), SLOT(helpClicked()));
  }
  else
    pwiz->help->setText(name);
  setSizes();
}

QButton *KWizard::getHelpButton()
{
  return pwiz->help;
}

void KWizard::setOkButton()
{
  setOkButton(klocale->translate("&OK"));
}

void KWizard::setOkButton(const char *name)
{
  if(!pwiz->ok)
  {
    pwiz->ok = new QPushButton(name, this);
    pwiz->ok->show();
    connect( pwiz->ok, SIGNAL(clicked()), SLOT(okClicked()));
  }
  else
    pwiz->ok->setText(name);
  setSizes();
}

QButton *KWizard::getOkButton()
{
  return pwiz->ok;
}

QButton *KWizard::getNextButton()
{
  return pwiz->next;
}

QButton *KWizard::getPreviousButton()
{
  return pwiz->previous;
}

KDirectionButton *KWizard::getLeftArrow()
{
  return pwiz->left;
}

KDirectionButton *KWizard::getRightArrow()
{
  return pwiz->right;
}

QSize KWizard::pageSize()
{
  //debug("Calculating sizes");
  QSize size(0,0);
  //int x = 0, y = 0;
  for(int i = 0; i < pwiz->numpages; i++)
  {
    QSize csize = pages->at(i)->w->minimumSize();
    if(size.height() < csize.height())
      size.setHeight(csize.height());
    if(size.width() < csize.width())
      size.setWidth(csize.width());
    //debug("Page size: %d x %d", size.width(), size.height());
  }

  return size;
}

void KWizard::setSizes()
{
  //debug("setSizes");
  QFont titlefont;
  //titlefont.setPointSize(titlefont.pointSize()*2);
  titlefont.setWeight(QFont::Bold);
  pwiz->title->setFont(titlefont);
  pwiz->title->adjustSize();

  //debug("Title points: %d", titlefont.pointSize());
  //debug("Title height: %d", title->height());

  pwiz->pagina->adjustSize();

  QSize pagesize = pageSize();

  int subtr = 5;
  bool f = false;
  if(pwiz->ok)
  {
    pwiz->ok->adjustSize();
    f = true;
    subtr = pwiz->ok->height() + 10;
  }
  if(pwiz->cancel)
  {
    pwiz->cancel->adjustSize();
    if(!f)
      subtr = pwiz->cancel->height() + 10;
  }
  if(pwiz->def)
  {
    pwiz->def->adjustSize();
    if(!f)
      subtr = pwiz->def->height() + 10;
  }
  if(pwiz->help)
  {
    pwiz->help->adjustSize();
    if(!f)
      subtr = pwiz->help->height() + 10;
  }

  int y = pwiz->title->height() + pagesize.height() +  pwiz->next->height() + 35 + subtr;
  int x = 20 + pagesize.width();
  setMinimumSize(x, y);
  //resize(x, y);
}

void KWizard::resizeEvent(QResizeEvent *)
{
  //QSize pagesize = pageSize();
  //debug("KWizard, resizeEvent()");

  int subtr = 4;
  if(pwiz->ok && pwiz->ok->isVisible())
    subtr = pwiz->ok->height() + 10;
  else if(pwiz->cancel && pwiz->cancel->isVisible())
    subtr = pwiz->cancel->height() + 10;
  else if(pwiz->def && pwiz->def->isVisible())
    subtr = pwiz->cancel->height() + 10;
  else if(pwiz->help && pwiz->help->isVisible())
    subtr = pwiz->help->height() + 10;

  //main->setGeometry(2, 2, width()-4, height()-(subtr));
  //debug("main");
  //pagina->adjustSize();

  pwiz->title->setGeometry(7, 7,
                           width()-14,
                           pwiz->title->sizeHint().height());

  pwiz->right->setGeometry(width()-(pwiz->title->sizeHint().height()+10),
                           5, // had to make a little hack :-(
                           pwiz->title->sizeHint().height(),
                           pwiz->title->sizeHint().height()+2);

  pwiz->left->setGeometry(width()-((pwiz->title->sizeHint().height()*2)+10),
                          5,
                          pwiz->title->sizeHint().height(),
                          pwiz->title->sizeHint().height()+2);

  pwiz->pagina->setGeometry(
        width()-(pwiz->pagina->sizeHint().width()+(pwiz->title->sizeHint().height()*2)+20),
                          7,
                          pwiz->pagina->sizeHint().width(),
                          pwiz->pagina->sizeHint().height());
  if(pwiz->numpages > 1)
    pwiz->pagina->show();
  else
    pwiz->pagina->hide();

  //debug("header - pagina: %d", pagina->width());
  pwiz->sep1->setGeometry(7,
                          pwiz->title->height()+10,
                          width()-14,
                          2);
  //debug("sep1");

  if(pwiz->currentwidget)
  {
    int hack = 15;
    if(pwiz->ok || pwiz->cancel || pwiz->help) hack = 0;
    int offs = pwiz->title->height() + 12;
    pwiz->currentwidget->setGeometry( 7, offs, width()-14,
           height()-( pwiz->next->height() + 40 + subtr + hack));
  }
  else debug("No currentwidget!");
  //debug("currentwidget");
  if(pwiz->directionsreflectspage)
  {
    QString str;
    if(pwiz->current < pwiz->numpages-1)
    {
      str = pages->at(pwiz->current+1)->title.data();
      str += " >>";
      pwiz->next->setText(str.data());
    }
    if(pwiz->current > 0)
    {
      str = "<< ";
      str += pages->at(pwiz->current-1)->title.data();
      pwiz->previous->setText(str.data());
    }
  }
  else
  {
    pwiz->next->setText(NEXT);
    pwiz->previous->setText(PREV);
  }

  pwiz->sep2->setGeometry(7, height()-(pwiz->next->height()+14+subtr),
                    width()-14, 2);
  //debug("sep2");
  pwiz->next->adjustSize();
  pwiz->previous->adjustSize();
  pwiz->next->move(width()-(pwiz->next->width()+7),
             height()-(pwiz->next->height()+7+subtr));
  pwiz->previous->move(width()-(pwiz->previous->width()+14+pwiz->next->width()),
             height()-(pwiz->previous->height()+7+subtr));

  int offs = 1;
  if(pwiz->ok && pwiz->ok->isVisible())
  {
    pwiz->ok->setGeometry(offs, height()-(pwiz->ok->height()+2),
                          pwiz->ok->width(), pwiz->ok->height());
    offs = 6 + pwiz->ok->width();
  }
  if(pwiz->cancel && pwiz->cancel->isVisible())
  {
    pwiz->cancel->setGeometry(offs, height()-(pwiz->cancel->height()+2),
                              pwiz->cancel->width(), pwiz->cancel->height());
    offs += 6 + pwiz->cancel->width();
  }
  if(pwiz->def && pwiz->def->isVisible())
    pwiz->def->setGeometry(offs, height()-(pwiz->def->height()+2),
                           pwiz->def->width(), pwiz->def->height());
  if(pwiz->help && pwiz->help->isVisible())
    pwiz->help->setGeometry(width()-(pwiz->help->width()+1),
                            height()-(pwiz->help->height()+2),
                            pwiz->help->width(), pwiz->cancel->height());

  //debug("KWizard, resizeEvent done");
}

void KWizard::paintEvent(QPaintEvent *)
{
  int subtr = 4;
  if(pwiz->ok)
    subtr = pwiz->ok->height() + 10;
  else if(pwiz->cancel)
    subtr = pwiz->cancel->height() + 10;
  else if(pwiz->help)
    subtr = pwiz->help->height() + 10;

  // start painting widget
  QPainter paint;
  paint.begin( this );
  QPen pen( white, 1 );
  paint.setPen( pen );

  // left
  paint.drawLine( 2, height()-subtr, 2, 3);

  // top
  paint.drawLine( 3 , 2, width()-4, 2);

  pen.setColor( black );
  paint.setPen( pen );

  // right
  paint.drawLine( width()-4 , 3, width()-4, height()-subtr);

  // bottom
  paint.drawLine( width()-4 , height()-subtr, 3, height()-subtr);

  paint.end();
}

int KWizard::addPage(KWizardPage *p)
{
  CHECK_PTR(p->w);

  p->w->recreate(this, 0, QPoint(0, 0));
  //debug("recreated");
  p->w->hide();
  //debug("hidden");
  if(pwiz->numpages == 0)
  {
    pwiz->current = 0;
    pwiz->currentwidget = p->w;
    pwiz->title->setText(p->title.data());
    pwiz->title->setEnabled(p->enabled);
    pwiz->currentwidget->setEnabled(p->enabled);
    pwiz->pagina->setEnabled(p->enabled);
    pwiz->currentwidget->show();
  }

  p->id = pwiz->numpages;
  pwiz->numpages++;
  pwiz->menu->insertItem(p->title.data(), p->id);
  pwiz->menu->setItemEnabled(p->id, p->enabled);
  //debug("inserted menuitem");
  pages->append(p);
  //titles.append(strtitle);

  if(pwiz->numpages > 1)
  {
    if(pwiz->current < (pwiz->numpages-1))
    {
      pwiz->next->show();
      if(pwiz->enablearrowbuttons)
        pwiz->right->show();
    }
    if(pwiz->current > 0)
    {
      pwiz->previous->show();
      if(pwiz->enablearrowbuttons)
        pwiz->left->show();
    }
  }

  //debug("enabled buttons");
  QString strpagina;
  strpagina.sprintf(klocale->translate("Page %d of %d"), pwiz->current+1, pwiz->numpages);
  if(pwiz->numpages > 1)
    pwiz->pagina->setText(strpagina.data());
  else
    pwiz->pagina->setText("");
  //debug("pagina");
  setSizes();
  //debug("Add page, done");

  return (p->id);
}

void KWizard::setPage(int id, QWidget *w)
{
  if(!w || pages->count() <= (uint)id)
    return;
  pages->at(id)->w = w;
}

void KWizard::setPage(int id, QString title)
{
  if(pages->count() <= (uint)id)
    return;
  pages->at(id)->title = title;
}

void KWizard::setPageEnabled(int id, bool state)
{
  if(id >= 0 && id < pwiz->numpages)
  {
    pages->at(id)->enabled = state;
    pwiz->menu->setItemEnabled(id, state);
    if(id == pwiz->current)
    {
      pwiz->title->setEnabled(state);
      pwiz->pagina->setEnabled(state);
      pwiz->currentwidget->setEnabled(state);
    }
  }
}

void KWizard::okClicked()
{
  emit okclicked();
}

void KWizard::cancelClicked()
{
  emit cancelclicked();
}

void KWizard::defaultClicked()
{
  emit defaultclicked(pwiz->current);
}

void KWizard::helpClicked()
{
  emit helpclicked(pwiz->current);
}

void KWizard::setDirectionsReflectsPage(bool state)
{
  pwiz->directionsreflectspage = state;
  setSizes();
}

bool KWizard::directionsReflectsPage()
{
  return pwiz->directionsreflectspage;
}

void KWizard::setEnablePopupMenu(bool state)
{
  pwiz->enablepopupmenu = state;
}

bool KWizard::enablePopupMenu()
{
  return pwiz->enablepopupmenu;
}

QPopupMenu *KWizard::getMenu()
{
  return pwiz->menu;
}

void KWizard::setEnableArrowButtons(bool state)
{
  pwiz->enablearrowbuttons = state;
}

bool KWizard::enableArrowButtons()
{
  return pwiz->enablearrowbuttons;
}

int KWizard::numPages()
{
  return pwiz->numpages;
}

void KWizard::gotoPage(int p)
{
  //debug("gotopage: %d", p);

  if(p >= pwiz->numpages) // || p == pwiz->current)
    return;

  //debug("Changing to page %d", p);

  if(p < (pwiz->numpages-1))
  {
    pwiz->next->show();
    if(pwiz->enablearrowbuttons)
      pwiz->right->show();
  }
  if(p > 0 && p < pwiz->numpages)
  {
    pwiz->previous->show();
    if(pwiz->enablearrowbuttons)
      pwiz->left->show();
  }
  if(p == (pwiz->numpages-1))
  {
    pwiz->next->hide();
    if(pwiz->enablearrowbuttons)
      pwiz->right->hide();
    emit nomorepages(false, true);
  }
  if(p == 0)
  {
    if(pwiz->numpages > 1)
    {
      pwiz->next->show();
      if(pwiz->enablearrowbuttons)
        pwiz->right->show();
    }
    pwiz->previous->hide();
    if(pwiz->enablearrowbuttons)
      pwiz->left->hide();
    emit nomorepages(false, false);
  }

  pwiz->current = p;

  QString strpagina;
  strpagina.sprintf(klocale->translate("Page %d of %d"), pwiz->current+1, pwiz->numpages);
  if(pwiz->numpages > 1)
    pwiz->pagina->setText(strpagina.data());
  else
    pwiz->pagina->setText("");

  pwiz->title->setText(pages->at(pwiz->current)->title.data());
  pwiz->currentwidget->hide();
  pwiz->currentwidget = pages->at(pwiz->current)->w;
  pwiz->title->setEnabled(pages->at(pwiz->current)->enabled);
  pwiz->currentwidget->setEnabled(pages->at(pwiz->current)->enabled);
  pwiz->pagina->setEnabled(pages->at(pwiz->current)->enabled);
  pwiz->currentwidget->show();
  //setSizes();
  // fake a resize event to trigger child widget moves
  QResizeEvent r( size(), size() );
  resizeEvent( &r );
  emit selected(pwiz->current);
}

void KWizard::nextPage()
{
  if((pwiz->current+1) == pwiz->numpages)
    emit nomorepages(true, true);
  else
    gotoPage(pwiz->current + 1);
}

void KWizard::previousPage()
{
  if((pwiz->current-1) < 0)
    emit nomorepages(true, false);
  else
    gotoPage(pwiz->current - 1);
}

// Grab QDialogs keypresses if non-modal and grab mouse events on title
// to popup menu.
bool KWizard::eventFilter( QObject *obj, QEvent *e )
{
  if ( e->type() == Event_MouseButtonPress && obj == pwiz->title)
  {
    QMouseEvent *m = (QMouseEvent*)e;
    if(pwiz->title->rect().contains( m->pos()) && m->button() == RightButton)
    {
      //debug("KWizard::eventFilter() - inside");
      emit popup(mapToGlobal(m->pos()));
      if(!pwiz->enablepopupmenu)
        return false;
      pwiz->menu->popup(mapToGlobal(m->pos()));
      return true;
    }
  }

  if ( e->type() == Event_KeyPress && obj == this)
  {
    QKeyEvent *k = (QKeyEvent*)e;
    if(k->key() == Key_PageUp)
    {
      //debug("Received keyevent PageUp");
      previousPage();
      return true;
    }
    else if(k->key() == Key_PageDown)
    {
      //debug("Received keyevent PageDown");
      nextPage();
      return true;
    }
    else
      return false;
  }

  return false;
}

void KWizard::closeEvent(QCloseEvent *e)
{
  e->accept();
  emit closed();
}

QSize KWizard::sizeHint()
{
  QSize s = minimumSize();
  int h = 0;
  if(pwiz->title)
    h += pwiz->title->height();
  if(pwiz->previous)
    h += pwiz->previous->height();
  if(pwiz->ok)
    h += pwiz->ok->height();
  else if(pwiz->cancel)
    h += pwiz->cancel->height();
  else if(pwiz->def)
    h += pwiz->def->height();
  else if(pwiz->help)
    h += pwiz->help->height();

  h += 20;

  s.setHeight(s.height() + h);
  return s;
}


#include "kwizard.moc"

--- NEW FILE: kwizard.h ---
/*  This file is part of the KDE Libraries
    Copyright (C) 1998 Thomas Tanghus (tanghus at earthling.net)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/  

#ifndef __KWIZARD_H
#define __KWIZARD_H

#define KWIZARD_VERSION_MAJOR 0
#define KWIZARD_VERSION_MINOR 20
#define KWIZARD_VERSION (KWIZARD_VERSION_MAJOR * 10) + KWIZARD_VERSION_MINOR

#include <qdialog.h>
#include <kapp.h>
#include <qpopupmenu.h>
#include <qlabel.h>
#include <qaccel.h>
#include <qfont.h>
#include <qpushbutton.h>
#include <qpainter.h>
#include <qpen.h>
#include <kdbtn.h>
#include <kseparator.h>

/**
* KDialog inherits QDialog. So far the only difference is that if the dialog is modeless
* and has a parent the default keybindings (escape = reject(), enter = accept() etc.) are
* disabled.
* @short KDialog
* @author Thomas Tanghus <tanghus at earthling.net>
* @version 0.1.1
*/
class KDialog : public QDialog
{
	Q_OBJECT

public:
/**
* Constructor. Takes the same arguments as QDialog.
*/
	KDialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0);
protected:

/**
* @internal
*/
	virtual void keyPressEvent(QKeyEvent*);
};

struct KWizProtected;

/**
* KWizardPage holds information about the pages in the wizard. Given as
* argument to @ref KWizard#addPage.
*/
struct KWizardPage
{
  QString title;
  QWidget *w;
  bool enabled;
  int id;
};


#define NEXT klocale->translate("&Next >>")
#define PREV klocale->translate("<< &Previous")


/**
* KWizard is a multi-purpose dialog. It is very useful for:
*
* - Configuration dialogs where the order in which the entries are filled is important.
*
* - Tutorials. Just create some HTML-widgets and feed them to a KWizard and your done (almost).
*
* - NoteBooks. KWizard is an integrated part of KNoteBook which provides a notebook
*   dialog similar to the ones in OS/2 Warp 4.
*
* - Propably many other things...
*
* The dialog contains:
*
* - A title at the top of the page.
*
* - A separator.
*
* - The userprovided page-widget.
*
* - A separator.
*
* - A label indicating the pagination.
*
* - A Previous and a Next button.
*
* - Optionally Ok, Cancel and Help buttons.
* 
* @short KWizard
* @author Thomas Tanghus <tanghus at earthling.net>
* @version 0.2
*/
class KWizard : public KDialog
{
friend class KNoteBook;
	Q_OBJECT

public:
/**
* Constructor
*/
	KWizard(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0);
/**
* Destructor
*/
	~KWizard();

/**
* Adds a page to the wizard.
* The pages are numbered from 0-n where 0 is the page first added and n is the
* page last added.
* @param p KWizardPage containing the page data.
*
* @return Returns the id of the new page.
*/
        int addPage(KWizardPage *p);

/**
* Changes the QWidget on the page with id "id" to "w".
*/
        void setPage(int id, QWidget *w);
/**
* Changes the title on the page with id "id" to "title".
*/
        void setPage(int id, QString title);
/**
* En/disable a specified page. If a page is disable its content will be grayd out
* and it will not receive keyboard input.
* @param page The page to en/disable.
* @param state If 'state' is false the page will be disabled, otherwise it will be enabled.
* @see KNoteBook#setPageEnabled
*/
        void setPageEnabled(int page, bool state);
/**
* Check the state of the page.
* @see #setPageEnabled
* @return Returns true if the page is enabled, otherwise false.
*/
        bool isPageEnabled(int page) { return pages->at(page)->enabled; };
/**
* Adds a Cancel button to the bottom of the dialog. The text will be a translated
* version of the string '&Cancel' thereby giving it the shortcut key 'c'.
* If any buttons are added a space will be created at the bottom of the dialog
* to fit the buttons. When clicked the button will emit the @ref cancelclicked signal.
* @see KLocale#translate
*/
        void setCancelButton();
/**
* Adds a Cancel button to the bottom of the dialog.
* @param text A user supplied text to write to the button.
*/
        void setCancelButton(const char *text);
/**
* Adds a Default button to the bottom of the dialog. The text will be a translated
* version of the string '&Default' thereby giving it the shortcut key 'd'.
* If any buttons are added a space will be created at the bottom of the dialog
* to fit the buttons. When clicked the button will emit the @ref defaultclicked signal.
* @see KLocale#translate
*/
        void setDefaultButton();
/**
* Adds a Default button to the bottom of the dialog.
* @param text A user supplied text to write to the button.
*/
        void setDefaultButton(const char *text);
/**
* Adds a Help button to the bottom right of the dialog. The text will be a translated
* version of the string '&Help' thereby giving it the shortcut key 'h'.
* If any buttons are added a space will be created at the bottom of the dialog
* to fit the buttons. When clicked the button will emit the @ref helpclicked signal.
* @see #getHelpButton
*/
        void setHelpButton();
/**
* Adds a Help button to the bottom of the dialog. This button will generate the
* signal @ref helpclicked where the int is the page to which the help was requested.
* @see #getHelpButton
* @param text A user supplied text to write to the button.
*/
        void setHelpButton(const char *);
/**
* Adds an Ok button to the bottom right of the dialog. The text will be a translated
* version of the string '&Ok' thereby giving it the shortcut key 'o'.
* If any buttons are added a space will be created at the bottom of the dialog
* to fit the buttons. When clicked the button will emit the @ref okclicked signal.
* @see #getOkButton
*/
        void setOkButton();
/**
* Adds an Ok button to the bottom of the dialog. This button will generate the
* signal @ref okclicked where the int is the page to which the help was requested.
* @see #getOkButton
* @param text A user supplied text to write to the button.
*/
        void setOkButton(const char *);
/**
* @see #setOkButton
* @return Returns the Ok buttonwidget or 0L if no button is added.
*/
        QButton * getOkButton();
/**
* @see #setCancelButton
* @return Returns the Cancel buttonwidget or 0L if no button is added.
*/
        QButton * getCancelButton();
/**
* @see #setDefaultButton
* @return Returns the Default buttonwidget or 0L if no button is added.
*/
        QButton * getDefaultButton();
/**
* @see #setHelpButton
* @return Returns the Help buttonwidget or 0L if no button is added.
*/
        QButton * getHelpButton();
/**
* getNextButton.
* @return Returns the Next buttonwidget.
*/
        QButton * getNextButton();
/**
* getPreviousButton
* @return Returns the Previous buttonwidget.
*/
        QButton * getPreviousButton();
/**
* @see #setEnableArrowButtons
* @return Returns the left arrowbutton.
*/
        KDirectionButton * getLeftArrow();
/**
* @see #setEnableArrowButtons
* @return Returns the right arrowbutton.
*/
        KDirectionButton * getRightArrow();
/**
* Let direction buttons reflect page.
* @see #directionsReflectsPage
* @param state If state is true the direction buttons (Previous and Next) will have the
* title of the corresponding page.
*/
        void setDirectionsReflectsPage(bool state);
/**
* @return Returns whether the direction buttons reflects the title of the corresponding page.
*
* @see #setDirectionsReflectsPage(bool state)
*/
        bool directionsReflectsPage();
/**
* En/Disable the popup menu.
* @see #enablePopupMenu
* @param state If state is true a menu containing the pages in the wizard
* will popup when the user RMB-clicks on the page-title.
*/
        void setEnablePopupMenu(bool state);
/**
* @see #setEnablePopupMenu
* @return Returns 'true' if the popupmenu is enabled.
*/
        bool enablePopupMenu();
/**
* getMenu
* @see #setEnablePopupMenu #enablePopupMenu
* @return Returns the handle of the popup menu.
*/
        QPopupMenu * getMenu();
/**
* En/Disable the arrow buttons at the rightmost of the title.
* @param state If state is true two arrows will appear to the right of the pagination
* allowing the user to change pages by clicking on them.
* @see #enableArrowButtons
*/
        void setEnableArrowButtons(bool state);
/**
* @see #setEnableArrowButtons
* @return Returns 'true' if the arrow buttons are enabled.
*/
        bool enableArrowButtons();
        QSize sizeHint();
        void adjustSize() { resize(sizeHint()); };
/**
* getTitle
* @return Returns the title of a specified page. Used by KNoteBook
* @param page The page to retrieve the title from.
*/
        const char * getTitle(int page) { return pages->at(page)->title.data(); };
/**
* numPages
* @return Returns the number of pages in the wizard.
*/
        int numPages();

signals:
/**
* This signal is emitted when the user clicks on the Ok button.
*/
        void okclicked();
/**
* This signal is emitted when the user clicks on the Cancel button.
*/
        void cancelclicked();
/**
* This signal is emitted when the user clicks on the Default button.
* The int is the page which was showing when default settings was requested.
*/
        void defaultclicked(int);
/**
* This signal is emitted when the user clicks on the Help button.
* The int is the page which was showing when help was requested.
* @see #setHelpButton
* <BR>
* @see #getHelpButton
*/
        void helpclicked(int);
/**
* This signal is emitted when a page is selected. The int is the page number
*/
        void selected(int);

/**
* This signal is emitted when the dialog is closed. Mainly usable if the dialog
* is a top level widget.
*/
        void closed();

/**
* This signal is emitted when a popup menu is requested. This happens when the user
* RMB-clicks somewhere in the title (not the titlebar). This is used by KNoteBook.
*/
        void popup(QPoint);
/**
* This signal is used by KNoteBook.
*/
        void nomorepages(bool, bool);

public slots:
/*
* Goto to a specified page.
* @param page The page number to turn to.
*/
        void gotoPage(int page);

protected slots:
        void nextPage();
	void previousPage();
	void okClicked();
	void cancelClicked();
	void defaultClicked();
        void helpClicked();

protected:
        bool eventFilter( QObject *, QEvent * );
        void closeEvent(QCloseEvent *);

/**
* @internal
*/
        QSize pageSize();
/**
* @internal
*/
        void setSizes();
/**
* @internal
*/
        void resizeEvent(QResizeEvent *);
/**
* @internal
*/
        void paintEvent(QPaintEvent *);

        QList<KWizardPage> *pages;
        //QList<QWidget> pages;
        //QStrList titles;
        KWizProtected *pwiz;
};

#endif // __KWIZARD_H



--- NEW FILE: ktabctl.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Alexander Sanda (alex at darkstar.ping.at)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/*
 * $Id: ktabctl.cpp,v 1.1 2006-10-03 11:26:32 dslinux_amadeus Exp $
 *
 * $Log: ktabctl.cpp,v $
 * Revision 1.1  2006-10-03 11:26:32  dslinux_amadeus
 * adding pristine copy of pixil to HEAD so I can branch from it
 *
 * Revision 1.1  2003/09/08 19:42:10  jasonk
 * Addition of packages directory and associated files.
 *
 * Revision 1.1.1.1  2003/08/07 21:18:33  jasonk
 * Initial import of PIXIL into new cvs repository.
 *
 * Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
 *
 *
 * Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
 * Initial import of ViewML
 *
 * Revision 1.16  1999/01/18 10:57:07  kulow
 * .moc files are back in kdelibs. Built fine here using automake 1.3
 *
 * Revision 1.15  1999/01/15 09:31:26  kulow
 * it's official - kdelibs builds with srcdir != builddir. For this I
 * automocifized it, the generated rules are easier to maintain than
 * selfwritten rules. I have to fight with some bugs of this tool, but
 * generally it's better than keeping them updated by hand.
 *
 * Revision 1.14  1998/09/01 20:22:19  kulow
 * I renamed all old qt header files to the new versions. I think, this looks
 * nicer (and gives the change in configure a sense :)
 *
 * Revision 1.13  1998/07/13 08:39:32  hoss
 * Fixed small bug in showTab. pages[i]->raise() does only work with more than
 * one widget!
 *
 * Revision 1.12  1998/06/16 21:23:36  hoss
 * Added support for setFont and setShape
 *
 * Revision 1.11  1997/11/23 22:23:55  leconte
 * Two patches have been applied for the header line painting bug:
 * I removed mine.
 *
 * Revision 1.10  1997/11/18 21:41:39  kalle
 * kiconloaderdialog uses the default fonts (patch by Paul Kendall)
 * ktabctl paints the header lines correctly (patch by Paul Kendall)
 *
 * Revision 1.9  1997/11/15 03:10:49  esken
 * Applied another patch by Bertrand Leconte, which corrects the
 * Tab-Changes-Focus bug.
 *
 * Revision 1.8  1997/11/13 14:11:45  esken
 * Applied the changes of Bertrand Leconte. Now KTabCtl paints its top line.
 * Additional fix by me: Color "white" of Top/Left line changed to
 * "colorGroup().light()" (This bug was observed by Bernd Deimel, thanks).
 *
 * Revision 1.7  1997/10/21 20:45:06  kulow
 * removed all NULLs and replaced it with 0L or "".
 * There are some left in mediatool, but this is not C++
 *
 * Revision 1.6  1997/10/16 11:15:54  torben
 * Kalle: Copyright headers
 * kdoctoolbar removed
 *
 * Revision 1.5  1997/10/09 11:46:29  kalle
 * Assorted patches by Fritz Elfert, Rainer Bawidamann, Bernhard Kuhn and Lars Kneschke
 *
 * Revision 1.4  1997/05/30 20:04:41  kalle
 * Kalle:
 * 30.05.97:	signal handler for reaping zombie help processes reinstalls itself
 * 		patch to KIconLoader by Christian Esken
 * 		slightly better look for KTabCtl
 * 		kdecore Makefile does not expect current dir to be in path
 * 		Better Alpha support
 *
 * Revision 1.3  1997/05/09 15:10:13  kulow
 * Coolo: patched ltconfig for FreeBSD
 * removed some stupid warnings
 *
 * Revision 1.2  1997/04/15 20:35:14  kalle
 * Included patch to ktabctl.cpp from kfind distribution
 *
 * Revision 1.1.1.1  1997/04/13 14:42:43  cvsuser
 * Source imported
 *
 * Revision 1.1.1.1  1997/04/09 00:28:09  cvsuser
 * Sources imported
 *
 * Revision 1.1  1997/03/15 22:40:57  kalle
 * Initial revision
 *
 * Revision 1.2.2.1  1997/01/07 14:41:57  alex
 * release 0.1
 *
 * Revision 1.2  1997/01/07 14:39:15  alex
 * some doc added, tested - ok.
 *
 * Revision 1.1.1.1  1997/01/07 13:44:53  alex
 * imported
 *
 *
 * KTabCtl provides a universal tab control. It is in no ways limited to dialogs and
 * can be used for whatever you want. It has no buttons or any other stuff.
 *
 * However, this is based on the original QTabDialog.
 */

#include "qtabbar.h"
#include "qpushbutton.h"
#include "qpainter.h"
#include "qpixmap.h"

#include "ktabctl.h"
#include "ktabctl.h"

KTabCtl::KTabCtl(QWidget *parent, const char *name)
    : QWidget(parent, name)
{
    tabs = new QTabBar(this, "_tabbar");
    connect(tabs, SIGNAL(selected(int)), this, SLOT(showTab(int)));
    tabs->move(2, 1);
    
    blBorder = TRUE;

    //    setFont(QFont("helvetica")); //BL: Why force a font ?
}

KTabCtl::~KTabCtl()
{
}

void KTabCtl::resizeEvent(QResizeEvent *)
{
    int i;
    QRect r = getChildRect();
    
    if (tabs) {
        for (i=0; i<(int)pages.size(); i++) {
            pages[i]->setGeometry(r);
        }
        if( ( tabs->shape() == QTabBar::RoundedBelow ) ||
            ( tabs->shape() == QTabBar::TriangularBelow ) ) {
            tabs->move( 0, height()-tabs->height()-4 );
        }
    }
}

void KTabCtl::setFont(const QFont & font)
{
    QFont f(font);
    f.setWeight(QFont::Light);
    QWidget::setFont(f);

    setSizes();
}

void KTabCtl::setTabFont(const QFont & font)
{
    QFont f(font);
//    f.setWeight(QFont::Light);
    tabs->setFont(f);

    setSizes();
}

void KTabCtl::show()
{
    unsigned int i;
    
    if(isVisible())
	return;

    setSizes();

    for(i = 0; i < pages.size(); i++)
	pages[i]->hide();

    QResizeEvent r(size(), size());
    resizeEvent(&r);

    QWidget::show();
}

bool KTabCtl::isTabEnabled(const char *name)
{
    unsigned int i;
    
    for(i = 0; i < pages.size(); i++)
	if (!qstrcmp( pages[i]->name(), name))
	    return tabs->isTabEnabled(i);   /* return the enabled status */
    return FALSE;     /* tab does not exist */
}

void KTabCtl::setTabEnabled(const char * name, bool state)
{
    unsigned i;

    if((name == 0L) || (strlen(name) == 0))
        return;
    
    for(i = 0; i < pages.size(); i++)
	if(!qstrcmp(pages[i]->name(), name))
	    tabs->setTabEnabled(i, state);
}

void KTabCtl::setSizes()
{
    unsigned i;
    
    QSize min(tabs->sizeHint());    /* the minimum required size for the tabbar */
    tabs->resize(min);         /* make sure that the tabbar does not require more space than actually needed. */
    
    
    QSize max(QCOORD_MAX,QCOORD_MAX);
    //int th = min.height();          /* the height of the tabbar itself (without pages and stuff) */

    for (i = 0; i < pages.size(); i++) {

        /*
         * check the actual minimum and maximum sizes
         */
        
	if (pages[i]->maximumSize().height() < max.height())
	    max.setHeight(pages[i]->maximumSize().height());
	if (pages[i]->maximumSize().width() < max.width())
	    max.setWidth( pages[i]->maximumSize().width());
	if ( pages[i]->minimumSize().height() > min.height())
	    min.setHeight( pages[i]->minimumSize().height());
	if ( pages[i]->minimumSize().width() > min.width())
	    min.setWidth( pages[i]->minimumSize().width());
    }

    // BL: min and max are sizes of children, not tabcontrol
    // min.setHeight(min.height() + th);

    if (max.width() < min.width())
	max.setWidth(min.width());
    if (max.height() < min.height())
	max.setHeight(min.height());

    /*
     * now, apply the calculated size values to all of the pages
     */
    
    for( i=0; i<(uint)pages.size(); i++ ) {
	pages[i]->setMinimumSize(min);
	pages[i]->setMaximumSize(max);
    }


    // BL: set minimum size of tabcontrol
    setMinimumSize(min.width()+4, min.height()+tabs->height()+4);

    /*
     * generate a resizeEvent, if we're visible
     */
    
    if(isVisible()) {
	QResizeEvent r(size(), size());
	resizeEvent(&r);
    }
}

void KTabCtl::setBorder( bool state )
{
    blBorder = state;
}

void KTabCtl::setShape( QTabBar::Shape shape )
{
    tabs->setShape( shape );  
}

void KTabCtl::paintEvent(QPaintEvent *)
{
    if (!tabs)
	return;

    if( !blBorder )
        return;
      
    QPainter p;
    p.begin(this);

    int y0 = getChildRect().top() - 1;
    int y1 = getChildRect().bottom() + 2;
    int x1 = getChildRect().right() + 2;
    int x0 = getChildRect().left() - 1;

    p.setPen( colorGroup().light() );
    p.drawLine(x0, y0, x1 - 1, y0);      /* top line */
    p.drawLine(x0, y0 + 1, x0, y1);      /* left line */
    p.setPen(black);
    p.drawLine(x1, y1, x0, y1);          /* bottom line */
    p.drawLine(x1, y1 - 1, x1, y0);
    p.setPen(colorGroup().dark());
    p.drawLine(x0 + 1, y1 - 1, x1 - 1, y1 - 1);  /* bottom */
    p.drawLine(x1 - 1, y1 - 2, x1 - 1, y0 + 1);
    p.end();
}

/*
 * return the client rect. This is the maximum size for any child
 * widget (page).
 */

QRect KTabCtl::getChildRect() const
{
    if( ( tabs->shape() == QTabBar::RoundedBelow ) || 
        ( tabs->shape() == QTabBar::TriangularBelow ) ) {
    	return QRect(2, 1, width() - 4,
		     height() - tabs->height() - 4);      
    } else {
      	return QRect(2, tabs->height() + 1, width() - 4,
		     height() - tabs->height() - 4);
    }
}

/*
 * show a single page, depending on the selected tab
 * emit tabSelected(new_pagenumber) BEFORE the page is shown
 */

void KTabCtl::showTab(int i)
{
    unsigned int j;
    for (j = 0; j < pages.size(); j++) {
      if (j != (unsigned)i) {
        pages[j]->hide();
      }
    }

    if((unsigned)i < pages.size()) {
        emit(tabSelected(i));
	if( pages.size() >= 2 ) { 
	  pages[i]->raise();
	}
        pages[i]->setGeometry(getChildRect());
        pages[i]->show();
    }
}

/*
 * add a tab to the control. This tab will manage the given Widget w.
 * in most cases, w will be a QWidget and will only act as parent for the
 * actual widgets on this page
 * NOTE: w is not required to be of class QWidget, but expect strange results with
 * other types of widgets
 */

void KTabCtl::addTab(QWidget *w, const char *name)
{
    QTab *t = new QTab();
    t->label = name;
    t->enabled = TRUE;
    int id = tabs->addTab(t);   /* add the tab itself to the tabbar */
    if (id == (int)pages.size()) {
	pages.resize(id + 1);
        pages[id] = w;          /* remember the widget to manage by this tab */
    }
    // BL: compute sizes
    setSizes();
}
#include "ktabctl.moc"

--- NEW FILE: kmenubar.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997, 1998 Sven Radej (sven at lisa.exp.univie.ac.at)
    Copyright (C) 1997 Matthias Ettrich (ettrich at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

//$Id: kmenubar.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
//$Log: kmenubar.h,v $
//Revision 1.1  2006-10-03 11:26:31  dslinux_amadeus
//adding pristine copy of pixil to HEAD so I can branch from it
//
//Revision 1.1  2003/09/08 19:42:09  jasonk
//Addition of packages directory and associated files.
//
//Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
//Initial import of PIXIL into new cvs repository.
//
//Revision 1.1.1.1  2003/06/23 22:04:23  jasonk
//
//
//Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
//Initial import of ViewML
//
//Revision 1.15.4.3  1999/05/29 18:55:00  denis
//Broken files repaired.
//It looks like nothing has missed.
//
//Revision 1.15.4.2  1999/04/18 18:36:27  radej
//sven: Docs.
//
//Revision 1.15.4.1  1999/03/24 16:48:57  ettrich
//workaround for qt-1.44 behaviour
//
//Revision 1.15  1998/12/16 01:27:14  ettrich
//fixed slightly broken macstyle removal
//
//Revision 1.14  1998/11/25 13:24:53  radej
//sven: Someone changed protected things to private (was it me?).
//
//Revision 1.13  1998/11/23 15:34:05  radej
//sven: Nicer sysmenu button
//
//Revision 1.12  1998/11/22 13:35:47  radej
//sven: IMPROVED Mac menubar: Accelerators, SystemMenu, look...
//
//Revision 1.11  1998/11/15 09:22:59  garbanzo
//Clean up kmenubar.h
//
//Revision 1.10  1998/11/11 14:32:12  radej
//sven: *Bars can be made flat by MMB (Like in Netscape, but this works)
//
//Revision 1.9  1998/08/31 00:52:12  torben
//Torben: One new function and made others virtual
//=> binary incompatible. Sorry. Please use virtual whenever it is
//not a performance problem.
//
//Revision 1.8  1998/05/07 23:13:23  radej
//Moving with KToolBoxManager
//

#ifndef _KMENUBAR_H
#define _KMENUBAR_H

#include <qmenubar.h>

class KToolBoxManager;

class _menuBar : public QMenuBar
 {
   Q_OBJECT

 public:
   _menuBar(QWidget *parent=0, const char *name=0);
   ~_menuBar();
protected:
     void resizeEvent( QResizeEvent* );
 };

/**
 * This is floatable toolbar. It can be set to float, Top, or Bottom
 * of KTopLevelWidget. It can be used without KTopLevelWidget, but
 * then you should maintain items (toolbars, menubar, statusbar)
 * yourself.
 *
 * Interface is the same as QMenuBar, except that you can't
 * add pixmaps.
 *
 * If you want to add other methods for 100% compatibility with QMenuBar
 * just add those methods, and pass all arguments ot menu bar.
 * see kmenubar.cpp for details. It is extremly simple.
 * @short KDE floatable menubar
 */
class KMenuBar : public QFrame
 {
   Q_OBJECT

 public:

   /**
    * Positions of menubar.
    */
   enum menuPosition{Top, Bottom, Floating, Flat, FloatingSystem};

   /**
    * Constructor. For all details about inserting items see
    * @ref QMenuBar
    */
   KMenuBar( QWidget *parent=0, const char *name=0);

   /**
    * Destructor. Embeds menubar back if floating. Delete menubar
    * in your destructor or closeEvent for 100% safety
    */
   ~KMenuBar();

   /**
    * Enable or disable moving. This only disables user moving
    * menubar can be moved wit @ref #setMenuBarPos.
    */
   void enableMoving(bool flag = TRUE);

   /**
    * Returns menubar position.
    */
   menuPosition menuBarPos() {return position;};

   /**
    * Enables/disables floating.
    */
   void enableFloating(bool flag = TRUE);

   /**
    * Sets position. Can be used when floating or moving is disabled.
    * This cannot be used to set toolbar flat. For that, use @ref setFlat .
    */
   void setMenuBarPos(menuPosition mpos);

   /**
    * Sets title for floating menu bar. Default is Main widget title.
    */
   void setTitle(const char *_title) {title = _title;};

   /**
    * The rest is standard QMenuBar interface. See Qt docs for
    * details.
    */
   virtual uint count();
   virtual int insertItem(const char *text,
                  const QObject *receiver, const char *member,
                  int accel=0 );

   virtual int insertItem(const char *text, int id=-1, int index=-1 );
   virtual int insertItem(const char *text, QPopupMenu *popup,
                  int id=-1, int index=-1 );

   virtual void insertSeparator(int index=-1 );
   virtual void removeItem(int id);
   virtual void removeItemAt(int index);
   virtual void clear();
   virtual int accel(int id);
   virtual void setAccel(int key, int id );
   virtual const char *text(int id);
   virtual void changeItem(const char *text, int id);
   virtual void setItemChecked(int id , bool flag);
   virtual void setItemEnabled(int id, bool flag);
   virtual int idAt( int index );

   int heightForWidth ( int max_width ) const;

   /**
   * This method switches flat/unflat mode. Carefull: might not work
   * If menubar is floating.
   */
   void setFlat (bool);

 protected slots:
   void ContextCallback(int index);
   void slotActivated (int id);
   void slotHighlighted (int id);
   void slotReadConfig ();
   void slotHotSpot (int i);

 protected:
   void init();
   void mousePressEvent ( QMouseEvent *m );
   void resizeEvent( QResizeEvent *e );
   void paintEvent(QPaintEvent *);
   void closeEvent (QCloseEvent *e);
   void leaveEvent (QEvent *e);
   bool eventFilter(QObject *, QEvent *);

private:
   bool moving;
   QWidget *Parent;
   int oldX;
   int oldY;
   int oldWFlags;
   const char *title;
   menuPosition position;
   menuPosition lastPosition;
   menuPosition movePosition;

   QPopupMenu *context;
   QMenuBar *menu;
   QFrame *frame;

signals:
    /**
     * This signal is connected to @ref KTopLevel::updateRects. It is
     * emited when menu bar changes its position.
     */
    void moved (menuPosition);

    /**
     * This signal is emited when item id is highlighted.
     */
    void highlighted(int id);

    /**
     * This signal is emited when item id is activated.
     */
    void activated(int id);

private:
   QFrame *handle;
   QPoint pointerOffset;
   QPoint parentOffset;
   int oldMenuFrameStyle;
   KToolBoxManager *mgr;
   bool highlight;
   bool transparent;
 };

#endif

--- NEW FILE: kstatusbar.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Mark Donohoe (donohoe at kde.org)
    Copyright (C) 1997, 1998 1998 Sven Radej (sven at lisa.exp.univie.ac.at)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef _KSTATUSBAR_H
#define _KSTATUSBAR_H
#include <qtimer.h>
#include <qframe.h>
#include <qstring.h> 
#include <qlist.h>
#include <qlabel.h> 

/**
 * Internal item class for use in KStatusBar
 * @short Internal class for use in KStatusBar
 */
class KStatusBarItem
{
public:
  KStatusBarItem (QWidget *w, int i, bool m=false) {item=w;id=i;mine=m;};
  ~KStatusBarItem () {if (mine) delete item;};
  void setGeometry (int x, int y, int w, int h) {item->setGeometry(x,y,w,h);};
  int width() {return item->width();};
  int height() {return item->height();};
  void show() {item->show();};
  void hide() {item->hide();};
  int ID() {return id;};
  QWidget *getItem() { return item;};
  
private:
  int id;
  QWidget *item;
  bool mine;
};


/**
 * Internal label class for use in KStatusBar
 * @short Internal class for use in KStatusBar
 */
class KStatusBarLabel : public QLabel {
  Q_OBJECT

public:

  KStatusBarLabel( const char *text, int ID, QWidget *parent=0L,
                  const char *name=0L );
  ~KStatusBarLabel () {};
  int w,h;
  
protected:
  void mousePressEvent(QMouseEvent *);
  void mouseReleaseEvent(QMouseEvent *);

private:
  int id;

signals:

  void Pressed(int);
  void Released(int);
};


/**
 * KStatusBar is widget for displaying status messages. You can insert
 * text labels or custom widgets. Managing of items is internal. KStatusBar
 * resizes itself, but positioning is left to KTopLevelWidget (or to you, if
 * you don't use KTopLevelWidget).<br>
 * special type of item is a message, a temporary text-message or custom
 * widget which is displayed on top of other items in full-width. Messages
 * are visible for specified time, or until you call slot clear().<br>
 * STILL UNIMPLEMENTED:<br>
 * It is also possible to replace one item by another, keeping the same
 * size and position.
 *
 * @short KDE statusbar widget
 * @author Mark Donohoe (donohoe at kde.org) Maintained by Sven Radej <sven at lisa.exp.univie.ac.at>
 */
class KStatusBar : public QFrame {
  Q_OBJECT
    
public:
  enum BarStatus{ Toggle, Show, Hide };
  enum Position{Top, Left, Bottom, Right, Floating};
  enum InsertOrder{LeftToRight, RightToLeft};

 /**
  * Constructs KStatusBar object.
  */
  KStatusBar(QWidget *parent = 0L, const char *name = 0L );
  /**
   * Destructor. Deletes all internal objects.
   */
  ~KStatusBar();

  /**
   * Insert text label into the status bar. When inserting the item send the
   * longest text you expect to go into the field as the first argument.
   * The field is sized to accomodate this text. However, the last field
   * inserted is always stretched to fit the window width.
   * @see #insertWidget
   */
  int insertItem( const char *text, int ID );

  /**
   * Insert custom widget into the status bar. The widget must have statusbar
   * as parent. The size is the width of the widget. However, the last item
   * inserted is always stretched to fit the window width.
   * @see #insertItem
   */
  int insertWidget (QWidget *_widget, int size, int id);

  /**
   * Removes item id. If that was your custom widget it's hidden
   * but not deleted.
   */
  void removeItem (int id);

  /**
   * NOT YET IMPLEMENTED!
   * Replaces item id with new label wich has text new_text. New
   * label will have the same position and size as old. If old item was
   * your custom widget it is not deleted. Note that it is rather pointless
   * to replace one label by another; use @ref #changeItem for that.
   */
  void replaceItem(int _id, const char *new_text);

  /**
   * NOT YET IMPLEMENTED!
   * Replaces item id with new widget new_widget. New widget will have the
   * same position and size as old item. If old item was your custom widget
   * it is not deleted.
   */
  
  void replaceItem(int _id, QWidget *new_widget);

  
  /**
   * Change the text in a status bar field. The field is not resized !!!
   * Usefull only for labels.
   */
  void changeItem( const char *text, int id );

  /** 
   * If order is KStatusBar::LeftToRight the fields are inserted from left
   * to right, in particular the last field ist streched to the right
   * border of the window. If order is KStatusBar::RightToLeft the fields
   * are inserted from the right.
   */
  void setInsertOrder(InsertOrder order);

  /**
   * Sets the alignment of a field. By default all fields are aligned left.
   * Usefull only for labels.
  */
  void setAlignment(int id, int align);

  /**
   * Sets the Height of the StatusBar. Default height is computed from
   * default font height.
   */
  void setHeight(int);

  /**
   * Sets the border width of the status bar seperators and frame.
   */
  void setBorderWidth(int);

  /**
   * Enable disable status bar. You can get the same effect with show
   * or hide.
   */
  bool enable( BarStatus stat );

  /**
   * Hides all items and displays temporary text message in whole statusbar.
   * Message will be removed (and old items redisplayed) after time (in ms).
   * If time is 0 (default) message will remain untill you call @ref #clear.
   * You can remove the message by calling @ref #clear any time.
   */
  void message (const char *text, int time=0);

  /**
   * Hides all items and displays temporary custom widget in whole statusbar.
   * Widget must have statusbar for it's parent.
   * Widget will be removed (and old items redisplayed) after time (in ms).
   * If time is 0 (default) widget will remain untill you call @ref #clear.
   * You can remove the message by calling @ref #clear any time. Upon
   * @ref #clear your widget will be hidden, not deleted.
   */
  void message (QWidget *wiiidget, int time=0);

  /**
   * SizeHint. For now returns height() and width().
   */
  QSize sizeHint ();
  
public slots:

  /**
   * Clears the message (if any), and shows back old
   * state. This method is slot, you can connect to it. Does nothing if
   * @ref #message was not called before. Message is hidden, not deleted.
   * If message was your custom widget you have to clean it up.
   */
  void clear ();
   
signals:
  /**
   * Emits when mouse is pressed over llabel id. Connect to this signal
   * if you want to notice mouse press events. If you want to catch this
   * signal for your custom widgets, they must not catch  mouse press
   * events.
   */
  void pressed(int);

  /**
   * Emits when mouse is released over item id. Conect to
   * this signal if you want to receive mouse click. If you want to catch
   * this signal for your custom widgets, they must not catch mouse release
   * events.
   */
  void released(int);

protected:
  void drawContents ( QPainter * );
  void resizeEvent( QResizeEvent* );
  void init();
  void updateRects( bool resize = FALSE );

protected slots:
  void slotPressed(int);
  void slotReleased(int);

private:
  QList <KStatusBarItem> items;
  InsertOrder insert_order;
  int fieldheight, borderwidth;
  KStatusBarLabel *tempMessage;
  QWidget *tempWidget;
  QTimer *tmpTimer; //for future bugfix

  //fut:
  bool bull;
  int tni;
  
};

#endif

//Eh?


--- NEW FILE: kstatusbar.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Mark Donohoe (donohoe at kde.org)
              (C) 1997,1998 Sven Radej (sven at lisa.exp.univie.ac.at)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <qpainter.h>

#include <ktopwidget.h>
#include <kstatusbar.h>
// $Id: kstatusbar.cpp,v 1.1 2006-10-03 11:26:32 dslinux_amadeus Exp $
// $Log: kstatusbar.cpp,v $
// Revision 1.1  2006-10-03 11:26:32  dslinux_amadeus
// adding pristine copy of pixil to HEAD so I can branch from it
//
// Revision 1.1  2003/09/08 19:42:10  jasonk
// Addition of packages directory and associated files.
//
// Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
// Initial import of PIXIL into new cvs repository.
//
// Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
//
//
// Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
// Initial import of ViewML
//
// Revision 1.18.4.1  1999/05/29 18:55:01  denis
// Broken files repaired.
// It looks like nothing has missed.
//
// Revision 1.18  1999/01/18 10:57:04  kulow
// .moc files are back in kdelibs. Built fine here using automake 1.3
//
// Revision 1.17  1999/01/15 09:31:23  kulow
// it's official - kdelibs builds with srcdir != builddir. For this I
// automocifized it, the generated rules are easier to maintain than
// selfwritten rules. I have to fight with some bugs of this tool, but
// generally it's better than keeping them updated by hand.
//
// Revision 1.16  1998/10/05 10:14:25  radej
// sven: Bugfix: SEGV when 10000 messages come in the same time
//
// Revision 1.15  1998/09/23 14:40:22  radej
// sven: connected timeout to clear. Thanks to Taj for hint, and no-thanks to
//       me - alzheimer for forgeting it
//
// Revision 1.14  1998/09/04 22:58:09  radej
// sven: added sizeHint. Very primitive - width is ?, but height is set
//       according to fontMetrics
//
// Revision 1.13  1998/08/05 09:58:47  radej
// sven: fixed removeItem SEGV; thanks to Frans van Dorsselaer for report.
//
// Revision 1.12  1998/05/08 16:25:55  radej
// Fixed timer ftr temp messages.
//
// Revision 1.11  1998/05/05 10:04:40  radej
// Not sunken in windows style
//
// Revision 1.10  1998/04/21 20:37:48  radej
// Added insertWidget and some reorganisation - BINARY INCOMPATIBLE
//


/*************************************************************************/
// We want a statusbar-fields to be by this amount heigher than fm.height().
// This does NOT include the border width which we set separately for the statusbar.

#define FONT_Y_DELTA 3
#define DEFAULT_BORDERWIDTH 0

KStatusBarLabel::KStatusBarLabel( const char *text, int _id,
                                 QWidget *parent, const char *) :
  QLabel( parent ) 
{   
  id = _id;

  QFontMetrics fm = fontMetrics();
  w = fm.width( text )+8;
  h = fm.height() + FONT_Y_DELTA;
  resize( w, h );
    
  setText( text );
  if ( style() == MotifStyle )
    setFrameStyle( QFrame::Panel | QFrame::Sunken );
  setAlignment( AlignLeft | AlignVCenter );
}


void KStatusBarLabel::mousePressEvent (QMouseEvent *)
{
  emit Pressed(id);
}

void KStatusBarLabel::mouseReleaseEvent (QMouseEvent *)
{
  emit Released (id);
}

/***********************************************************************/

KStatusBar::KStatusBar( QWidget *parent, const char *name )
  : QFrame( parent, name )
{
  init();
}

KStatusBar::~KStatusBar ()
{
  tmpTimer->stop();
  for ( KStatusBarItem *b = items.first(); b; b=items.next() )
    delete b;
  if (tempMessage)
    delete tempMessage;

  delete tmpTimer; // What do I have to notice!?
};

void KStatusBar::drawContents( QPainter * )
{
}

void KStatusBar::init()
{
  borderwidth = DEFAULT_BORDERWIDTH;
  fieldheight = fontMetrics().height() + FONT_Y_DELTA;

  insert_order = KStatusBar::LeftToRight;
  setFrameStyle( QFrame::NoFrame );
  resize( width(), fieldheight + 2* borderwidth);
  tempWidget=0;
  tempMessage=0;

  tmpTimer = new QTimer(this);
  connect (tmpTimer, SIGNAL(timeout()), this, SLOT(clear()));

}

void KStatusBar::setHeight(int h){

  fieldheight = h - 2* borderwidth;
  resize( width(),h);
  
}


void KStatusBar::setBorderWidth(int b){
  
  borderwidth = b;
  resize( width(),height() + 2* borderwidth);
  
}

void KStatusBar::resizeEvent( QResizeEvent * ) {
  if (tempMessage)
    tempMessage->setGeometry(borderwidth, borderwidth,
                             width()-2*borderwidth, fieldheight);
  else if (tempWidget)
    tempWidget->setGeometry(borderwidth, borderwidth,
                            width()-2*borderwidth, fieldheight);
  else
    updateRects( ); // False? You wouldn't sell that to toolbar... (sven)
}

void KStatusBar::setInsertOrder(InsertOrder order){

  insert_order = order;

}

void KStatusBar::updateRects( bool res ){
  
  if( insert_order == KStatusBar::LeftToRight){

    int offset= borderwidth;	
    for ( KStatusBarItem *b = items.first(); b; b=items.next() ) {

      b->setGeometry( offset, borderwidth, b->width(), fieldheight );	
      offset+=b->width() + borderwidth;
    }
    
    if ( !res ) {
      KStatusBarItem *l = items.getLast();
      if( l ) {
		offset-=l->width() + borderwidth;
		l->setGeometry( offset ,borderwidth, width() - offset - borderwidth, fieldheight );
      }
    }
  }
  else{ // KStatusBar::RightToLeft
    int offset = width();

    for ( KStatusBarItem *b = items.first(); b; b=items.next() ) {
      offset -=b->width() + borderwidth;
      b->setGeometry(offset,borderwidth,b->width(),fieldheight );

    }
    
    if ( !res ) {
      KStatusBarItem *l = items.getLast();
      if( l != 0L ) {
		offset+=l->width() - borderwidth;
		l->setGeometry(borderwidth,borderwidth,offset,fieldheight);
      }
    }
  }	
}

bool KStatusBar::enable( BarStatus stat )
{
  bool mystat = isVisible();
  if ( (stat == Toggle && mystat) || stat == Hide )
    hide();
  else
    show();
  return ( isVisible() == mystat );
}	

int KStatusBar::insertItem( const char *text, int id )
{
  KStatusBarLabel *label = new KStatusBarLabel( text, id, this );
  KStatusBarItem *item = new KStatusBarItem(label, id, true);
/*
  // resize last item to default
  KStatusBarItem *l = items.getLast();
  if( l )
  {
    QFontMetrics fm = fontMetrics();
    int w = fm.width(((QLabel *) l->getItem())->text() )+8;
    int h = fm.height() + FONT_Y_DELTA;
    l->getItem()->resize( w, h );
  }
*/
  items.append( item );
  updateRects( TRUE );
  connect (label, SIGNAL(Pressed(int)), this, SLOT(slotPressed(int)));
  connect (label, SIGNAL(Released(int)), this, SLOT(slotReleased(int)));
  return items.at();
}

int KStatusBar::insertWidget(QWidget *_widget, int size, int id)
{
   KStatusBarItem *item = new KStatusBarItem(_widget, id, false);

   items.append( item );
   _widget->resize(size, fieldheight);
   updateRects( TRUE );
   return items.at();
}

void KStatusBar::removeItem (int id)
{
  for ( KStatusBarItem *b = items.first(); b; b=items.next() ) 
    if ( b->ID() == id )
    {
      items.remove();
      delete b;
      updateRects(false );
    }
  
}

void KStatusBar::replaceItem(int /* _id */, const char * /* _text */ )
{
 debug ("Not yet implemented. Sorry.");
}

void KStatusBar::replaceItem(int /* _id */ , QWidget * /* _widget */)
{
 debug ("Not yet implemented. Sorry.");
}

void KStatusBar::changeItem( const char *text, int id )
{
  for ( KStatusBarItem *b = items.first(); b; b=items.next() ) 
	if ( b->ID() == id )
	  ((KStatusBarLabel *)b->getItem())->setText( text );
}

void KStatusBar::setAlignment( int id, int align)
{
  for ( KStatusBarItem *b = items.first(); b; b=items.next() ) 
    if ( b->ID() == id ){
	  ((KStatusBarLabel *)b->getItem())->setAlignment(align|AlignVCenter);
    }
}

void KStatusBar::message(const char *text, int time)
{
  if (tmpTimer->isActive())
    tmpTimer->stop();
  
  if (tempMessage)
  {
    delete tempMessage;
    tempMessage = 0;
  }
  else if (tempWidget)
  {
    tempWidget->hide();
    tempWidget=0;
  }
  else
    for ( KStatusBarItem *b = items.first(); b; b=items.next() )
      b->hide();

  
  tempMessage = new KStatusBarLabel( text, -1, this );
  tempMessage->setGeometry(borderwidth, borderwidth,
                           width()-2*borderwidth, fieldheight);
  tempMessage->show();
  if (time >0)
    tmpTimer->start(time, true);
}

void KStatusBar::message(QWidget *widget, int time)
{
  if (tmpTimer->isActive())
    tmpTimer->stop();
  
  if (tempMessage)
  {
    delete tempMessage;
    tempMessage = 0;
  }
  else if (tempWidget)
  {
    tempWidget->hide();
    tempWidget=0;
  }
  else
    for ( KStatusBarItem *b = items.first(); b; b=items.next() )
      b->hide();

  // Hi, Trolls
  
  tempWidget = widget;
  tempWidget->setGeometry(borderwidth, borderwidth,
                          width()-2*borderwidth, fieldheight);
  tempWidget->show();
  if (time >0)
    tmpTimer->start(time, true);
}


void KStatusBar::clear()
{
  tmpTimer->stop();
  if (tempMessage)
    delete tempMessage;
  if (tempWidget)
    tempWidget->hide();
  
  for ( KStatusBarItem *b = items.first(); b; b=items.next() )
    b->show();

  tempMessage=0;
  tempWidget=0;
}

void KStatusBar::slotPressed(int _id)
{
  emit pressed(_id);
}

void KStatusBar::slotReleased(int _id)
{
  emit released(_id);
}

QSize KStatusBar::sizeHint()
{
  return QSize(width(), height());
}


#include "kstatusbar.moc"

//Eh!!!


--- NEW FILE: ktabbar.cpp ---
/*  This file is part of the KDE Libraries
    Copyright (C) 1998 Thomas Tanghus (tanghus at earthling.net)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/  

#include "ktabbar.h"

struct KTabBarProtected
{
    QTabBar *qtab;
    QWidget *tabw;
    KTabButton *right;
    KTabButton *left;
    bool rightscroll;
    bool leftscroll;
    int tpos;
    int t_width;
    int tw_width;
    int tw_height;
    int tw_start;
};

KTabBar::KTabBar(QWidget *parent, const char *name)
 : QWidget(parent, name)
{
  initMetaObject();
  init();
}

KTabBar::~KTabBar()
{
  //debug("KTabBar - destructor");

  //debug("KTabBar - destructor done");
}

void KTabBar::init()
{
  ptab = new KTabBarProtected;
  ptab->tpos = 0;
  ptab->leftscroll = ptab->rightscroll = false;
  ptab->tabw = new QWidget(this);
  ptab->qtab = new QTabBar(ptab->tabw);

  ptab->left = new KTabButton(LeftArrow, this);
  connect( ptab->left, SIGNAL(clicked()), SLOT( leftClicked()) );

  ptab->right = new KTabButton(RightArrow, this);
  connect( ptab->right, SIGNAL(clicked()), SLOT( rightClicked()) );

  connect( ptab->qtab, SIGNAL(selected(int)), SLOT( emitSelected(int)) );

  //debug("init - done");
}

QTabBar *KTabBar::getQTab()
{
  return ptab->qtab;
}

QSize KTabBar::sizeHint()
{
  return ptab->qtab->sizeHint();
}

int KTabBar::addTab( QTab *tab )
{
  return ptab->qtab->addTab( tab );
}

void KTabBar::setTabEnabled( int tab, bool enable )
{
  ptab->qtab->setTabEnabled( tab, enable );
}

bool KTabBar::isTabEnabled( int tab )
{
  return ptab->qtab->isTabEnabled( tab );
}

int KTabBar::currentTab()
{
  return ptab->qtab->currentTab();
}

QTab *KTabBar::tab( int tab )
{
  return ptab->qtab->tab( tab );
}

int KTabBar::keyboardFocusTab()
{
  return ptab->qtab->keyboardFocusTab();
}

void KTabBar::setCurrentTab(int tab)
{
  ptab->qtab->setCurrentTab(tab);
}

void KTabBar::setCurrentTab(QTab *tab)
{
  ptab->qtab->setCurrentTab(tab);
}

void KTabBar::leftClicked()
{
  if(ptab->tpos == (0-(2*JUMP)))
    ptab->tpos += (2 * JUMP);
  else
    ptab->tpos += JUMP;
  QResizeEvent e(size(), size());
  resizeEvent(&e);
  emit scrolled( RightArrow );
}

void KTabBar::rightClicked()
{
  if(ptab->tpos == 0)
    ptab->tpos -= (2 * JUMP);
  else
    ptab->tpos -= JUMP;
  QResizeEvent e(size(), size());
  resizeEvent(&e);
  emit scrolled( LeftArrow );
}

void KTabBar::emitSelected(int tab)
{
  emit selected(tab);
}

void KTabBar::setSizes()
{
  ptab->leftscroll = ptab->rightscroll = false;
  ptab->tw_width = width();
  ptab->t_width = ptab->qtab->sizeHint().width();
  if(ptab->tw_width > ptab->t_width)
    ptab->tw_width = ptab->t_width;
  ptab->tw_height = ptab->qtab->sizeHint().height();
  ptab->tw_start = 0;
  int r = 0;

  //debug("width: %d - t_width: %d", width(), ptab->t_width);
  //debug("tpos %d", ptab->tpos);

  if(width() >= ptab->t_width)
    ptab->tpos = 0;
  else
  {
    if(ptab->tpos < 0)
    {
      //debug("leftscroll");
      ptab->leftscroll = true;
      ptab->tw_start = ptab->tw_height;
      ptab->tw_width -= ptab->tw_start;
      r = ptab->tw_height;
    }

    if(width() < (ptab->t_width + ptab->tpos + ptab->tw_start))
    {
      //debug("rightscroll");
      ptab->rightscroll = true;
      ptab->tw_width -= ptab->tw_height;
    }
  }
  if(ptab->tw_width > (ptab->t_width+ptab->tpos))
    ptab->tw_width = ptab->t_width + ptab->tpos;
  //debug("tw_width %d", tw_width);
  //debug("\n");
}

void KTabBar::resizeEvent(QResizeEvent *)
{
  //debug("KTabBar, resizing");

  setSizes();

  if(ptab->leftscroll)
  {
    ptab->left->setGeometry( 0, 0, ptab->tw_height, ptab->tw_height);
    ptab->left->show();
  }
  else
    ptab->left->hide();

  if(ptab->rightscroll)
  {
    ptab->right->setGeometry( width()-ptab->tw_height, 0,
                              ptab->tw_height, ptab->tw_height);
    ptab->right->show();
  }
  else
    ptab->right->hide();

  ptab->tabw->setGeometry( ptab->tw_start, 0,
                           ptab->tw_width, ptab->tw_height);
  ptab->qtab->setGeometry( ptab->tpos, 0,
                           ptab->qtab->sizeHint().width(), ptab->tw_height);
  //debug("KTabBar\ntabw: %dx%d\nqtab: %dx%d", tw_width, tw_height,
  //                          qtab->sizeHint().width(), tw_height);

  QPaintEvent pe(geometry());
  paintEvent( &pe );

  //debug("KTabBar, resize - done");
}

void KTabBar::paintEvent(QPaintEvent *)
{
  //debug("KTabBar - painting");

  int end = width()-1;
  int start = ptab->tw_width + ptab->tpos;
  //debug("width: %d - start: %d", width(), start);

  if(ptab->leftscroll)  // if we need a left button we start the tabs at tw_height
    start = ptab->tw_height; // ( tw_height == left->width() )
  //start = 0;
  if(ptab->rightscroll)
    end -= ptab->tw_height;
  //debug("width: %d", width());
  //debug("tw_width: %d", tw_width);
  //debug("tw_start: %d", tw_start);
  //debug("2*tw_height + tw_width: %d", (2*tw_height)+tw_width);
  //debug("start: %d - end: %d", start, end);

  QPainter p;
  // start painting widget
  p.begin(this);
  QPen pen( white, 1 );
  p.setPen( pen );

  // draw bottom line
  if(start < end)
    p.drawLine( start, ptab->tw_height-1, end, ptab->tw_height-1);

  p.end();

  //qtab->repaint();

  //debug("KTabBar - painting done");
}
#include "ktabbar.moc"

--- NEW FILE: knewpanner.cpp ---
// $Id: knewpanner.cpp,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $

/* This file is part of the KDE libraries
    Copyright (C) 1997 Richard Moore (moorer at cs.man.ac.uk)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/


#include "knewpanner.h"
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

KNewPanner::KNewPanner(QWidget *parent, const char *name,
			   Orientation orient, Units units, int pos)
    : QWidget(parent, name)
{
    orientation= orient;
    currentunits= units;
    position= pos;
    initialised= false;
    showlabels= false;
    startHeight= 0;

    label0= 0;
    label1= 0;
}

KNewPanner::~KNewPanner()
{
}

void KNewPanner::activate(QWidget *c0, QWidget *c1)
{
    int minx, maxx, miny, maxy, pos;

    child0= c0;
    child1= c1;

    // Set the minimum and maximum sizes
    if (orientation == Horizontal) {
	miny= c0->minimumSize().height() + c1->minimumSize().height()+4;
	maxy= c0->maximumSize().height() + c1->maximumSize().height()+4;
	minx= (c0->minimumSize().width() > c1->minimumSize().width())
	    ? c0->minimumSize().width() : c1->minimumSize().width();
	maxx= (c0->maximumSize().width() > c1->maximumSize().width())
	    ? c0->maximumSize().width() : c1->maximumSize().width();

	miny= (miny > 4) ? miny : 4;
	maxy= (maxy < 2000) ? maxy : 2000;
	minx= (minx > 2) ? minx : 2;
	maxx= (maxx < 2000) ? maxx : 2000;

	setMinimumSize(minx, miny);
	setMaximumSize(maxx, maxy);
    }
    else {
	minx= c0->minimumSize().width() + c1->minimumSize().width()+4;
	maxx= c0->maximumSize().width() + c1->maximumSize().width()+4;
	miny= (c0->minimumSize().height() > c1->minimumSize().height())
	    ? c0->minimumSize().height() : c1->minimumSize().height();
	maxy= (c0->maximumSize().height() > c1->maximumSize().height())
	    ? c0->maximumSize().height() : c1->maximumSize().height();

	minx= (minx > 4) ? minx : 4;
	maxx= (maxx < 2000) ? maxx : 2000;
	miny= (miny > 2) ? miny : 2;
	maxy= (maxy < 2000) ? maxy : 2000;

	setMinimumSize(minx, miny);
	setMaximumSize(maxx, maxy);
    }

    divider= new QFrame(this, "pannerdivider");
    divider->setFrameStyle(QFrame::Panel | QFrame::Raised);
    divider->setLineWidth(1);
    divider->raise();

    if (orientation == Horizontal)
        divider->setCursor(QCursor(sizeVerCursor));
    else
        divider->setCursor(QCursor(sizeHorCursor));

    divider->installEventFilter(this);

    initialised= true;

    pos= position;
    position=0;

    setSeparatorPos(pos);
}

void KNewPanner::deactivate()
{
  delete divider;
  initialised= false;
}

void KNewPanner::setLabels(const char *text0, const char *text1)
{
   if (label0 == 0) {
      label0= new QLabel(this, "label0");
      label0->setFrameStyle(QFrame::Sunken | QFrame::Panel);
   }
   if (label1 == 0) {
      label1= new QLabel(this, "label1");
      label1->setFrameStyle(QFrame::Sunken | QFrame::Panel);
   }

   label0->setText(text0);
   label1->setText(text1);
   label0->adjustSize();
   label1->adjustSize();

   if (!showlabels) {
      label0->hide();
      label1->hide();
   }
      
   if (showlabels && initialised) {
      resizeEvent(0);
   }
}

void KNewPanner::showLabels(bool newval)
{
  if (orientation == Vertical)
    showlabels= newval;

   if ((label0 == 0) || (label1 == 0))
     setLabels("", "");

   if (showlabels) {
      label0->show();
      label1->show();
   }
   else {
      label0->hide();
      label1->hide();
   }

  if (initialised && showlabels) {
     label0->adjustSize();
     label1->adjustSize();
  }
  if (initialised)
     resizeEvent(0);
}

int KNewPanner::seperatorPos()
{
  //  fprintf(stderr,
  //	  "seperatorPos() is deprecated, use separatorPos() insead.\n");
  return separatorPos();
}

void KNewPanner::setSeperatorPos(int pos)
{
  //  fprintf(stderr,
  //	  "setSeperatorPos() is deprecated, use setSeparatorPos() insead.\n");
  setSeparatorPos(pos);
}

int KNewPanner::absSeperatorPos()
{
  //  fprintf(stderr,
  //  "absSeperatorPos() is deprecated, use absSeparatorPos() insead.\n");
  return absSeparatorPos();
}

void KNewPanner::setAbsSeperatorPos(int pos, bool do_resize)
{
  //  fprintf(stderr,
  //  "setAbsSeperatorPos() is deprecated, use setAbsSeparatorPos() insead.\n");
  setAbsSeparatorPos(pos, do_resize);
}

int KNewPanner::separatorPos()
{
  return position;
}

void KNewPanner::setSeparatorPos(int pos)
{
  position = pos;
}

void KNewPanner::setAbsSeparatorPos(int pos, bool do_resize)
{
    pos= checkValue(pos);

    if (pos != absSeparatorPos()) {
      if (currentunits == Percent)
	position= pos * 100 / (orientation == Vertical?width():height());
      else
	position= pos;
      if (do_resize)
	resizeEvent(0);
    }
}

int KNewPanner::absSeparatorPos()
{
    int value;

    if (currentunits == Percent)
	value= (orientation == Vertical?width():height())*position/100;
    else
	value= position;
	    
    return value;
}

KNewPanner::Units KNewPanner::units()
{
    return currentunits;
}

void KNewPanner::setUnits(Units u)
{
    currentunits= u;
}

void KNewPanner::resizeEvent(QResizeEvent*)
{
  if (initialised) {
     if (orientation == Horizontal) {
      child0->setGeometry(0, 0, width(), absSeparatorPos());
      child1->setGeometry(0, absSeparatorPos()+4, width(), 
			  height()-absSeparatorPos()-4);
      divider->setGeometry(0, absSeparatorPos(), width(), 4);
    }
    else {
      if (showlabels) {
	label0->move(0,0);
	label0->resize(absSeparatorPos(), label0->height());
	label1->move(absSeparatorPos()+4, 0);
	label1->resize(width()-absSeparatorPos()-4, label1->height());
	startHeight= label0->height();
      }
      else {
	 startHeight= 0;
      }
      child0->setGeometry(0, startHeight, absSeparatorPos(), 
			  (height())-startHeight);
      child1->setGeometry(absSeparatorPos()+4, startHeight,
			  (width())-(absSeparatorPos()+4), 
			  (height())-startHeight);
      divider->setGeometry(absSeparatorPos(), startHeight, 4, 
			   (height())-startHeight);
    }
  }
}

int KNewPanner::checkValue(int pos)
{
   if (initialised) {
    if (orientation == Vertical) {
	if (pos < (child0->minimumSize().width()))
	    pos= child0->minimumSize().width();
	if ((width()-4-pos) < (child1->minimumSize().width()))
	    pos= width() - (child1->minimumSize().width()) -4;
    }
    else {
	if (pos < (child0->minimumSize().height()))
	    pos= (child0->minimumSize().height());
	if ((height()-4-pos) < (child1->minimumSize().height()))
	    pos= height() - (child1->minimumSize().height()) -4;
    }
   }
   
    if (pos < 0) pos= 0;

   if ((orientation == Vertical) && (pos > width()))
     pos= width();
   if ((orientation == Horizontal) && (pos > height()))
     pos= height();

    return pos;
}

bool KNewPanner::eventFilter(QObject *, QEvent *e)
{
    QMouseEvent *mev;
    bool handled= false;

    switch (e->type()) {
    case Event_MouseMove:
	mev= (QMouseEvent *)e;
	child0->setUpdatesEnabled(false);
	child1->setUpdatesEnabled(false);
	if (orientation == Horizontal) {
	    setAbsSeparatorPos(divider->mapToParent(mev->pos()).y(), false);
	    divider->setGeometry(0, absSeparatorPos(), width(), 4);
	    divider->repaint(0);
	}
	else {
	    setAbsSeparatorPos(divider->mapToParent(mev->pos()).x(), false);
	    divider->setGeometry(absSeparatorPos(), 0, 4, height());
	    divider->repaint(0);
	}
	handled= true;
	break;
    case Event_MouseButtonRelease:
	mev= (QMouseEvent *)e;

	child0->setUpdatesEnabled(true);
	child1->setUpdatesEnabled(true);

	if (orientation == Horizontal) {
	    resizeEvent(0);
// 	    child0->repaint(true);
// 	    child1->repaint(true);
	    divider->repaint(true);
	}
	else {
	    resizeEvent(0);
// 	    child0->repaint(true);
// 	    child1->repaint(true);
	    divider->repaint(true);
	}
	handled= true;
	break;
    }

    return handled;
}

#include "knewpanner.moc"


--- NEW FILE: USERS.kdatepicker ---
This file contains known users of the KDatePicker class. It is used to 
inform users about new features and for seeking bugs.
It is maintained by Mirko Sucker (mirko at kde.org).
If you use the class in your application and are not listed here, 
send me an email.

Programs using KDatePicker are

korganizer (preston.brown at yale.edu)
kab (mirko at kde.org)


--- NEW FILE: ktablistbox.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 The KDE Team

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/* Written by Stefan Taferner <taferner at kde.org>
 *            Alessandro Russo <axela at bigfoot.com>
 * A multi column listbox. Requires the Qt widget set.
 */
#ifndef KTabListBox_h
#define KTabListBox_h

#undef del_item
#include <qdict.h>
#include <qtableview.h>
#include <qcolor.h>
#include <qpixmap.h>
#include <drag.h>
#include <stdlib.h>

#define MAX_SEP_CHARS 16

class KTabListBoxColumn;
class KTabListBoxTable;
class KTabListBoxItem;
class KTabListBox;
class KNumCheckButton;

typedef QDict<QPixmap> KTabListBoxDict;

//-----------------------------------------------------
/**
* Provides a different type of Check button.
* 
*/
class KNumCheckButton : public QWidget
{
    Q_OBJECT
public:
    KNumCheckButton( QWidget *_parent = 0L, const char *name = 0L );
    ~KNumCheckButton() {};
    void setText( const char * );
     
signals:
    void        selected();
    void        deselected();    
    /** leftbutton=true if is a leftbutton, =false if is a rightbutton
    *   centerbutton doubleclick events aren't emitted.
    */
    void	doubleclick(bool leftbutton);

protected:
    virtual void leaveEvent( QEvent *_ev );
    virtual void enterEvent( QEvent *_ev );
    virtual void mousePressEvent( QMouseEvent * );
    virtual void mouseDoubleClickEvent( QMouseEvent * );
    virtual void paintEvent( QPaintEvent *event);    
    
 private:    
    bool raised;
    QString     btext;
};


//--------------------------------------------------
#define KTabListBoxTableInherited QTableView
class KTabListBoxTable: public QTableView
{
  Q_OBJECT
  friend KTabListBox;
public:
  KTabListBoxTable(KTabListBox *owner=0);
  virtual ~KTabListBoxTable();
  void enableKey();
  int findRealCol(int x);

protected:
  virtual void focusInEvent(QFocusEvent*);
  virtual void focusOutEvent(QFocusEvent*);
  virtual void mouseDoubleClickEvent (QMouseEvent*);
  virtual void mousePressEvent (QMouseEvent*);
  virtual void mouseReleaseEvent (QMouseEvent*);
  virtual void mouseMoveEvent (QMouseEvent*);
  virtual void doItemSelection (QMouseEvent*, int idx);

  virtual void paintCell (QPainter*, int row, int col);
  virtual int cellWidth (int col);

  void reconnectSBSignals (void);

  QPoint dragStartPos;
  int dragCol, dragRow;
  int selIdx;
  bool dragging;
};


//--------------------------------------------------
#define KTabListBoxInherited KDNDWidget

/** A multi column listbox
 * Features:
 *  - User resizeable columns.
 *  - The order of columns can be changed with drag&drop. (Alex)
 *  - 3 modes: Standard, SimpleOrder, ComplexOrder. (Alex)
 * ToDo: 
 *  - Configurable vertical column divisor lines. 
 *  - Save all setting to config file.
 *  - fix flickering into column headers.
 */
class KTabListBox : public KDNDWidget
{
  Q_OBJECT
  friend KTabListBoxTable;
  friend KTabListBoxColumn;

public:
  enum ColumnType { TextColumn, PixmapColumn, MixedColumn };
  enum OrderMode { Ascending, Descending };
  enum OrderType { NoOrder, SimpleOrder, ComplexOrder };

  KTabListBox (QWidget *parent=0, const char *name=0, 
	       int columns=1, WFlags f=0);
  virtual ~KTabListBox();

  /** This enable the key-bindings (and set StrongFocus!)
   * if you don't want StrongFocus you can implement your own keyPressEvent
   * and send an event to KTabListBox from there... */
  void enableKey(void) { lbox.enableKey(); }
  
  /** Returns the number of rows */
  uint count (void) const { return numRows(); };
  
  /** Insert a line before given index, using the separator character to separate the fields. If no index is given the line is appended at the end. Returns index of inserted item. */
  virtual void insertItem (const char* string, int itemIndex=-1);

  /** Append a QStrList */
  void appendStrList( QStrList const *strLst );

  /** Same as insertItem, but always appends the new item. */
  void appendItem (const char* string) { insertItem(string); }

  /** Change contents of a line using the separator character to separate the fields. */
  virtual void changeItem (const char* string, int itemIndex);

  /** Change part of the contents of a line. */
  virtual void changeItemPart (const char* string, int itemIndex, int column);

  /** Change color of line. Changes last inserted item when itemIndex==-1 */
  virtual void changeItemColor (const QColor& color, int itemIndex=-1);

  /** Get number of pixels one tab character stands for. Default: 10 */
  int tabWidth(void) const { return tabPixels; }
  /** Set number of pixels one tab character stands for. Default: 10 */
  virtual void setTabWidth(int);

  /** Returns contents of given row/column. If col is not set the
   contents of the whole row is returned, seperated with the current 
   seperation character. In this case the string returned is a 
   temporary string that will change on the next text() call on any
   KTabListBox object. */
  const QString& text(int idx, int col=-1) const;

  /** Remove one item from the list. */
  virtual void removeItem (int itemIndex);

  /** Remove contents of listbox */
  virtual void clear (void);

  /** Return index of current item */
  int currentItem (void) const { return current; }

  /** Set the current (selected) column. colId is the value that
    is transfered with the selected() signal that is emited. */
  virtual void setCurrentItem (int idx, int colId=-1);

  /** Unmark all items */
  virtual void unmarkAll (void);

  /** Mark/unmark item with index idx. */
  virtual void markItem (int idx, int colId=-1);
  virtual void unmarkItem (int idx);

  /** Returns TRUE if item with given index is marked. */
  virtual bool isMarked (int idx) const;

  /** Find item at given screen y position. */
  int findItem (int yPos) const { return (itemShowList[lbox.findRow(yPos)]); }

  /** Returns first item that is currently displayed in the widget. */
  int topItem (void) const { return (itemShowList[lbox.topCell()]); }

  /** Change first displayed item by repositioning the visible part
    of the list. */
  void setTopItem (int idx) { lbox.setTopCell(itemPosList(idx)); }

  /** Set number of columns. Warning: this *deletes* the contents
    of the listbox. */
  virtual void setNumCols (int);

  /** Set number of rows in the listbox. The contents stays as it is. */
  virtual void setNumRows (int);

  /** See the docs for the QTableView class. */
  int numRows (void) const { return lbox.numRows(); }
  /** See the docs for the QTableView class. */
  int numCols (void) const { return lbox.numCols(); }
  /** See the docs for the QTableView class. */
  int cellWidth (int col) { return lbox.cellWidth(col); }
  /** See the docs for the QTableView class. */
  int totalWidth (void) { return lbox.totalWidth(); }
  /** See the docs for the QTableView class. */
  int cellHeight (int row) { return lbox.cellHeight(row); }
  /** See the docs for the QTableView class. */
  int totalHeight (void) { return lbox.totalHeight(); }
  /** See the docs for the QTableView class. */
  int topCell (void) const { return itemShowList[lbox.topCell()]; }
  /** See the docs for the QTableView class. */
  int leftCell (void) const { return colShowList[lbox.leftCell()]; }
  /** See the docs for the QTableView class. */
  int lastColVisible (void) const { return colShowList[lbox.lastColVisible()]; }
  /** See the docs for the QTableView class. */
  int lastRowVisible (void) const { return itemShowList[lbox.lastRowVisible()]; }
  /** See the docs for the QTableView class. */
  bool autoUpdate (void) const { return lbox.autoUpdate(); }
  /** See the docs for the QTableView class. */
  void setAutoUpdate (bool upd) { lbox.setAutoUpdate(upd); }
  /** See the docs for the QTableView class. */
  void clearTableFlags(uint f=~0) { lbox.clearTableFlags(f); }
  /** See the docs for the QTableView class. */
  uint tableFlags(void) { return lbox.tableFlags(); }
  /** See the docs for the QTableView class. */
  bool testTableFlags(uint f) { return lbox.testTableFlags(f); }
  /** See the docs for the QTableView class. */
  void setTableFlags(uint f) { lbox.setTableFlags(f); }
  /** See the docs for the QTableView class. */
  int findCol(int x) { return lbox.findRealCol(x); }
  /** See the docs for the QTableView class. */
  int findRow(int y) { return itemShowList[lbox.findRow(y)]; }
  /** See the docs for the QTableView class. */
  bool colXPos(int col, int* x) { return lbox.colXPos(colPosList(col),x); }
  /** See the docs for the QTableView class. */
  bool rowYPos(int row, int* y) { return lbox.rowYPos(itemPosList(row),y); }

  /** This call the 'compar' functions if they were been defined in 
  * setColumn or else use strcmp. (i.e. if you want a case-insensitive sort
  * put strcasecmp in setColumn call).
  * That compar function must take as arguments two char *, and must return
  * an integer less  than, equal  to,  or  greater than zero if the first
  * argument is considered to be respectively  less  than,  equal  to, 
  * or greater than the second. */
  virtual void reorderRows();
  
  /** Set column caption, width, type,order-type and order-mode */
  virtual void setColumn (int col, const char* caption, 
			  int width=0, ColumnType type=TextColumn,
			  OrderType ordt=NoOrder,
			  OrderMode omode=Descending,
			  bool verticalLine=false,
			  int (*compar)(const char *, const char *)=0L);

  /** Set column width. */
  virtual void setColumnWidth (int col, int width=0);
  /** Get column width. */
  int columnWidth (int col) { return lbox.cellWidth(col); }

  /** Set default width of all columns. */
  virtual void setDefaultColumnWidth(int width0, ...);

  /** change the Ascending/Descending mode of column col.*/
  void changeMode(int col);
  /** Clear all number-check-buttons (ComplexOrder only) */
  void clearAllNum();
  
  /** Set separator character, e.g. '\t'. */
  virtual void setSeparator (char sep) { sepChar = sep; } 

  /** Return separator character. */
  virtual char separator (void) const { return sepChar; }

  /** For convenient access to the dictionary of pictures that this listbox understands. */
  KTabListBoxDict& dict (void) { return pixDict; }

  void repaint (void);

  /** Indicates that a drag has started with given item. Returns TRUE if we are dragging, FALSE if drag-start failed. */
  bool startDrag(int col, int row, const QPoint& mousePos);

  QPixmap& dndPixmap(void) { return dndDefaultPixmap; }

  /** Read the config file entries in the group with the name of the listbox and set the default column widths and those. */
  virtual void readConfig(void);

  /** Write the config file entries in the group with the name of the listbox*/
  virtual void writeConfig(void);
  
  /** Return the actual position of the colum in the table.*/
  int colPosList(int num);
  
  /** Return the actual positon of the row number num.*/
  int itemPosList(int num);

  /** Get/set font of the table. font() and setFont() apply to the
    caption only. */
  const QFont& tableFont(void) const { return lbox.font(); }
  void setTableFont(const QFont& fnt) { lbox.setFont(fnt); }
  
signals:
  /** emited when the current item changes (either via setCurrentItem() or via mouse single-click). */
  void highlighted (int Index, int column);

  /** emitted when the user double-clicks into a line. */
  void selected (int Index, int column);

  /** emitted when the user presses the right mouse button over a line. */
  void popupMenu (int Index, int column);

  /** emitted when the user presses the middle mouse button over a line. */
  void midClick (int Index, int column);

  /** emitted when the user clicks on a column header. */
  void headerClicked (int column);

protected slots:
  void horSbValue(int val);
  void horSbSlidingDone();

protected:
  /** Used to create new column objects. Overwrite this method
   * in a subclass to have your own column objects (e.g. with custom
   * data in it). You will then also need customData()/setCustomData()
   * methods in here that access the elememts in itemList[]. */
  virtual KTabListBoxColumn* newKTabListBoxColumn(void);

  bool itemVisible (int idx) { return lbox.rowIsVisible(idx); }
  void updateItem (int idx, bool clear = TRUE);
  bool needsUpdate (int id);

  /// Internal method called by keyPressEvent.
  void setCItem  (int idx);
  /// Adjust the number in the number check boxes.
  void adjustNumber(int num);
  // This should really go into kdecore and should be used by all
  // apps that have long scrollable widgets.
  void flushKeys();
  
  /// For internal use.
  bool recursiveSort(int level,int n,KTabListBoxColumn **c,int *iCol);
  
  KTabListBoxItem* getItem (int idx);
  const KTabListBoxItem* getItem (int idx) const;

  virtual void keyPressEvent(QKeyEvent*);
  virtual void resizeEvent (QResizeEvent*);
  virtual void paintEvent (QPaintEvent*);
  virtual void mouseMoveEvent(QMouseEvent*);
  virtual void mousePressEvent(QMouseEvent*);
  virtual void mouseReleaseEvent(QMouseEvent*);

  /** Resize item array. Per default enlarge it to double size. */
  virtual void resizeList (int newNumItems=-1);

  /** Called to set drag data, size, and type. If this method returns FALSE then no drag occurs. */
  virtual bool prepareForDrag (int col, int row, char** data, int* size, 
			       int* type);

  /** Internal method that handles resizing of columns with the mouse. */
  virtual void doMouseResizeCol(QMouseEvent*);

  /** Internal method that handles moving of columns with the mouse. */
  virtual void doMouseMoveCol(QMouseEvent*);
  
  // This array contain the list of columns as they are inserted.
  KTabListBoxColumn**	colList;
  // This array contain the column numbers as they are shown.
  int *colShowList;
  // This array contain the row numbers as they are shown.
  int *itemShowList;
  KTabListBoxItem**	itemList;
  int			maxItems, numColumns;
  int			current;
  char			sepChar;
  KTabListBoxDict	pixDict;
  KTabListBoxTable	lbox;
  int			labelHeight;
  
  QPixmap		dndDefaultPixmap;
  QPixmap		upPix,downPix;
  QPixmap		disabledUpPix,disabledDownPix;
  int			columnPadding;
  QColor		highlightColor;
  int			tabPixels;
  bool			mResizeCol;
  bool			stopOrdering;
  bool			needsSort;
  /// contain the number of the last column where the user clicked on checkbutton.
  int                   lastSelectedColumn;
  int			nMarked; //number of marked rows.
  int			mSortCol;  // selected column for sorting order or -1

  int		mMouseCol; // column where the mouse action started
			   // (resize, click, reorder)
  int		mMouseColLeft; // left offset of mouse column
  int		mLastX; // Used for drawing the XORed rect in column-drag.
  int		mMouseColWidth; // width of mouse column
  QPoint		mMouseStart;
  bool		mMouseAction;
  bool		mMouseDragColumn; // true when dragging the header of a column.

private:
  // Disabled copy constructor and operator=
  KTabListBox (const KTabListBox &) {}
  KTabListBox& operator= (const KTabListBox&) { return *this; }
};


//--------------------------------------------------
class KTabListBoxItem
{
public:
  KTabListBoxItem(int numColumns=1);
  virtual ~KTabListBoxItem();

  virtual const QString& text(int column) const { return txt[column]; }
  void setText (int column, const char *text) { txt[column] = text; }
  virtual void setForeground (const QColor& fg ) { fgColor = fg; }
  const QColor& foreground (void) { return fgColor; }

  KTabListBoxItem& operator= (const KTabListBoxItem&);

  int marked (void) const { return mark; }
  bool isMarked (void) const { return (mark >= -1); }
  virtual void setMarked (int m) { mark = m; }
 
private:
  QString* txt;
  int columns;
  QColor fgColor;
  int mark;

  friend class KTabListBox;
};

typedef KTabListBoxItem* KTabListBoxItemPtr;


//--------------------------------------------------
class KTabListBoxColumn: public QObject
{
  Q_OBJECT

public:
  KTabListBoxColumn (KTabListBox* parent, int w=0);
  virtual ~KTabListBoxColumn();

  int width (void) const { return iwidth; }
  virtual void setWidth (int w) { iwidth = w; }

  int defaultWidth (void) const { return idefwidth; }
  virtual void setDefaultWidth (int w) { idefwidth = w; }

  virtual void setType (KTabListBox::ColumnType lbt) { colType = lbt; }
  KTabListBox::ColumnType type (void) const { return colType; }

  /// @return true if need repaint.
  virtual bool changeMode (void);
  
  virtual void setNumber(int num);
  int number (void) const { return inumber;}
  void hideCheckButton(void) { if(mbut) mbut->hide(); }
  virtual void setOrder (KTabListBox::OrderType type,
                             KTabListBox::OrderMode mode);
  KTabListBox::OrderType orderType (void) const {return ordtype;}
  KTabListBox::OrderMode orderMode (void) const {return ordmode;}
  
  virtual void paintCell (QPainter*, int row, const QString& string, 
			  bool marked);
  virtual void paint (QPainter*);

protected slots:
  virtual void setButton();
  virtual void resetButton();
  virtual void clearAll(bool leftbutton);
  
protected:
  int iwidth, idefwidth, inumber;
  KTabListBox::OrderMode ordmode;
  KTabListBox::OrderType ordtype;
  KTabListBox::ColumnType colType;
  KTabListBox* parent;
  KNumCheckButton *mbut;
public:
  int (*columnSort)(const char *, const char *);
  bool vline; // if true print a vertical line to the end of column.
};

typedef KTabListBoxColumn* KTabListBoxColumnPtr;


inline KTabListBoxItem* KTabListBox :: getItem (int idx)
{
    return ((idx>=0 && idx<maxItems) ? itemList[idx] : (KTabListBoxItem*)0L);
}

inline const KTabListBoxItem* KTabListBox :: getItem (int idx) const
{
  return ((idx>=0 && idx<maxItems) ? itemList[idx] : (KTabListBoxItem*)0L);
}

#endif /*KTabListBox_h*/

--- NEW FILE: Makefile.am ---

#	This file is part of the KDE libraries
#    Copyright (C) 1997 Matthias Kalle Dalheimer (kalle at kde.org)
#			  (C) 1997 Stephan Kulow (coolo at kde.org)

#    This library is free software; you can redistribute it and/or
#    modify it under the terms of the GNU Library General Public
#    License as published by the Free Software Foundation; either
#    version 2 of the License, or (at your option) any later version.

#    This library is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#    Library General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with this library; see the file COPYING.  If not, write to
#    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
#    Boston, MA 02111-1307, USA.


INCLUDES= -I$(top_srcdir)/kdecore -I$(top_srcdir)/kfile $(QT_INCLUDES) $(X_INCLUDES) 
EXTRA_DIST = $(data_DATA) CHANGES.kdatepicker USERS.kdatepicker

lib_LTLIBRARIES = libkdeui.la
libkdeui_la_LDFLAGS = -version-info 2:0  

include_HEADERS = kledlamp.h kprogress.h kpanner.h kcolordlg.h kselect.h \
		kdatepik.h kdatetbl.h \
		kfontdialog.h kmsgbox.h kpopmenu.h ktabctl.h\
		ktreelist.h kstatusbar.h ktopwidget.h ktmainwindow.h \
		ktoolbar.h kmenubar.h kbutton.h kslider.h kseparator.h \
		klined.h kcombo.h krestrictedline.h kintegerline.h	\
		kspinbox.h kcolorbtn.h kiconloaderdialog.h \
		kwmmapp.h kbuttonbox.h ktablistbox.h kcontainer.h \
		knewpanner.h kcontrol.h keditcl.h ktoolboxmgr.h kled.h	\
		kdbtn.h knotebook.h ktabbar.h kwizard.h kkeydialog.h \
		kurllabel.h kruler.h kquickhelp.h kcursor.h

libkdeui_la_SOURCES = kledlamp.cpp kprogress.cpp kpanner.cpp kcolordlg.cpp\
		kselect.cpp kdatepik.cpp kdatetbl.cpp \
		kfontdialog.cpp kmsgbox.cpp kpopmenu.cpp ktabctl.cpp\
		ktreelist.cpp kstatusbar.cpp ktopwidget.cpp ktmainwindow.cpp \
		kmenubar.cpp ktoolbar.cpp kbutton.cpp kslider.cpp \
		kseparator.cpp klined.cpp kcombo.cpp krestrictedline.cpp \
		kintegerline.cpp kspinbox.cpp kcontrol.cpp \
		kcolorbtn.cpp kiconloaderdialog.cpp kwmmapp.cpp	\
		kbuttonbox.cpp ktablistbox.cpp knewpanner.cpp \
		keditcl1.cpp keditcl2.cpp ktoolboxmgr.cpp kled.cpp	\
		kdbtn.cpp knotebook.cpp ktabbar.cpp kwizard.cpp kcontainer.cpp \
		kkeydialog.cpp kurllabel.cpp kruler.cpp kquickhelp.cpp kcursor.cpp

libkdeui_la_METASOURCES = kbutton.moc kbuttonbox.moc kcolorbtn.moc \
	kcolordlg.moc kcombo.moc kcontainer.moc kcontrol.moc kdatepik.moc \
	kdatetbl.moc kdbtn.moc keditcl.moc kfontdialog.moc \
	kiconloaderdialog.moc kintegerline.moc kkeydialog.moc kled.moc \
	kledlamp.moc klined.moc kmenubar.moc kmsgbox.moc knewpanner.moc \
	knotebook.moc kpanner.moc kpopmenu.moc kprogress.moc \
	kquickhelp.moc krestrictedline.moc kruler.moc kselect.moc \
	kslider.moc kspinbox.moc kstatusbar.moc ktabbar.moc ktabctl.moc \
	ktablistbox.moc ktmainwindow.moc ktoolbar.moc ktoolboxmgr.moc \
	ktopwidget.moc ktreelist.moc kurllabel.moc kwizard.moc kwmmapp.moc

data_DATA = error.xpm exclamation.xpm info.xpm stopsign.xpm question.xpm \
	arrow_up.xbm arrow_down.xbm arrow_left.xbm arrow_right.xbm	
datadir = $(kde_datadir)/kde/pics



--- NEW FILE: arrow_down.xbm ---
#define arrow_down_width 16
#define arrow_down_height 16
static char arrow_down_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03,
   0xc0, 0x03, 0xfc, 0x3f, 0xfc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xe0, 0x07,
   0xc0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00};

--- NEW FILE: kselect.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Martin Jones (mjones at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
// Selector widgets for KDE Color Selector, but probably useful for other
// stuff also.

#include <stdlib.h>
#include <qimage.h>
#include <qpainter.h>
#include <qdrawutil.h>
#include <qevent.h>
#include <dither.h>
#include "kselect.h"
#include "kselect.h"

#define STORE_W 8
#define STORE_W2 STORE_W * 2

//-----------------------------------------------------------------------------
/*
 * 2D value selector.
 * The contents of the selector are drawn by derived class.
 */

KXYSelector::KXYSelector( QWidget *parent, const char *name )
	: QWidget( parent, name )
{
	xPos = 0;
	yPos = 0;
	minX = 0;
	minY = 0;
	maxX = 100;
	maxY = 100;
	store.optimize( TRUE );
	store.resize( STORE_W2, STORE_W2 );
}

void KXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY )
{
	px = 2;
	py = 2;
	minX = _minX;
	minY = _minY;
	maxX = _maxX;
	maxY = _maxY;
}

void KXYSelector::setValues( int _xPos, int _yPos )
{
	xPos = _xPos;
	yPos = _yPos;

	if ( xPos > maxX )
		xPos = maxX;
	else if ( xPos < minX )
		xPos = minX;
	
	if ( yPos > maxY )
		yPos = maxY;
	else if ( yPos < minY )
		yPos = minY;

	int xp = 2 + (width() - 4) * xPos / (maxX - minX);
	int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY);

	setPosition( xp, yp );
}

QRect KXYSelector::contentsRect()
{
	return QRect( 2, 2, width()-4, height()-4 );
}

void KXYSelector::paintEvent( QPaintEvent * )
{
	QPainter painter;

	painter.begin( this );

	QBrush brush;
	qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(),
			TRUE, 2, &brush );

	drawContents( &painter );
	bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W,
		STORE_W2, STORE_W2, CopyROP );
	drawCursor( painter, px, py );

	painter.end();
}

void KXYSelector::mousePressEvent( QMouseEvent *e )
{
	setPosition( e->pos().x() - 2, e->pos().y() - 2 );

	emit valueChanged( xPos, yPos );
}

void KXYSelector::mouseMoveEvent( QMouseEvent *e )
{
	setPosition( e->pos().x() - 2, e->pos().y() - 2 );

	emit valueChanged( xPos, yPos );
}

void KXYSelector::setPosition( int xp, int yp )
{
	QPainter painter;

	if ( xp < 2 )
		xp = 2;
	else if ( xp > width() - 2 )
		xp = width() - 2;

	if ( yp < 2 )
		yp = 2;
	else if ( yp > height() - 2 )
		yp = height() - 2;

	painter.begin( this );

	bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0,
			STORE_W2, STORE_W2, CopyROP );
	bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W,
			STORE_W2, STORE_W2, CopyROP );
	drawCursor( painter, xp, yp );
	px = xp;
	py = yp;

	painter.end();

	xPos = ( (maxX-minX) * (xp-2) ) / ( width()-4 );
	yPos = maxY - ( ( (maxY-minY) * (yp-2) ) / ( height()-4 ) );
	
	if ( xPos > maxX )
		xPos = maxX;
	else if ( xPos < minX )
		xPos = minX;
	
	if ( yPos > maxY )
		yPos = maxY;
	else if ( yPos < minY )
		yPos = minY;
}

void KXYSelector::drawCursor( QPainter &painter, int xp, int yp )
{
	painter.setPen( QPen( white ) );

	painter.setClipRect( contentsRect() );
	painter.setClipping( TRUE );
	painter.drawLine( xp - 6, yp - 6, xp - 2, yp - 2 );
	painter.drawLine( xp - 6, yp + 6, xp - 2, yp + 2 );
	painter.drawLine( xp + 6, yp - 6, xp + 2, yp - 2 );
	painter.drawLine( xp + 6, yp + 6, xp + 2, yp + 2 );
	painter.setClipping( FALSE );
}

//-----------------------------------------------------------------------------
/*
 * 1D value selector with contents drawn by derived class.
 * See KColorDialog for example.
 */


KSelector::KSelector( Orientation o, QWidget *parent, const char *name )
	: QWidget( parent, name ), QRangeControl()
{
	_orientation = o;
	_indent = TRUE;
}

QRect KSelector::contentsRect()
{
	if ( orientation() == Vertical )
		return QRect( 2, 5, width()-9, height()-10 );
	else
		return QRect( 5, 2, width()-10, height()-9 );
}

void KSelector::paintEvent( QPaintEvent * )
{
	QPainter painter;

	painter.begin( this );

	drawContents( &painter );

	QBrush brush;

	if ( indent() )
	{
		if ( orientation() == Vertical )
			qDrawShadePanel( &painter, 0, 3, width()-5, height()-6,
				colorGroup(), TRUE, 2, &brush );
		else
			qDrawShadePanel( &painter, 3, 0, width()-6, height()-5,
				colorGroup(), TRUE, 2, &brush );
	}

	QPoint pos = calcArrowPos( value() );
	drawArrow( painter, TRUE, pos );   

	painter.end();
}

void KSelector::mousePressEvent( QMouseEvent *e )
{
	moveArrow( e->pos() );
}

void KSelector::mouseMoveEvent( QMouseEvent *e )
{
	moveArrow( e->pos() );
}

void KSelector::valueChange()
{
	QPainter painter;
	QPoint pos;

	painter.begin( this );

	pos = calcArrowPos( prevValue() );
	drawArrow( painter, FALSE, pos );   

	pos = calcArrowPos( value() );
	drawArrow( painter, TRUE, pos );   

	painter.end();
}

void KSelector::moveArrow( const QPoint &pos )
{
	int val;

	if ( orientation() == Vertical )
		val = ( maxValue() - minValue() ) * (height()-pos.y()-3)
				/ (height()-10) + minValue();
	else
		val = ( maxValue() - minValue() ) * (width()-pos.x()-3)
				/ (width()-10) + minValue();

	if ( val > maxValue() )
		val = maxValue();
	if ( val < minValue() )
		val = minValue();

	emit valueChanged( val );
	setValue( val );
}

QPoint KSelector::calcArrowPos( int val )
{
	QPoint p;

	if ( orientation() == Vertical )
	{
		p.setY( height() - ( (height()-10) * val
				/ ( maxValue() - minValue() ) + 5 ) );
		p.setX( width() - 5 );
	}
	else
	{
		p.setX( width() - ( (width()-10) * val
				/ ( maxValue() - minValue() ) + 5 ) );
		p.setY( height() - 5 );
	}

	return p;
}

void KSelector::drawArrow( QPainter &painter, bool show, const QPoint &pos )
{
	QPointArray array(3);

	if ( show )
	{
		painter.setPen( QPen() );
		painter.setBrush( QBrush( black ) );
	}
	else
	{
		painter.setPen( QPen( backgroundColor() ) );
		painter.setBrush( backgroundColor() );
	}

	if ( orientation() == Vertical )
	{
		array.setPoint( 0, pos.x()+0, pos.y()+0 );
		array.setPoint( 1, pos.x()+5, pos.y()+5 );
		array.setPoint( 2, pos.x()+5, pos.y()-5 );
	}
	else
	{
		array.setPoint( 0, pos.x()+0, pos.y()+0 );
		array.setPoint( 1, pos.x()+5, pos.y()+5 );
		array.setPoint( 2, pos.x()-5, pos.y()+5 );
	}

	painter.drawPolygon( array );
}

//----------------------------------------------------------------------------

KGradientSelector::KGradientSelector( Orientation o, QWidget *parent,
		const char *name )
	: KSelector( o, parent, name )
{
	color1.setRgb( 0, 0, 0 );
	color2.setRgb( 255, 255, 255 );

	text1 = text2 = "";
}

void KGradientSelector::drawContents( QPainter *painter )
{
	QImage image( contentsRect().width(), contentsRect().height(), 32 );

	QColor col;
	float scale;

	int redDiff   = color2.red() - color1.red();
	int greenDiff = color2.green() - color1.green();
	int blueDiff  = color2.blue() - color1.blue();

	if ( orientation() == Vertical )
	{
		for ( int y = 0; y < image.height(); y++ )
		{
			scale = 1.0 * y / image.height();
			col.setRgb( color1.red() + int(redDiff*scale),
						color1.green() + int(greenDiff*scale),
						color1.blue() + int(blueDiff*scale) );

			unsigned int *p = (uint *) image.scanLine( y );
			for ( int x = 0; x < image.width(); x++ )
				*p++ = col.rgb();
		}
	}
	else
	{
		unsigned int *p = (uint *) image.scanLine( 0 );

		for ( int x = 0; x < image.width(); x++ )
		{
			scale = 1.0 * x / image.width();
			col.setRgb( color1.red() + int(redDiff*scale),
						color1.green() + int(greenDiff*scale),
						color1.blue() + int(blueDiff*scale) );
			*p++ = col.rgb();
		}

		for ( int y = 1; y < image.height(); y++ )
			memcpy( image.scanLine( y ), image.scanLine( y - 1),
				 sizeof( unsigned int ) * image.width() );
	}

	QColor ditherPalette[8];

	for ( int s = 0; s < 8; s++ )
		ditherPalette[s].setRgb( color1.red() + redDiff * s / 8,
								color1.green() + greenDiff * s / 8,
								color1.blue() + blueDiff * s / 8 );

	kFSDither dither( ditherPalette, 8 );
	QImage dImage = dither.dither( image );

	QPixmap p;
	p.convertFromImage( dImage );

	painter->drawPixmap( contentsRect().x(), contentsRect().y(), p );

	if ( orientation() == Vertical )
	{
		int yPos = contentsRect().top() + painter->fontMetrics().ascent() + 2;
		int xPos = contentsRect().left() + (contentsRect().width() -
			 painter->fontMetrics().width( text2 )) / 2;
		QPen pen( color2 );
		painter->setPen( pen );
		painter->drawText( xPos, yPos, text2 );

		yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2;
		xPos = contentsRect().left() + (contentsRect().width() - 
			painter->fontMetrics().width( text1 )) / 2;
		pen.setColor( color1 );
		painter->setPen( pen );
		painter->drawText( xPos, yPos, text1 );
	}
	else
	{
		int yPos = contentsRect().bottom()-painter->fontMetrics().descent()-2;

		QPen pen( color2 );
		painter->setPen( pen );
		painter->drawText( contentsRect().left() + 2, yPos, text1 );

		pen.setColor( color1 );
		painter->setPen( pen );
		painter->drawText( contentsRect().right() -
			 painter->fontMetrics().width( text2 ) - 2, yPos, text2 );
	}
}

//-----------------------------------------------------------------------------

#include "kselect.moc"


--- NEW FILE: ktoolbar.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997, 1998 Stephan Kulow (coolo at kde.org)
              (C) 1997, 1998 Mark Donohoe (donohoe at kde.org)
              (C) 1997, 1998 Sven Radej (radej at kde.org)
              (C) 1997, 1998 Matthias Ettrich (ettrich at kde.org)
              
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
[...2381 lines suppressed...]
  buttons[id]->setRadio(false);
  buttons.remove(id);
}

void KRadioGroup::slotToggled(int id)
{
  if (buttons[id] && buttons[id]->isOn())
  {
    QIntDictIterator<KToolBarButton> it(buttons);
    while (it.current())
    {
      if (it.currentKey() != id)
        it.current()->on(false);
      ++it;
    }
  }
}

#include "ktoolbar.moc"


--- NEW FILE: ktoolbar.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997, 1998 Stephan Kulow (coolo at kde.org)
              (C) 1997, 1998 Sven Radej (radej at kde.org)
              (C) 1997, 1998 Mark Donohoe (donohoe at kde.org)
              (C) 1997, 1998 Matthias Ettrich (ettrich at kde.org)
              
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
    */

// $Id: ktoolbar.h,v 1.1 2006-10-03 11:26:33 dslinux_amadeus Exp $
// $Log: ktoolbar.h,v $
// Revision 1.1  2006-10-03 11:26:33  dslinux_amadeus
// adding pristine copy of pixil to HEAD so I can branch from it
//
// Revision 1.1  2003/09/08 19:42:11  jasonk
// Addition of packages directory and associated files.
//
// Revision 1.1.1.1  2003/08/07 21:18:33  jasonk
// Initial import of PIXIL into new cvs repository.
//
// Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
//
//
// Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
// Initial import of ViewML
//
// Revision 1.46.4.1  1999/04/18 18:36:25  radej
// sven: Docs.
//
// Revision 1.46  1998/11/25 13:22:00  radej
// sven: Someone made some private things protected (was it me?).
//
// Revision 1.45  1998/11/21 19:27:20  radej
// sven: doubleClicked signal for buttons.
//
// Revision 1.44  1998/11/11 14:32:11  radej
// sven: *Bars can be made flat by MMB (Like in Netscape, but this works)
//
// Revision 1.43  1998/11/09 00:28:43  radej
// sven: Docs update (more to come)
//
// Revision 1.42  1998/11/06 12:54:54  radej
// sven: radioGroup is in. handle changed again (broken in vertical mode)
//
// Revision 1.41  1998/10/09 12:42:21  radej
// sven: New: (un) highlight sugnals, Autorepeat buttons, button down when
//       pressed. kdetest/kwindowtest updated. This is Binary COMPATIBLE.
//
// Revision 1.40  1998/09/15 05:56:47  antlarr
// I've added a setIconText function to change the state of a variable
// in KToolBar
//
// Revision 1.39  1998/09/01 20:22:24  kulow
// I renamed all old qt header files to the new versions. I think, this looks
// nicer (and gives the change in configure a sense :)
//
// Revision 1.38  1998/08/09 14:01:19  radej
// sven: reintroduced makeDisabledPixmap code, and dumped QIconSet. Fixed a bug
//       with paletteChange too.
//
// Revision 1.37  1998/08/06 15:39:03  radej
// sven: Popups & delayedPopups. Uses QIconSet. Needs Qt-1.4x
//
// Revision 1.36  1998/06/20 10:57:00  radej
// sven: mispelled something...
//
// Revision 1.35  1998/06/19 13:09:31  radej
// sven: Docs.
//
// Revision 1.34  1998/05/04 16:38:36  radej
// Bugfixes for moving + opaque moving
//
// Revision 1.33  1998/04/28 09:17:49  radej
// New moving and docking BINARY INCOMPATIBLE
//

#ifndef _KTOOLBAR_H
#define _KTOOLBAR_H

#include <qlist.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qpopupmenu.h>
#include <qbutton.h>
#include <qfont.h>
#include <qsize.h>
#include <qintdict.h>

//#include <qiconset.h>

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "kcombo.h"
#include "klined.h"

class KToolBar;
class KToolBoxManager;

#define Item QWidget

enum itemType {
    ITEM_LINED = 0,
    ITEM_BUTTON = 1,
    ITEM_COMBO = 2,
    ITEM_FRAME = 3,
    ITEM_TOGGLE = 4,
    ITEM_ANYWIDGET=5
};

class KToolBarItem
{
public:
  KToolBarItem (Item *_item, itemType _type, int _id,
                bool _myItem=true);
  ~KToolBarItem ();
    
  void resize (int w, int h) { item->resize(w, h); };
  void move(int x, int y) { item->move(x, y); };
  void show () { item->show(); };
  void hide () { item->hide(); };
  void setEnabled (bool enable) { item->setEnabled(enable); };
  bool isEnabled () { return item->isEnabled(); };
  int ID() { return id; };
  bool isRight () { return right; };
  void alignRight  (bool flag) { right = flag; };
  void autoSize (bool flag) { autoSized = flag; };
  bool isAuto ()  { return autoSized; };
  int width() { return item->width(); };
  int height() { return item->height(); };
  int x() { return item->x(); };
  int y() { return item->y(); };
  int winId () { return item->winId(); };
  
  Item *getItem() { return item; };
  
private:
  int id;
  bool right;
  bool autoSized;
  Item *item;
  itemType type;
  bool myItem;
};


/**
 * This is internal button for use in KToolBar and...
 */

class KToolBarButton : public QButton
 {
   Q_OBJECT

 public:
   KToolBarButton(const QPixmap& pixmap, int id, QWidget *parent,
                  const char *name=0L, int item_size = 26, const char *txt=0,
                  bool _mb = false);
   KToolBarButton(QWidget *parent=0L, const char *name=0L);
   ~KToolBarButton() {};
   void setEnabled(bool enable);
   
   virtual void setPixmap( const QPixmap & );
   virtual void setText ( const char *text);
   void on(bool flag);
   void toggle();
   void beToggle(bool);
   bool ImASeparator () {return sep;};
   void youreSeparator () {sep = true;};
   QPopupMenu *popup () {return myPopup;};
   void setPopup (QPopupMenu *p);
   void setDelayedPopup (QPopupMenu *p);
   void setRadio(bool f);
   
 public slots:
   void modeChange();
   
 protected:
   void paletteChange(const QPalette &);
   void leaveEvent(QEvent *e);
   void enterEvent(QEvent *e);
   void drawButton(QPainter *p);
   bool eventFilter (QObject *o, QEvent *e);
   void showMenu();
   //void setIconSet (const QPixmap &);
   void makeDisabledPixmap();
   
 private:
   bool toolBarButton;
   bool sep;
   QPixmap enabledPixmap;
   QPixmap disabledPixmap;
   int icontext;
   int highlight;
   bool raised;
   int id;
   int _size;
   KToolBar *parentWidget;
   QString btext;
   QFont buttonFont;
   QPopupMenu *myPopup;
   bool delayPopup;
   QTimer *delayTimer;
   bool radio;
   
 protected slots:
     void ButtonClicked();
     void ButtonPressed();
     void ButtonReleased();
     void ButtonToggled();
     void slotDelayTimeout();

 signals:
     void clicked(int);
     void doubleClicked(int);
     void pressed(int);
     void released(int);
     void toggled(int);
     void highlighted (int, bool);
 };


/**
 * KToolBar is a self resizing, floatable widget.
 * It is usually managed from KTopLevelWidget, but can be
 * used even if you don't use KTopLevelWidget. If you want
 * to handle this without KTopLevelWidget, see updateRects .<BR>
 * KToolBar can contain buttons Line inputs Combo Boxes, frames, and
 * custom widgets.
 * Combos, Frames and Lineds, and Widgets can be  autosized to full width.
 * Any Item can be right aligned, and buttons can be toggle buttons. Item
 * height,  type of buttons (icon or icon+text), and option for highlighting
 * is adjustable on constructor invocation by reading config file.
 * Toolbar will reread config-file when it recieves signal
 * Kapplication:appearanceChanged.
 * Toolbar can float, be dragged from and docked back to parent window.
 * It autoresizes itself. This may lead to
 * some flickering, but there is no way to solve it (as far as I
 * know). <BR>
 * You can bind popups and delayed popups to buttons. <BR>
 * You normaly use toolbar from subclassed KTopLevelWidget. When
 * you create toolbar object, insert items that you want to be in it.
 * Items can be inserted or removed ( removeItem() ) later, when toolbar
 * is displayed. It will update itself.
 * Then set their propperties ( alignItemRight , setItemAutoSized ,
 * setToggle ...) After that set the toolbar itself, enable ,setBarPos ...).
 * Then simply do addToolbar (toolbar),
 * and you're on. See how it's done in kwindowtest.
 * @short KDE Toolbar widget
 * @author Stephan Kulow <coolo at kde.org> Maintained by Sven Radej <radej at kde.org>
 */
 class KToolBar : public QFrame
  {

  Q_OBJECT

  friend class KToolBarButton;
  friend class KRadioGroup;
  
public:
  enum BarStatus{Toggle, Show, Hide};
  enum BarPosition{Top, Left, Bottom, Right, Floating, Flat};

  /**
   * Constructor.
   * Toolbar will read global-config file for item Size higlight
   * option and button type. However, you can pass desired height.
   * If you specify height here, config value has no effect.
   * Exception is if you set Icontext mode to 3 (icons under text) whic sets
   * size to minimum 40 pixels. For setting IconText mode, see
   * @ref #setIconText .
   * Setting size in constructor is not recomended.
   */
  KToolBar(QWidget *parent=0L, const char *name=0L, int _item_size = -1);

  /**
   * Destructor. If toolbar is floating it will cleanup itself.
   */
  virtual ~KToolBar();

  /**
   * Inserts KButton with pixmap. You should connect to one or more signals in
   * KToolBar: @ref #clicked , @ref #pressed , @ref #released ,
   * @ref highlighted  and
   * if toolbar is toggle button (@ref #setToggle ) @ref #toggled . Those
   * signals have id of a button that caused the signal.
   * If you want to bound an popup to button, see  @ref #setButton
   * @param index the position of the button. (-1 = at end).
   * @return Returns item index
   */
  int insertButton(const QPixmap& pixmap, int ID, bool enabled = true,
                   const char *ToolTipText = 0L, int index=-1 );
  /**
   * This is the same as above, but with specified signals and
   * slots to which this button will be connected. Button emits
   * signals pressed, clicked and released, and
   * if toolbar is toggle button ( @ref #setToggle ) @ref #toggled .
   * You can add more signals with @ref #addConnection .
   * @return Returns item index
   */
  int insertButton(const QPixmap& pixmap, int ID, const char *signal,
                   const QObject *receiver, const char *slot,
                   bool enabled = true,
                   const char *tooltiptext = 0L, int index=-1 );

  /**
   * This inserts a button with popupmenu. Button will have small
   * trialngle. You have to connect to popup's signals. The
   * signals pressed, released, clikced or doubleClicked are NOT emmited by
   * this button (see @ref #setDelayedPopup for that).
   * You can add custom popups which inherit @ref QPopupMenu to get popups
   * with tables, drawings etc. Just don't fiddle with events there.
   */
  int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup,
                   bool enabled, const char *_text, int index=-1);
  
  /**
   * Inserts a KLined. You have to specify signals and slots to
   * which KLined will be connected. KLined has all slots QLineEdit
   * has, plus signals @ref KLined::completion and @ref KLined::rotation
   * KLined can be set to autoresize itself to full free width
   * in toolbar, that is to last right aligned item. For that,
   * toolbar must be set to full width (which it is by default).
   * @see #setFullWidth
   * @see #setItemAutoSized
   * @see KLined
   * @return Returns item index
   */
  int insertLined (const char *text, int ID,
                   const char *signal,
                   const QObject *receiver, const char *slot,
                   bool enabled = true,
                   const char *toolTipText = 0L, int size = 70, int index =-1);

  /**
   * Inserts KComboBox with list. Can be writable, but cannot contain pixmaps. By
   * default inserting policy is AtBottom, i.e. typed items are placed at the bottom
   * of the list. Can be autosized
   * KCombo is almost the same thing as QComboBox.
   * @see #setFullWidth
   * @see #setItemAutoSized
   * @see KCombo
   * @return Returns item index
   */
  int insertCombo (QStrList *list, int id, bool writable,
                   const char *signal, QObject *recevier,
                   const char *slot, bool enabled=true,
                   const char *tooltiptext=0L,
                   int size=70, int index=-1,
                   KCombo::Policy policy = KCombo::AtBottom);

  /**
   * Inserts KCombo with text. The rest is the same as above.
   * @see #setItemAutoSized
   * @see KCombo
   * @return Returns item index
   */
  int insertCombo (const char *text, int id, bool writable,
                   const char *signal, QObject *recevier,
                   const char *slot, bool enabled=true,
                   const char *tooltiptext=0L,
                   int size=70, int index=-1,
                   KCombo::Policy policy = KCombo::AtBottom);
  /**
   * Insert separator
   */
  int insertSeparator(int index=-1);

  /**
   * This function is deprecated and will be removed. Use @ref #insertWidget
   * to insert anything.
   * Inserts frame with specified width. You can get
   * pointer to this frame with @ref #getFrame
   * Frame can be autosized to full width.
   * @see #setItemAutoSized
   * @return Returns item index
   */
  int insertFrame(int id, int width, int index =-1);

  /**
   * Insert a user defined widget. Widget must have a QWidget for
   * base class.
   * Widget can be autosized to full width. If you forget about it, you
   * can get pointer to this widget with @ref #getWidget .
   * @see #setItemAutoSized
   * @return Returns item index
   */
  int insertWidget(int id, int width, QWidget *_widget, int index=-1);

  /**
   * This adds connection to items. Therefore it is important that you
   * know id of particular item. Nothing happens if you miss id.
   */
  void addConnection (int id, const char *signal,
                      const QObject *receiver, const char *slot);
  /**
   * Enables/disables item.
   */
  void setItemEnabled( int id, bool enabled );

  /**
   * Sets button pixmap.
   * Can be used while button is visible.
   */
  void setButtonPixmap( int id, const QPixmap& _pixmap );

  /**
   * Sets delayed popup to a button. Delayed popup is what you see in
   * netscape's Previous&next buttons: if you click them you go back,
   * or forth. If you press them long enough, you get a history-menu.
   * This is exactly what we do here. <BR>
   * You will insert normal button with connection (or use signals from
   * toolbar):
   * <pre>
   * bar->insertButton(pixmap, id, const SIGNAL(clicked ()), this,
   *     		SLOT (slotClick()), true, "click or wait for popup");
   * </pre> And then add a delayed popup:
   * <pre>
   * bar->setDelayedPopup (id, historyPopup); </pre>
   *
   * Don't add delayed popups to buttons which have normal popups.
   *
   * You may add popups wich are derived from QPopupMenu. You may
   * add popups that are already in menu bar or are submenus of other popups.
   */
  void setDelayedPopup (int id , QPopupMenu *_popup);

 /**
   * Makes a button autorepeat button. Toggle, buttons with menu or
   * delayed menu cannot be autorepeat. More, you can and will receive
   * only signals clicked, and not pressed or released.
   * When user presses this buton, you will receive signal clicked,
   * and if button is still pressed after some time, more clicks
   * in some interval. Since this uses @ref QButton::setAutoRepeat ,
   * I don't know how much is 'some'.
   */
  void setAutoRepeat (int id, bool flag=true);
  
   
  /**
   * Makes button a toggle button if flag is true
   */
  void setToggle (int id, bool flag = true);

  /**
   * If button is toggle (@ref #setToggle must be called first)
   * button state will be toggled. This will also cause toolbar to
   * emit signal @ref #toggled wit parameter id. You must connect to
   * this signal, or use @ref #addConnection to connect directly to
   * button-signal toggled.
   */
  void toggleButton (int id);

  /**
   * If button is toggle (@ref #setToggle must be called first)
   * this will set him to state flag. This will also emit signal
   * #ref toggled . <BR>
   * @see #setToggle
   */
  void setButton (int id, bool flag);

  /**
   * Returns true if button is on, false if button is off.
   * If button is not a toggle button returns false
   * @see #setToggle
   */
  bool isButtonOn (int id);
  
  /**
   * Sets text in Lined.
   * Cursor is set at end of text.
   */
  void setLinedText (int id, const char *text);

  /**
   * Returns Lined text.
   * If you want to store this text, you have to deep-copy it somwhere.
   */
  const char *getLinedText (int id);

  /**
   * Inserts text in combo id with at position index.
   */
  void insertComboItem (int id, const char *text, int index);

  /**
   * Inserts list in combo id at position index
   */
  void insertComboList (int id, QStrList *list, int index);

  /**
   * Removes item index from Combo id.
   */
  void removeComboItem (int id, int index);

  /**
   * Sets item index to be current item in Combo id.
   */
  void setCurrentComboItem (int id, int index);

  /**
   * Changes item index in Combo id to text.
   * index = -1 means current item (one displayed in the button).
   */
  void changeComboItem  (int id, const char *text, int index=-1);

  /**
   * Clears combo id.
   * Does not delete it or hide it.
   */
  void clearCombo (int id);

  /**
   * Returns text of item index from Combo id.
   * index = -1 means current item
   */

  const char *getComboItem (int id, int index=-1);

  /**
   * This returns pointer to Combo. Example:
   * <pre>
   * KCombo *combo = toolbar->getCombo(combo_id);
   * </pre>
   * That way you can get access to other public methods
   * that @ref KCombo provides. @ref KCombo is KDE enhancement
   * of @ref QComboBox . KCombo inherits QComboBox, so you can
   * use pointer to QComboBox too.
   */
  KCombo * getCombo(int id);
  
  /**
   * This returns pointer to KToolBarLined. Example:
   * <pre>
   * KLined * lined = toolbar->getKTollBarLined(lined_id);
   * </pre>
   * That way you can get access to other public methods
   * that @ref KLined provides. @ref KLined is the same thing
   * as @ref QLineEdit plus completion signals.
   */  
  KLined * getLined (int id);

  /**
   * This returns a pointer to KToolBarButton. Example:
   * <pre>
   * KToolBarButton * button = toolbar->getButton(button_id);
   * </pre>
   * That way you can get access to other public methods
   * that @ref KToolBarButton provides. Using of this method is not
   * recomended.
   */  
  KToolBarButton * getButton (int id);

  /**
   * Alignes item right.
   * This works only if toolbar is set to full width.
   * @see #setFullWidth
   */
  void alignItemRight (int id, bool right = true);

  /**
   * This function is deprecated and might be removed. Use @ref #insertWidget
   * and @ref #getWidget instead.<br>
   * Returns pointer to inserted frame. Wrong ids are not tested.
   * Example:
   * <pre>
   * QFrame *frame = toolbar->getframe (frameid);
   * </pre>
   * You can do with this frame whatever you want,
   * except change its height (hardcoded). If you change its width
   * you will probbably have to call toolbar->@ref #updateRects (true)
   * @see QFrame
   * @see #updateRects
   */
  QFrame * getFrame (int id);

  /**
   * Returns pointer to inserted widget. Wrong ids are not tested.
   * You can do with this whatever you want,
   * except change its height (hardcoded). If you change its width
   * you will probbably have to call toolbar->@ref #updateRects (true)
   * @see QWidget
   * @see #updateRects
   */
  QWidget *getWidget (int id);
  
  /**
   * Sets item autosized. This works only if toolbar is set to full width.
   * ONLY ONE item can be autosized, and it has to be
   * the last left-aligned item. Items that come after this must be right
   * aligned. Items that can be right aligned are Lineds, Frames, Widgets and
   * Combos. Auto sized item will resize itself whenever toolbar geometry
   * changes, to last right-aligned item (or till end of toolbar if there
   * are no right aligned items
   * @see #setFullWidth
   * @see #alignItemRight
   */
  void setItemAutoSized (int id, bool yes = true);

  /**
   * Removes item id.
   * Item is deleted. Toolbar is redrawn after it.
   */
  void removeItem (int id);

  /**
   * Hides item.
   */
  void hideItem (int id);

  /**
   * shows item.
   */
  void showItem (int id);
  
  /**
   * Sets toolbar to full parent width (or to value set by setMaxWidth).
   * You have to call this function if you want to have right aligned items or
   * autosized item. <BR>
   * The toolbar is set to full width by default.
   * @see #alignItemRight
   * @see #setItemAutoSized
   */
  void setFullWidth(bool flag = true);    // Top and Bottom pos only

  /**
   * Enables or disables moving of toolbar.
   */
  void enableMoving(bool flag = true);

  /**
   * Sets position of toolbar. This cannot be used to set toolbar flat. For
   * That, use @ref setFlat .
   * @see #BarPosition
   */
  void setBarPos (BarPosition bpos);

  /**
   * Returns position of toolbar
   */
  BarPosition barPos() {return position;};

  /**
   * This shows, hides, or toggles toolbar. If toolbar floats,
   * hiding means minimizing. Warning: kwm will not show minimized toolbar
   * on taskbar. Therefore hiding means hiding.
   * @see #BarStatus
   */
  bool enable(BarStatus stat);

  /**
   * Sets maximal height of vertical (Right or Left) toolbar. You normaly
   * do not have to call it, since it's called from
   * @ref KTopLevelWidget#updateRects
   * If you reimplement @ref KTopLevelWidget#resizeEvent or
   * KTopLevelWidget#updateRects,
   * be sure to call this function with maximal height toolbar can have.
   * In 0xFE cases out of 0xFF you don't need to use this function.
   * @see #updateRects
   */
  void setMaxHeight (int h);  // Set max height for vertical toolbars

  /**
   * Sets maximal width of horizontal (top or bottom) toolbar. This works
   * only for horizontal toolbars (at Top or Bottom), and has no effect
   * otherwise. Has no effect when toolbar is floating.
   */
  void setMaxWidth (int dw);

  /**
   * Sets title for toolbar when it floats. Titles are however not (yet)
   * visible. You can't change toolbar's title while it's floating.
   */
  void setTitle (const char *_title) {title = _title;};

  /**
   * Enables or disables floating.
   * Floating is enabled by default.
   * This only disables menu entry Floating in popup menu, so
   * toolbar can still be moved by @ref #setBarPos or by dragging.
   * This function is obsolete and do not use it. If you want to make
   * toolbar static use @ref enableMoving
   */
  void enableFloating (bool arrrrrrgh);

  /**
   * Sets the kind of painting for buttons between : 0 (only icons),
   * 1 (icon and text, text is left from icons), 2 (only text),
   * and 3 (icons and text, text is under icons).
   */

  void setIconText(int it);

  /**
   * Redraw toolbar and resize it if resize is true.
   * You normaly don't have to call it, since it's called from
   * @ref KTopLevelWidget#updateRects or from resizeEvent. You can call it
   * if you manualy change width of inserted frame, or if you wish to force
   * toolbar to recalculate itself. <BR>
   * You don't want to fiddle with this.
   * @ref KtopLevelWidget works closely with toolbar. If you want to
   * subclass KTopLevelWidget to change its resize policy, hear this: <BR>
   * <BR>
   * resizeEvent() in KTopLevelWidget just calls updateRects, which handles
   * children sizes. Call updateRects when you're done with your things. <BR>
   * <BR>
   * If you want to handle everything yourself:<BR>
   * <BR>
   * KToolBar manages itself by calling toolbar->@ref #updateRects (true).
   * It will autosize itself, but won't move itself.
   * You have to do the moving. <BR>
   * First setup & move anything that is above toolbars (menus...). Then
   * setup statusbars and other horizontal things on bottom. Then loop through
   * all HORIZONTAL toolbars, call their updateRects(true), _then_ take their
   * size, an move them (note that they size themselves according to parent
   * width()). After  you have looped through HORIZONTAL toolbars, calculate
   * the maximum height that vertical toolbars may have (this is your free
   * area height). Then loop through vertical toolbars,
   * @ref #setMaxHeight (calculated_max_height) on them,
   * call their updateRects(true), and _then_ move them to their locations.
   * In 0xFE cases out of 0xFF you don't need to use this function.
   * @see KtopLevelWidget#updateRects
   */
  void updateRects(bool resize = false);

  /**
     * Returns minimal width for top-level window, so that toolbar
     * has only one row.
     */
  QSize sizeHint();
  /**
   * This method switches flat/unflat mode. Carefull: might not work
   * If toolbar is floating.
   */
  void setFlat (bool flag);
    
signals:
    /**
     * Emits when button id is clicked.
     */
    void clicked(int id);

    /**
     * Emits when button id is double clicked. Note: you will always
     * recive two @ref #clicked , @ref #pressed and @ref #released signals.
     * There is no way to avoid it - at least no easy way.
     * If you need to resolve this all you can do is set up timers
     * which waits for @ref QApplication::doubleClickInterval to expire.
     * if in that time you don't get this signal, you may belive that
     * button was only clicked.
     * And please note that butons with popup menus do not emit this signal,
     * but those with delayed popup do.
     */
    void doubleClicked (int id);
    
    /**
     * Emits when button id is pressed.
     */
    void pressed(int);

    /**
     * Emits when button id is released.
     */
    void released(int);

    /**
     * Emits when toggle button changes state
     * Emits also if you change state
     * with @ref #setButton or @ref #toggleButton
     * If you make a button normal again, with
     * @ref #setToggle (false), this signal won't
     * be emited.
     */
    void toggled(int);
    
    /**
     * This signal is emmited when item id gets highlighted/unhighlighted
     * (i.e when mouse enters/exits). Note that this signal is emited from
     * all buttons (normal, disabled and toggle) even when there is no visible
     * change in buttons (meaning, buttons do not raise when mouse enters).
     * Parameter isHighlighted is true when mouse enters and false when
     * mouse exits.
     */
    void highlighted(int id, bool isHighlighted);

    /**
     * Emits when toolbar changes its position, or when
     * item is removed from toolbar. This is normaly connected to
     * @ref KTopLevelWidget::updateRects.
     * If you subclass @ref KTopLevelWidget and reimplement
     * @ref KTopLevelWidget::resizeEvent or
     * @ref KTopLevelWidget::updateRects, be sure to connect to
     * this signal. You can connect this signal to slot that
     * doesn't take parameter.
     * @see #updateRects
     */
    void moved( BarPosition );

    /**
     * Internal. This signal is emited when toolbar detects changing of
     * following parameters:
     * highlighting, button-size, button-mode. This signal is
     * internal, aimed to buttons.
     */
    void modechange ();
  
private:
    
  QList<KToolBarItem> items;

  const char *title;
  bool fullWidth;
  BarPosition position;
  bool moving;
  QWidget *Parent;
  int toolbarWidth;
  int toolbarHeight;

  int oldX;
  int oldY;
  int oldWFlags;
  
  int max_width;
  int max_height;
  
  BarPosition lastPosition; // Where was I last time I was?
  BarPosition movePos;      // Where was I moved to?
  bool mouseEntered;  // Did the mouse touch the cheese?
  bool horizontal;    // Do I stand tall?
  bool localResize;   // Am I trying to understand recursion?
  bool wasFullWidth;  // Was I loong when I was?
  bool haveAutoSized; // Do I have a problem?

  KToolBoxManager *mgr;
  
protected:
  QPopupMenu *context;

  void drawContents ( QPainter *);
  void resizeEvent(QResizeEvent*);
  void paintEvent(QPaintEvent*);
  void closeEvent (QCloseEvent *);
  void mousePressEvent ( QMouseEvent *);
  void init();
  void layoutVertical ();
  void layoutHorizontal ();
  void leaveEvent (QEvent *e);
  
  
private slots:
  void ButtonClicked(int);
  void ButtonDblClicked( int id );
  void ButtonPressed(int);
  void ButtonReleased(int);
  void ButtonToggled(int);
  void ButtonHighlighted(int,bool);
   
  void ContextCallback(int);
  void slotReadConfig ();
  void slotHotSpot (int i);
  
protected:
  void mouseMoveEvent(QMouseEvent*);
  void mouseReleaseEvent ( QMouseEvent *);

private:
   QPoint pointerOffset;
   QPoint parentOffset;
   int item_size;  // normal: 26
   int icon_text;  // 1 = icon+text, 0 icon+tooltip
   bool highlight; // yes/no
   QSize szh;      // Size for sizeHint
   bool fixed_size; // do not change the toolbar size
   bool transparent; // type of moving
  };


/*************************************************************************
 *                          KRadioGroup                                  *
 *************************************************************************/
 /**
  * KRadioGroup is class for group of radio butons in toolbar.
  * Take toggle buttons which you already inserted into toolbar,
  * create KRadioGroup instance and add them here.
  * All buttons will emit signals toggled (bool) (or you can
  * use sitgnal @ref #toggled (int id) from toolbar). When one button is set
  * down, all others are unset. All buttons emit signals - those who
  * "go down" and those who "go up".
  *
  * @author Sven Radej <radej at kde.org>
  * @short Class for group of radio butons in toolbar.
  */
class KRadioGroup : public QObject
{
  Q_OBJECT

public:
  /**
   * Constructor. Parent must be @ref KToolBar .
   */
  KRadioGroup (QWidget *_parent, const char *_name=0);
  /**
   * Destructor.
   */
  ~KRadioGroup () {};

  /**
   * Adds button to group. Button cannot be unset by mouse clicks (you
   * must press some other button tounset this one)
   */
  void addButton (int id);

  /**
   * Removes button from group, making it again toggle button (i.e.
   * You can unset it with mouse).
   */
  void removeButton (int id);

public slots:
  /**
   * Internal - nothing for you here.
   */
  void slotToggled (int);

private:
  QIntDict<KToolBarButton> buttons;
  KToolBar *tb;
};


#endif

--- NEW FILE: kpopmenu.cpp ---
#include "kpopmenu.h"
#include "kpopmenu.h"
#include <qpainter.h>
#include <klocale.h>
#include <kapp.h>

KPopupMenu::KPopupMenu(QWidget *parent, const char *name)
    : QPopupMenu(parent, name)
{
    initialize(klocale->translate("Untitled"));
}

KPopupMenu::KPopupMenu(const char *title, QWidget *parent, const char *name)
    : QPopupMenu(parent, name)
{
    initialize(title);
}


KPopupMenu::~KPopupMenu()
{
}


const char *KPopupMenu::title() const
{
    return text(0);
}

void KPopupMenu::setTitle(const char *title)
{
    changeItem(title, 0);
}
    
void KPopupMenu::initialize(const char *title)
{
    insertItem(title);
    insertSeparator();
    insertSeparator();
}
   
void KPopupMenu::paintCell(QPainter *p, int row, int col)
{
    if (row != 0)
        QPopupMenu::paintCell(p, row, col);
    else if ( ( (row == 0) && (col == 1) && (isCheckable()) ) || 
		( (row == 0) && (col == 0) && (!isCheckable()) ) ) {
        int cellh = cellHeight(0);
        int cellw = cellWidth(0);
        QColorGroup cg = this->colorGroup();
        
        p->setPen(cg.light());
		p->drawText(6, 3, cellw, cellh-4, 
			DontClip|AlignVCenter|ShowPrefix|SingleLine, text(0));
        p->setPen(cg.text());
		p->drawText(5, 2, cellw, cellh-4, 
			DontClip|AlignVCenter|ShowPrefix|SingleLine, text(0));
    }
}
    
#include "kpopmenu.moc"

--- NEW FILE: kkeydialog.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Nicolas Hadacek <hadacek at via.ecp.fr>
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef KKEYDIALOG_H
#define KKEYDIALOG_H

#include <qdict.h>
#include <qaccel.h>

#include <qdialog.h>
#include <qlistbox.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qbuttongroup.h>
#include <qtableview.h>
#include <qstrlist.h>
#include <qpopupmenu.h>
#include <qgroupbox.h>
#include <qobject.h>

#include <kapp.h>
#include "kaccel.h"
#include "kglobalaccel.h"

/**
* A list box item for KSplitList.It uses two columns to display
* action/key combination pairs.
* @short A list box item for KSplitList.
*/
class KSplitListItem : public QObject, public QListBoxItem
{
	Q_OBJECT
	
public:
    KSplitListItem( const char *s , int _id = 0);
    ~KSplitListItem (){};
    int getId(){return id;}

protected:
    virtual void paint( QPainter * );
    virtual int height( const QListBox * ) const;
    virtual int width( const QListBox * ) const;

public slots:
	void setWidth( int newWidth );
	
protected:
	int halfWidth;
	QString keyName;
	QString actionName;
	int id;
};

/**
* A list box that can report its width to the items it
* contains. Thus it can be used for multi column lists etc.
* @short A list box capable of multi-columns
*/
class KSplitList: public QListBox
{
	Q_OBJECT

public:
	KSplitList( QWidget *parent = 0, const char *name = 0 );
	~KSplitList() { }
	int getId(int index){
	    return ((KSplitListItem*) (item(index)))->getId();
	}

signals:
	void newWidth( int newWidth );

protected:
	void resizeEvent( QResizeEvent * );
	void paletteChange ( const QPalette & oldPalette );
	void styleChange ( GUIStyle );

protected:
	QColor selectColor;
	QColor selectTextColor;
};

/**
* A push button that looks like a keyboard key.
* @short A push button that looks like a keyboard key.
*/
class KKeyButton: public QPushButton
{
	Q_OBJECT

public:
	KKeyButton( const char* name = 0, QWidget *parent = 0);
	~KKeyButton();
	void setText( QString text );
	void setEdit( bool edit );
	bool editing;

protected:
	void paint( QPainter *_painter );
	void drawButton( QPainter *p ) { paint( p ); }
};

/**
 * The KKeyDialog class is used for configuring dictionaries of key/action
 * associations for KAccel and KGlobalAccel. It uses the KKeyChooser widget and
 * offers buttons to set all keys to defaults and invoke on-line help.
 *
 * Two static methods are supplied which provide the most convienient interface
 * to the dialog. For example you could use KAccel and KKeyDialog like this
 *
 * KAccel keys;
 *
 * keys.insertItem( i18n("Zoom in" ), "Zoom in", "+" );
 * keys.connectItem( "Zoom in", myWindow, SLOT( zoomIn() ) );
 *
 * keys.connectItem( KAccel::Print, myWindow, SLOT( print() ) );
 *
 * keys.readSettings();
 *
 * if( KKeyDialog::configureKeys( &keys ) ) {
 *		...
 *	}
 *
 * This will also implicitely save the settings. If you don't want this, you can call
 *
 * if( KKeyDialog::configureKeys( &keys, false ) ) { // do not save settings
 *		...
 *	}
 *
 */
class KKeyDialog : public QDialog
{
	Q_OBJECT
	
public:
	KKeyDialog( QDict<KKeyEntry> *aKeyDict, QWidget *parent = 0,
		    bool check_against_std_keys = false);
	~KKeyDialog() {};

	static int configureKeys( KAccel *keys, bool save_settings = true  );
	static int configureKeys( KGlobalAccel *keys,  bool save_settings = true );
	
private:
	QPushButton *bDefaults, *bOk, *bCancel, *bHelp;
};

/**
 * The KKeyChooser widget is used for configuring dictionaries of key/action
 * associations for KAccel and KGlobalAccel.
 *
 * The class takes care of all aspects of configuration, including handling key
 * conflicts internally. Connect to the allDefault slot if you want to set all
 * configurable keybindings to their default values.
 */
class KKeyChooser : public QWidget
{
	Q_OBJECT

public:
	enum { NoKey = 1, DefaultKey, CustomKey };
	
	KKeyChooser( QDict<KKeyEntry> *aKeyDict, QWidget *parent = 0,
		     bool check_against_std_keys = false);
	~KKeyChooser();
	
	QDictIterator<KKeyEntry> *aIt;
	QDictIterator<KKeyEntry> *aKeyIt;

signals:
	void keyChange();

public slots:
	void allDefault();
	void listSync();

protected slots:
	void toChange(int index);
	void changeKey();
	void updateAction(int index);
	void defaultKey();
	void noKey();
	void keyMode(int m);
	void shiftClicked();
	void ctrlClicked();
	void altClicked();
	void editKey();
	void editEnd();
	void readGlobalKeys();
	void readStdKeys();

protected:
	void keyPressEvent( QKeyEvent *e );
	void fontChange( const QFont & );

protected:
	QDict<int> *globalDict;
	QDict<int> *stdDict;
	KKeyEntry *pEntry;
	QString sEntryKey;
	KSplitList *wList;
	QLabel *lInfo, *lNotConfig;
	QLabel *actLabel, *keyLabel;
	KKeyButton *bChange;
	QCheckBox *cShift, *cCtrl, *cAlt;
	QGroupBox *fCArea;
	//QLineEdit *eKey;
	QButtonGroup *kbGroup;

	bool bKeyIntercept;
	
	int kbMode;

	const QString item( uint keyCode, const QString& entryKey );
	bool isKeyPresent();
	void setKey( uint kCode );
};



#endif

--- NEW FILE: kcombo.h ---
#ifndef _KCOMBO_H_
#define _KCOMBO_H_

#include <qcombobox.h>

class KCombo : public QComboBox {
	Q_OBJECT

public:
	KCombo( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
	KCombo( bool readWrite, QWidget* parent = 0, 
		const char* name = 0, WFlags f = 0 );
	virtual ~KCombo(){};


	/* the following functions are there for compatibility with
	 * the former KCombo. Most of them are dummies now.
	 * Their functionality will soon be available in QComboBox
	 */

	void setLabelFlags( int) {};
	int labelFlags() const {return 0;};
	void cursorAtEnd(){};
	void setText( const char *text );
        void setCompletion( bool){};     
	
 private:
	bool set_text_called;
	
};

#endif // _KCOMBO_H_

--- NEW FILE: kmenubar.cpp ---
/*
    Copyright (C) 1997, 1998 Sven Radej (sven at lisa.exp.univie.ac.at)
    Copyright (C) 1997 Matthias Ettrich (ettrich at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#include <qpainter.h>
#include <qdrawutil.h>
#include <qpalette.h>
#include <qstring.h>
#include <qframe.h>

#include "qobjectlist.h"

#include "ktopwidget.h"

#include "kmenubar.h"

#include <klocale.h>
#include <kapp.h>
#include <kwm.h>
#include <ktoolboxmgr.h>
#include <kwm.h>

#define CONTEXT_TOP 1
#define CONTEXT_BOTTOM 2
#define CONTEXT_FLOAT 3

// $Id: kmenubar.cpp,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
// $Log: kmenubar.cpp,v $
// Revision 1.1  2006-10-03 11:26:31  dslinux_amadeus
// adding pristine copy of pixil to HEAD so I can branch from it
//
// Revision 1.1  2003/09/08 19:42:09  jasonk
// Addition of packages directory and associated files.
//
// Revision 1.1.1.1  2003/08/07 21:18:32  jasonk
// Initial import of PIXIL into new cvs repository.
//
// Revision 1.1.1.1  2003/06/23 22:04:23  jasonk
//
//
// Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
// Initial import of ViewML
//
// Revision 1.63.2.3  1999/06/02 09:21:02  radej
// sven: From 1.1.1. release due to corruption
//
// Revision 1.63.2.2  1999/03/24 16:48:56  ettrich
// workaround for qt-1.44 behaviour
//
// Revision 1.63.2.1  1999/03/06 21:45:58  radej
// sven: Flat/Unflat with LMB too. Arrows and animation to come.
//
// Revision 1.63  1999/02/05 19:16:54  ettrich
// fixed mac-style toggling for applications with multiple toplevel windows
//
// Revision 1.62  1999/01/18 10:56:49  kulow
// .moc files are back in kdelibs. Built fine here using automake 1.3
//
// Revision 1.61  1999/01/15 09:31:08  kulow
// it's official - kdelibs builds with srcdir != builddir. For this I
// automocifized it, the generated rules are easier to maintain than
// selfwritten rules. I have to fight with some bugs of this tool, but
// generally it's better than keeping them updated by hand.
//
// Revision 1.60  1998/12/16 01:42:21  ettrich
// last fix for today
//
// Revision 1.59  1998/12/16 01:40:22  ettrich
// yet another bugfix (don't worry, didn't effect any yet-existing program)
//
// Revision 1.58  1998/12/16 01:27:12  ettrich
// fixed slightly broken macstyle removal
//
// Revision 1.57  1998/12/16 00:01:38  ettrich
// small fix for menubars
//
// Revision 1.56  1998/12/09 14:11:58  radej
// sven: Bad geometry (vanishing last item) fixed. Debug output commented out.
//
// Revision 1.55  1998/12/07 21:47:26  tibirna
// Endorsed by: Sven Radej <sven at kde.org>
//
// CT: 1)         ~/.kderc#[Menubar]\TopOfScreen=yes|no
//        becomes ~/.kderc#[KDE]\macStyle=on|off
//     2) GUI config for the macStyle
//     3) krootwm supports "hot" switching of macStyle (still small problems,
// 	a restart of krootwm fixes them)
//
// Revision 1.54  1998/12/02 16:22:21  radej
// sven: Flat menubar looks like flat toolbars in Motif style
//
// Revision 1.53  1998/11/23 18:32:04  radej
// sven: MACmode: runtime change works,
//
// Revision 1.52  1998/11/23 15:34:04  radej
// sven: Nicer sysmenu button
//
// Revision 1.51  1998/11/23 11:57:17  radej
// sven: Mac: Force show, if on top y= -2, take icon in showEvent.
//       Still doesn't gets hidden when it's window loses focus.
//       ToolBar does.
//
// Revision 1.50  1998/11/23 09:57:49  ettrich
// small improvement, hope Sven likes it
//
// Revision 1.49  1998/11/23 00:12:27  radej
// sven: MACMenu: doesn't show if app doesn't want it to (kvt) + icon size fix
//
// Revision 1.48  1998/11/22 13:35:46  radej
// sven: IMPROVED Mac menubar: Accelerators, SystemMenu, look...
//
// Revision 1.47  1998/11/21 20:28:39  ettrich
// yet another small fix
//
// Revision 1.46  1998/11/21 20:25:41  ettrich
// small fix
//
// Revision 1.45  1998/11/18 01:00:03  radej
// sven: set*BarPos(Flat) works now (I hope)
//
// Revision 1.44  1998/11/11 14:32:10  radej
// sven: *Bars can be made flat by MMB (Like in Netscape, but this works)
//
// Revision 1.43  1998/11/10 14:12:47  radej
// sven: windows-style handle smaller
//
// Revision 1.42  1998/11/07 22:39:13  radej
// sven: Fixed QAccel too (unrepaired what repairEventFilter messed)
//
// Revision 1.41  1998/11/07 17:13:57  radej
// sven: Fixed KAccel, for now
//
// Revision 1.40  1998/11/06 17:59:55  radej
// sven: fixed dynamic style change (QMenuBar is buggy)
//
// Revision 1.39  1998/11/06 16:48:21  radej
// sven: nicer docking, some bugfixes
//
// Revision 1.38  1998/11/06 15:08:49  radej
// sven: finished handles. Comments?
//
// Revision 1.37  1998/11/06 12:55:53  radej
// sven: handle changed again (still not perfect)
//
// Revision 1.36  1998/11/05 18:23:32  radej
// sven: new look for *Bar handles (unfinished)
//
// Revision 1.35  1998/10/05 15:09:52  kulow
// purify (and me) likes initialized members, so I choose one (like the compiler
// would do :)
//
// Revision 1.34  1998/09/07 18:44:29  ettrich
// Matthias: preparation for new features
//
// Revision 1.33  1998/09/07 13:46:58  ettrich
// Matthias: removed some debug output...
//
// Revision 1.32  1998/09/07 13:45:19  ettrich
// Matthias: removed old qt-1.2 compatibility hack
//
// Revision 1.31  1998/09/01 20:22:03  kulow
// I renamed all old qt header files to the new versions. I think, this looks
// nicer (and gives the change in configure a sense :)
//
// Revision 1.30  1998/08/31 00:52:11  torben
// Torben: One new function and made others virtual
// => binary incompatible. Sorry. Please use virtual whenever it is
// not a performance problem.
//
// Revision 1.29  1998/07/23 09:43:38  radej
// sven: Improved look under diff styles. Winlook is beetter now.
//
// Revision 1.28  1998/06/18 08:58:14  radej
// sven: removed debug output
//
// Revision 1.27  1998/05/28 21:49:39  kulow
// I thought, a little sync between my different acinclude.m4.ins. I've done much
// to much to know, which version is where ;)
//
// Revision 1.26  1998/05/19 14:10:23  radej
// Bugfixes: Unhighlighting a handle and catching the fast click
//
// Revision 1.25  1998/05/07 23:13:09  radej
// Moving with KToolBoxManager
//

// This file was corrupted in KDE_1_1_BRANCH

static bool standalone_menubar = FALSE;
static bool toggleFlatOnRelease = false;

static QPixmap* miniGo = 0;

_menuBar::_menuBar (QWidget *parent, const char *name)
  : QMenuBar (parent, name)
{
   // Menubar is raised in motif style
   //setFrameStyle(NoFrame);
	
   //MD (17-9-97)
  setLineWidth(1);
 }

_menuBar::~_menuBar ()
 {
 }


// workaround for qt-1.44's slightly changed menu bar handling

void _menuBar::resizeEvent( QResizeEvent* e)
{
    static bool inHere = FALSE;
    
    if (inHere)
	return;
    
    inHere = TRUE;
    QMenuBar::resizeEvent( e );
    inHere = FALSE;
    // ignore;
}


/*************************************************************/

KMenuBar::KMenuBar(QWidget *parent, const char *name)
  : QFrame( parent, name )
{
  Parent = parent;        // our father
  title = 0;
  oldWFlags = getWFlags();

  standalone_menubar = FALSE;
  frame = new QFrame (this);
  frame->setFrameStyle(NoFrame);
  menu = new _menuBar (frame);
  oldMenuFrameStyle = menu->frameStyle();

  connect (menu, SIGNAL(activated(int)), this, SLOT(slotActivated(int)));
  connect (menu, SIGNAL(highlighted(int)), this, SLOT(slotHighlighted(int)));
  handle = new QFrame (this);
  handle->setMouseTracking( TRUE );
  handle->setFrameStyle(NoFrame);
  handle->installEventFilter(this);
  handle->show();
  handle->raise();
  init();
}

int KMenuBar::idAt( int index )
{
  return menu->idAt( index );
}

int KMenuBar::heightForWidth ( int max_width ) const
{
  return menu->heightForWidth( max_width - 9);
}

void KMenuBar::resizeEvent (QResizeEvent *)
{
  if (position == Flat)
    return;
  int hwidth = 9;
  if (standalone_menubar)
    hwidth = 20;

  frame->setGeometry(hwidth , 0, width()-hwidth,
                     menu->heightForWidth(width()-hwidth));
  menu->resize(frame->width(), frame->height());
  
  handle->setGeometry(0,0,hwidth,height());
  if (height() != heightForWidth(width()))
  {
    resize(width(), heightForWidth(width()));
    return;
  }
}

void KMenuBar::ContextCallback( int )
{
  int i;
  i = context->exec();
  switch (i)
   {
    case CONTEXT_TOP:
      setMenuBarPos( Top );
      break;
    case CONTEXT_BOTTOM:
      setMenuBarPos( Bottom );
      break;
    case CONTEXT_FLOAT:
      if (position == Floating || position == FloatingSystem){
        setMenuBarPos (lastPosition);
      }
      else {
        setMenuBarPos( Floating );
	move(QCursor::pos());
	show();
      }
      break;
   }

  handle->repaint (false);
}

void KMenuBar::init()
{
  context = new QPopupMenu( 0, "context" );
  context->insertItem( klocale->translate("Top"),  CONTEXT_TOP );
  context->insertItem( klocale->translate("Bottom"), CONTEXT_BOTTOM );
  context->insertItem( klocale->translate("Floating"), CONTEXT_FLOAT );

  position = Top;
  moving = TRUE;
  highlight = false;
  transparent = false;

  setLineWidth( 0 );

  resize( Parent->width(), menu->height());
  enableFloating (TRUE);
  connect (kapp, SIGNAL(appearanceChanged()), this, SLOT(slotReadConfig()));
  slotReadConfig();

  mgr =0;

}


KMenuBar::~KMenuBar()
{
  if (!QApplication::closingDown())
    delete context;
}

void KMenuBar::mousePressEvent ( QMouseEvent *e )
{
  QApplication::sendEvent(menu, e);
}

void KMenuBar::slotReadConfig ()
{
  int _highlight;
  bool _transparent;

  KConfig *config = kapp->getConfig();
  QString group = config->group();
  config->setGroup("Toolbar style");
  _highlight =config->readNumEntry("Highlighting", 1);
  _transparent = config->readBoolEntry("TransparentMoving", true);

  if (_highlight != highlight)
    highlight = _highlight;

  if (_transparent != transparent)
    transparent= _transparent;

  if (style() == MotifStyle)
  {
    menu->setStyle(style()); //Uh!
    menu->setMouseTracking(false);
    if (position != Floating || position == FloatingSystem)
      menu->setFrameStyle(Panel | Raised);
  }
  else
  {
    menu->setStyle(style()); //Uh!
    menu->setMouseTracking(true);
    if (position != Floating && position != FloatingSystem)
      menu->setFrameStyle(NoFrame);
  }

  config->setGroup("KDE");//CT as Sven asked
  bool macmode = false;
  if (config->readEntry("macStyle") == "on") //CT as Sven asked
    macmode = true;

  if ( menuBarPos() != FloatingSystem && macmode) //was not and now is
  {
      standalone_menubar = TRUE;
      if (Parent->isVisible())
	  setMenuBarPos( FloatingSystem );
      else {
	  Parent->installEventFilter(this); // to show menubar
      }
  }
  else if (menuBarPos() == FloatingSystem && !macmode) //was and now is not
  {
    standalone_menubar = FALSE;
    setMenuBarPos (lastPosition);
  }
  //else if was and now is - nothing;
  //else if was not and now is not - nothing;
  config->setGroup(group);
}

void KMenuBar::slotHotSpot (int hs)
{
  if (mgr == 0)
    return;
  if (!transparent) // opaque
  {
    switch (hs)
    {
      case 0: //top
        setMenuBarPos(Top);
        break;

      case 1: //bottom
        setMenuBarPos(Bottom);
        break;

      case -1: // left all
        setMenuBarPos(Floating);
        break;
    }
    if (position != Floating)
    {
      QPoint p(Parent->mapToGlobal(pos())); // OH GOOOOODDDD!!!!!
      mgr->setGeometry(p.x(), p.y(), width(), height());
    }
    if (!isVisible())
      show();
  }
  else // transparent
  {
    switch (hs)
    {
      case 0: //top
        mgr->setGeometry(0);
        movePosition=Top;
        break;

      case 1: //bottom
        mgr->setGeometry(1);
        movePosition=Bottom;
        break;

      case -1: // left all
        mgr->setGeometry(mgr->mouseX(), mgr->mouseY(), width(), height());
        movePosition=Floating;
        break;
    }
  }
}


void KMenuBar::paintEvent(QPaintEvent *)
{
  //QApplication::sendEvent(menu, e);
  menu->repaint();
}

void KMenuBar::closeEvent (QCloseEvent *e)
{
  if (position == Floating)
   {
     position = lastPosition;
     recreate (Parent, oldWFlags, QPoint (oldX, oldY), TRUE);
     context->changeItem (klocale->translate("Float"), CONTEXT_FLOAT);
     emit moved (position);
     e->ignore();
     return;
   }
  e->accept();
}

void KMenuBar::leaveEvent (QEvent *e){
  QApplication::sendEvent(menu, e);
}


bool KMenuBar::eventFilter(QObject *ob, QEvent *ev){


  if (ob == Parent && ev->type() == Event_Show && standalone_menubar)
  {
    //bool aha = isVisible(); // did app enable show?
      setMenuBarPos(FloatingSystem);
      Parent->removeEventFilter(this); //One time only
      return false;
  }

  if (mgr)
    return true;


  if (ob == handle){
    if (ev->type() == Event_MouseButtonPress)
    {
      if (standalone_menubar)
      {
        //Dunno but krootwm does this; without it menu stays...
        XUngrabPointer(qt_xdisplay(), CurrentTime);
        XSync(qt_xdisplay(), False);

        QString x,y;
        x.setNum(pos().x());
        y.setNum(pos().y()+height());
        while (x.length()<4)
          x.prepend("0");
        while (y.length()<4)
          y.prepend("0");
        //if (((QMouseEvent*)ev)->button() == LeftButton)
          KWM::sendKWMCommand(QString("kpanel:go")+x+y);
        //else
        //  KWM::sendKWMCommand(QString("krootwm:go")+x+y);
        return false; //or true? Bah...
      }

      if ( moving && ((QMouseEvent*)ev)->button() == RightButton)
	{
	  context->popup( handle->mapToGlobal(((QMouseEvent*)ev)->pos()), 0 );
	  ContextCallback(0);
	}
      else if (((QMouseEvent*)ev)->button() == MidButton &&
               position != Floating)
        setFlat (position != Flat);
      else if (((QMouseEvent*)ev)->button() == LeftButton)
        toggleFlatOnRelease=true;
      return TRUE;
    }

    if (ev->type() == Event_MouseMove &&
        ((QMouseEvent*) ev)->state() == LeftButton &&
        toggleFlatOnRelease)
      {
        toggleFlatOnRelease = false;
        //Move now
        QRect rr(Parent->geometry());
        int ox = rr.x();
        int oy = rr.y();
        int ow = rr.width();
        int oh = rr.height();

        int  fat = 25; //ness

        mgr = new KToolBoxManager(this, transparent);

        mgr->addHotSpot(ox, oy, ow, fat);           // top
        mgr->addHotSpot(ox, oy+oh-fat, ow, fat);    // bottom

        movePosition = position;
        connect (mgr, SIGNAL(onHotSpot(int)), SLOT(slotHotSpot(int)));
        if (transparent)
          mgr->doMove(true, false, true);
        else
        {
          mgr->doMove(true, false, false);
        }

        if (transparent)
        {
          setMenuBarPos (movePosition);

          if (movePosition == Floating)
            move (mgr->x(), mgr->y());
          if (!isVisible())
            show();
        }
        delete mgr;
        mgr=0;
        handle->repaint(false);
        //debug ("KMenuBar: moving done");
        return true; // Or false? Never knew what evFilter returns...
      }

    if (ev->type() == Event_MouseButtonRelease)
      {
	if (mgr)
          mgr->stop();
        if (toggleFlatOnRelease && position != Floating)
          setFlat (position != Flat);
        toggleFlatOnRelease = false;
        return TRUE;
      }

    if ((ev->type() == Event_Paint)||(ev->type() == Event_Enter)||(ev->type() == Event_Leave) ){

      QColorGroup g = QWidget::colorGroup();
      QPainter paint(handle);
      QBrush b = QWidget::backgroundColor();

      if (standalone_menubar)
      {
        if ( style() == WindowsStyle )
          qDrawWinButton( &paint, 0, 0, handle->width(), handle->height(),
                          g, false );
        else
          qDrawShadePanel( &paint, 0, 0, handle->width(), handle->height(),
                           g, false, 1, 0L );

        if (miniGo)
        {
          int dx = ( handle->width() - miniGo->width() ) / 2;
          int dy = ( handle->height() - miniGo->height() ) / 2;
          paint.drawPixmap( dx, dy, *miniGo);
        }

        return true;
      }

      int stipple_height;
      if (ev->type() == Event_Enter && highlight) // highlight? - sven
        b = kapp->selectColor; // this is much more logical then
                               // the hardwired value used before!!
      //else
      //  b = QWidget::backgroundColor();
      int h = handle->height();
      int w = handle->width();

      if (style() == MotifStyle) //Motif style handle
      {
        if (position == Flat)
        {
          qDrawShadePanel( &paint, 0, 0, w, 9,
			   g , FALSE, 1, &b );
	  paint.setPen( g.light() );
          stipple_height = 3;
          while ( stipple_height < w-4 ) {
            paint.drawPoint( stipple_height+1, 1);
            paint.drawPoint( stipple_height, 4 );
            stipple_height+=3;
          }
          paint.setPen( g.dark() );
          stipple_height = 4;
          while ( stipple_height < w-4 ) {
            paint.drawPoint( stipple_height+1, 2 );
            paint.drawPoint( stipple_height, 5);
            stipple_height+=3;
	  }
	  paint.drawLine( 1, 9, w, 9);
          return true;
        }
        qDrawShadePanel( &paint, 0, 0, 9, h,
                           g , FALSE, 1, &b );


        paint.setPen( g.light() );
        stipple_height = 3;
        while ( stipple_height < h-4 ) {
          paint.drawPoint( 1, stipple_height+1);
          paint.drawPoint( 4, stipple_height);
          stipple_height+=3;
        }
        paint.setPen( g.dark() );
        stipple_height = 4;
        while ( stipple_height < h-4 ) {
          paint.drawPoint( 2, stipple_height+1);
          paint.drawPoint( 5, stipple_height);
          stipple_height+=3;
        }
        return TRUE;
      }
      else //windows style handle
      {
        if (position == Flat)
        {
          qDrawPlainRect ( &paint, 0, 0, handle->width(), 9,
                           g.mid(), 0, &b);

          h = 16;
          paint.setClipRect(2, 0, w-4, 6);
          paint.setPen( g.light() );
          int a = 0-h;
          while (a <= w+h)
          {
            paint.drawLine(w-a, h, w-a+h, 0);
            paint.drawLine(w-a+1, h, w-a+1+h, 0);
            a +=6;
          }
          a = 0-h;
          paint.setPen( g.dark() );
          while (a <= w+h)
          {
            paint.drawLine(w-a+2, h, w-a+2+h, 0);
            paint.drawLine(w-a+3, h, w-a+3+h, 0);
            a +=6;
          }
         return true;
        }

        qDrawPlainRect ( &paint, 0, 0, 6, handle->height(),
                         g.mid(), 0, &b);
        w=6;
        paint.setClipRect(0, 2, w, h-4);

        paint.setPen( g.light() );
        int a=0-w;
        while (a <= h+5)
        {
          paint.drawLine(0, h-a, h, 0-a);
          paint.drawLine(0, h-a+1, h, 0-a+1);
          a +=6;
        }
        a=0-w;
        paint.setPen( g.dark() );
        while (a <= h+5)
        {
          paint.drawLine(0, h-a+2, h, 0-a+2);
          paint.drawLine(0, h-a+3, h, 0-a+3);
          a +=6;
        }
        return TRUE;
      }
    }
  }
  return FALSE;
}

void KMenuBar::enableMoving(bool flag)
{
  moving = flag;
}

void KMenuBar::setMenuBarPos(menuPosition mpos)
{
    if (position == FloatingSystem && standalone_menubar == true) {
	return; // Ignore positioning of Mac menubar
    }

  if (position != mpos)
   {
     if (mpos == Floating || mpos == FloatingSystem)
      {
	  lastPosition = position;
	  position = mpos;
	  oldX = x();
	  oldY = y();
	  if ( mpos == FloatingSystem && position == Floating)
	      lastPosition = Top;
	  else
	      oldWFlags = getWFlags();
	  QPoint p = mapToGlobal(QPoint(0,0));
	  parentOffset = pos();
	  hide();
	  recreate(0, 0,
		   p, FALSE);
	  XSetTransientForHint( qt_xdisplay(), winId(), Parent->topLevelWidget()->winId());
	  if (mpos == FloatingSystem)
	      KWM::setDecoration(winId(), KWM::noDecoration | KWM::standaloneMenuBar | KWM::noFocus);
	  else
	      KWM::setDecoration(winId(), KWM::tinyDecoration | KWM::noFocus);
	  KWM::moveToDesktop(winId(), KWM::desktop(Parent->winId()));
	  setCaption(""); // this triggers a qt bug
	  if (title){
	      setCaption(title);
	  }
	  else {
	      QString s = Parent->caption();
	      s.append(" [menu]");
	      setCaption(s);
	  }
	  setFrameStyle( NoFrame);
	  if (mpos == FloatingSystem)
	      {
		  if (style() == MotifStyle)
		      menu->setFrameStyle(Panel | Raised);
		  else
		      menu->setFrameStyle(WinPanel | Raised) ;
	      }
	  else
	      menu->setFrameStyle( NoFrame) ;
	  context->changeItem (klocale->translate("UnFloat"), CONTEXT_FLOAT);
	
	

	if (mpos == FloatingSystem) {
	    QRect r =  KWM::getWindowRegion(KWM::currentDesktop());
	    setGeometry(r.x(),(r.y()-1)<=0?-2:r.y()-1, r.width(), // check panel top
			heightForWidth(r.width()));
	    int dim = fontMetrics().height();
	    if (!miniGo)
		miniGo = new QPixmap(kapp->kde_datadir() + "/kpanel/pics/mini/go.xpm");
	
	    QPixmap px(KWM::miniIcon(Parent->winId(), dim, dim));
	    if (!px.isNull())
		*miniGo = px;
	    show();
	}

        emit moved (mpos);
//        if (style() == MotifStyle)
//          menu->setMouseTracking(false);
//        else
//          menu->setMouseTracking(true);
//----------------------------------------------------------------------------
        // Repair repaired Accelerators (Eh, those Trolls...)
        QObjectList	*accelerators = queryList( "QAccel" );
        QObjectListIt it( *accelerators );
        QObject *obj;
        while ( (obj=it.current()) != 0 )
        {
          ++it;
          this->removeEventFilter(obj); //Man...
          disconnect( this, SIGNAL(destroyed()), obj, SLOT(tlwDestroyed()));

          Parent->installEventFilter(obj);
          connect( Parent, SIGNAL(destroyed()), obj, SLOT(tlwDestroyed()));
        }
//----------------------------------------------------------------------------

        return;
      }
     else if (position == Floating || position == FloatingSystem) // was floating
      {
        position = mpos;
        hide();
	setFrameStyle(NoFrame);
	menu->setFrameStyle(oldMenuFrameStyle);
        recreate(Parent, oldWFlags, QPoint(oldX, oldY), TRUE);
        context->changeItem (klocale->translate("Float"), CONTEXT_FLOAT);
        emit moved (mpos);
        if (style() == MotifStyle)
        {
//          menu->setMouseTracking(false);
          menu->setFrameStyle(Panel | Raised);
        }
        else
        {
//          menu->setMouseTracking(true);
          menu->setFrameStyle(NoFrame);
        }

        return;
      }
     else
      {
        if (mpos == Flat)
        {
          setFlat (true);
          return;
        }
        enableFloating (true);
        position = mpos;
        emit moved ( mpos );
        return;
      }
   }
}

void KMenuBar::enableFloating (bool arrrrrrgh)
{
  context->setItemEnabled (CONTEXT_FLOAT, arrrrrrgh);
}

/*******************************************************/

uint KMenuBar::count()
{
  return menu->count();
}

int KMenuBar::insertItem(const char *text,
               const QObject *receiver, const char *member,
               int accel)
{
  return menu->insertItem(text, receiver, member, accel);
}

int KMenuBar::insertItem( const char *text, int id, int index)
{
  return menu->insertItem(text, id, index);
}
int KMenuBar::insertItem( const char *text, QPopupMenu *popup,
                          int id, int index)
{
  return menu->insertItem(text, popup, id, index);
}
/* Later - should be virtual and I can't do it right now - sven
int KMenuBar::insertItem (const QPixmap &pixmap, const QObject *receiver,
                          const char *member, int accel)
{
  return->menu->insertItem (pixmap, receiver, member, accel);
}
*/
void KMenuBar::insertSeparator(int index)
{
  menu->insertSeparator(index);
}

void KMenuBar::removeItem( int id )
{
  menu->removeItem(id);
}
void KMenuBar::removeItemAt( int index )
{
  menu->removeItemAt(index);
}
void KMenuBar::clear()
{
  menu->clear();
}

int KMenuBar::accel( int id )
{
  return menu->accel(id);
}
void KMenuBar::setAccel( int key, int id )
{
  menu->setAccel(key, id);
}

const char *KMenuBar::text( int id )
{
  return menu->text(id);
}

void KMenuBar::changeItem( const char *text, int id )
{
  menu->changeItem(text, id);
}

void KMenuBar::setItemChecked(int id , bool flag)
{
  menu->setItemChecked(id , flag);
}

void KMenuBar::setItemEnabled(int id, bool flag)
{
  menu->setItemEnabled(id, flag);
}


void KMenuBar::slotActivated (int id)
{
  emit activated(id);
}

void KMenuBar::slotHighlighted (int id)
{
  emit highlighted (id);
}

void KMenuBar::setFlat (bool flag)
{

#define also

  if (flag && ((position == Floating  || position == FloatingSystem) && position == Flat))
    return;
  if (!flag && (position != Flat))
    also return;


  if (flag) //flat
  {
    lastPosition = position; // test float. I did and it works by miracle!?
    //debug ("Flat");
    position = Flat;
    resize(30, 10);
    handle->resize(30, 10);
    frame->move(100, 100); // move menubar out of sight
    enableFloating(false);
    emit moved(Flat); // KTM will block this->updateRects
  }
  else //unflat
  {
    //debug ("Unflat");
    setMenuBarPos(lastPosition);
    enableFloating(true);
    emit moved (position); // KTM will call this->updateRects
  }
}
#include "kmenubar.moc"

--- NEW FILE: keditcl.h ---
/*
  $Id: keditcl.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $

  KEdit, a simple text editor for the KDE project

  Copyright (C) 1996 Bernd Johannes Wuebben
                     wuebben at math.cornell.edu

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
  */


#ifndef __KEDIT_H__
#define __KEDIT_H__

#include <qpopupmenu.h>
#include <qmenubar.h>
#include <qstrlist.h>
#include <qapplication.h>
#include <qkeycode.h>
#include <qaccel.h>
#include <qregexp.h>
#include <qobject.h>
#include <qmultilinedit.h>
#include <qlineedit.h>
#include <qradiobutton.h>
#include <qfiledialog.h>
#include <qcheckbox.h>
#include <qmessagebox.h>
#include <qcombobox.h>
#include <qpushbutton.h>
#include <qgroupbox.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <qkeycode.h>
#include <qfileinfo.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <ctype.h>
#include <pwd.h>

#include <kapp.h>
#include <kfontdialog.h>

///
class KIntLineEdit : public QLineEdit
{
  Q_OBJECT

public:
  KIntLineEdit( QWidget *parent = 0, const char *name = 0 )
    : QLineEdit( parent, name ) {};

  int getValue() { return atoi( text() ); };

protected:
	
  void keyPressEvent( QKeyEvent *e ) {
    char key = e->ascii();

    if( isdigit( key )
	|| ( e->key() == Key_Return) || ( e->key() == Key_Enter    )
	|| ( e->key() == Key_Delete) || ( e->key() == Key_Backspace)
	|| ( e->key() == Key_Left  ) || ( e->key() == Key_Right    )){

      QLineEdit::keyPressEvent( e );
      return;
    } else {
      e->ignore();
      return;
    }
  };
};

///
class KEdGotoLine : public QDialog
{
	Q_OBJECT

public:

	KEdGotoLine( QWidget *parent = 0, const char *name = 0 );

	int getLineNumber();
	KIntLineEdit *lineNum;

private:
	QPushButton *ok, *cancel;
	QGroupBox *frame;
	void resizeEvent(QResizeEvent *);
	void focusInEvent(QFocusEvent *);

public slots:

	void selected( int );
};

///
class KEdSrch : public QDialog
{
    Q_OBJECT

public:

    KEdSrch ( QWidget *parent = 0, const char *name=0);

    QString getText();
    void setText(QString string);
    bool case_sensitive();
    bool get_direction();

protected:
    void focusInEvent( QFocusEvent *);
    void resizeEvent(QResizeEvent *);

private:

    QPushButton *ok, *cancel;
    QCheckBox *sensitive;
    QCheckBox *direction;
    QGroupBox *frame1;
    QLineEdit *value;

signals:

    void search_signal();
    void search_done_signal();

public slots:

    void done_slot();
    void ok_slot();

};

///
class KEdReplace : public QDialog
{
    Q_OBJECT

public:

    KEdReplace ( QWidget *parent = 0, const char *name=0);

    QString 	getText();
    QString 	getReplaceText();
    void 	setText(QString);
    QLineEdit 	*value;
    QLineEdit 	*replace_value;
    QLabel 	*label;
    bool 	case_sensitive();
    bool 	get_direction();

protected:

    void focusInEvent( QFocusEvent *);
    void resizeEvent ( QResizeEvent *);

private:

    QPushButton *ok, *cancel, *replace, *replace_all;
    QCheckBox 	*sensitive;
    QCheckBox 	*direction;
    QGroupBox 	*frame1;


signals:

    void replace_signal();
    void find_signal();
    void replace_all_signal();
    void replace_done_signal();

public slots:

    void done_slot();
    void replace_slot();
    void replace_all_slot();
    void ok_slot();

};


///
class KEdit : public QMultiLineEdit
{
    Q_OBJECT

public:

    KEdit (KApplication *a=NULL,QWidget *parent=NULL, const char *name=NULL,
	   const char *filename=NULL);

    ~KEdit();


    enum { NONE,
	   FORWARD,
	   BACKWARD };

    enum { KEDIT_OK 		= 0,
	   KEDIT_OS_ERROR 	= 1,
	   KEDIT_USER_CANCEL 	= 2 ,
	   KEDIT_RETRY 		= 3,
	   KEDIT_NOPERMISSIONS 	= 4};

    enum { OPEN_READWRITE 	= 1,
	   OPEN_READONLY 	= 2,
	   OPEN_INSERT 		= 4 };


    /// Opens a new untitled document in the text widget
      /** Opens a new untitled document in the text widget The user is given
          a chance to save the current document if the current document has
	  been modified.
       */
    int  	newFile();

    /// Saves the file if necessary under the current file name
      /** Saves the file if necessary under the current file name. If the current file
	name is Untitled, as it is after a call to newFile(), this routing will
	call saveAs().
       */
    int 	doSave();

    /// Saves the file as filename
      /** Saves the file as filename
       */
    int 	doSave( const char *filename );

    /// Allows the user to save the file under a new name
	  /** Allows the user to save the file under a new name
	   */
    int 	saveAs();

    /// Let the user open an new file
    /** This will present an open file dialog and open  the file specified by the user,
        if possible. The return codes are KEDIT_OK, KEDIT_USER_CANCEL and
	KEDIT_OS_ERROR. The user will be given a chance to save the current file if
	it has been modified. mode is one of OPEN_READONLY, OPEN_READWRITE.
	OPEN_READONLY means  that the user will not be able to insert characters
	into the document.
     */
    int 	openFile( int mode );

    /// Lets the user insert a file at the current cursor position
    /** Calling this method will let the user insert a file at the current cursor
        position. Return codes are KEDIT_OK, KEDIT_USER_CANCEL, KDEDIT_OS_ERROR.
    */
    int 	insertFile();

    /// Loads the file filemane in the editor
	/** Loads the file filename into editor. The possible modes are
            OPEN_READONLY, OPEN_READWRITE, OPEN_INSERT.
	    OPEN_READONLY means  that the user will not be able to insert characters
	    into the document. OPEN_INSERT means that the file will be inserted
	    into the current document at the current cursor position.
	   */
    int 	loadFile( QString filename , int mode );


    /// Returns the filename of the current file.
    /** Returns the filename of the currnet file. You can use setName() to set the
        filename of the current file
    */
    QString 	getName();

    /// Sets the filename of the current file.
    /** Sets the filename of the currnet file. You can use getName() to set the
        filename of the current file
    */
    void 	setName( const char *_name );

    /// Returns the currently marked text.
    /** Returns the currently marked text.
     */
    QString 	markedText();

    /// Lets the user select a font and sets the font of the textwidget.
    /** Lets the user select a font and sets the font of the textwidget to that
        selected font.
    */
    void 	selectFont();

    /// Presents a search dialog to the user
    /** Presents a search dialog to the user
     */
    void 	Search();

    /// Repeats the last search specified on the search dialog.
    /** Repeasts the last search specified on the search dialog. If the user
        hasn't searched for anything until now, this method will simply return
	without doing anything.
    */
    int 	repeatSearch();

    /// Presents a Search and Replace Dialog to the User.
    /**  Presents a Search and Replace Dialog to the User.
     */
    void 	Replace();

    /// Presents a "Goto Line" dialog to the User
    /** Presents a "Goto Line" dialog to the User
     */
    void 	doGotoLine();

    /// Returns true if the document has been modified.
    /**Returns true if the document has been modified.
    */
    bool 	isModified();

    /// Toggles the modification status of the document
    /** Toggles the modification status of the document. TRUE = Modified,
        FALSE = UNMODIFIED. Methods such as doSave() rely on this to see whether
	the document needs to be saved.
    */
    void 	toggleModified( bool );

    ///  Sets Indent Mode
    /**  Sets the Indent Mode. TRUE = Indent  mode on, FALSE = Indent mode off.
     */
    void 	setAutoIndentMode( bool );

    /// Returns the Indent Mode
    /** Returns the Indent Mode. TRUE = Indent  mode on, FALSE = Indent mode off.
     */
    bool        AutoIndentMode(){ return autoIndentMode; };

    /// Install a Popup Menue for KEdit.
    /** Install a Popup Menue for KEdit. The Popup Menu will be activated on
        a right mouse button press event.
     */
    void 	installRBPopup( QPopupMenu* );

    /// Return the current Line number
	  /** Returns the current line number, that is the line the cursor is on.
	   */
    int 	currentLine();

    /// Returns the current Column number
	  /** This returns the actual column number the cursor is on. This call differs
	    from QMultiLineEdit::getCursorPosition in that it returns the actual cursor
	    position and not the character position. Use currentLine() and currentColumn()
	    if you want to display the current line or column in the status bar for
	    example.
	    */
    int 	currentColumn();

    /// Returns TRUE if word wrap is on
	   /** Returns TRUE if word wrap is on. You also need to specify the fill column
	       with setFillColumnMode() otherwise wordwrap is not in effect.
	       */
    bool 	WordWrap();

    /// Turn word wrap mode on or off.
	   /** You also need to specify the fill column
	       with setFillColumnMode() otherwise wordwrap is not in effect.
	       */
    void 	setWordWrap(bool );

    /// Returns TRUE if fill column mode is on
	   /**  Returns TRUE if fill column mode is on, that is if the line will
	        be broken automatically when if a character is to be inserted past
		this position.
		*/
    bool 	FillColumnMode();

    /// Set the fill column to column col if line is strictly larger than 0.
	   /**  Set the fill column to column col, if col is strictly larger than 0.
	        If col  is 0, fill column mode is turned off.
	        In fill column mode, the line will
	        be broken automatically at column col, when a character is
		inserted past column col..
		*/
    void  	setFillColumnMode(int line, bool set);

    /// save a backup copy
	  /** If copy is TRUE KEdit will make a backup copy of the document that
	      is being edited on opening it. The backup copy will receive the
	      suffix ~. The default is TRUE.
	    */
    void       saveBackupCopy(bool copy);

    /// set the name of the file
	  /** Sets the name of the file if a file is open.
	    */
    void       setFileName(char* name);

    /// save the current file as 'name'
	  /** saves the current file as 'name'
	    */


    void       saveasfile(char* name);

    /// remove tabs and whitespace on the end of lines during a justify operation
	  /** remove tabs and whitespace on the end of lines during a justify operation
	    */
    void       setReduceWhiteOnJustify(bool reduce);

    bool 	format(QStrList& );
    bool 	format2(QStrList& par, int& upperbound);
    void 	getpar(int line,QStrList& par);
    void 	getpar2(int line,QStrList& par,int& upperbound,QString &prefix);

signals:

    /// This signal is emitted when the document in the textwidget has changed
	  /** This signal is emitted when the document in the textwidget has changed
	   */
    void 	fileChanged();

    ///  This signal is emitted whenever the cursor position changed.
	   /** This signal is emitted whenever the cursor position changed.
	       Use this in conjunction with currentLine(), currentColumn()
	       if you need to know the cursor position.
	       */
    void 	CursorPositionChanged();

    /// This signal is emitted just before saving a file.
	  /** This signal is emitted just before saving a file. Since KEdit calls
	      kapp->processEvents(), you have a chance to let the user know what's 	
	      going to happen.
	   */
    void 	saving();

    /// This signal is emitted just before loading a file.
	  /** This signal is emitted just before loading a file. Since KEdit calls
	      kapp->processEvents(), you have a chance to let the user know what's 	
	      going to happen.
	   */
    void 	loading();

    /// This signal is emitted if the user toggles from overwrite to insert mode
	 /** This signal is emitted if the user toggles from overwrite to insert mode.
	     He can do so by pressing the "Insert" Button on a PC keyboard.
	     */
    void 	toggle_overwrite_signal();




public slots:

    void setModified();

    void search_slot();

    void searchdone_slot();

    void replace_slot();

    void replace_all_slot();

    void replace_search_slot();

    void replacedone_slot();

    void computePosition();


    void repaintAll();


protected:
#if QT_VERSION >= 142
    QTimer* repaintTimer;
#endif

    int 	saveFile();

    int 	doSearch(QString s_pattern, bool case_sensitive,
			 bool regex, bool forward,int line, int col);

    int 	doReplace(QString s_pattern, bool case_sensitive,
			  bool regex, bool forward,int line, int col,bool replace);

    QFileDialog* getFileDialog(const char* captiontext);


protected:

    bool 	eventFilter	 ( QObject *, QEvent * );
    void 	keyPressEvent 	 ( QKeyEvent *  );
    void 	mousePressEvent  ( QMouseEvent* );
    void 	mouseReleaseEvent( QMouseEvent* );
    void 	mouseMoveEvent 	 ( QMouseEvent* );


private:

    void 	setContextSens();
    void        mynewLine();
    QString 	prefixString(QString);


private:

    QString	killbufferstring;
    QWidget     *p_parent;
    QFileDialog *fbox;
    KEdSrch 	*srchdialog;
    KEdReplace 	*replace_dialog;
    KEdGotoLine *gotodialog;
    QPopupMenu  *rb_popup;
    KApplication* mykapp;
    QFileDialog *file_dialog;
    QStrList	par;

    QString 	filename;
    QString     pattern;
    QString     current_directory;

    bool 	modified;
    bool 	autoIndentMode;
    bool 	can_replace;
    bool	killing;
    bool 	killtrue;
    bool 	lastwasanewline;
    bool        reduce_white_on_justify;
    int		cursor_offset;
    int 	edit_mode;
    int 	last_search;
    int 	last_replace;
    int 	replace_all_line;
    int 	replace_all_col;

    int 	line_pos, col_pos;
    bool        fill_column_is_set;
    bool        word_wrap_is_set;
    int         fill_column_value;
    bool        make_backup_copies;

};



#endif

--- NEW FILE: kspinbox.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Andre Fornacon (afc at fh-zwickau.de)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
// -*- c++ -*-
// KSpinBox.h - cycle through a bunch of items
// started: 970506 afo
// [Last modified: 970717 09:51:42 by afo at fh-zwickau.de (Andre Fornacon)]


#ifndef _KSPINBOX_H
#define _KSPINBOX_H

#include <qpushbutton.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qtimer.h>
#include <qstrlist.h>

/// KSpinBox - cycle trough a bunch of items

/** The KSpinBox Widget lets the user cycle trough a bunch of items.
	this class alone doesn't do really usefull things
	it provides the base for things like KNumericSpinBox or
	KListSpinBox.

	You can use it in two ways:

	1. The "is A" Variant : derive a subclass from KSpinBox
	   and implement your own functionality
	
	2. The "has A" Variant : instantiate a KSpinBox object and
	   catch the valueIncreased() and valueDecreased() signals
	   and do what you want in the slots.

*/
class KSpinBox : public QWidget
{
  Q_OBJECT

public:
  /** construct a KSpinBox Widget */
  KSpinBox(QWidget *parent=0,const char *name=0,int align=AlignLeft);
  ~KSpinBox();

  /** get the value shown the text field */
  const char *getValue();

  /** set the value which should be displayed in the text field */
  void setValue(const char *);

  /** query if the user is allowed to edit the values */
  bool isEditable();

  /** decide if the user can edit the values or not */
  void setEditable(bool);

  /** set the alignment of the text field.
	  possible values for align are AlignLeft, AlignCenter, AlignRight */
  void setAlign(int align);

  /** get the alignment of the text field.
	  possible return values AlignLeft, AlignCenter, AlignRight */
  int getAlign();

  QSize sizeHint();
	
  signals:
  void valueIncreased();
  void valueDecreased();

 public slots:
 void slotIncrease();
  void slotDecrease();
	
 protected slots:
 void slotStartIncr();
  void slotStopIncr();
  void slotStartDecr();
  void slotStopDecr();
	
protected:
  void resizeEvent(QResizeEvent *);

  QLabel *_label;
  QLineEdit *_edit;
  QPushButton *_incr,*_decr;	

private:
  bool _editable;
  QTimer *_incrTimer,*_decrTimer;
  int _align;
	
};


/// KNumericSpinBox - cycle trough a range of numeric values

/** The KNumericSpinBox Widget lets you cycle trough a range of numeric
	values. <br>
	you can set the minimum and minimum of the range .
	it's possible to specify the step - the value which is used for
	increment and decrement.
	<p>
	Warning: if you set let the user edit the values through a
	call to setEditable(TRUE) the behaviour is undefined, e.g..
	the range isn't checked
  */

class KNumericSpinBox : public KSpinBox
{
  Q_OBJECT

public:
  /** called if you create a KNumericSpinBox widget */
  KNumericSpinBox(QWidget *parent=0,const char *name=0,int align=AlignLeft);

  /** called if you destroy a KNumericSpinBox widget */
  ~KNumericSpinBox();

  /** set the value which should be displayed in the text field */
  void setValue(int value);

  /** get the value shown in the text field */
  int getValue();

  /** return the current value used for increment and decrement */
  int getStep();
		
  /** set the value used for increment and decrement */
  void setStep(int step);

  /** get the currently allowed range of values */
  void getRange(int &minimum, int &maximum);

  /** set the range allowed range of values */
  void setRange(int minimum, int maximum);

 public slots:
 void slotIncrease();
  void slotDecrease();

private:
  int _step;
  int _min,_max;
};


/// KListSpinBox - cycle trough a supplied list of items

/** The KNumericSpinBox Widget cycles trough a supplied list of items
	you can use it to let the user select things like day of week,
	month' or somethings like that.
	look into testkspinbox.cc for samples
  */

class KListSpinBox : public KSpinBox
{
  Q_OBJECT

public:
  /** called if you create a KListSpinBox widget */
  KListSpinBox(QStrList *list,QWidget *parent=0,const char *name=0,int align=AlignLeft);

  /** called if you destroy a KListSpinBox widget */
  ~KListSpinBox();

  /** set the index of the list item to be shown */
  void setIndex(unsigned int index);

  /** get the index of currently displayed list item */
  unsigned int getIndex();
	
 public slots:
 void slotIncrease();
  void slotDecrease();

private:
  QStrList *_list;
  unsigned int _index;
};


#endif // _KSPINBOX_H

--- NEW FILE: ktmainwindow.cpp ---
/* This file is part of the KDE libraries
    Copyright  (C) 1997 Stephan Kulow (coolo at kde.org)
               (C) 1997 Sven Radej (sven.radej at iname.com)
               (C) 1997 Matthias Ettrich (ettrich at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
[...1007 lines suppressed...]
  if (localKill)
  {
    //debug ("KTM: ACK tb kill, local kill, NOT removed from list");
    return;
  }

  // No dead souls in here.
  const QObject *dyer = sender (); // Who need last rites?

  if (dyer)
  {
    toolbars.removeRef((KToolBar *) dyer); // remove it from the list;
      //debug ("KTM: ACK tb kill, removed from list");
    //else
      //debug ("KTM: ACK tb kill, NOT removed from list");
  }
//  else
    //debug ("KTM: ACK tb kill, dyer zero, NOT removed from list");
}
#include "ktmainwindow.moc"

--- NEW FILE: knewpanner.h ---
// -*- c++ -*-

#ifndef KNEWPANNER_H
#define KNEWPANNER_H

/* This file is part of the KDE libraries
    Copyright (C) 1997 Richard Moore (moorer at cs.man.ac.uk)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qwidget.h>
#include <qframe.h>
#include <qlabel.h>

/**
 * KNewPanner is a simple widget for managing two children which
 * are seperated by a draggable divider. The user can resize both
 * children by moving the bar. You can also label the two children
 * and the labels will be adjusted as the divider is moved.
 *
 * This widget is considerably easier to use than the old one, simply
 * set the minimum and maximum sizes of the two children then call
 * activate(). Note that the widgets to be panned should be children
 * of the panner widget.
 *
 * This widget fixes a number of design
 * problems in the original KPanner class which show up particularly
 * if you try to use it under a layout manager (such as QBoxLayout).
 *
 * PLEASE NOTE: This panner is NOT source or binary compatable with
 * the old one.
 *
 * @version $Id: knewpanner.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
 * @author Richard Moore rich at kde.org
 */
class KNewPanner : public QWidget
{
    Q_OBJECT

public:
    /**
     * Constants used to specify the orientation.
     */
    enum Orientation { Vertical, Horizontal };

    /**
     * Constants used to choose between absolute (pixel) sizes and
     * percentages.
     */
    enum Units { Percent, Absolute };

    /**
     * Construct a KNewPanner widget.
     *
     * @param parent  The parent widget
     * @param name  The name of the panner widget.
     * @param orient  The orientation of the panner, one of the constants
     *   Vertical or Horizontal.
     * @param units  The units in which you want to specify the seperator position. This must be one of the constants Percent or Absolute.
     * @param pos  The initial seperator position in the selected units.
     */
    KNewPanner(QWidget *parent= 0, const char *name= 0,
		 Orientation orient= Vertical, Units units= Percent, int pos= 50);

    /**
     * Clean up
     */
    virtual ~KNewPanner();

  /**
   * Begin managing these two widgets. If you want to set the minimum or
   * maximum sizes of the children then you should do it before calling this
   * method.
   */
  void activate(QWidget *c0, QWidget *c1);

  /**
   * Call this method to restore the panner to it's initial state. This allows you
   * to call activate() a second time with different children.
   */
  void deactivate();

  /**
   * Set the label texts for the two windows, note that they are only shown
   * if you have called showLabels(true).
   */
  void setLabels(const char *text0, const char *text1);

  /**
   * Call this to show or hide the labels. Note that labels are only
   * supported when the panner is oriented vertically. If it is not
   * then calling this method has no effect.
   */
  void showLabels(bool);


  /**
   * @deprecated Use separatorPos() instead.
   */
  int seperatorPos();

  /**
   * @deprecated Use setSeperatorPos() instead.
   */
  void setSeperatorPos(int pos);

  /**
   * @deprecated Use absSeperatorPos() instead.
   */
  int absSeperatorPos();

  /**
   * @deprecated Use setAbsSeperatorPos() instead.
   */
  void setAbsSeperatorPos(int pos, bool do_resize = true);

  /**
   * This gets the current position of the separator in the current
   * units.
   */
  int separatorPos();

  /**
   * This sets the position of the seperator to the specified position.
   * The position is specified in the currently selected units.
   */
  void setSeparatorPos(int pos);

  /**
   * This gets the current position of the separator in absolute 
   * (pixel) units.
   */
  int absSeparatorPos();

  /**
   * This sets the position of the seperator to the specified position.
   * The position is specified in absolute units (pixels) irrespective
   * of the the currently selected units.
   */
  void setAbsSeparatorPos(int pos, bool do_resize = true);

    /**
     * Get the current units.
     */
    Units units();

    /**
     * Set the current units.
     */
    void setUnits(Units);

protected:
    /**
     * This returns the closest valid absolute seperator position to the
     * position specified in the parameter.
     */
    int checkValue(int);

    /**
     * This method handles changes in the panner size, it will automatically resize
     * the child widgets as appropriate.
     */
    void resizeEvent(QResizeEvent *);

  /**
   * Filter the events from the divider
   */
  bool eventFilter(QObject *, QEvent *);

private:
  // The managed children
  QWidget *child0, *child1;

  // Labels of the children
  QLabel *label0, *label1;

  // The height at which the children start
  int startHeight;

  // Have we started yet?
  bool initialised;

  // Should we show labels?
  bool showlabels;

  // The divider widget
  QFrame *divider;

  // The position in pixel units
  int position;
  Units currentunits;
  Orientation orientation;
};

#endif






--- NEW FILE: kbuttonbox.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Mario Weilguni (mweilguni at sime.com)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

/* 
 * KButtonBox class
 *
 * A container widget for buttons. Uses Qt layout control to place the
 * buttons, can handle both vertical and horizontal button placement.
*
 * HISTORY
 *
 * 11/13/98 Reginald Stadlbauer <reggie at kde.org>
 * Now in Qt 1.4x motif default buttons have no extra width/height anymore.
 * So the KButtonBox doesn't add this width/height to default buttons anymore
 * which makes the buttons look better.
 *
 * 01/17/98  Mario Weilguni <mweilguni at sime.com>
 * Fixed a bug in sizeHint()
 * Improved the handling of Motif default buttons
 *
 * 01/09/98  Mario Weilguni <mweilguni at sime.com>
 * The last button was to far right away from the right/bottom border.
 * Fixed this. Removed old code. Buttons get now a minimum width.
 * Programmer may now override minimum width and height of a button.
 *
 */

#include "kbuttonbox.h"

// taken from Qt source
// Reggie: In Qt 1.4x we don't have additional width/height!
const int extraMotifWidth = 0;
const int extraMotifHeight = 0;

const int minButtonWidth = 50;

KButtonBox::KButtonBox(QWidget *parent, int _orientation, 
		       int border, int autoborder) 
  :  QWidget(parent) 
{
  orientation = _orientation;
  _border = border;
  if(autoborder < 0)
    _autoborder = border;
  else
    _autoborder = autoborder;

  buttons.setAutoDelete(TRUE);
}

KButtonBox::~KButtonBox() {
  // an empty destructor is needed for g++ if a class uses
  // a qlist, qarray or similar, otherwise it will not
  // compile
}

QPushButton *KButtonBox::addButton(const char *text, bool noexpand) {
  KButtonBoxItem *item = new KButtonBoxItem;

  item->button = new QPushButton(text, this);
  item->noexpand  = noexpand;
  buttons.append(item);
  item->button->adjustSize();
  
  return item->button;
}

void KButtonBox::addStretch(int scale) {
  if(scale > 0) {
    KButtonBoxItem *item = new KButtonBoxItem;
    item->button = 0;
    item->noexpand  = FALSE;
    item->stretch = scale;  
    buttons.append(item);
  }
}

void KButtonBox::layout() {
  // resize all buttons
  QSize bs = bestButtonSize();

  for(unsigned i = 0; i < buttons.count(); i++) {
    KButtonBoxItem *item = buttons.at(i);
    QPushButton *b = item->button;
    if(b != 0) {
      if(!item->noexpand) {
	if(b->style() == MotifStyle && b->isDefault()) {
	  QSize s = bs;
	  s.setWidth(bs.width() + extraMotifWidth);
	  s.setHeight(bs.height() + extraMotifHeight);
	  b->setFixedSize(s);
	  b->setDefault(TRUE);
	} else {
	  b->setFixedSize(bs);
	}
      } else
	b->setFixedSize(buttonSizeHint(b));
    }
  }  

  setMinimumSize(sizeHint());
}

void KButtonBox::placeButtons() {
  unsigned i;

  if(orientation == HORIZONTAL) {
    // calcualte free size and stretches
    int fs = width() - 2 * _border;
    int stretch = 0;
    for(i = 0; i < buttons.count(); i++) {
      KButtonBoxItem *item = buttons.at(i);
      if(item->button != 0) {
	if(i == buttons.count() - 1)
	  fs -= item->button->width();
	else
	  fs -= item->button->width() + _autoborder;
      } else
	stretch +=item->stretch;
    }

    // distribute buttons
    int x_pos = _border;
    for(i = 0; i < buttons.count(); i++) {
      KButtonBoxItem *item = buttons.at(i);
      if(item->button != 0) {
	QPushButton *b = item->button;
	if(b->style() == MotifStyle && b->isDefault()) {
	  b->move(x_pos + extraMotifWidth/2, 
		  (height() - b->height()) / 2 + extraMotifHeight/2);
	  if(_autoborder < extraMotifWidth/2)
	    x_pos += extraMotifWidth;
	} else
	  b->move(x_pos, (height() - b->height()) / 2);
      
	x_pos += b->width() + _autoborder;
      } else
	x_pos += (int)((((double)fs) * item->stretch) / stretch);
    }
  } else { // VERTICAL
    // calcualte free size and stretches
    int fs = height() - 2 * _border;
    int stretch = 0;
    for(i = 0; i < buttons.count(); i++) {
      KButtonBoxItem *item = buttons.at(i);
      if(item->button != 0) 
	fs -= item->button->height() + _autoborder;
      else
	stretch +=item->stretch;
    }

    // distribute buttons
    int y_pos = _border;
    for(i = 0; i < buttons.count(); i++) {
      KButtonBoxItem *item = buttons.at(i);
      if(item->button != 0) {
	QPushButton *b = item->button;
	if(b->style() == MotifStyle && b->isDefault()) {
	  b->move((width() - b->width()) / 2 + extraMotifWidth/2,
		  y_pos + extraMotifHeight/2);
	  if(_autoborder < extraMotifHeight/2)
	    y_pos += extraMotifHeight;
	} else
	  b->move((width() - b->width()) / 2,
		  y_pos);
      
	y_pos += b->height() + _autoborder;
      } else
	y_pos += (int)((((double)fs) * item->stretch) / stretch);
    }
  }
}

void KButtonBox::resizeEvent(QResizeEvent *) {
  placeButtons();
}

QSize KButtonBox::bestButtonSize() const {
  QSize s(0, 0);
  unsigned i;

  // calculate optimal size
  for(i = 0; i < buttons.count(); i++) {
    KButtonBox *that = (KButtonBox*)this; // to remove the const ;(
    KButtonBoxItem *item = that->buttons.at(i);
    QPushButton *b = item->button;
 
    if(b != 0 && !item->noexpand) {      
      QSize bs = buttonSizeHint(b);

      if(bs.width() > s.width())
	s.setWidth(bs.width());
      if(bs.height() > s.height())
	s.setHeight(bs.height());      
    }
  }

  return s;
}

QSize KButtonBox::sizeHint() const {
  unsigned i, dw;
  bool hasMotifDefault = FALSE;

  if(buttons.count() == 0)
    return QSize(0, 0);
  else {
    dw = 2 * _border;

    QSize bs = bestButtonSize();
    for(i = 0; i < buttons.count(); i++) {
      KButtonBox *that = (KButtonBox*)this;
      KButtonBoxItem *item = that->buttons.at(i);
      QPushButton *b = item->button;
      if(b != 0) {
	hasMotifDefault |= (style() == MotifStyle) && (b->isDefault());

	QSize s;
	if(item->noexpand)
	  s = that->buttonSizeHint(b);
	else
	  s = bs;
	
	if(orientation == HORIZONTAL)
	  dw += s.width();
	else
	  dw += s.height();

	if( i != buttons.count() - 1 )
	  dw += _autoborder;
      }
    }

    if(orientation == HORIZONTAL) {
      if(style() == MotifStyle && hasMotifDefault) 	
	return QSize(dw + extraMotifWidth, 
		     bs.height() + 2 * _border + extraMotifHeight);
      else
	return QSize(dw, bs.height() + 2 * _border);
    } else {
      if(style() == MotifStyle)
	return QSize(bs.width() + 2 * _border + extraMotifWidth, 
		     dw + extraMotifHeight);
      else
	return QSize(bs.width() + 2 * _border, dw);
    }
  }  
}

/*
 * Returns the best size for a button. If a button is less than 
 * minButtonWidth pixels wide, return minButtonWidth pixels 
 * as minimum width
 */
QSize KButtonBox::buttonSizeHint(QPushButton *b) const {
  QSize s = b->sizeHint();  
  QSize ms = b->minimumSize();
  if(s.width() < minButtonWidth)
    s.setWidth(minButtonWidth);

  // allows the programmer to override the settings
  if(ms.width() > s.width())
    s.setWidth(ms.width());
  if(ms.height() > s.height())
    s.setHeight(ms.height());
  
  return s;
}

#include "kbuttonbox.moc"

--- NEW FILE: kurllabel.cpp ---
/**
 * KURLLabel class implementation
 * kurllable.cpp
 *
 * Copyright (C) 1998 Kurt Granroth <granroth at kde.org>
 */
#include "kurllabel.h"

#include <qtooltip.h>
#include <kcursor.h>

KURLLabel::KURLLabel(QWidget *parent, const char* name, WFlags f)
	: QLabel(parent, name, f),
	  m_textAlign(Bottom),
	  m_url(0),
	  m_tipText(0),
	  m_float(false),
	  m_tips(false),
	  m_glow(true),
	  m_underline(true),
	  m_inRegion(false),
	  m_haveCursor(true),
	  m_transparent(false)
{
	/* set the defaults */
	m_hc.setNamedColor("blue");
	m_sc.setNamedColor("red");
	m_bc        = backgroundColor();


	setUseCursor(true);
	setMouseTracking(true);

	m_resetPalette();
}

KURLLabel::~KURLLabel()
{
}

const char* KURLLabel::url() const
{
	return m_url;
}

const char* KURLLabel::text() const
{
	return (const char*)m_text;
}

const QPixmap* KURLLabel::pixmap() const
{
	return &m_pixmap;
}

void KURLLabel::setURL(const char* url)
{
	/* save the input */
	m_url = url;

	/* show the tool tip if we are allowed to */
	if (m_tips)
	{
		if (m_tipText)
			QToolTip::add(this, m_tipText);
		else
			QToolTip::add(this, m_url);
	}
}

void KURLLabel::setTextAlignment(TextAlignment align)
{
	m_textAlign = align;

	if (autoResize())
		adjustSize();
	else
		repaint(true);
}

void KURLLabel::setUseCursor(bool use_cursor, const QCursor* cursor)
{
	/* set the global var */
	m_haveCursor = use_cursor;

	/* if this is false, then use the default cursor */
	if (use_cursor == false)
	{
		m_customCursor = QCursor();
		return;
	}

	/* set the cursor to the user defined one if supplied */
	if (cursor)
	{
		m_customCursor = *cursor;
	}
	else
	{
		/* otherwise, use the "hand" cursor */
		m_customCursor = KCursor::handCursor();
	}
}

void KURLLabel::setTipText(const char* tip)
{
	/* make sure there is something coming in */
	if (!tip)
		return;

	/* assign the input */
	m_tipText = tip;

	/* reset the tooltips if we can */
	if (m_tips)
		QToolTip::add(this, m_tipText);
}

void KURLLabel::setUseTips(bool tips)
{
	/* save the input */
	m_tips = tips;

	/* setup the tool tip if we are ready */
	if (m_tips)
	{
		/* can we use a user tip? */
		if (m_tipText)
			QToolTip::add(this, m_tipText);
		else if (m_url)
			QToolTip::add(this, m_url);
	}
}

void KURLLabel::setFloat(bool do_float)
{
	/* save the input */
	m_float = do_float;
}

void KURLLabel::setFont(const QFont& font)
{
	/* set the underlining */
	QFont new_font = font;
	new_font.setUnderline(m_underline);

	/* use the base setFont to do all the real work */
	QLabel::setFont(new_font);
}

void KURLLabel::setText(const char* text)
{
	/**
	 * we set the underlining now and in setUnderline
	 * and in setFont to cover all the bases.
	 * this allows the user to invoke these functions
	 * in either order.
	 */
	QFont tmp_font = font();
	tmp_font.setUnderline(m_underline);
	setFont(tmp_font);

	/* set the palette to normal (at first)*/
	setPalette(m_nsp);

	/* save a copy of the text for our uses */
	m_text = text;

	/* use the native setText for some processing */
	QLabel::setText(text);

	/* if we don't have a decent URL, set it equal to our text */
	if (m_url == 0)
		m_url = text;

	/* show the tool tip if we are allowed to */
	if (m_tips)
	{
		if (m_tipText)
			QToolTip::add(this, m_tipText);
		else
			QToolTip::add(this, m_url);
	}
}

void KURLLabel::setAltPixmap(const QPixmap& pixmap)
{
	/* set the "alt" pixmap */
	m_altPixmap = pixmap;
}

void KURLLabel::setPixmap(const QPixmap& pixmap)
{
	/* save a copy of the pixmap for use later */
	m_pixmap = pixmap;

	/* let the base setPixmap do all the work */
	QLabel::setPixmap(pixmap);
}

void KURLLabel::setMovie(const QMovie& movie)
{
	/* save a copy of the movie */
	m_movie = movie;

	/* let the base function do all the work */
	QLabel::setMovie(movie);
}

void KURLLabel::setGlow(bool glow)
{
	/* save the input */
	m_glow = glow;
}

void KURLLabel::setUnderline(bool underline)
{
	/* save the input */
	m_underline = underline;

	/* turn on or off the underlining */
	QFont tmp_font = font();
	tmp_font.setUnderline(m_underline);
	setFont(tmp_font);
}

void KURLLabel::setHighlightedColor(const QColor& high)
{
	/* set the new color */
	m_hc = high;

	/* reset the palette to display the new color */
	m_resetPalette();
	setPalette(m_nsp);
}

void KURLLabel::setHighlightedColor(const char* high)
{
	/* set the new color */
	m_hc.setNamedColor(high);

	/* reset the palette to display the new color */
	m_resetPalette();
	setPalette(m_nsp);
}

void KURLLabel::setSelectedColor(const QColor& selected)
{
	/* set the new color */
	m_sc = selected;

	/* reset the palette to display the new color */
	m_resetPalette();
}

void KURLLabel::setSelectedColor(const char* selected)
{
	/* set the new color */
	m_sc.setNamedColor(selected);

	/* reset the palette to display the new color */
	m_resetPalette();
}

void KURLLabel::setBackgroundColor(const QColor& back)
{
	/* set the new color */
	m_bc = back;

	/* reset the palette to display the new color */
	m_resetPalette();
	setPalette(m_nsp);
}

void KURLLabel::setBackgroundColor(const char* back)
{
	/* set the new color */
	m_bc.setNamedColor(back);

	/* reset the palette to display the new color */
	m_resetPalette();
	setPalette(m_nsp);
}

QSize KURLLabel::sizeHint() const
{
	int x_min, x_max, y_min, y_max;

	/* get the bounding rectangles for text and pixmap */
	QRect text_rect = m_textRect();
	QRect pixmap_rect = m_pixmapRect();

	/* get the outer x coordinates */
	x_min = QMIN(text_rect.topLeft().x(), pixmap_rect.topLeft().x());
	x_max = QMAX(text_rect.topRight().x(), pixmap_rect.topRight().x());

	/* get the outer y coordinates */
	y_min = QMIN(text_rect.topLeft().y(), pixmap_rect.topLeft().y());
	y_max = QMAX(text_rect.bottomLeft().y(), pixmap_rect.bottomLeft().y());

	return QSize((x_max - x_min)+1, (y_max - y_min)+1);
}

void KURLLabel::mouseMoveEvent(QMouseEvent *event)
{
	/* get the boundries of the text and/or pixmap */
	QRect text_rect = m_textRect();
	QRect pixmap_text = m_pixmapRect();
	int tx_min = text_rect.topLeft().x();
	int ty_min = text_rect.topLeft().y();
	int tx_max = text_rect.bottomRight().x();
	int ty_max = text_rect.bottomRight().y();
	int px_min = pixmap_text.topLeft().x();
	int py_min = pixmap_text.topLeft().y();
	int px_max = pixmap_text.bottomRight().x();
	int py_max = pixmap_text.bottomRight().y();

	/* process this event only if we are within the text boundry */
	if (((event->x() > tx_min) && (event->x() < tx_max) &&
	    (event->y() > ty_min) && (event->y() < ty_max)) ||
	   ((event->x() > px_min) && (event->x() < px_max) &&
	    (event->y() > py_min) && (event->y() < py_max))) 
	{
		/**
		 * if we were not within the region before, then this is
		 * a enter event
		 */
		if (m_inRegion == false)
		{
			m_inRegion = true;
			m_enterEvent();
		}
	}
	/* if we were in the region before, then this is a leave event */
	else if (m_inRegion == true)
	{
		m_inRegion = false;
		m_leaveEvent();
	}
}


void KURLLabel::m_enterEvent()
{
	/* emit this signal with our URL*/
	emit(enteredURL(m_url));
	emit(enteredURL());

	/* check if we have an "alt" pixmap */
	if (!m_altPixmap.isNull() && (m_float || m_glow))
	{
		/* display it instead of the regular pixmap */
		m_origPixmap = m_pixmap;
		m_pixmap = m_altPixmap;
	}

	/* if we are using a custom cursor, use it */
	if (m_haveCursor);
		setCursor(m_customCursor);

	/* check if we are in float mode */
	if (m_float)
	{
		/* turn on underlining */
		QFont tmp_font = font();
		tmp_font.setUnderline(true);
		QLabel::setFont(tmp_font);

		/* and "glow" this */
		setPalette(m_sp);
	}
	else
	/* if we are in "glow" mode, turn on the selected palette */
	if (m_glow)
		setPalette(m_sp);
}

void KURLLabel::leaveEvent(QEvent*)
{
	/* let m_leaveEvent handle this if we are in the region */
	if (m_inRegion)
	{
		m_inRegion = false;
		m_leaveEvent();
	}
}

void KURLLabel::m_leaveEvent()
{
	/* emit this signal with our URL*/
	emit(leftURL(m_url));
	emit(leftURL());

	/* check if we have an "alt" pixmap */
	if (!m_altPixmap.isNull() && (m_float || m_glow))
	{
		/* change back to the original */
		m_pixmap = m_origPixmap;
	}

	/* if we are using a custom cursor, set it back */
	if (m_haveCursor)
		setCursor(QCursor());

	/* check if we are in float mode */
	if (m_float)
	{
		/* switch underlining back to original state */
		QFont tmp_font = font();
		tmp_font.setUnderline(m_underline);
		QLabel::setFont(tmp_font);

		/* set palette back to normal*/
		setPalette(m_nsp);
	}
	else
	/* if we are in "glow" mode, turn off the selected palette */
	if (m_glow)
		setPalette(m_nsp);
} 

void KURLLabel::mousePressEvent(QMouseEvent *event)
{
	if (m_inRegion)
	{
		/* set the palette to "selected"*/
		setPalette(m_sp);

		/* select the pixmap only if there is one */
		if (!m_pixmap.isNull())
		{
			/* save the original pixmap */
			m_unselPixmap = m_pixmap;

			/* select the pixmap */
			QBrush b(m_sc, Dense4Pattern);
			QPainter p(&m_pixmap);
			p.fillRect(0, 0, m_pixmap.width(), m_pixmap.height(), b);
		}

		/**
		 * set the timer for 1/2 second.  this allows time
		 * to show that this is selected
		 */
		startTimer(500);

		/**
		 * emit the proper signal based on which button the
		 * user clicked
		 */
		switch (event->button())
		{
			case LeftButton:
				emit(leftClickedURL(m_url));
				emit(leftClickedURL());
				break;
			case RightButton:
				emit(rightClickedURL(m_url));
				emit(rightClickedURL());
				break;
			case MidButton:
				emit(middleClickedURL(m_url));
				emit(middleClickedURL());
				break;
		}
	}
}

void KURLLabel::timerEvent(QTimerEvent *event)
{
	/* reset the the palette to normal */
	setPalette(m_nsp);

	if (!m_unselPixmap.isNull())
	{
		/* redraw the original pixmap */
		QPainter p(&m_pixmap);
		p.drawPixmap(0, 0, m_unselPixmap);
	}

	/* kill the timer */
	killTimer(event->timerId());
}

void KURLLabel::m_resetPalette()
{
	/* reset the palette with any colors that have changed */
	m_nsp.setNormal(
		QColorGroup(
			m_hc,
			m_bc,
			palette().normal().light(),
			palette().normal().dark(),
			palette().normal().mid(),
			m_hc,
			palette().normal().base()
		)
	);
	m_sp.setNormal(
		QColorGroup(
			m_sc,
			m_bc,
			palette().normal().light(),
			palette().normal().dark(),
			palette().normal().mid(),
			m_sc,
			palette().normal().base()
		)
	);
}

QRect KURLLabel::m_textRect() const
{
	int x_min = 0, y_min = 0;
	int pixmap_width = 0, pixmap_height = 0;

	/* get the pixmap info if it exists */
	if (!m_pixmap.isNull())
	{
		pixmap_height = m_pixmap.height();
		pixmap_width = m_pixmap.width();
	}

	/* return 0 if there is no text */
	if (m_text.isEmpty())
		return QRect(0, 0, 0, 0);

	/**
	 * calculate the boundry rect for the text based on the
	 * text metrics and the current alignment
	 */
	QFontMetrics fm(font());
	if (alignment() & AlignHCenter)
	{
		switch (m_textAlign)
		{
			case Bottom:
			case Top:
				if (autoResize())
					x_min = (pixmap_width > fm.width(m_text)) ? 
						         (pixmap_width - fm.width(m_text)) / 2 : 0;
				else
					x_min = (width() - fm.width(m_text)) / 2;
				break;
			case Left:
				if (autoResize())
					x_min = 0;
				else
					x_min = (width() - fm.width(m_text) - pixmap_width) / 2;
				break;
			case Right:
				if (autoResize())
					x_min = pixmap_width;
				else
					x_min = (width() - fm.width(m_text) + pixmap_width) / 2;
				break;
		}
	}

	if (alignment() & AlignVCenter)
	{
		switch (m_textAlign)
		{
			case Bottom:
				if (autoResize())
					y_min = pixmap_height;
				else
					y_min = (height() + pixmap_height - fm.height()) / 2;
				break;
			case Top:
				if (autoResize())
					y_min = 0;
				else
					y_min = ((height() - pixmap_height - fm.height()) / 2) + 3;
				break;
			case Left:
			case Right:
				y_min = (height() - fm.height()) / 2;
				break;
		}
	}

	if (alignment() & AlignLeft)
	{
		switch (m_textAlign)
		{
			case Top:
			case Bottom:
			case Left:
				x_min = 0;
				break;
			case Right:
				x_min = pixmap_width;
				break;
		}
	}	

	if (alignment() & AlignTop)
	{
		switch (m_textAlign)
		{
			case Top:
			case Left:
			case Right:
				y_min = 0;
				break;
			case Bottom:
				y_min = pixmap_height;
				break;
		}
	}

	if (alignment() & AlignRight)
	{
		switch (m_textAlign)
		{
			case Top:
			case Bottom:
			case Right:
				x_min = width() - fm.width(m_text);
				break;
			case Left:
				x_min = width() - pixmap_width - fm.width(m_text);
				break;
		}
	}

	if (alignment() & AlignBottom)
	{
		switch (m_textAlign)
		{
			case Top:
				y_min = height() - pixmap_height - fm.height();
				break;
			case Bottom:
			case Right:
			case Left:
				y_min = height() - fm.height();
				break;
		}
	}

	/* construct the bounding rectangle */
	return QRect(x_min, y_min, fm.width(m_text), fm.height());
}

QRect KURLLabel::m_pixmapRect() const
{
	int x_min = 0, y_min = 0;
	int text_width = 0, text_height = 0;

	/* get the text info if necessary */
	if (!m_text.isEmpty())
	{
		QFontMetrics metrics(font());
		text_height = metrics.height();
		text_width = metrics.width(m_text);
	}

	/* return now if there is no pixmap */
	if (m_pixmap.isNull())
		return QRect(0, 0, 0, 0);

	/**
	 * calculate the boundry rect for the pixmap based on its
	 * size and the current alignment
	 */
	if (alignment() & AlignHCenter)
	{
		switch (m_textAlign)
		{
			case Bottom:
			case Top:
				if (autoResize())
					x_min = m_pixmap.width() > text_width ? 
					            0 : (text_width - m_pixmap.width()) / 2;
				else
					x_min = (width() - m_pixmap.width()) / 2;
				break;
			case Left:
				if (autoResize())
					x_min = text_width;
				else
					x_min = (width() - m_pixmap.width() + text_width) / 2;
				break;
			case Right:
				if (autoResize())
					x_min = 0;
				else
					x_min = (width() - m_pixmap.width() - text_width) / 2;
				break;
		}
	}

	if (alignment() & AlignVCenter)
	{
		switch (m_textAlign)
		{
			case Bottom:
				if (autoResize())
					y_min = 0;
				else
					y_min = (height() - m_pixmap.height() - text_height) / 2;
				break;
			case Top:
				if (autoResize())
					y_min = text_height;
				else
					y_min = (height() - m_pixmap.height() + text_height) / 2;
				break;
			case Left:
			case Right:
				if (autoResize())
					y_min = 0;
				else
					y_min = (height() - m_pixmap.height()) / 2;
				break;
		}
	}

	if (alignment() & AlignLeft)
	{
		switch (m_textAlign)
		{
			case Left:
				x_min = text_width;
				break;
			case Right:
			case Top:
			case Bottom:
				x_min = 0;
		}
	}

	if (alignment() & AlignTop)
	{
		switch (m_textAlign)
		{
			case Top:
				y_min = text_height;
				break;
			case Left:
			case Right:
			case Bottom:
				y_min = 0;
				break;
		}
	}

	if (alignment() & AlignRight)
	{
		switch (m_textAlign)
		{
			case Bottom:
			case Top:
			case Left:
				x_min = width() - m_pixmap.width();
				break;
			case Right:
				x_min = width() - m_pixmap.width() - text_width;
				break;
		}
	}

	if (alignment() & AlignBottom)
	{
		switch (m_textAlign)
		{
			case Top:
			case Left:
			case Right:
				y_min = height() - m_pixmap.height();
				break;
			case Bottom:
				y_min = height() - m_pixmap.height() - text_height;
				break;
		}
	}

	/* construct the bounding rectangle */
	return QRect(x_min, y_min, m_pixmap.width(), m_pixmap.height());
}

void KURLLabel::drawContents(QPainter* p)
{
	/* get the bounding rectangles for both the text and pixmap */
	QRect text_rect = m_textRect();
	QRect pixmap_rect = m_pixmapRect();

	/* draw the text only if it is not null */
	if (!m_text.isEmpty())
		p->drawText(text_rect.bottomLeft().x(), text_rect.bottomLeft().y()-3,
		            m_text);

	/* draw the pixmap only if it is not null */
	if (!m_pixmap.isNull())
	{
		p->drawPixmap(pixmap_rect.topLeft().x(), pixmap_rect.topLeft().y(),
		              m_pixmap);
	}
}

void KURLLabel::setTransparentMode(bool state)
{
	m_transparent = state;
	setBackgroundMode(state ? NoBackground : PaletteBackground); 
}

void KURLLabel::paintEvent(QPaintEvent*)
{ // Mirko Sucker, 1998/11/16:
	QPen pen;
	QPainter paint(this);
	// -----
	if(m_transparent && parentWidget()!=0)
	{
		QPixmap bg(width(), height());
		// -----
		bg.fill(parentWidget(), mapToParent(QPoint(0, 0)));
		paint.drawPixmap(0, 0, bg);
	}
	drawFrame(&paint);
	drawContents(&paint);
	paint.end();
}
#include "kurllabel.moc"

--- NEW FILE: knotebook.h ---
/*  This file is part of the KDE Libraries
    Copyright (C) 1998 Thomas Tanghus (tanghus at earthling.net)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/  

#ifndef __KNOTEBOOK_H
#define __KNOTEBOOK_H

#define KNOTEBOOK_VERSION_MAJOR 0
#define KNOTEBOOK_VERSION_MINOR 20
#define KNOTEBOOK_VERSION (KNOTEBOOK_VERSION_MAJOR * 10) + KNOTEBOOK_VERSION_MINOR

#ifndef KDE_KDIRECTIONBUTTON
#define KDE_KDIRECTIONBUTTON
#endif
#ifndef KDE_KWIZARD
#define KDE_KWIZARD
#endif
#ifndef KDE_KTABBAR
#define KDE_KTABBAR
#endif

#include <ktabbar.h>
#include <kwizard.h>

struct KNoteBookProtected;

/**
* KNoteBook is a tabbed dialog where each tab can have multiple pages.
* The widget has the advantages of both KTabCtl and QTabDialog plus some more.
*
* Features:
*
* - Multiple pages per tab with previous/next button and optional arrow buttons in the title..
*
* - An optional popup menu which takes you to a specific page in a specific section (tab).
*
* - Easy additions of Ok, Cancel, Default and Help buttons.
*
* - Automatic resizing/repainting/repositioning of buttons. Not like QTabDialog where
* there is always an Ok button.
*
* - Scrollable tab bar.
*
* - Can be used as both modal/non-modal dialog and a child widget.
*
* @short KNoteBook
* @author Thomas Tanghus <tanghus at earthling.net>
* @version 0.3
*/
class KNoteBook : public KDialog
{
        Q_OBJECT
public:
/**
* Constructs a KNoteBook.
*
* A modal notebook can be created like this:
* <pre>
* KNoteBook *nb = new KNoteBook(this, "notebook", true);
* connect(nb, SIGNAL(okclicked()), SLOT(nb->hide()));
* connect(nb, SIGNAL(okclicked()), SLOT(readNewInput()));
* </pre>
*
* A very simple program where the main window is a KNoteBook with one tab
* and one page inserted could look like this:
* <pre>
* int main(int argc, char **argv)
* {
*   KApplication a(argc,argv,"knotebooktest");  // create an application object
*   KNoteBook *nb = new KNoteBook(); // create the notebook
*   nb->setCancelButton();           // add a Cancel button and connect it to the quit() slot
*   QObject::connect( nb, SIGNAL(cancelclicked()), &a, SLOT(quit()) );
* 
*   QTab *tab = new QTab;            // create a QTab to hold the tab data
*   tab->label = "A tab";
*   tab->enabled = true;
*   nb->addTab( tab );
*   QLabel *l = new QLabel(nb);
*   l->setAlignment(AlignCenter);
*   l->setText("This is a QLabel as a page");
*   l->setMinimumSize(400, 300);
*   KWizardPage *p = new KWizardPage;
*   p->w = l;
*   p->title.setNum("A page title");
*   p->enabled = true;
*   nb->addPage( p );
* 
*   a.setMainWidget(nb);
*   nb->adjustSize();
*   nb->show();
*   return a.exec();
* }
</pre>
* @see QDialog::QDialog
*
* @param parent The parent of the notebook.
*
* @param name The internal name.
*
* @param modal If modal is true the notebook wil become a modal dialog.
*
* @param f Window flags.
*/
        KNoteBook(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0);
/**
* Destructor
*/
        ~KNoteBook();
/**
* Adds a new tab to the notebook and creates a new @ref KWizard to hold the pages.
* The tabs are numbered from 0 to n where 0 is the tab first added and n is the
* tab last added. if you add 4 tabs the last tab will be number 3. 
* Subsequent calls to @ref addPage will add pages to this tab  until a new call to addTab().
*
* @param tab The QTab containing the tab data.
*
* @param p The optional KWizardPage containing the page data.If 'p' is not 0 it
* will be added as a new page.
* This is equivalent to @ref addPage (p);
* @return Returns the id of the new tab.
*/
        int addTab(QTab *tab, KWizardPage *p = 0L);
/**
* Adds a new page to the last added tab.
* The pages are numbered from 0 to n where 1 is the page first added and n is the
* page last added. Subsequent calls to @ref addPage will add pages to the last added
* tab until a new call to addTab().
*
* @param p The KWizardPage containing the page data..
*
* @return Returns the id of the new page. The id is relative to the KWizard, NOT
* the KNoteBook.
*/
        int addPage(KWizardPage *p);
/**
* Turn to another tab. This method calls @ref showSection to show the corresponding KWizard.
*
* @param tab The tab to turn to
*/
        void gotoTab(int tab);

        QSize sizeHint() { return minimumSize(); };
        void adjustSize() { resize(sizeHint()); };

/**
* Adds a Cancel button to the bottom of the dialog. The text will be a translated
* version of the string '&Cancel' thereby giving it the shortcut key 'c'.
* If any buttons are added a space will be created at the bottom of the dialog
* to fit the buttons. When clicked the button will emit the @ref cancelclicked signal.
* @see KLocale#translate
*/
        void setCancelButton();
/**
* Adds a Cancel button to the bottom of the dialog.
* @param text A user supplied text to write to the button.
*/
        void setCancelButton(const char *text);
/**
* Adds a Default button to the bottom of the dialog. The text will be a translated
* version of the string '&Default' thereby giving it the shortcut key 'd'.
* If any buttons are added a space will be created at the bottom of the dialog
* to fit the buttons. When clicked the button will emit the @ref defaultclicked signal.
* @see KLocal::translate
*/
        void setDefaultButton();
/**
* Adds a Default button to the bottom of the dialog.
* @param text A user supplied text to write to the button.
*/
        void setDefaultButton(const char *text);
/**
* Adds a Help button to the bottom right of the dialog. The text will be a translated
* version of the string '&Help' thereby giving it the shortcut key 'h'.
* If any buttons are added a space will be created at the bottom of the dialog
* to fit the buttons. When clicked the button will emit the @ref helpclicked signal.
*/
        void setHelpButton();
/**
* Adds a Help button to the bottom of the dialog. This button will generate the
* signal @ref helpclicked where the int is the page to which the help was requested.
* @param text A user supplied text to write to the button.
*/
        void setHelpButton(const char *);
/**
* Adds an Ok button to the bottom right of the dialog. The text will be a translated
* version of the string '&Ok' thereby giving it the shortcut key 'o'.
* If any buttons are added a space will be created at the bottom of the dialog
* to fit the buttons. When clicked the button will emit the @ref okclicked signal.
*/
        void setOkButton();
/**
* Adds an Ok button to the bottom of the dialog. This button will generate the
* signal @ref okclicked where the int is the page to which the help was requested.
* @param text A user supplied text to write to the button.
*/
        void setOkButton(const char *);
/**
* Get Ok button.
* @return Returns the Ok buttonwidget or 0L if no button is added.
*/
        QButton *getOkButton();
/**
* Get Cancel button.
* @return Returns the Cancel buttonwidget or 0L if no button is added.
*/
        QButton *getCancelButton();
/**
* Get Default button.
* @return Returns the Default buttonwidget or 0L if no button is added.
*/
        QButton *getDefaultButton();
/**
* Get Help button.
* @return Returns the Help buttonwidget or 0L if no button is added.
*/
        QButton *getHelpButton();
/**
* Let direction buttons reflect page.
* @param state If state is true the direction buttons (Previous and Next) will have the
* title of the corresponding page.
* @see #directionsReflectsPage
*/
        void setDirectionsReflectsPage(bool state);
/**
* @return Returns whether the direction buttons reflects the title of the corresponding page.
*
* @see #setDirectionsReflectsPage(bool state)
*/
        bool directionsReflectsPage();
/**
* En/Disable the popup menu.
* @param state If state is true a menu containing the pages in the wizard
* will popup when the user RMB-clicks on the page-title.
*/
        void setEnablePopupMenu(bool state);
/**
* Returns whether the menu is enabled or not.
* @return 'true' if the menu is enabled, otherwise 'false'.
*/
        bool enablePopupMenu();
/**
* Get the popup menu.
* @return Returns the handle of the popup menu.
*/
        QPopupMenu *getMenu();
/**
* En/Disable the arrowbuttons.
* @param state If state is true two arrows will appear to the right of the title.
* @see #enableArrowButtons
* @see KWizard#setEnableArrowButtons.
*/
        void setEnableArrowButtons(bool state);
/**
* @return Returns whether the arrow buttons are enabled or not.
* @see #setEnableArrowButtons
* @see KWizard#enableArrowButtons.
*/
        bool enableArrowButtons();
/**
* Returns the handle of the tab bar.
*/
        KTabBar *getTabBar();
/**
* Returns the number of tabs in the notebook.
*/
        int numTabs();
/**
* En/Disable a tab in the notebook. If a tab is disabled it is not selectable
* from the tab bar. If the user reaches a disabled tab by traversing through
* the pages the notebook will jump to the next enabled tab.
*/
        void setTabEnabled(int tab, bool state);
/**
* @return Returns whether the tab is enabled or not.
* @see #setTabEnabled
*/
        bool isTabEnabled(int tab);
/**
* En/Disable a page in a section (tab) in the notebook
* @see KWizard#setPageEnabled
*/
        void setPageEnabled(int tab, int page, bool state);
/**
* @return Returns whether a page in a section (tab) is enabled or not.
* @see #setTabEnabled
*/
        bool isPageEnabled(int tab, int page);

signals:
/**
* This signal is emitted when the user clicks on the Ok button.
*/
        void okclicked();
/**
* This signal is emitted when the user clicks on the Cancel button.
*/
        void cancelclicked();
/**
* This signal is emitted when the user clicks on the Default button.
*/
        void defaultclicked(int);
/**
* This signal is emitted when the user clicks on the Help button.
* The int is the page which was showing when help was requested.
* @see #setHelpButton
*/
        void helpclicked(int);

protected slots:
/**
* Called by @ref gotoTab to show the appropriate KWizard.
*/
        void showSection(int);
/**
* If the menu is enabled by @ref enablePopupMenu this method will let the menu
* popup at 'pos'.
* @internal
*/
        void popupMenu(QPoint pos);
/**
* @internal
*/
        void menuChoice(int);
/**
* @internal
*/
        void menuChoiceRedirect(int);
/**
* @internal
*/
        void directionButton(bool, bool);
/**
* @internal
*/
        void okClicked();
/**
* @internal
*/
        void cancelClicked();
/**
* @internal
*/
        void defaultClicked();
/**
* @internal
*/
        void helpClicked();
/**
* @internal
*/
        void tabScroll( ArrowType );

protected:
/**
* @internal
*/
        void init();
/**
* @internal
*/
        void resizeEvent(QResizeEvent *);
/**
* @internal
*/
        void paintEvent(QPaintEvent *);
/*
 @internal

        bool eventFilter( QObject *, QEvent * );
*/
/**
* @internal
*/
        void setSizes();
/**
* @internal
*/
        QSize childSize();

/**
* @internal
*/
        KNoteBookProtected *pnote;
/**
* @internal
*/
        QList<KWizard> *sections;

};

#endif //  __KNOTEBOOK_H




--- NEW FILE: kled.h ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: kled.cpp ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: keditcl1.cpp ---
 /*

  $Id: keditcl1.cpp,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $

  KEdit, a simple text editor for the KDE project

  Copyright (C) 1997 Bernd Johannes Wuebben
  wuebben at math.cornell.edu

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

[...1825 lines suppressed...]
		gotodialog = new KEdGotoLine( this, "gotodialog" );

	this->clearFocus();

	gotodialog->show();
	// this seems to be not necessary
	// gotodialog->setFocus();
	if( gotodialog->result() ) {
		setCursorPosition( gotodialog->getLineNumber()-1 , 0, FALSE );
		emit CursorPositionChanged();
		setFocus();
	}
}

void  KEdit::setReduceWhiteOnJustify(bool reduce){

  reduce_white_on_justify = reduce;

}
#include "keditcl.moc"

--- NEW FILE: ktopwidget.cpp ---
/* This file is part of the KDE libraries
    Copyright  (C) 1997, 1998 Stephan Kulow (coolo at kde.org)
               (C) 1997, 1998 Sven Radej (sven at lisa.exp.univie.ac.at)
               (C) 1997, 1998 Matthias Ettrich (ettrich at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
    */

 // $Id: ktopwidget.cpp,v 1.1 2006-10-03 11:26:33 dslinux_amadeus Exp $
 // $Log: ktopwidget.cpp,v $
 // Revision 1.1  2006-10-03 11:26:33  dslinux_amadeus
 // adding pristine copy of pixil to HEAD so I can branch from it
 //
 // Revision 1.1  2003/09/08 19:42:11  jasonk
 // Addition of packages directory and associated files.
 //
 // Revision 1.1.1.1  2003/08/07 21:18:33  jasonk
 // Initial import of PIXIL into new cvs repository.
 //
 // Revision 1.1.1.1  2003/06/23 22:04:24  jasonk
 //
 //
 // Revision 1.1.1.1  2000/07/07 16:11:00  jasonk
 // Initial import of ViewML
 //
 // Revision 1.46  1999/01/18 10:57:13  kulow
 // .moc files are back in kdelibs. Built fine here using automake 1.3
 //
 // Revision 1.45  1999/01/15 09:31:32  kulow
 // it's official - kdelibs builds with srcdir != builddir. For this I
 // automocifized it, the generated rules are easier to maintain than
 // selfwritten rules. I have to fight with some bugs of this tool, but
 // generally it's better than keeping them updated by hand.
 //
 // Revision 1.44  1998/08/02 09:31:22  radej
 // sven: added closeEvent to behave like old KTW
 //
 // Revision 1.43  1998/08/01 21:59:29  radej
 // sven: inherits KTMainWindow now. KTW is dead.
 //
 // Revision 1.42  1998/06/18 19:17:02  radej
 // sven: That was kfind bug! And I fixed it there and forgot about it.
 //       No changes but I don't know how to stop this thing.
 //
 // Revision 1.41  1998/06/12 19:39:17  ettrich
 // Matthias: Something I noticed with KLyX
 //
 //
 //     /** Deletes all KTMainWindows. This is a good thing to call before
 //       * an applications wants to exit via kapp->quit(). Rationale: The
 //       * destructors of main windows may want to delete other widgets
 //       * as well. Now, if an application calls kapp->quit() then Qt
 //       * will destroy all widgets in a somewhat random order which may
 //       * result in double-free'ed memory (=segfault). Since not every
 //       * program checks for QApplication::closingDown() before deleting
 //       * a widget, calling KTMainWindow::deleteAll() before is a good
 //       * and proper solution.
 //      */
 //   static void deleteAll();
 //
 //     /** Deletes all KTopLevelWidgets. This is a good thing to call before
 //       * an applications wants to exit via kapp->quit(). Rationale: The
 //       * destructors of main windows may want to delete other widgets
 //       * as well. Now, if an application calls kapp->quit() then Qt
 //       * will destroy all widgets in a somewhat random order which may
 //       * result in double-free'ed memory (=segfault). Since not every
 //       * program checks for QApplication::closingDown() before deleting
 //       * a widget, calling KTopLevelWidgets::deleteAll() before is a good
 //       * and proper solution.
 //       */
 //       static void deleteAll();
 //
 // Revision 1.40  1998/05/10 17:42:00  radej
 // Fixed: two vertical toolbars when window is tall enough to
 // have one under another. All toolbars had with of the first one.
 // Fixedsize mode has even bigger bug. Ugh.
 //
 // Revision 1.39  1998/04/16 18:46:49  radej
 // Removed som debug messages before beta4
 //
 // Revision 1.38  1998/04/16 16:06:48  ettrich
 // Matthias: kfm session management showstopper hopefully fixed
 //
 // Revision 1.37  1998/04/05 18:18:44  radej
 // Reverted to old interface (before Matthias' changes)
 //



#include <ktopwidget.h>
#include <ktopwidget.h>

// a static pointer (too bad we cannot have static objects in libraries)
//QList<KTopLevelWidget>* KTopLevelWidget::memberList = 0L;

KTopLevelWidget::KTopLevelWidget( const char *name )
  : KTMainWindow(name)
{}

KTopLevelWidget::~KTopLevelWidget()
{}

void KTopLevelWidget::closeEvent (QCloseEvent *ev)
{
  ev->accept();
}
#include "ktopwidget.moc"


--- NEW FILE: ktreelist.cpp ---
/* qktstreelist.cpp
-------------------------------------------------------------------
$Id: ktreelist.cpp,v 1.1 2006-10-03 11:26:33 dslinux_amadeus Exp $
  
KTreeList class implementation

Copyright (C) 1996 Keith Brown and KtSoft

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. You should have received a
copy of the GNU Library General Public License along with this program; if
not, write to the Free Software Foundation, Inc, 675 Mass Ave, 
[...1958 lines suppressed...]
		if(!clearing) 
			if(index == currentItem() && index > numRows() - 1)
				setCurrentItem(numRows() - 1);
			
    if(autoU && isVisible())
      repaint();
    setAutoUpdate(autoU);
  }
}

// visits each item, calculates the maximum width  
// and updates QTableView
void KTreeList::updateCellWidth()
{
  int maxW = 0;
  forEveryVisibleItem(&KTreeList::getMaxItemWidth, &maxW);
  setCellWidth(maxW);
}
#include "ktreelist.moc"


--- NEW FILE: kkeydialog.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1998 Mark Donohoe <donohoe at kde.org>
    Copyright (C) 1997 Nicolas Hadacek <hadacek at via.ecp.fr>
    Copyright (C) 1998 Matthias Ettrich <ettrich at kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
[...1063 lines suppressed...]
			
			QString str;
			str.sprintf( i18n(
				"The %s key combination has already been allocated\nto the %s action.\n\nPlease choose a unique key combination."),
				keyName.data(),
				actionName.data() );
				
			QMessageBox::warning( this, i18n("Key conflict"), str.data() );
			
			return TRUE;
		}
		++(*aIt);
	}
	
	//	emit keyChange();
	
	return FALSE;
}
#include "kkeydialog.moc"


--- NEW FILE: kslider.cpp ---
/* This file is part of the KDE libraries
    Copyright (C) 1997-1999 Christian Esken (esken at kde.org)
              (C) 1997      Martin Jones    (mjones at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------------
// KSlider control V2.2
// KSlider now maintained by Christian Esken (esken at kde.org)
// Revision information.
// 1.0 KSlider by Martin R. Jones
// 1.1 All changes now by Christian Esken: sanity checks ( checkWidth() ).
// 1.2 Implemented rangeChange()
// 1.3 Reworked drawArrow(). For avoiding paint problems with some servers, I
//     am now painting the arrow with "precise" lines.
// 2.0 Now KSlider is a derivation of QSlider
// 2.1 Cleanups. Replacing eraseRect() by fillRect(). I would have thought,
//     eraseRect() would use BackgroundColor, but it doesn't.
// 2.2 Cleaning up and inline documentantiaon. Correcting drawing of
//     vertical slider.

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qpainter.h>
#include <qdrawutil.h>

#include "kslider.h"
#include "kslider.h"

#define ARROW_LENGTH	13

KSlider::KSlider( QWidget *parent, const char *name )
  : QSlider( parent, name )
{
  QSlider::setTickmarks(Below);
  isFocussed = false;
  update();
}

KSlider::KSlider( Orientation o, QWidget *parent, const char *name )
  : QSlider( o, parent, name )
{
  QSlider::setTickmarks(Below);
  isFocussed = false;
  update();
}

KSlider::KSlider( int _minValue, int _maxValue, int _Step, int _value,
		  Orientation o, QWidget *parent, const char *name )
  : QSlider( _minValue, _maxValue, _Step, _value, o,
             parent, name )
{
  // We always have TickMarks
  if ( orientation() == QSlider::Vertical) {
    QSlider::setTickmarks(Right);
  }
  else
    QSlider::setTickmarks(Below);
  isFocussed = false;
  update();
}



void KSlider::drawShadeLine( QPainter *painter )
{
  if ( orientation() == QSlider::Vertical )
    qDrawShadeLine(painter, 5, 3, 5, height()-3, colorGroup(), true, 1, 2);
  else
    qDrawShadeLine(painter, 3, 5, width()-3, 5, colorGroup(), true, 1, 2);
}


void KSlider::drawFocusBar(QPainter *painter, const QRect & )
{
/*
   if ( isFocussed )
     painter->setPen(colorGroup().dark() );
   else
     painter->setPen(colorGroup().background() );
*/
   if ( isFocussed )
     qDrawPlainRect(painter,0,0,width(),height(), colorGroup().dark(),1,0);
   else
     qDrawPlainRect(painter,0,0,width(),height(), colorGroup().background(),1,0);
}


void KSlider::paintSlider(QPainter *painter, const QRect &re )
{
  QPoint pos;

  // erase old arrow
  pos = calcArrowPos( prevValue() );
  drawArrow( painter, false, pos );

  // show, if focussed
  drawFocusBar(painter, re);
  drawShadeLine(painter);

  // draw new arrow
  pos = calcArrowPos( value() );
  drawArrow( painter, true, pos );
}

void KSlider::drawArrow( QPainter *painter, bool show, const QPoint &pos )
{
  QPen        arrowPen;
  QPointArray array(5);

  // Select Horizontal or Vertical Polygon Array
  if ( orientation() == QSlider::Vertical ) {
    array.setPoint( 0, pos.x()+0, pos.y()+0 );
    array.setPoint( 1, pos.x()-4, pos.y()+4 );
    array.setPoint( 2, pos.x()-ARROW_LENGTH, pos.y()+4 );
    array.setPoint( 3, pos.x()-ARROW_LENGTH, pos.y()-4 );
    array.setPoint( 4, pos.x()-4, pos.y()-4 );
  }
  else {
    array.setPoint( 0, pos.x()+0, pos.y()+0 );
    array.setPoint( 1, pos.x()+4, pos.y()-4 );
    array.setPoint( 2, pos.x()+4, pos.y()-ARROW_LENGTH );
    array.setPoint( 3, pos.x()-4, pos.y()-ARROW_LENGTH );
    array.setPoint( 4, pos.x()-4, pos.y()-4 );
  }

  // Select a base pen, then change parameters
  if ( show )
    arrowPen = QPen( colorGroup().light() );
  else
    arrowPen = QPen( colorGroup().background() );

  arrowPen.setWidth(1);		// Yup, we REALLY want width 1, not 0 here !!
  painter->setPen(arrowPen);
  painter->setBrush( colorGroup().background() );

  painter->drawPolygon( array );

  if ( show )
    {
      arrowPen = QPen( colorGroup().dark() );
      arrowPen.setWidth(1);	// Yup, we REALLY want width 1, not 0, here !!
      painter->setPen(arrowPen);
      painter->drawPolyline( array, 0, 3);

      // !!! This fixes a problem with a missing point! Qt Bug?
      // !!! I will wait for Qt1.3 to see the results
      // painter->drawPoint(array[1]);
    }
}


QSize KSlider::sizeHint() const
{
  QSize size;

  if ( orientation() == QSlider::Vertical ) {
    size.setWidth( ARROW_LENGTH + 5 + 1 );
    size.setHeight( -1 );
  }
  else {
    size.setWidth( -1 );
    size.setHeight( ARROW_LENGTH + 5 + 1 );
  }
  return size;
}



QPoint KSlider::calcArrowPos( int val )
{
  QPoint p;
  int diffMaxMin = checkWidth();	// sanity check, Christian Esken
  int noOffsetValue = val - minValue();

  /**
    Calculate the arrow position. More precisely, calculate the
    position of the arrow "tip". Calculation works like this
    (in vertical case):
    x position is simply the arrow length.
    y position is more complicated:
     1. There is always a 5 pixel border left and right
        This leaves "height()-10" point as working area
     2. The slider range must be mapped linear onto the
        working area.
        a) So I calculate a relative Position in the slider
           range: (val - minValue() ) / (maxValue() - minValue()
           Actually I call it "noOffsetValue / diffmaxMin".
        b) I don't set the braces around "noOffsetValue / diffmaxMin"
           because this would loose precision.
        c) This will lead to a arrow position inside [ 0,height()-10 ]
           I do currect this, by "adding" 5. Actually I do reverse
           the slider, so that low values are at the bottom. This
           means, do not add "5", but "height()-5".
   */
  if ( orientation() == QSlider::Vertical ) {
    p.setY(   height() - 5 -
              (  ((height()-10) * noOffsetValue )
                 / diffMaxMin
              )
          );
    p.setX( ARROW_LENGTH );
  }
  else {
    p.setX(   5 +
              (
                ((width()-10) * noOffsetValue )
                / diffMaxMin
              )
          );
    p.setY( ARROW_LENGTH );
  }
  return p;
}


void KSlider::drawTickMarks(QPainter *painter)
{
  QPen tickPen = QPen( colorGroup().dark() );
  tickPen.setWidth(1);	// Yup, we REALLY want width 1, not 0 here !!
  painter->setPen(tickPen);

  int i;
  int diffMaxMin = checkWidth();	// sanity check
  if ( orientation() == QSlider::Vertical ) {
    // first clear the tickmark area
    painter->fillRect(ARROW_LENGTH+1,0, ARROW_LENGTH + 6, height()-1, colorGroup().background()  );

    // draw ruler marks
    for ( i = 0; i <= maxValue() - minValue(); i += lineStep() ) {
      int pos = (height()-10) * i / diffMaxMin + 5;
      painter->drawLine( ARROW_LENGTH+1, pos, ARROW_LENGTH + 4, pos );
    }
    for ( i = 0; i <= maxValue() - minValue(); i += pageStep() ) {
      int pos = (height()-10) * i / diffMaxMin + 5;
      painter->drawLine( ARROW_LENGTH+1, pos, ARROW_LENGTH + 6, pos );
    }
  }
  else {
    // first clear the tickmark area
    painter->fillRect(0, ARROW_LENGTH+1, width()-1, ARROW_LENGTH + 6, colorGroup().background() );
    // draw ruler marks
    for ( i = 0; i <= maxValue() - minValue(); i += lineStep() ) {
      int pos = (width()-10) * i / diffMaxMin + 5;
      painter->drawLine( pos, ARROW_LENGTH+1, pos, ARROW_LENGTH + 4 );
    }
    for ( i = 0; i <= maxValue() - minValue(); i += pageStep() ) {
      int pos = (width()-10) * i / diffMaxMin + 5;
      painter->drawLine( pos, ARROW_LENGTH+1, pos, ARROW_LENGTH + 6 );
    }
  }
}

void KSlider::drawTicks ( QPainter * p, int , int , int )
{
  drawTickMarks(p);
}

void KSlider::drawWinGroove (QPainter *, QCOORD)
{
  // Do nothing
}

void KSlider::paintEvent( QPaintEvent *qpe )
{
  QPainter painter;

  painter.begin( this );
  // build a rect for the paint event
  QRect rect(x(),y(),width(),height());
  // Clear widget area, because there might be "pixel dirt" around.
  // Especially then, when rangeChange(), resizes, such things happen.

  painter.fillRect(qpe->rect().x(),qpe->rect().y(),qpe->rect().width(),qpe->rect().height(), colorGroup().background() );
  // painter.eraseRect(qpe->rect().x(),qpe->rect().y(),qpe->rect().width(),qpe->rect().height());
  paintSlider(&painter, rect);

  if ( orientation() == QSlider::Vertical ) {
    QRect TickRect(ARROW_LENGTH+1,0,width(),height());
    if (qpe->rect().intersects(TickRect))
       drawTickMarks(&painter);
  }
  else {
    QRect TickRect(0, ARROW_LENGTH+1,width(),height());
    if (qpe->rect().intersects(TickRect)) {
      drawTickMarks(&painter);
    }
  }
  painter.end();
}


void KSlider::valueChange()
{
  QSlider::valueChange();
  if ( orientation() == QSlider::Vertical )
    repaint(0,0,ARROW_LENGTH,height());
  else
    repaint(0,0,width(),ARROW_LENGTH);

//  emit valueChanged( value() );
}


void KSlider::rangeChange()
{
  QSlider::rangeChange();
  // when range changes, everything must be repainted  
  update();
}

int KSlider::checkWidth()
{
  int diff = maxValue() - minValue();
  if ( diff == 0)
    // If (max - min) has no "secure" value, set it to lineStep().
    diff=lineStep();
  return diff;
}

void KSlider::paletteChange(const QPalette &)
{
  update();
}

void KSlider::backgroundColorChange(const QPalette &)
{
  update();
}

void KSlider::focusInEvent( QFocusEvent * )
{
  QPainter painter;
  QRect rect(x(),y(),width(),height());
  painter.begin( this );
  isFocussed = true;
  paintSlider(&painter,rect);
  painter.end();
}

void KSlider::focusOutEvent( QFocusEvent * )
{
  QPainter painter;
  QRect rect(x(),y(),width(),height());
  painter.begin( this );
  isFocussed = false;
  paintSlider(&painter,rect);
  painter.end();
}
#include "kslider.moc"


--- NEW FILE: kcursor.cpp ---
/**
 * KCursor class implementation
 * kcursor.cpp
 *
 * Copyright (C) 1998 Kurt Granroth <granroth at kde.org>
 */
#include <kcursor.h>

#include <kapp.h>
#include <qbitmap.h>

KCursor::KCursor()
{
}

QCursor KCursor::handCursor()
{
	static QCursor *hand_cursor = 0;

	if (hand_cursor == 0)
	{
		if (KApplication::style() == WindowsStyle)
		{
			unsigned char HAND_BITS[] = {
				0x80, 0x01, 0x00, 0x40, 0x02, 0x00, 0x40, 0x02, 0x00, 0x40, 0x02,
				0x00, 0x40, 0x02, 0x00, 0x40, 0x02, 0x00, 0x40, 0x1e, 0x00, 0x40,
				0xf2, 0x00, 0x40, 0x92, 0x01, 0x70, 0x92, 0x02, 0x50, 0x92, 0x04,
				0x48, 0x80, 0x04, 0x48, 0x00, 0x04, 0x48, 0x00, 0x04, 0x08, 0x00,
				0x04, 0x08, 0x00, 0x04, 0x10, 0x00, 0x04, 0x10, 0x00, 0x04, 0x20,
				0x00, 0x02, 0x40, 0x00, 0x02, 0x40, 0x00, 0x01, 0xc0, 0xff, 0x01};
			unsigned char HAND_MASK_BITS[] = {
				0x80, 0x01, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03,
				0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x1f, 0x00, 0xc0,
				0xff, 0x00, 0xc0, 0xff, 0x01, 0xf0, 0xff, 0x03, 0xf0, 0xff, 0x07,
				0xf8, 0xff, 0x07, 0xf8, 0xff, 0x07, 0xf8, 0xff, 0x07, 0xf8, 0xff,
				0x07, 0xf8, 0xff, 0x07, 0xf0, 0xff, 0x07, 0xf0, 0xff, 0x07, 0xe0,
				0xff, 0x03, 0xc0, 0xff, 0x03, 0xc0, 0xff, 0x01, 0xc0, 0xff, 0x01};
			QBitmap hand_bitmap(22, 22, HAND_BITS, true); 
			QBitmap hand_mask(22, 22, HAND_MASK_BITS, true); 
			hand_cursor = new QCursor(hand_bitmap, hand_mask, 7, 0);
		}
		else
		{
			unsigned char HAND_BITS[] = {
				0x00, 0x00, 0xfe, 0x01, 0x01, 0x02, 0x7e, 0x04, 0x08, 0x08, 0x70,
				0x08, 0x08, 0x08, 0x70, 0x14, 0x08, 0x22, 0x30, 0x41, 0xc0, 0x20,
				0x40, 0x12, 0x80, 0x08, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00};
			unsigned char HAND_MASK_BITS[] = {
				0xfe, 0x01, 0xff, 0x03, 0xff, 0x07, 0xff, 0x0f, 0xfe, 0x1f, 0xf8,
				0x1f, 0xfc, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xf8, 0xff, 0xf0, 0x7f,
				0xe0, 0x3f, 0xc0, 0x1f, 0x80, 0x0f, 0x00, 0x07, 0x00, 0x02};
			QBitmap hand_bitmap(16, 16, HAND_BITS, true); 
			QBitmap hand_mask(16, 16, HAND_MASK_BITS, true); 
			hand_cursor = new QCursor(hand_bitmap, hand_mask, 0, 0);
		}
	}

	CHECK_PTR(hand_cursor);
	return *hand_cursor;
}

/**
 * All of the follow functions will return the Qt default for now regardless
 * of the style.  This will change at some later date
 */
QCursor KCursor::arrowCursor()
{
	return ::arrowCursor;
}


QCursor KCursor::upArrowCursor()
{
	return ::upArrowCursor;
}


QCursor KCursor::crossCursor()
{
	return ::crossCursor;
}


QCursor KCursor::waitCursor()
{
	return ::waitCursor;
}


QCursor KCursor::ibeamCursor()
{
	return ::ibeamCursor;
}


QCursor KCursor::sizeVerCursor()
{
	return ::sizeVerCursor;
}


QCursor KCursor::sizeHorCursor()
{
	return ::sizeHorCursor;
}


QCursor KCursor::sizeBDiagCursor()
{
	return ::sizeBDiagCursor;
}


QCursor KCursor::sizeFDiagCursor()
{
	return ::sizeFDiagCursor;
}


QCursor KCursor::sizeAllCursor()
{
	return ::sizeAllCursor;
}


QCursor KCursor::blankCursor()
{
	return ::blankCursor;
}


--- NEW FILE: kintegerline.cpp ---
/**********************************************************************
**
** $Id: kintegerline.cpp,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
**
** Implementation of 
**
** Copyright (C) 1997 Michael Wiedmann, <mw at miwie.in-berlin.de>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the Free
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
**
*****************************************************************************/

#include <kintegerline.h>
#include <qkeycode.h>

#include <stdlib.h>

#include "kintegerline.h"


KIntegerLine::KIntegerLine( QWidget *parent, 
							const char *name,
							KEditLineType t)
  : KRestrictedLine( parent, name, "0123456789" )
{
  switch (lineType = t)
    {
    case KEditTypeOct:
      setValidChars("01234567");
      break;
      
    case KEditTypeHex:
      setValidChars("0123456789ABCDEFabcdef");
      break;

    default:
      break;
    }

  connect( this, SIGNAL( textChanged( const char* ) ),
		   this, SLOT( internalValueChanged() ) );
}

KIntegerLine::KIntegerLine()
  : KRestrictedLine()
{
  ;
}

KIntegerLine::~KIntegerLine()
{
  ;
}

KEditLineType KIntegerLine::getType()
{
  return (lineType);
}


int KIntegerLine::value( void )
{
  QString s = text();
  return getValue( s );
}


void KIntegerLine::setValue( int value )
{
  QString s;
  putValue( s, value );
}

 
void KIntegerLine::keyPressEvent( QKeyEvent *e )
{
  QString tmp(text());
  int i;
  
  switch(e->key())
    {
    case Key_Up:
      putValue(tmp, getValue(tmp)+1);
      break;
      
    case Key_Down:
      i = getValue(tmp);
      if (i>0) i--;
      putValue(tmp, i);
      break;
      
    case Key_Prior:
      incValue(tmp, getValue(tmp));
      break;
            
    case Key_Next:
      decValue(tmp, getValue(tmp));
      break;
      
    default: // switch (e->key())
      KRestrictedLine::keyPressEvent(e);
      break;
    }
  
  return;
}


int KIntegerLine::getValue(QString &s)
{
  return (strtol(s, 0, (int)lineType));
}

void KIntegerLine::putValue(QString &s, int val)
{
  switch (lineType)
    {
	case  KEditTypeOct:
	  s.sprintf("%o", val);
	  break;
       
	case  KEditTypeDec:
	  s.sprintf("%d", val);
	  break;

	case  KEditTypeHex:
	  s.sprintf("%X", val);
	  break;
    }
  setText(s);
}

void KIntegerLine::incValue(QString &s, int val)
{
  switch (lineType)
    {
	case  KEditTypeOct:
	  val += 8;
	  s.sprintf("%o", val);
	  break;
       
	case  KEditTypeDec:
	  val += 10;
	  s.sprintf("%d", val);
	  break;

	case  KEditTypeHex:
	  val +=16;
	  s.sprintf("%X", val);
	  break;
    }
  setText(s);
}

void KIntegerLine::decValue(QString &s, int val)
{
  switch (lineType)
    {
	case  KEditTypeOct:
	  if (val > 7)   val -= 8;
	  s.sprintf("%o", val);
	  break;
       
	case  KEditTypeDec:
	  if (val > 9)   val -= 10;
	  s.sprintf("%d", val);
	  break;

	case  KEditTypeHex:
	  if (val > 15)   val -= 16;
	  s.sprintf("%X", val);
	  break;
    }
  setText(s);
}


void KIntegerLine::internalValueChanged()
{
  emit valueChanged( value() );
}
#include "kintegerline.moc"


--- NEW FILE: kcontrol.h ---
/*
  kcontrol - Base for KDE Control Applications

  written 1997 by Matthias Hoelzer

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
  */


#ifndef _K_CONTROL_
#define _K_CONTROL_


#include <qtabbar.h>
#include <qtabdialog.h>
#include <qstrlist.h>
#include <qpushbutton.h>

#include <kapp.h>


class KControlApplication;


/** KControlDialog is a QTabDialog that is internally used by KControl Applications.
*/

class KControlDialog : public QTabDialog
{
  Q_OBJECT

  friend KControlApplication;

public:

  /// Initializes the dialog
  KControlDialog();


protected:

  /// Resizes the dialog
  void resizeEvent(QResizeEvent *event);


protected slots:

  /// Closing the dialog will end the application
  virtual void done(int);


private:

  QPushButton *helpBtn;
  QPushButton *defaultBtn;
    
};


/** The base widget for setup dialog.

    It provides methods to load and apply the settings.
*/
class KConfigWidget : public QWidget
{
  Q_OBJECT

public:

  /// Constructor.
  KConfigWidget(QWidget *parent, const char *name=0) : QWidget(parent, name) {};

  /// Loads the settings, usually from an rc-file.
  virtual void loadSettings() = 0;

  /// Applies the settings.
  virtual void applySettings() = 0;

  /// Sets default values.
  virtual void defaultSettings() {};
    
};


/** KControlApplication is the common base for setup applications.

    It provides a tab dialog and functionality common to most setup programs.

    @author Matthias H"olzer (hoelzer at physik.uni-wuerzburg.de)
    @short Common base for setup applications.
*/
class KControlApplication : public KApplication
{
  Q_OBJECT

public:

  /** Creates the setup application.

      The constructor scans the command line arguments. If there is a single argument, "-init",
      the function init() is called and the application terminates.
      Otherwise the setup dialog is created and inkoved.

      @param argc  number of commandline arguments
      @param argv  commandline arguments
      @param name  name of the application
   */
  KControlApplication(int &argc, char **argv, const char *name=0);

  /// Destructor. Cleans up.
  ~KControlApplication();

  /** Sets the title of the dialog.

      It's not possible to set the title within the constructor,
      because we need the application to get the translator and
      it would mean a lot of effort to do it without the one in kapp.

      @param title text to be shown in the dialogs titlebar
    */
  void setTitle(const char *title);

  /** Determines if the setup dialog has to be run.

      The setup dialog has to be run if the application has not been invoked with a single commandline
      argument containing "-init".

      Due to the fact the QApplication::exec() is not virtual, this construction has to be used to
      execute a KControlApplication:

      KControlApplication app(argc, argv, "name", "title");
      app.createPages();

      if (app.runGUI())
        return app.exec();
      else
        return 0;

      Just running app.exec() will fail if "-init" has been requested.
  */
  bool runGUI() { return !justInit; };


  /// Returns the tabbed dialog object.
  QTabDialog *getDialog() { return dialog; };


  /// Returns the list of pages to show.
  QStrList *getPageList() { return pages;};


  /// Adds a new page to the dialog.
  void addPage(QWidget *page, const QString &name, const QString &help_name);


public slots:

  /** This function is called at startup to initialize the settings.

      This function must be overriden by all setup application that want to have persistent settings.
  */
  virtual void init() {};


  /** This function is called to apply the settings currently selected in the dialog.

      This function must be overriden by all setup applications.
  */
  virtual void apply() {};


  /** This function is called when the help button is pressed.

      The default behaviour is to call

      kapp->invokeHTMLHelp("kcontrol/$(appname)/$(help_name).html","");
  */
  virtual void help();


  /** This function is called when the user presses the default button.

      This function must be overriden by all setup application.
  */
  virtual void defaultValues() {};

protected:

  KControlDialog *dialog;
  QStrList       *pages;
  QStrList       helpNames;
  bool           justInit;

private:

  QString        swallowCaption;
};


#endif

--- NEW FILE: kcombo.cpp ---
#include <qpainter.h>
#include <qdrawutil.h>
#include <qkeycode.h>
#include "kcombo.h"
#include "kcombo.h"
#include <qaccel.h>

KCombo::KCombo( QWidget* parent, const char* name, WFlags ) :
	QComboBox( parent, name)
{
    set_text_called = false;
}

KCombo::KCombo( bool readWrite, QWidget* parent, const char* name, WFlags ) :
	QComboBox( readWrite, parent, name)
{
    set_text_called = false;
}

void KCombo::setText( const char *text)
{
    setCurrentItem(0);
    if (!set_text_called) {
	set_text_called = true;
	insertItem(text, 0);
    } 
    changeItem(text, 0);
}

#include "kcombo.moc"


--- NEW FILE: kiconloaderdialog.cpp ---
// -*- C++ -*-

//
//  kiconloaderdialog
//
//  Copyright (C) 1997 Christoph Neerfeld
//  email:  Christoph.Neerfeld at home.ivm.de or chris at kde.org
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU Library General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Library General Public License for more details.
//
//  You should have received a copy of the GNU Library General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//

#include <qapplication.h>
#include <qdir.h>
#include <qpainter.h>
#include <qwmatrix.h>

#include "kiconloaderdialog.h"
#include "kiconloaderdialog.h"

#include <kpixmap.h>
#include <klocale.h>
#define klocale KApplication::getKApplication()->getLocale()

//----------------------------------------------------------------------
//---------------  KICONLOADERCANVAS   ---------------------------------
//----------------------------------------------------------------------
KIconLoaderCanvas::KIconLoaderCanvas (QWidget *parent, const char *name )
  :QTableView( parent, name )
{
  max_width = 0;
  max_height = 0;
  setFrameStyle(Panel | Sunken);
  setTableFlags(Tbl_autoScrollBars);
  pixmap_list.setAutoDelete(TRUE);
  name_list.setAutoDelete(TRUE);
  sel_id = 0;
  timer = new QTimer( this );
  connect( timer, SIGNAL( timeout() ), SLOT( process() ) );
}

KIconLoaderCanvas::~KIconLoaderCanvas()
{
  delete timer;
  name_list.clear();
  pixmap_list.clear(); 
}

void KIconLoaderCanvas::loadDir( QString dirname, QString filter )
{
  if ( timer->isActive() )
    {
      timer->stop();
      QApplication::restoreOverrideCursor();
    }
  dir_name = dirname;
  QDir d(dir_name);
  name_list.clear();
  pixmap_list.clear();
  if( !filter.isEmpty() )
    {
      d.setNameFilter(filter);
    }
  if( d.exists() )
    {
      file_list = *d.entryList( QDir::Files | QDir::Readable, QDir::Name );
      QApplication::setOverrideCursor( waitCursor );
      curr_indx = 0;
      sel_id = 0;
      max_width  = 16;
      max_height = 16;
      setTopLeftCell(0,0);
      timer->start( 0, true );
    }
  else
    {
      setNumCols( 0 );
      setNumRows( 0 );
      max_width = 20;
      max_height = 20;
      setCellWidth(max_width+4);
      setCellHeight(max_height+4);
      repaint();
    }
}

void KIconLoaderCanvas::process()
{
  KPixmap *new_xpm = 0;
  const char *current = file_list.at( curr_indx );

  for( int i = 0; i < 10 && current != 0; i++, curr_indx++ )
    {
      new_xpm = new KPixmap;
      new_xpm->load( dir_name + '/' + current, 0, KPixmap::LowColor );
      if( new_xpm->isNull() )
        {
          delete new_xpm;
          continue;
        }
      if( new_xpm->width() > 60 || new_xpm->height() > 60 )
        { // scale pixmap to a size of 60*60
          QWMatrix m;
          float scale;
          if( new_xpm->width() > new_xpm->height() )
            scale = 60 / (float) new_xpm->width();
	  else
	    scale = 60 / (float) new_xpm->height();
	  m.scale( scale, scale );
	       QPixmap tmp_xpm = new_xpm->xForm(m);
	       new_xpm->resize( tmp_xpm.width(), tmp_xpm.height() );
	       bitBlt( new_xpm, 0, 0, &tmp_xpm );
	       if ( tmp_xpm.mask() )
		   new_xpm->setMask( *tmp_xpm.mask() );
	 }
       max_width  = ( max_width  > new_xpm->width()  ? max_width  : new_xpm->width() );
       max_height = ( max_height > new_xpm->height() ? max_height : new_xpm->height() );
       name_list.append(current);
       pixmap_list.append(new_xpm);
       current = file_list.next();
    }

  if ( !current )
    {
      QApplication::restoreOverrideCursor();
      file_list.clear();
    }
  else
      timer->start( 0, true );

  // progressive display is nicer if these don't change too often
  max_width  = ( max_width + 7 ) / 8 * 8;
  max_height = ( max_height + 7 ) / 8 * 8;

  if( name_list.count() == 0 )
    {
      setNumCols( 0 );
      setNumRows( 0 );
      max_width = 20;
      max_height = 20;
      setCellWidth(max_width+4);
      setCellHeight(max_height+4);
      repaint();
    }
  else
    {
      setNumCols( width() / (max_width+4) );
      setNumRows( name_list.count() / numCols() + 1 );
      setCellWidth(max_width+4);
      setCellHeight(max_height+4);
      if ( rowIsVisible( curr_indx / numCols() ) )
	  repaint();
    }

}

void KIconLoaderCanvas::paintCell( QPainter *p, int r, int c )
{
  int item_nr = r * numCols() + c;
  if( item_nr >= (int) pixmap_list.count() || item_nr < 0 )
    {
      return;
    }
  QPixmap *pixmap = pixmap_list.at(item_nr);
  if( !pixmap )
    return;
  int w = cellWidth();
  int h = cellHeight();
  int pw = pixmap->width();
  int ph = pixmap->height();
  int x = (w-pw)/2;
  int y = (h-ph)/2;
  p->drawPixmap( x, y, *pixmap );
  if( item_nr == sel_id )
    p->drawRect( 0, 0, cellWidth(), cellHeight() );
}

void KIconLoaderCanvas::mouseMoveEvent( QMouseEvent *e)
{
  if( (e->pos().x() > numCols() * cellWidth()) || (e->pos().y() > numRows() * cellHeight()) )
    {
      emit nameChanged("");
      return;
    }
  int item_nr = findRow(e->pos().y()) * numCols() + findCol(e->pos().x());
  if( item_nr >= (int) name_list.count() || item_nr < 0 )
    {
      emit nameChanged("");
      return;
    }
  QString name = name_list.at(item_nr);
  emit nameChanged( (const char *) name );
}

void KIconLoaderCanvas::mousePressEvent( QMouseEvent *e)
{
  if( name_list.count () == 0 )
    return;
  int i = sel_id;
  sel_id = findRow(e->pos().y()) * numCols() + findCol(e->pos().x());
  updateCell( i / numCols(), i % numCols() );
  updateCell( findRow(e->pos().y()), findCol(e->pos().x()) );
}

void KIconLoaderCanvas::mouseDoubleClickEvent( QMouseEvent * )
{
  emit doubleClicked();
}

void KIconLoaderCanvas::resizeEvent( QResizeEvent * e)
{
  if( !isVisible() )
    return;
  setNumCols( width() / (max_width+4) );
  setNumRows( name_list.count() / numCols() + 1 );
  QTableView::resizeEvent(e);
  repaint(TRUE);
}

void KIconLoaderCanvas::cancelLoad()
{
  if ( timer->isActive() )
    {
      timer->stop();
      QApplication::restoreOverrideCursor();
      emit interrupted();
    }
}

//----------------------------------------------------------------------
//---------------  KICONLOADERDIALOG   ---------------------------------
//----------------------------------------------------------------------

void KIconLoaderDialog::init()
{
  setCaption(klocale->translate("Select Icon"));
  //---
  i_filter = new QLineEdit(this);
  i_filter->setGeometry(310, 8, 150, 24);
  //---
  l_filter = new QLabel( klocale->translate("Filter:"), this );
  l_filter->setGeometry( 310 - 50, 8, 40, 24 );
  //---
  canvas = new KIconLoaderCanvas(this);
  canvas->setGeometry(10, 38, 450, 124);
  //---
  l_name = new QLabel("", this);
  l_name->setGeometry(10, 165, 110, 24);
  //---
  cb_dirs = new QComboBox(FALSE, this);
  cb_dirs->setGeometry(10, 8, 230, 24);
  //---
  ok = new QPushButton( klocale->translate("OK"), this );
  cancel = new QPushButton( klocale->translate("Cancel"), this );
  ok->setGeometry(65, 200, 80, 30);
  cancel->setGeometry(325, 200, 80, 30);
  connect( ok, SIGNAL(clicked()), this, SLOT(accept()) );
  connect( cancel, SIGNAL(clicked()), this, SLOT(reject()) );
  connect( canvas, SIGNAL(nameChanged(const char *)), l_name, SLOT(setText(const char *)) );
  connect( canvas, SIGNAL(doubleClicked()), this, SLOT(accept()) );
  connect( canvas, SIGNAL(interrupted()), this, SLOT(needReload()) );
  connect( i_filter, SIGNAL(returnPressed()), this, SLOT(filterChanged()) );
  connect( cb_dirs, SIGNAL(activated(const char *)), this, SLOT(dirChanged(const char*)) );
  setDir(icon_loader->getDirList());
  resize( 470, 350 );
  setMinimumSize( 470, 250 );
}

KIconLoaderDialog::KIconLoaderDialog ( QWidget *parent, const char *name )
  : QDialog( parent, name, TRUE )
{
  icon_loader = KApplication::getKApplication()->getIconLoader();
  init();
}

KIconLoaderDialog::KIconLoaderDialog ( KIconLoader *loader, QWidget *parent, const char *name )
  : QDialog( parent, name, TRUE )
{
  icon_loader = loader;
  init();
}

KIconLoaderDialog::~KIconLoaderDialog()
{
  disconnect( ok );
  disconnect( cancel );
  disconnect( canvas );
}

void KIconLoaderDialog::reject()
{
  canvas->cancelLoad(); 
  QDialog::reject();
}

void KIconLoaderDialog::needReload()
{
  i_filter->setText("");
}

int KIconLoaderDialog::exec(QString filter)
{
  setResult( 0 );
  if( filter != i_filter->text() )
    {
      canvas->loadDir( cb_dirs->currentText(), filter );
      i_filter->setText( filter );
    }
  show();
  return result();
}

void KIconLoaderDialog::resizeEvent( QResizeEvent * )
{
  int w = width();
  int h = height();
  canvas->resize( w - 20, h - 106 );
  l_name->resize( canvas->width(), 24 );
  l_name->move( 10, 38 + canvas->height() );
  i_filter->move( w - 160, 8 );
  l_filter->move( w - 200, 8 );
  cb_dirs->resize( canvas->width() - i_filter->width() - l_filter->width() - 18, 24 );
  ok->move( 65, h - 40  );
  cancel->move( w - 145, h - 40 );
}

void KIconLoaderDialog::filterChanged()
{
  canvas->loadDir( cb_dirs->currentText(), i_filter->text() );
}

void KIconLoaderDialog::dirChanged(const char * dir)
{
  canvas->loadDir( dir, i_filter->text() );
}

QPixmap KIconLoaderDialog::selectIcon( QString &name, const QString &filter)
{
  QPixmap pixmap;
  QString pix_name, old_filter;
  old_filter = i_filter->text();
  if( old_filter.isEmpty() )
    old_filter = filter;
  if( exec(old_filter) )
  {
      if( (pix_name = canvas->getCurrent()) )
	  pixmap = icon_loader->loadIcon( pix_name );
  }
  name = pix_name;
  return pixmap;
}

KIconLoaderButton::KIconLoaderButton( QWidget *_parent ) : QPushButton( _parent )
{
    iconStr = "";
    connect( this, SIGNAL( clicked() ), this, SLOT( slotChangeIcon() ) );
    iconLoader = kapp->getIconLoader();
    loaderDialog = new KIconLoaderDialog();
}

KIconLoaderButton::KIconLoaderButton( KIconLoader *_icon_loader, QWidget *_parent ) : QPushButton( _parent )
{
    iconStr = "";
    connect( this, SIGNAL( clicked() ), this, SLOT( slotChangeIcon() ) );
    loaderDialog = new KIconLoaderDialog( _icon_loader );
    iconLoader = _icon_loader;
}

void KIconLoaderButton::slotChangeIcon()
{
    QString name;
    QPixmap pix = loaderDialog->selectIcon( name, "*" );
    if( !pix.isNull() )
    {
	setPixmap(pix);
	iconStr = name.data();
	emit iconChanged( iconStr );
    }    
}

void KIconLoaderButton::setIcon( const char *_icon )
{
    iconStr = _icon;

    // A Hack, since it uses loadApplicationIcon!!!
    setPixmap( KApplication::getKApplication()->getIconLoader()->loadApplicationIcon( iconStr ) );
}

KIconLoaderButton::~KIconLoaderButton() 
{
    if ( loaderDialog )
	delete loaderDialog;
}
#include "kiconloaderdialog.moc"


--- NEW FILE: kdbtn.h ---
/*  This file is part of the KDE Libraries
    Copyright (C) 1998 Thomas Tanghus (tanghus at earthling.net)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/  

#ifndef __KDIRECTIONBUTTON_H__
#define __KDIRECTIONBUTTON_H__

#include <qdrawutil.h>
#include <qbutton.h>

class QPainter;
class QWidget;

/**
* KDirectionButton is a helper class for KTabBar and KWizard. It provides the buttons
* used to scroll the tab bar and to change pages in KWizard.
* @short KDirectionButton
* @author Thomas Tanghus <tanghus at earthling.net>
* @version 0.1
*/
class KDirectionButton : public QButton
{
    Q_OBJECT
public:
    KDirectionButton( QWidget * parent = 0, const char * name = 0 );
    KDirectionButton( ArrowType d, QWidget * parent = 0, const char * name = 0 );
   ~KDirectionButton();

    void setDirection( ArrowType d) { direct = d; };
    ArrowType direction( ) { return direct; };

protected:
   virtual void drawButton(QPainter *);

   ArrowType direct;
};

/**
* KTabButton is a helper class for KTabBar. It provides the buttons
* used to scroll the tab bar.
* @short KTabButton
* @author Thomas Tanghus <tanghus at earthling.net>
* @version 0.1
*/
class KTabButton : public KDirectionButton
{
    Q_OBJECT
public:
    KTabButton( QWidget * parent = 0, const char * name = 0 );
    KTabButton( ArrowType d, QWidget * parent = 0, const char * name = 0 );
   ~KTabButton() { };

protected:
   virtual void drawButton(QPainter *);
};

#endif // __KDIRECTIONBUTTON_H__



--- NEW FILE: kwmmapp.cpp ---
/*

    $Id: kwmmapp.cpp,v 1.1 2006-10-03 11:26:33 dslinux_amadeus Exp $

    This file is part of the KDE libraries
    Copyright (C) 1997 Matthias Ettrich (ettrich at kde.org)


    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.

    $Log: kwmmapp.cpp,v $
    Revision 1.1  2006-10-03 11:26:33  dslinux_amadeus
    adding pristine copy of pixil to HEAD so I can branch from it

    Revision 1.1  2003/09/08 19:42:12  jasonk
    Addition of packages directory and associated files.

    Revision 1.1.1.1  2003/08/07 21:18:33  jasonk
    Initial import of PIXIL into new cvs repository.

    Revision 1.1.1.1  2003/06/23 22:04:24  jasonk


    Revision 1.1.1.1  2000/07/07 16:11:01  jasonk
    Initial import of ViewML

    Revision 1.18  1999/01/18 10:57:18  kulow
    .moc files are back in kdelibs. Built fine here using automake 1.3

    Revision 1.17  1999/01/15 09:31:37  kulow
    it's official - kdelibs builds with srcdir != builddir. For this I
    automocifized it, the generated rules are easier to maintain than
    selfwritten rules. I have to fight with some bugs of this tool, but
    generally it's better than keeping them updated by hand.

    Revision 1.16  1999/01/12 12:45:30  ettrich
    fixes for dialog handling

    Revision 1.15  1998/10/22 16:50:14  ettrich
    support for kstart

    Revision 1.14  1998/03/08 22:08:50  wuebben
    Bernd: adjusted the size of kfontdialog for localization

    Revision 1.13  1998/03/08 05:51:02  wuebben
    Bernd: several small fixes


*/

#include "kwmmapp.h"

int KWMModuleXErrorHandler(Display *, XErrorEvent *){

  return 0; // ignore Xerrors

};

KWMModuleApplication::KWMModuleApplication( int &argc, char *argv[])
                     :KApplication(argc, argv){

    XSetErrorHandler(KWMModuleXErrorHandler);
    module = new QWidget;

}

KWMModuleApplication::KWMModuleApplication(
					   int &argc, char *argv[],
					   const QString& rAppName
					   )
                      :KApplication(argc, argv, rAppName){

    XSetErrorHandler(KWMModuleXErrorHandler);
    module = new QWidget;

}


void KWMModuleApplication::connectToKWM(bool dock_module){

  if (!dock_module)
    KWM::setKWMModule(module->winId());
  else
    KWM::setKWMDockModule(module->winId());

}

bool KWMModuleApplication::x11EventFilter( XEvent * ev){


  static bool atoms = FALSE;

  static Atom module_init;
  static Atom module_initialized;
  static Atom module_desktop_change;
  static Atom module_win_add;
  static Atom module_dialog_win_add;
  static Atom module_win_remove;
  static Atom module_win_change;
  static Atom module_win_raise;
  static Atom module_win_lower;
  static Atom module_win_activate;
  static Atom module_win_icon_change;
  static Atom module_desktop_name_change;
  static Atom module_desktop_number_change;
  static Atom kwm_command;
  static Atom module_dockwin_add;
  static Atom module_dockwin_remove;
  static Atom sound;
  static Atom register_sound;
  static Atom unregister_sound;

  Atom a;
  Window w;
  Window *wp;


  if (KApplication::x11EventFilter(ev))
    return True;

  if (ev->xany.window == module->winId()
      && ev->type == ClientMessage){

    if (!atoms){

      module_init = XInternAtom(qt_xdisplay(),
				"KWM_MODULE_INIT", False);
      module_initialized = XInternAtom(qt_xdisplay(),
				"KWM_MODULE_INITIALIZED", False);
      module_desktop_change = XInternAtom(qt_xdisplay(),
					  "KWM_MODULE_DESKTOP_CHANGE", False);
      module_desktop_name_change = XInternAtom(qt_xdisplay(),
				   "KWM_MODULE_DESKTOP_NAME_CHANGE", False);
      module_desktop_number_change = XInternAtom(qt_xdisplay(),
                                     "KWM_MODULE_DESKTOP_NUMBER_CHANGE", False);

      module_win_add = XInternAtom(qt_xdisplay(),
				   "KWM_MODULE_WIN_ADD", False);
      module_dialog_win_add = XInternAtom(qt_xdisplay(),
				   "KWM_MODULE_DIALOG_WIN_ADD", False);
      module_win_remove = XInternAtom(qt_xdisplay(),
				      "KWM_MODULE_WIN_REMOVE", False);
      module_win_change = XInternAtom(qt_xdisplay(),
				      "KWM_MODULE_WIN_CHANGE", False);
      module_win_raise = XInternAtom(qt_xdisplay(),
				     "KWM_MODULE_WIN_RAISE", False);
      module_win_lower = XInternAtom(qt_xdisplay(), "KWM_MODULE_WIN_LOWER", False);
      module_win_activate = XInternAtom(qt_xdisplay(),
					"KWM_MODULE_WIN_ACTIVATE", False);
      module_win_icon_change = XInternAtom(qt_xdisplay(),
					   "KWM_MODULE_WIN_ICON_CHANGE", False);
      kwm_command = XInternAtom(qt_xdisplay(),
				"KWM_COMMAND", False);

      module_dockwin_add = XInternAtom(qt_xdisplay(),
					"KWM_MODULE_DOCKWIN_ADD", False);
      module_dockwin_remove = XInternAtom(qt_xdisplay(),
					   "KWM_MODULE_DOCKWIN_REMOVE", False);
      sound = XInternAtom(qt_xdisplay(),
			  "KDE_SOUND_EVENT", False);
      register_sound = XInternAtom(qt_xdisplay(),
				   "KDE_REGISTER_SOUND_EVENT", False);
      unregister_sound = XInternAtom(qt_xdisplay(),
				     "KDE_UNREGISTER_SOUND_EVENT", False);

      atoms = true; // was missing --Bernd
    }

    a = ev->xclient.message_type;
    w = (Window) (ev->xclient.data.l[0]);


    if ( a ==  module_init) {
      windows.clear();
      windows_sorted.clear();
      dock_windows.clear();
      emit init();
    }
    else if ( a == module_initialized) {
	emit initialized();
    }
    else if ( a == module_desktop_change) {
	int d = (int) w;
	emit desktopChange(d);
    }
    else if (a == module_desktop_name_change){
      int d = (int) w;
      emit desktopNameChange(d, KWM::getDesktopName(d));
    }
    else if (a == module_desktop_number_change){
      int d = (int) w;
      emit desktopNumberChange(d);
    }
    else if (a == module_win_add){

      wp = new Window;
      *wp = w;
      windows.append(wp);
      windows_sorted.append(wp);
      emit windowAdd(w);
    }
    else if (a == module_dialog_win_add){
      emit dialogWindowAdd(w);
    }

    else if (a == module_win_remove){

      for (wp=windows.first(); wp; wp=windows.next()){

	if (*wp == w){

	  windows.remove();
	  break;
	}
      }

      for (wp=windows_sorted.first(); wp; wp=windows_sorted.next()){

	if (*wp == w){

	  windows_sorted.remove();
	  delete wp;
	  break;
	}
      }

      emit windowRemove(w);
    }

    else if (a == module_win_change){
      emit windowChange(w);
    }

    else if (a == module_win_raise){
      for (wp=windows_sorted.first(); wp; wp=windows_sorted.next()){

	if (*wp == w) {

	  windows_sorted.remove();
	  windows_sorted.append(wp);
	  break;
	}
      }
      emit windowRaise(w);
    }

    else if (a == module_win_lower){

      for (wp=windows_sorted.first(); wp; wp=windows_sorted.next()){

	if (*wp == w) {
	  windows_sorted.remove();
	  windows_sorted.insert(0, wp);
	  break;
	}
      }

      emit windowLower(w);
    }

    else if (a == module_win_activate){
      emit windowActivate(w);
    }

    else if (a == module_win_icon_change){
      emit windowIconChanged(w);
    }

    else if (a == kwm_command){
      char c[21];
      int i;
      for (i=0;i<20;i++)
	c[i] = ev->xclient.data.b[i];
      c[i] = '\0';
      QString com = c;
      emit commandReceived(com);
    }

    else if (a == module_dockwin_add){
      wp = new Window;
      *wp = w;
      dock_windows.append(wp);
      emit dockWindowAdd(w);
    }

    else if (a == module_dockwin_remove){
      for (wp=dock_windows.first(); wp; wp=dock_windows.next()){
	if (*wp == w){
	  dock_windows.remove();
	  break;
	}
      }
      emit dockWindowRemove(w);
    }

    else if (a == sound){
      char c[21];
      int i;
      for (i=0;i<20;i++)
	c[i] = ev->xclient.data.b[i];
      c[i] = '\0';
      QString com = c;
      emit playSound(com);
    }

    else if (a == register_sound){
      char c[21];
      int i;
      for (i=0;i<20;i++)
	c[i] = ev->xclient.data.b[i];
      c[i] = '\0';
      QString com = c;
      emit registerSound(com);
    }

    else if (a == unregister_sound){
      char c[21];
      int i;
      for (i=0;i<20;i++)
	c[i] = ev->xclient.data.b[i];
      c[i] = '\0';
      QString com = c;
      emit unregisterSound(com);
    }

    return TRUE;

  }

  return FALSE;
}


bool KWMModuleApplication::hasWindow(Window w){

  Window *wp;
  for (wp=windows.first(); wp && *wp != w; wp=windows.next());

  return wp != 0L;

}
#include "kwmmapp.moc"


--- NEW FILE: kintegerline.h ---
/**********************************************************************
**
** $Id: kintegerline.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
**
** Definition of KIntegerLine
**
** Copyright (C) 1997 Michael Wiedmann, <mw at miwie.in-berlin.de>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the Free
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
**
*****************************************************************************/

#ifndef KINTEGERLINE_H
#define KINTEGERLINE_H

#include "krestrictedline.h"

/** Enum for the possible types of Editlines
    */
enum KEditLineType{
  KEditTypeOct =  8,
  KEditTypeDec = 10,
  KEditTypeHex = 16
};

/** IntegerEditline: Editline for Integers. Only octal, decimal or
    hexadecimal characters are valid input characters for this sort 
    of edit lines. 
    A few special keys are supported by this class:
    <ul>
    <li>The up-arrow increments the contents by 1, 
    <li>the down-arrow decrements the contents by 1,
    <li>Page-Up increments by 8, 10 or 16 (depending on the EditLineType),
    <li>Page-Down decrements by 8, 10 or 16 (depending on the EditLinetype)
    </ul>

    @author Michael Wiedmann <mw at miwie.in-berlin.de>
    @version 0.0.1
  */
class KIntegerLine : public KRestrictedLine
{
  Q_OBJECT
  
public:
  /**@name methods */
  //@{
  /** Default - empty - constructor
	*/
  KIntegerLine();
    
  /** Contructor: This constructor takes three - optional - arguments.
	  The first two parameters are simply passed to KRestrictedLine.
	  @param parent   pointer to the parent widget
	  @param name     pointer to the name of this widget
	  @param t        type of this integer line (defaults to KEditTypeDec)
  */
  KIntegerLine( QWidget *parent=0, 
				const char *name=0, 
				KEditLineType t=KEditTypeDec);

  /// Destructor
  ~KIntegerLine();

  /// Get the type of this Line
  KEditLineType getType();

  /// Get the current value in the lined
  int value( void );
  
  /// Set the current value in the lined
  void setValue( int value );
  //@}

signals:
  // emitted whenever the value changes
  void valueChanged( int );

protected:
  /** Key press event handler. 
	  Handles the following special keys:
	  <UL>
	  <LI>Key_Up:    Increments contents of line by 1
	  <LI>Key_Prior: Increments contents of line by 8, 10 or 16
	  <LI>Key_Down:  Decrements contents of line by 1
	  <LI>Key_Next:  Decrements contents of line by 8, 10 or 16
	  </UL>
  */
  void	keyPressEvent( QKeyEvent *e );

private slots:
  void internalValueChanged();

private:
  /// type of this line
  KEditLineType lineType;

  /// get value based on radix of this line
  int getValue(QString &s);
    
  /// put value based on radix of this line
  void putValue(QString &s, int val);  

  /// increment value based on radix of this line
  void incValue(QString &s, int val);

  /// decrement value based on radix of this line
  void decValue(QString &s, int val);
};

#endif // 


--- NEW FILE: arrow_left.xbm ---
#define arrow_left_width 16
#define arrow_left_height 16
static char arrow_left_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x01, 0xe0, 0x01, 0xf0, 0x01,
   0xf8, 0x7f, 0xfc, 0x7f, 0xfc, 0x7f, 0xf8, 0x7f, 0xf0, 0x01, 0xe0, 0x01,
   0xc0, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00};

--- NEW FILE: info.xpm ---
/* XPM */
static char *magick[] = {
/* columns rows colors chars-per-pixel */
"48 48 5 1",
"  c #000000",
". c #a0a0a4",
"X c #c0c0c0",
"o c #ffffff",
"O c None",
/* pixels */
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOO........OOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOO...oooooooo...OOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOO..oooooooooooooo..OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOO.oooooooooooooooooo.OOOOOOOOOOOOOOO",
"OOOOOOOOOOOO.oooooooo    oooooooo OOOOOOOOOOOOOO",
"OOOOOOOOOOO.oooooooo      oooooooo OOOOOOOOOOOOO",
"OOOOOOOOOO.ooooooooo      ooooooooo OOOOOOOOOOOO",
"OOOOOOOOO.ooooooooooo    ooooooooooo OOOOOOOOOOO",
"OOOOOOOOO.oooooooooooooooooooooooooo .OOOOOOOOOO",
"OOOOOOOO.oooooooooooooooooooooooooooo .OOOOOOOOO",
"OOOOOOOO.oooooooooo       ooooooooooo .OOOOOOOOO",
"OOOOOOOO.oooooooooooo     ooooooooooo ..OOOOOOOO",
"OOOOOOOO.oooooooooooo     ooooooooooo ..OOOOOOOO",
"OOOOOOOO.oooooooooooo     ooooooooooo ..OOOOOOOO",
"OOOOOOOO.oooooooooooo     ooooooooooo ..OOOOOOOO",
"OOOOOOOO.oooooooooooo     ooooooooooo ..OOOOOOOO",
"OOOOOOOOO.ooooooooooo     oooooooooo ...OOOOOOOO",
"OOOOOOOOO.ooooooooooo     oooooooooo ...OOOOOOOO",
"OOOOOOOOOO.oooooooooo     ooooooooo ...OOOOOOOOO",
"OOOOOOOOOOO ooooooo         oooooo ....OOOOOOOOO",
"OOOOOOOOOOOO oooooooooooooooooooo ....OOOOOOOOOO",
"OOOOOOOOOOOOO oooooooooooooooooo ....OOOOOOOOOOO",
"OOOOOOOOOOOOOO  oooooooooooooo  ....OOOOOOOOOOOO",
"OOOOOOOOOOOOOOO.   oooooooo   .....OOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOO...   oooo .......OOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOO.... ooo .....OOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOO. ooo ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOO oo ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOO o ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOO  ..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOO...OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOO..OOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO",
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
};

--- NEW FILE: kiconloaderdialog.h ---
// -*- C++ -*-

//
//  kiconloaderdialog
//
//  Copyright (C) 1997 Christoph Neerfeld
//  email:  Christoph.Neerfeld at home.ivm.de or chris at kde.org
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU Library General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Library General Public License for more details.
//
//  You should have received a copy of the GNU Library General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//

// CHANGES
// Torben, added KIconLoaderButton

#ifndef KICONLOADERDIALOG_H
#define KICONLOADERDIALOG_H

#include <qapplication.h>
#include <qlist.h>
#include <qpixmap.h>
#include <qstrlist.h>
#include <qstring.h>
#include <qtableview.h>
#include <qdialog.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qcombobox.h>
#include <qtimer.h>

#include <kapp.h>
#include <kiconloader.h>

/**
* Internal display class for @ref KIconLoaderDialog
* @short Internal display class for KIconLoaderDialog
* @version $Id: kiconloaderdialog.h,v 1.1 2006-10-03 11:26:31 dslinux_amadeus Exp $
* @author Christoph.Neerfeld at bonn.netsurf.de
*/
class KIconLoaderCanvas : public QTableView
{
  Q_OBJECT
public:
  KIconLoaderCanvas (QWidget *parent=0, const char *name=0);
  ~KIconLoaderCanvas ();

  void loadDir(QString dirname, QString filter);
  QString getCurrent() { if(name_list.isEmpty()) return ""; return name_list.at(sel_id); }
  void cancelLoad();

signals:
  void nameChanged( const char * );
  void doubleClicked();
  void interrupted();

protected slots:
  void process();

protected:
  virtual void resizeEvent( QResizeEvent *e );

  void paintCell( QPainter *p, int r, int c );
  void enterEvent( QEvent * ) { setMouseTracking(TRUE); }
  void leaveEvent( QEvent * ) { setMouseTracking(FALSE); }
  void mouseMoveEvent( QMouseEvent *e );
  void mousePressEvent( QMouseEvent *e );
  void mouseDoubleClickEvent( QMouseEvent *e );

  int            sel_id;
  int            max_width;
  int            max_height;
  int            curr_indx;
  QList<QPixmap> pixmap_list;
  QStrList       file_list;
  QStrList       name_list;
  QTimer         *timer;
  QString        dir_name;
};

/** 
* Dialog for interactive selection of icons.
*
* KIconLoaderDialog is a derived class from QDialog.
* It provides one function selectIcon() which displays a dialog.
* This dialog lets you select the icons within the IconPath by image.
*/
class KIconLoaderDialog : public QDialog
{
  Q_OBJECT
public:
  /// Constructor
  /**
     The KIconLoaderDialog is a modal dialog; i.e. it has its own eventloop
     and the normal program will stop after a call to selectIcon() until
     selectIcon() returns.
     This constructor creates a KIconLoaderDialog that will call
     KApplication::getKApplication()->getIconLoader() to load any icons.
     Note that it will not use this KIconLoader to display the icons, but
     the QPixmap that it returns will be know to this KIconLoader.
     KIconLoaderDialog caches all icons it has loaded as long as they are in the
     same directory between two calls to selectIcon(). So it is a good idea to
     delete the KIconLoaderDialog when it is not needed anymore.
  */
  KIconLoaderDialog ( QWidget *parent=0, const char *name=0 );

  /**
     If you want to use another KIconLoader you can create the KIconLoaderDialog
     with this constructor which accepts a pointer to a KIconLoader.
     Make sure that this pointer is valid.
  */
  KIconLoaderDialog ( KIconLoader *loader, QWidget *parent=0, const char *name=0 );

  /// Destructor
  ~KIconLoaderDialog ();

  /// Select an icon from a modal choose dialog
  /**
	 This function pops up a modal dialog and lets you select an icon by its
	 picture not name. The function returns a QPixmap object and the icons 
	 name in 'name'
	 if the user has selected an icon, or null if the user has pressed the 
	 cancel button. So check the result before taking any action.
	 The argument filter specifies a filter for the names of the icons to 
	 display. For example "*" displays all icons and "mini*" displays only 
	 those icons which names start with 'mini'.
  */
  QPixmap selectIcon( QString &name, const QString &filter);
  void setDir( const QStrList *l ) { cb_dirs->clear(); cb_dirs->insertStrList(l); }
  int exec(QString filter);

protected slots:
  void filterChanged();
  void dirChanged(const char *);
  void reject();
  void needReload();
  
protected:
  void init();
  virtual void resizeEvent( QResizeEvent *e );

  KIconLoaderCanvas *canvas;
  QLabel            *l_name;
  QLineEdit         *i_filter;
  QLabel            *l_filter;
  QPushButton       *ok;
  QPushButton       *cancel;
  QLabel            *text;
  QComboBox         *cb_dirs;
  KIconLoader       *icon_loader;
};

/**
 * This is a button that uses the @ref KIconLoaderDialog.
 * It shows the currently selected icon. Pressing on
 * the icon will open the dialog. If the icon changes, a
 * signal is emitted and the buttons pixmap becomes updated.
 *
 * HACK
 * Since I did not want to break binary compatibility, it does
 * NOT use the same search path as the dialog. This IS a bug.
 */
class KIconLoaderButton : public QPushButton
{
    Q_OBJECT
public:
    /**
     * Creates a new button.
     */
    KIconLoaderButton( QWidget *_widget );
    KIconLoaderButton( KIconLoader *_icon_loader, QWidget *_widget );
    ~KIconLoaderButton();
    
    /**
     * Set the buttons icon. 
     *
     * @param _icon is a parameter as usually passed to @ref KIconLoader.
     */
    void setIcon( const char *_icon );
    /**
     * @return the name of the icon without path.
     */
    const char* icon() { return iconStr.data(); }
    /**
     * @return a reference to the icon loader dialog used.
     */
    KIconLoaderDialog* iconLoaderDialog() { return loaderDialog; }
    
public slots:
    void slotChangeIcon();
    
signals:
    /**
     * Emitted if the icons has changed.
     */
    void iconChanged( const char *icon );
    
protected:
    KIconLoaderDialog *loaderDialog;
    QString iconStr;
    KIconLoader *iconLoader;
};


#endif // KICONLOADERDIALOG_H




--- NEW FILE: kwmmapp.h ---
/* This file is part of the KDE libraries
    Copyright (C) 1997 Matthias Ettrich (ettrich at kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
/*
 * kwmmapp.h. Part of the KDE project.
 *
 * Copyright (C) 1997 Matthias Ettrich
 *
 */

#ifndef KWM_MODULE_APPLICATION_H
#define KWM_MODULE_APPLICATION_H

#include <qapplication.h>
#include <qlist.h>
#include <qwidget.h>
#include <kapp.h>

#include "kwm.h"


/**
 * The class KWMModuleApplication is the base class for KDE
 * windowmanager modules. It mainly informs a module about all
 * currently managed windows and changes to them (via Qt
 * signals). There are no methods to manipulate windows. These are
 * defined in the class KWM (see kwm.h).
 * @short Base class for KDE Window Manager modules.
 * @author Matthias Ettrich (ettrich at kde.org)
 * @version $Id: kwmmapp.h,v 1.1 2006-10-03 11:26:33 dslinux_amadeus Exp $
 */
class KWMModuleApplication:public KApplication {
  Q_OBJECT

public:

  KWMModuleApplication( int &argc, char *argv[]);
  KWMModuleApplication( int &argc, char *argv[], const QString& rAppName);
  virtual ~KWMModuleApplication(){};

  /**
   * Connect to KWM. This cannot be done in the constructor, since your
   * application probably is not ready to recieve messages at this state.
   */
  void connectToKWM(bool dock_module = false);

  /**
	if you inherit KWMModuleApplication and overload x11EventFilter,
     be sure to call its x11EventFilter in your x11EventFilter:
           if (KWMModuleApplication::x11EventFilter(XEvent *))
               return True;
  */
  virtual bool x11EventFilter( XEvent * );

  /**
   * A list of all toplevel windows currently managed by the
   * windowmanger in the order of creation. Please do not rely on
   * indexes of this list: Whenever you enter Qt's eventloop in your
   * application it may happen, that entries are removed or added! So
   * your module should perhaps work on a copy of this list and verify a
   * window with hasWindow() before any operations.
   */
  QList <Window> windows;

  /**
   * A list of all toplevel windows currently managed by the
   * windowmanger in the current stacking order (from lower to
   * higher). May be useful for pagers.
   */
  QList <Window> windows_sorted;

  /**
   * Is <Window> still managed at present?
   */
  bool hasWindow(Window);


  /**
    * The dock windows. Only valid if you are succesfully connected as
    * docking module
    */
  QList <Window> dock_windows;

signals:

  /**
   * Note that an init() may also be emitted if the window manager is
   * restarted. So your module MUST react on it by clearing all internal
   * data structures.
   */
  void init();


  /**
   *    This signal is emitted when a connect is complete, i.e. when
   *    all existing windows or soundevents have been transfered to
   *    the module
   */
  void initialized();

  /**
   * Switch to another virtual desktop
   */
  void desktopChange(int);

  /**
   * Add a window
   */
  void windowAdd(Window);

  /**
     Add a dialog window. Note that dialog windows are also included
     in the set of windows you recieve with windowAdd (see above).
     The dialogs are reported extra (before the windowAdd) to allow a
     taskbar to exclude them. The dialogWindowAdd signal is guaranteed
     to be emitted before the correspondinging windowAdd signal.
   */
  void dialogWindowAdd(Window);

  /**
   * Remove a window
   */
  void windowRemove(Window);

  /**
   * A window has been changed (size, title, etc.)
   */
  void windowChange(Window);

  /**
   * Raise a window
   */
  void windowRaise(Window);

  /**
   * Lower a window
   */
  void windowLower(Window);

  /**
   * Hint that <Window> is active (= has focus) now.
   */
  void windowActivate(Window);

  /**
    * A command kwm did not understand. Maybe it is for
    * your module.
    */
  void commandReceived(QString);


  /**
    * This is not integrated into windowChange since reading
    * icons is somewhat expensive via the KWM class.
    */
  void windowIconChanged(Window);

  /**
    * The specified desktop got a new name
    */
  void desktopNameChange(int, QString);

  /**
    * The number of desktops changed
    */
  void desktopNumberChange(int);

  /**
   * Add a dock window
   */
  void dockWindowAdd(Window);

  /**
   * Remove a dock window
   */
  void dockWindowRemove(Window);

  /**
    * Play/register/unregister a sound
    */
  void playSound(QString);
  void registerSound(QString);
  void unregisterSound(QString);


private:
  QWidget* module;

};

#endif // KWM_MODULE_APPLICATION_H







More information about the dslinux-commit mailing list