• 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
30class TQWidgetStack;
31
42class TDEAccelString
43{
44public:
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
67private:
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
80typedef TQValueList<TDEAccelString> TDEAccelStringList;
81
82
90class TDEAccelManagerAlgorithm
91{
92public:
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
122class TQPopupMenu;
123
124
134class TDEPopupAccelManager : public TQObject
135{
136 TQ_OBJECT
137
138public:
139
140 static void manage(TQPopupMenu *popup);
141
142
143protected:
144
145 TDEPopupAccelManager(TQPopupMenu *popup);
146
147
148private slots:
149
150 void aboutToShow();
151
152
153private:
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
167class QWidgetStackAccelManager : public TQObject
168{
169 TQ_OBJECT
170
171public:
172
173 static void manage(TQWidgetStack *popup);
174
175
176protected:
177
178 QWidgetStackAccelManager(TQWidgetStack *popup);
179
180
181private slots:
182
183 void aboutToShow(TQWidget *);
184 bool eventFilter ( TQObject * watched, TQEvent * e );
185
186private:
187
188 void calculateAccelerators();
189
190 TQWidgetStack *m_stack;
191 TDEAccelStringList m_entries;
192
193};
194
195
196#endif
TDEAccelManagerAlgorithm
This class encapsulates the algorithm finding the 'best' distribution of accelerators in a hierarchy ...
Definition: tdeaccelmanager_private.h:91
TDEAccelManagerAlgorithm::findAccelerators
static void findAccelerators(TDEAccelStringList &result, TQString &used)
Method to call to find the best distribution of accelerators.
Definition: tdeaccelmanager.cpp:682
TDEAccelManagerAlgorithm::FIRST_CHARACTER_EXTRA_WEIGHT
@ FIRST_CHARACTER_EXTRA_WEIGHT
Additional weight for first character in string.
Definition: tdeaccelmanager_private.h:99
TDEAccelManagerAlgorithm::STANDARD_ACCEL
@ STANDARD_ACCEL
Additional weight for KDE standard accelerators.
Definition: tdeaccelmanager_private.h:113
TDEAccelManagerAlgorithm::MENU_TITLE_WEIGHT
@ MENU_TITLE_WEIGHT
Default weight for menu titles.
Definition: tdeaccelmanager_private.h:111
TDEAccelManagerAlgorithm::GROUP_BOX_WEIGHT
@ GROUP_BOX_WEIGHT
Default weight for group boxes (low priority)
Definition: tdeaccelmanager_private.h:109
TDEAccelManagerAlgorithm::DIALOG_BUTTON_EXTRA_WEIGHT
@ DIALOG_BUTTON_EXTRA_WEIGHT
Additional weight for the dialog buttons (large, we basically never want these reassigned)
Definition: tdeaccelmanager_private.h:103
TDEAccelManagerAlgorithm::WANTED_ACCEL_EXTRA_WEIGHT
@ WANTED_ACCEL_EXTRA_WEIGHT
Additional weight for a 'wanted' accelerator.
Definition: tdeaccelmanager_private.h:105
TDEAccelManagerAlgorithm::DEFAULT_WEIGHT
@ DEFAULT_WEIGHT
Default control weight.
Definition: tdeaccelmanager_private.h:97
TDEAccelManagerAlgorithm::WORD_BEGINNING_EXTRA_WEIGHT
@ WORD_BEGINNING_EXTRA_WEIGHT
Additional weight for the beginning of a word.
Definition: tdeaccelmanager_private.h:101
TDEAccelManagerAlgorithm::ACTION_ELEMENT_WEIGHT
@ ACTION_ELEMENT_WEIGHT
Default weight for an 'action' widget (ie, pushbuttons)
Definition: tdeaccelmanager_private.h:107
TDEAccelString
A string class handling accelerators.
Definition: tdeaccelmanager_private.h:43
TDEPopupAccelManager
This class manages a popup menu.
Definition: tdeaccelmanager_private.h:135

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.9.4
This website is maintained by Timothy Pearson.