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

tdecore

  • tdecore
tdeaccelmanager_private.h
1 /* This file is part of the KDE project
2  Copyright (C) 2002 Matthias Hoelzer-Kluepfel <mhk@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 
21 #ifndef __TDEACCELMANAGER_PRIVATE_H__
22 #define __TDEACCELMANAGER_PRIVATE_H__
23 
24 
25 #include <tqstring.h>
26 #include <tqmemarray.h>
27 #include <tqvaluelist.h>
28 #include <tqobject.h>
29 
30 class TQWidgetStack;
31 
42 class TDEAccelString
43 {
44 public:
45 
46  TDEAccelString() : m_pureText(), m_accel(-1) {}
47  TDEAccelString(const TQString &input, int initalWeight=-1);
48 
49  void calculateWeights(int initialWeight);
50 
51  const TQString &pure() const { return m_pureText; }
52  TQString accelerated() const;
53 
54  int accel() const { return m_accel; }
55  void setAccel(int accel) { m_accel = accel; }
56 
57  int originalAccel() const { return m_orig_accel; }
58  TQString originalText() const { return m_origText; }
59 
60  TQChar accelerator() const;
61 
62  int maxWeight(int &index, const TQString &used);
63 
64  bool operator == (const TDEAccelString &c) const { return m_pureText == c.m_pureText && m_accel == c.m_accel && m_orig_accel == c.m_orig_accel; }
65 
66 
67 private:
68 
69  int stripAccelerator(TQString &input);
70 
71  void dump();
72 
73  TQString m_pureText, m_origText;
74  int m_accel, m_orig_accel;
75  TQMemArray<int> m_weight;
76 
77 };
78 
79 
80 typedef TQValueList<TDEAccelString> TDEAccelStringList;
81 
82 
90 class TDEAccelManagerAlgorithm
91 {
92 public:
93 
95  enum {
97  DEFAULT_WEIGHT = 50,
99  FIRST_CHARACTER_EXTRA_WEIGHT = 50,
101  WORD_BEGINNING_EXTRA_WEIGHT = 50,
103  DIALOG_BUTTON_EXTRA_WEIGHT = 300,
105  WANTED_ACCEL_EXTRA_WEIGHT = 150,
107  ACTION_ELEMENT_WEIGHT = 50,
109  GROUP_BOX_WEIGHT = -2000,
111  MENU_TITLE_WEIGHT = 250,
113  STANDARD_ACCEL = 300
114  };
115 
117  static void findAccelerators(TDEAccelStringList &result, TQString &used);
118 
119 };
120 
121 
122 class TQPopupMenu;
123 
124 
134 class TDEPopupAccelManager : public TQObject
135 {
136  Q_OBJECT
137 
138 public:
139 
140  static void manage(TQPopupMenu *popup);
141 
142 
143 protected:
144 
145  TDEPopupAccelManager(TQPopupMenu *popup);
146 
147 
148 private slots:
149 
150  void aboutToShow();
151 
152 
153 private:
154 
155  void calculateAccelerators();
156 
157  void findMenuEntries(TDEAccelStringList &list);
158  void setMenuEntries(const TDEAccelStringList &list);
159 
160  TQPopupMenu *m_popup;
161  TDEAccelStringList m_entries;
162  int m_count;
163 
164 };
165 
166 
167 class QWidgetStackAccelManager : public TQObject
168 {
169  Q_OBJECT
170 
171 public:
172 
173  static void manage(TQWidgetStack *popup);
174 
175 
176 protected:
177 
178  QWidgetStackAccelManager(TQWidgetStack *popup);
179 
180 
181 private slots:
182 
183  void aboutToShow(TQWidget *);
184  bool eventFilter ( TQObject * watched, TQEvent * e );
185 
186 private:
187 
188  void calculateAccelerators();
189 
190  TQWidgetStack *m_stack;
191  TDEAccelStringList m_entries;
192 
193 };
194 
195 
196 #endif
TDEAccelManagerAlgorithm::findAccelerators
static void findAccelerators(TDEAccelStringList &result, TQString &used)
Method to call to find the best distribution of accelerators.
Definition: tdeaccelmanager.cpp:682
TDEAccelString
A string class handling accelerators.
Definition: tdeaccelmanager_private.h:42
TDEAccelManagerAlgorithm::DEFAULT_WEIGHT
Default control weight.
Definition: tdeaccelmanager_private.h:97
TDEAccelManagerAlgorithm::WORD_BEGINNING_EXTRA_WEIGHT
Additional weight for the beginning of a word.
Definition: tdeaccelmanager_private.h:101
TDEAccelManagerAlgorithm::DIALOG_BUTTON_EXTRA_WEIGHT
Additional weight for the dialog buttons (large, we basically never want these reassigned) ...
Definition: tdeaccelmanager_private.h:103
TDEAccelManagerAlgorithm::GROUP_BOX_WEIGHT
Default weight for group boxes (low priority)
Definition: tdeaccelmanager_private.h:109
TDEPopupAccelManager
This class manages a popup menu.
Definition: tdeaccelmanager_private.h:134
TDEAccelManagerAlgorithm
This class encapsulates the algorithm finding the 'best' distribution of accelerators in a hierarchy ...
Definition: tdeaccelmanager_private.h:90
TDEAccelManagerAlgorithm::STANDARD_ACCEL
Additional weight for KDE standard accelerators.
Definition: tdeaccelmanager_private.h:113
TDEAccelManagerAlgorithm::MENU_TITLE_WEIGHT
Default weight for menu titles.
Definition: tdeaccelmanager_private.h:111
TDEAccelManagerAlgorithm::FIRST_CHARACTER_EXTRA_WEIGHT
Additional weight for first character in string.
Definition: tdeaccelmanager_private.h:99
TDEAccelManagerAlgorithm::ACTION_ELEMENT_WEIGHT
Default weight for an 'action' widget (ie, pushbuttons)
Definition: tdeaccelmanager_private.h:107
TDEAccelManagerAlgorithm::WANTED_ACCEL_EXTRA_WEIGHT
Additional weight for a 'wanted' accelerator.
Definition: tdeaccelmanager_private.h:105

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.8
This website is maintained by Timothy Pearson.