• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

tdeaccelmanager_private.h

00001 /*  This file is part of the KDE project
00002     Copyright (C) 2002 Matthias Hoelzer-Kluepfel <mhk@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 
00021 #ifndef __TDEACCELMANAGER_PRIVATE_H__
00022 #define __TDEACCELMANAGER_PRIVATE_H__
00023 
00024 
00025 #include <tqstring.h>
00026 #include <tqmemarray.h>
00027 #include <tqvaluelist.h>
00028 #include <tqobject.h>
00029 
00030 class TQWidgetStack;
00031 
00042 class TDEAccelString
00043 {
00044 public:
00045 
00046   TDEAccelString() : m_pureText(), m_accel(-1) {}
00047   TDEAccelString(const TQString &input, int initalWeight=-1);
00048 
00049   void calculateWeights(int initialWeight);
00050 
00051   const TQString &pure() const { return m_pureText; }
00052   TQString accelerated() const;
00053 
00054   int accel() const { return m_accel; }
00055   void setAccel(int accel) { m_accel = accel; }
00056 
00057   int originalAccel() const { return m_orig_accel; }
00058   TQString originalText() const { return m_origText; }
00059 
00060   TQChar accelerator() const;
00061 
00062   int maxWeight(int &index, const TQString &used);
00063 
00064   bool operator == (const TDEAccelString &c) const { return m_pureText == c.m_pureText && m_accel == c.m_accel && m_orig_accel == c.m_orig_accel; }
00065 
00066 
00067 private:
00068 
00069   int stripAccelerator(TQString &input);
00070 
00071   void dump();
00072 
00073   TQString        m_pureText,  m_origText;
00074   int            m_accel, m_orig_accel;
00075   TQMemArray<int> m_weight;
00076 
00077 };
00078 
00079 
00080 typedef TQValueList<TDEAccelString> TDEAccelStringList;
00081 
00082 
00090 class TDEAccelManagerAlgorithm
00091 {
00092 public:
00093 
00095   enum {
00097     DEFAULT_WEIGHT = 50,
00099     FIRST_CHARACTER_EXTRA_WEIGHT = 50,
00101     WORD_BEGINNING_EXTRA_WEIGHT = 50,
00103     DIALOG_BUTTON_EXTRA_WEIGHT = 300,
00105     WANTED_ACCEL_EXTRA_WEIGHT = 150,
00107     ACTION_ELEMENT_WEIGHT = 50,
00109     GROUP_BOX_WEIGHT = -2000,
00111     MENU_TITLE_WEIGHT = 250,
00113     STANDARD_ACCEL = 300
00114   };
00115 
00117   static void findAccelerators(TDEAccelStringList &result, TQString &used);
00118 
00119 };
00120 
00121 
00122 class TQPopupMenu;
00123 
00124 
00134 class TDEPopupAccelManager : public TQObject
00135 {
00136   Q_OBJECT
00137 
00138 public:
00139 
00140   static void manage(TQPopupMenu *popup);
00141 
00142 
00143 protected:
00144 
00145   TDEPopupAccelManager(TQPopupMenu *popup);
00146 
00147 
00148 private slots:
00149 
00150   void aboutToShow();
00151 
00152 
00153 private:
00154 
00155   void calculateAccelerators();
00156 
00157   void findMenuEntries(TDEAccelStringList &list);
00158   void setMenuEntries(const TDEAccelStringList &list);
00159 
00160   TQPopupMenu       *m_popup;
00161   TDEAccelStringList m_entries;
00162   int              m_count;
00163 
00164 };
00165 
00166 
00167 class QWidgetStackAccelManager : public TQObject
00168 {
00169   Q_OBJECT
00170 
00171 public:
00172 
00173   static void manage(TQWidgetStack *popup);
00174 
00175 
00176 protected:
00177 
00178   QWidgetStackAccelManager(TQWidgetStack *popup);
00179 
00180 
00181 private slots:
00182 
00183   void aboutToShow(TQWidget *);
00184     bool eventFilter ( TQObject * watched, TQEvent * e );
00185 
00186 private:
00187 
00188   void calculateAccelerators();
00189 
00190   TQWidgetStack     *m_stack;
00191   TDEAccelStringList m_entries;
00192 
00193 };
00194 
00195 
00196 #endif

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.7.1
This website is maintained by Timothy Pearson.