kkbdaccessextensions.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005, Gary Cramblitt <garycramblitt@comcast.net>
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// TQt includes
21#include <tqsplitter.h>
22#include <tqdockwindow.h>
23#include <tqdockarea.h>
24#include <tqevent.h>
25#include <tqcursor.h>
26#include <tqobjectlist.h>
27#include <tqwidgetlist.h>
28#include <tqlabel.h>
29#include <tqtooltip.h>
30
31// KDE includes
32#include <tdelocale.h>
33#include <tdeglobal.h>
34#include <tdeapplication.h>
35#include <tdemainwindow.h>
36#include <tdeaction.h>
37#include <kdebug.h>
38
39// KKbdAccessExtensions includes
41// TODO: See eventFilter method.
42//#include "kkbdaccessextensions.moc"
43
44class KPanelKbdSizerIcon : public TQCursor
45{
46 public:
47 KPanelKbdSizerIcon() :
48 TQCursor(TQt::SizeAllCursor),
49 isActive(false)
50 {
51 currentPos = TQPoint(-1, -1);
52 }
53
54 ~KPanelKbdSizerIcon()
55 {
56 hide();
57 }
58
59 void show(const TQPoint p) {
60 if (!isActive) {
61 originalPos = TQCursor::pos();
62 kapp->setOverrideCursor(*this);
63 isActive = true;
64 }
65 if (p != pos())
66 setPos(p);
67 currentPos = p;
68 }
69
70 void hide() {
71 if (isActive) {
72 kapp->restoreOverrideCursor();
73 TQCursor::setPos(originalPos);
74 }
75 isActive = false;
76 }
77
78 void setShape(int shayp)
79 {
80 if (shayp != shape()) {
81 // Must restore and override to get the icon to refresh.
82 if (isActive) kapp->restoreOverrideCursor();
83 TQCursor::setShape((TQt::CursorShape)shayp);
84 if (isActive) kapp->setOverrideCursor(*this);
85 }
86 }
87
88 // Return the difference between a position and where icon is supposed to be.
89 TQSize delta(const TQPoint p)
90 {
91 TQPoint d = p - currentPos;
92 return TQSize(d.x(), d.y());
93 }
94
95 // Return the difference between where the icon is currently positioned and where
96 // it is supposed to be.
97 TQSize delta() { return delta(pos()); }
98
99 // True if the sizing icon is visible.
100 bool isActive;
101
102 private:
103 // Icon's current position.
104 TQPoint currentPos;
105 // Mouse cursor's original position when icon is shown.
106 TQPoint originalPos;
107};
108
109class KKbdAccessExtensionsPrivate
110{
111 public:
112 KKbdAccessExtensionsPrivate() :
113 fwdAction(0),
114 revAction(0),
115 accessKeysAction(0),
116 panel(0),
117 handleNdx(0),
118 icon(0),
119 stepSize(10),
120 accessKeyLabels(0) {};
121
122 ~KKbdAccessExtensionsPrivate()
123 {
124 delete icon;
125 // TODO: This crashes, but should delete in the event that TDEMainWindow is not deleted.
126 if (accessKeyLabels) {
127 accessKeyLabels->setAutoDelete(false);
128 delete accessKeyLabels;
129 }
130 }
131
132 // Action that starts panel sizing (defaults to F8), forward and reverse;
133 TDEAction* fwdAction;
134 TDEAction* revAction;
135
136 // Action that starts access keys.
137 TDEAction* accessKeysAction;
138
139 // The splitter or dockwindow currently being sized. If 0, sizing is not in progress.
140 TQWidget* panel;
141
142 // Index of current handle of the panel. When panel is a TQDockWindow:
143 // 1 = size horizontally
144 // 2 = size vertically
145 uint handleNdx;
146
147 // Sizing icon.
148 KPanelKbdSizerIcon* icon;
149
150 // Sizing increment.
151 int stepSize;
152
153 // List of the access key TQLabels. If not 0, access keys are onscreen.
154 TQPtrList<TQLabel>* accessKeyLabels;
155
156 // Pointer to the TDEMainWindow.
157 TDEMainWindow* mainWindow;
158};
159
161 TQObject(parent, name)
162{
163 // kdDebug() << "KKbdAccessExtensions::KKbdAccessExtensions: running." << endl;
164 d = new KKbdAccessExtensionsPrivate;
165 d->mainWindow = parent;
166 d->fwdAction = new TDEAction(i18n("Resize Panel Forward"), TDEShortcut("F8"),
167 0, 0, parent->actionCollection(), "resize_panel_forward");
168 d->revAction = new TDEAction(i18n("Resize Panel Reverse"), TDEShortcut("Shift+F8"),
169 0, 0, parent->actionCollection(), "resize_panel_reverse");
170 d->accessKeysAction = new TDEAction(i18n("Access Keys"), TDEShortcut("Alt+F8"),
171 0, 0, parent->actionCollection(), "access_keys");
172 // "Disable" the shortcuts so we can see them in eventFilter.
173 d->fwdAction->setEnabled(false);
174 d->revAction->setEnabled(false);
175 d->accessKeysAction->setEnabled(false);
176 d->icon = new KPanelKbdSizerIcon();
177 kapp->installEventFilter(this);
178}
179
181{
182 kapp->removeEventFilter(this);
183 if (d->panel) exitSizing();
184 delete d;
185}
186
187int KKbdAccessExtensions::stepSize() const { return d->stepSize; }
188
189void KKbdAccessExtensions::setStepSize(int s) { d->stepSize = s; }
190
191bool KKbdAccessExtensions::eventFilter( TQObject *o, TQEvent *e )
192{
193 if ( e->type() == TQEvent::KeyPress ) {
194 // TODO: This permits only a single-key shortcut. For example, Alt+S,R would not work.
195 // If user configures a multi-key shortcut, it is undefined what will happen here.
196 // It would be better to handle these as TDEShortcut activate() signals, but the problem
197 // is that once a TQDockWindow is undocked and has focus, the TDEShortcut activate() signals
198 // don't fire anymore.
199 TDEShortcut fwdSc = d->fwdAction->shortcut();
200 TDEShortcut revSc = d->revAction->shortcut();
201 TDEShortcut accessKeysSc = d->accessKeysAction->shortcut();
202 TQKeyEvent* kev = dynamic_cast<TQKeyEvent *>(e);
203 KKey k = KKey(kev);
204 TDEShortcut sc = TDEShortcut(k);
205 // kdDebug() << "KKbdAccessExtensions::eventFilter: Key press " << sc << endl;
206 if (!d->accessKeyLabels) {
207 if (sc == fwdSc) {
208 nextHandle();
209 return true;
210 }
211 if (sc == revSc) {
212 prevHandle();
213 return true;
214 }
215 }
216 if (d->panel) {
217 if (k == KKey(Key_Escape))
218 exitSizing();
219 else
220 resizePanelFromKey(kev->key(), kev->state());
221 // Eat the key.
222 return true;
223 }
224 if (sc == accessKeysSc && !d->panel) {
225 if (d->accessKeyLabels) {
226 delete d->accessKeyLabels;
227 d->accessKeyLabels = 0;
228 } else
230 return true;
231 }
232 if (d->accessKeyLabels) {
233 if (k == KKey(Key_Escape)) {
234 delete d->accessKeyLabels;
235 d->accessKeyLabels = 0;
236 } else
237 handleAccessKey(kev);
238 return true;
239 }
240 return false;
241 }
242 else if (d->icon->isActive && e->type() == TQEvent::MouseButtonPress) {
243 exitSizing();
244 return true;
245 }
246 else if (d->accessKeyLabels && e->type() == TQEvent::MouseButtonPress) {
247 delete d->accessKeyLabels;
248 d->accessKeyLabels = 0;
249 return true;
250 }
251/* else if (e->type() == TQEvent::MouseMove && d->icon->isActive) {
252 // Lock mouse cursor down.
253 showIcon();
254 dynamic_cast<TQMouseEvent *>(e)->accept();
255 return true;
256 }*/
257 else if (e->type() == TQEvent::MouseMove && d->icon->isActive && d->panel) {
258 // Resize according to mouse movement.
259 TQMouseEvent* me = dynamic_cast<TQMouseEvent *>(e);
260 TQSize s = d->icon->delta();
261 int dx = s.width();
262 int dy = s.height();
263 resizePanel(dx, dy, me->state());
264 me->accept();
265 showIcon();
266 return true;
267 }
268 else if (e->type() == TQEvent::Resize && d->panel && o == d->panel) {
269 // TODO: This doesn't always work.
270 showIcon();
271 }
272 return false;
273}
274
276{
277 TQWidgetList* allWidgets = kapp->allWidgets();
278 TQWidgetList* allPanels = new TQWidgetList;
279 TQWidget* widget = allWidgets->first();
280 while (widget) {
281 if (widget->isVisible()) {
282 if (::tqt_cast<TQSplitter*>( widget )) {
283 // Only size TQSplitters with at least two handles (there is always one hidden).
284 if (dynamic_cast<TQSplitter *>(widget)->sizes().count() >= 2)
285 allPanels->append(widget);
286 } else if (::tqt_cast<TQDockWindow*>( widget )) {
287 if (dynamic_cast<TQDockWindow *>(widget)->isResizeEnabled()) {
288 // kdDebug() << "KKbdAccessExtensions::getAllPanels: TQDockWindow = " << widget->name() << endl;
289 allPanels->append(widget);
290 }
291 }
292 }
293 widget = allWidgets->next();
294 }
295 delete allWidgets;
296 return allPanels;
297}
298
300{
301 TQWidget* panel = d->panel;
302 // See if current panel has another handle. If not, find next panel.
303 if (panel) {
304 bool advance = true;
305 d->handleNdx++;
306 if (::tqt_cast<TQSplitter*>( panel ))
307 advance = (d->handleNdx >= dynamic_cast<TQSplitter *>(panel)->sizes().count());
308 else
309 // Undocked windows have only one "handle" (center).
310 advance = (d->handleNdx > 2 || !dynamic_cast<TQDockWindow *>(panel)->area());
311 if (advance) {
312 TQWidgetList* allWidgets = getAllPanels();
313 allWidgets->findRef(panel);
314 panel = 0;
315 if (allWidgets->current()) panel = allWidgets->next();
316 delete allWidgets;
317 d->handleNdx = 1;
318 }
319 } else {
320 // Find first panel.
321 TQWidgetList* allWidgets = getAllPanels();
322 panel = allWidgets->first();
323 delete allWidgets;
324 d->handleNdx = 1;
325 }
326 d->panel = panel;
327 if (panel)
328 showIcon();
329 else
330 exitSizing();
331}
332
334{
335 TQWidget* panel = d->panel;
336 // See if current panel has another handle. If not, find previous panel.
337 if (panel) {
338 bool rewind = true;
339 d->handleNdx--;
340 rewind = (d->handleNdx < 1);
341 if (rewind) {
342 TQWidgetList* allWidgets = getAllPanels();
343 allWidgets->findRef(panel);
344 panel = 0;
345 if (allWidgets->current()) panel = allWidgets->prev();
346 delete allWidgets;
347 if (panel) {
348 if (::tqt_cast<TQSplitter*>( panel ))
349 d->handleNdx = dynamic_cast<TQSplitter *>(panel)->sizes().count() - 1;
350 else {
351 if (dynamic_cast<TQDockWindow *>(panel)->area())
352 d->handleNdx = 2;
353 else
354 d->handleNdx = 1;
355 }
356 }
357 }
358 } else {
359 // Find last panel.
360 TQWidgetList* allWidgets = getAllPanels();
361 panel = allWidgets->last();
362 delete allWidgets;
363 if (panel) {
364 if (::tqt_cast<TQSplitter*>( panel ))
365 d->handleNdx = dynamic_cast<TQSplitter *>(panel)->sizes().count() - 1;
366 else {
367 if (dynamic_cast<TQDockWindow *>(panel)->area())
368 d->handleNdx = 2;
369 else
370 d->handleNdx = 1;
371 }
372 }
373 }
374 d->panel = panel;
375 if (panel)
376 showIcon();
377 else
378 exitSizing();
379}
380
382{
383 // kdDebug() << "KKbdAccessExtensions::exiting sizing mode." << endl;
384 hideIcon();
385 d->handleNdx = 0;
386 d->panel = 0;
387}
388
390{
391 if (!d->panel) return;
392 TQPoint p;
393 // kdDebug() << "KKbdAccessExtensions::showIcon: topLevelWidget = " << d->panel->topLevelWidget()->name() << endl;
394 if (::tqt_cast<TQSplitter*>( d->panel )) {
395 TQSplitter* splitter = dynamic_cast<TQSplitter *>(d->panel);
396 int handleNdx = d->handleNdx - 1;
397 TQValueList<int> sizes = splitter->sizes();
398 // kdDebug() << "KKbdAccessExtensions::showIcon: sizes = " << sizes << endl;
399 if (splitter->orientation() == TQt::Horizontal) {
400 d->icon->setShape(TQt::SizeHorCursor);
401 p.setX(sizes[handleNdx] + (splitter->handleWidth() / 2));
402 p.setY(splitter->height() / 2);
403 } else {
404 d->icon->setShape(TQt::SizeVerCursor);
405 p.setX(splitter->width() / 2);
406 p.setY(sizes[handleNdx] + (splitter->handleWidth() / 2));
407 }
408 // kdDebug() << "KKbdAccessExtensions::showIcon: p = " << p << endl;
409 p = splitter->mapToGlobal(p);
410 // kdDebug() << "KKbdAccessExtensions::showIcon: mapToGlobal = " << p << endl;
411 } else {
412 TQDockWindow* dockWindow = dynamic_cast<TQDockWindow *>(d->panel);
413 p = dockWindow->pos();
414 if (dockWindow->area()) {
415 // kdDebug() << "KKbdAccessExtensions::showIcon: pos = " << p << " of window = " << dockWindow->parentWidget()->name() << endl;
416 p = dockWindow->parentWidget()->mapTo(dockWindow->topLevelWidget(), p);
417 // kdDebug() << "KKbdAccessExtensions::showIcon: mapTo = " << p << " of window = " << dockWindow->topLevelWidget()->name() << endl;
418 // TODO: How to get the handle width?
419 if (d->handleNdx == 1) {
420 d->icon->setShape(TQt::SizeHorCursor);
421 if (dockWindow->area()->orientation() == TQt::Vertical) {
422 if (dockWindow->area()->handlePosition() == TQDockArea::Normal)
423 // Handle is to the right of the dock window.
424 p.setX(p.x() + dockWindow->width());
425 // else Handle is to the left of the dock window.
426 } else
427 // Handle is to the right of the dock window.
428 p.setX(p.x() + dockWindow->width());
429 p.setY(p.y() + (dockWindow->height() / 2));
430 } else {
431 d->icon->setShape(TQt::SizeVerCursor);
432 p.setX(p.x() + (dockWindow->width() / 2));
433 if (dockWindow->area()->orientation() == TQt::Vertical)
434 // Handle is below the dock window.
435 p.setY(p.y() + dockWindow->height());
436 else {
437 if (dockWindow->area()->handlePosition() == TQDockArea::Normal)
438 // Handle is below the dock window.
439 p.setY(p.y() + dockWindow->height());
440 // else Handle is above the dock window.
441 }
442 }
443 p = dockWindow->topLevelWidget()->mapToGlobal(p);
444 } else {
445 d->icon->setShape(TQt::SizeAllCursor);
446 p = TQPoint(dockWindow->width() / 2, dockWindow->height() / 2);
447 p = dockWindow->mapToGlobal(p); // Undocked. Position in center of window.
448 }
449 }
450 // kdDebug() << "KKbdAccessExtensions::showIcon: show(p) = " << p << endl;
451 d->icon->show(p);
452}
453
455{
456 d->icon->hide();
457}
458
459void KKbdAccessExtensions::resizePanel(int dx, int dy, int state)
460{
461 int adj = dx + dy;
462 if (adj == 0) return;
463 // kdDebug() << "KKbdAccessExtensions::resizePanel: panel = " << d->panel->name() << endl;
464 if (::tqt_cast<TQSplitter*>( d->panel )) {
465 TQSplitter* splitter = dynamic_cast<TQSplitter *>(d->panel);
466 int handleNdx = d->handleNdx - 1;
467 TQValueList<int> sizes = splitter->sizes();
468 // kdDebug() << "KKbdAccessExtensions::resizePanel: before sizes = " << sizes << endl;
469 sizes[handleNdx] = sizes[handleNdx] + adj;
470 // kdDebug() << "KKbdAccessExtensions::resizePanel: setSizes = " << sizes << endl;
471 splitter->setSizes(sizes);
472 TQApplication::postEvent(splitter, new TQEvent(TQEvent::LayoutHint));
473 } else {
474 // TODO: How to get the handle width?
475 TQDockWindow* dockWindow = dynamic_cast<TQDockWindow *>(d->panel);
476 if (dockWindow->area()) {
477 // kdDebug() << "KKbdAccessExtensions::resizePanel: fixedExtent = " << dockWindow->fixedExtent() << endl;
478 TQSize fe = dockWindow->fixedExtent();
479 if (d->handleNdx == 1) {
480 // When vertically oriented and dock area is on right side of screen, pressing
481 // left arrow increases size.
482 if (dockWindow->area()->orientation() == TQt::Vertical &&
483 dockWindow->area()->handlePosition() == TQDockArea::Reverse) adj = -adj;
484 int w = fe.width();
485 if (w < 0) w = dockWindow->width();
486 w = w + adj;
487 if (w > 0 ) dockWindow->setFixedExtentWidth(w);
488 } else {
489 // When horizontally oriented and dock area is at bottom of screen,
490 // pressing up arrow increases size.
491 if (dockWindow->area()->orientation() == TQt::Horizontal &&
492 dockWindow->area()->handlePosition() == TQDockArea::Reverse) adj = -adj;
493 int h = fe.height();
494 if (h < 0) h = dockWindow->height();
495 h = h + adj;
496 if (h > 0) dockWindow->setFixedExtentHeight(h);
497 }
498 dockWindow->updateGeometry();
499 TQApplication::postEvent(dockWindow->area(), new TQEvent(TQEvent::LayoutHint));
500 // kdDebug() << "KKbdAccessExtensions::resizePanel: fixedExtent = " << dockWindow->fixedExtent() << endl;
501 } else {
502 if (state == TQt::ShiftButton) {
503 TQSize s = dockWindow->size();
504 s.setWidth(s.width() + dx);
505 s.setHeight(s.height() + dy);
506 dockWindow->resize(s);
507 } else {
508 TQPoint p = dockWindow->pos();
509 p.setX(p.x() + dx);
510 p.setY(p.y() + dy);
511 dockWindow->move(p);
512 }
513 }
514 }
515}
516
518{
519 // kdDebug() << "KPanelKdbSizer::resizePanelFromKey: key = " << key << " state = " << state << endl;
520 if (!d->panel) return;
521 int dx = 0;
522 int dy = 0;
523 int stepSize = d->stepSize;
524 switch (key) {
525 case TQt::Key_Left: dx = -stepSize; break;
526 case TQt::Key_Right: dx = stepSize; break;
527 case TQt::Key_Up: dy = -stepSize; break;
528 case TQt::Key_Down: dy = stepSize; break;
529 case TQt::Key_Prior: dy = -5 * stepSize; break;
530 case TQt::Key_Next: dy = 5 * stepSize; break;
531 }
532 int adj = dx + dy;
533 // kdDebug() << "KKbdAccessExtensions::resizePanelFromKey: adj = " << adj << endl;
534 if (adj != 0)
535 resizePanel(dx, dy, state);
536 else {
537 if (key == TQt::Key_Enter && ::tqt_cast<TQDockWindow*>( d->panel )) {
538 TQDockWindow* dockWindow = dynamic_cast<TQDockWindow *>(d->panel);
539 if (dockWindow->area())
540 dockWindow->undock();
541 else
542 dockWindow->dock();
543 }
544 }
545 showIcon();
546}
547
549{
550 // Build a list of valid access keys that don't collide with shortcuts.
551 TQString availableAccessKeys = "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
552 TQPtrList<KXMLGUIClient> allClients = d->mainWindow->factory()->clients();
553 TQPtrListIterator<KXMLGUIClient> it( allClients );
554 KXMLGUIClient *client;
555 while( (client=it.current()) !=0 )
556 {
557 ++it;
558 TDEActionPtrList actions = client->actionCollection()->actions();
559 for (int j = 0; j < (int)actions.count(); j++) {
560 TDEAction* action = actions[j];
561 TDEShortcut sc = action->shortcut();
562 for (int i = 0; i < (int)sc.count(); i++) {
563 KKeySequence seq = sc.seq(i);
564 if (seq.count() == 1) {
565 TQString s = seq.toString();
566 if (availableAccessKeys.contains(s))
567 availableAccessKeys.remove(s);
568 }
569 }
570 }
571 }
572 // Find all visible, focusable widgets and create a TQLabel for each. Don't exceed
573 // available list of access keys.
574 TQWidgetList* allWidgets = kapp->allWidgets();
575 TQWidget* widget = allWidgets->first();
576 int accessCount = 0;
577 int maxAccessCount = availableAccessKeys.length();
578 int overlap = 20;
579 TQPoint prevGlobalPos = TQPoint(-overlap, -overlap);
580 while (widget && (accessCount < maxAccessCount)) {
581 if (widget->isVisible() && widget->isFocusEnabled() ) {
582 TQRect r = widget->rect();
583 TQPoint p(r.x(), r.y());
584 // Don't display an access key if within overlap pixels of previous one.
585 TQPoint globalPos = widget->mapToGlobal(p);
586 TQPoint diffPos = globalPos - prevGlobalPos;
587 if (diffPos.manhattanLength() > overlap) {
588 accessCount++;
589 TQLabel* lab=new TQLabel(widget, "", widget, 0, TQt::WDestructiveClose);
590 lab->setPalette(TQToolTip::palette());
591 lab->setLineWidth(2);
592 lab->setFrameStyle(TQFrame::Box | TQFrame::Plain);
593 lab->setMargin(3);
594 lab->adjustSize();
595 lab->move(p);
596 if (!d->accessKeyLabels) {
597 d->accessKeyLabels = new TQPtrList<TQLabel>;
598 d->accessKeyLabels->setAutoDelete(true);
599 }
600 d->accessKeyLabels->append(lab);
601 prevGlobalPos = globalPos;
602 }
603 }
604 widget = allWidgets->next();
605 }
606 if (accessCount > 0) {
607 // Sort the access keys from left to right and down the screen.
608 TQValueList<KSortedLabel> sortedLabels;
609 for (int i = 0; i < accessCount; i++)
610 sortedLabels.append(KSortedLabel(d->accessKeyLabels->at(i)));
611 qHeapSort( sortedLabels );
612 // Assign access key labels.
613 for (int i = 0; i < accessCount; i++) {
614 TQLabel* lab = sortedLabels[i].label();
615 TQChar s = availableAccessKeys[i];
616 lab->setText(s);
617 lab->adjustSize();
618 lab->show();
619 }
620 }
621}
622
623// Handling of the HTML accesskey attribute.
624bool KKbdAccessExtensions::handleAccessKey( const TQKeyEvent* ev )
625{
626// TQt interprets the keyevent also with the modifiers, and ev->text() matches that,
627// but this code must act as if the modifiers weren't pressed
628 if (!d->accessKeyLabels) return false;
629 TQChar c;
630 if( ev->key() >= Key_A && ev->key() <= Key_Z )
631 c = 'A' + ev->key() - Key_A;
632 else if( ev->key() >= Key_0 && ev->key() <= Key_9 )
633 c = '0' + ev->key() - Key_0;
634 else {
635 // TODO fake XKeyEvent and XLookupString ?
636 // This below seems to work e.g. for eacute though.
637 if( ev->text().length() == 1 )
638 c = ev->text()[ 0 ];
639 }
640 if( c.isNull())
641 return false;
642
643 TQLabel* lab = d->accessKeyLabels->first();
644 while (lab) {
645 if (lab->text() == c) {
646 lab->buddy()->setFocus();
647 delete d->accessKeyLabels;
648 d->accessKeyLabels = 0;
649 return true;
650 }
651 lab = d->accessKeyLabels->next();
652 }
653 return false;
654}
655
656KSortedLabel::KSortedLabel(TQLabel* l) :
657 m_l(l) { }
658
659KSortedLabel::KSortedLabel() :
660 m_l(0) { }
661
662bool KSortedLabel::operator<( KSortedLabel l )
663{
664 TQPoint p1 = m_l->mapToGlobal(m_l->pos());
665 TQPoint p2 = l.label()->mapToGlobal(l.label()->pos());
666 return (p1.y() < p2.y() || (p1.y() == p2.y() && p1.x() < p2.x()));
667}
void hideIcon()
Hides the sizer icon.
int stepSize() const
Returns number of pixels panel is sized for each arrow key pressed.
bool handleAccessKey(const TQKeyEvent *ev)
Handles an access keypress.
void nextHandle()
Advances to the next Panel handle.
void resizePanelFromKey(int key, int state)
Moves panel handle based on key pressed.
void prevHandle()
Moves to the previous Panel handle.
TQWidgetList * getAllPanels()
Retrieves a list of all Splitter and DockArea widgets in the application.
void setStepSize(int s)
Sets number of pixels panel is sized for each arrow key pressed.
void resizePanel(int dx, int dy, int state)
Moves panel handle based on deltaX and deltaY and state of keyboard modifier keys.
void exitSizing()
Exits Sizing mode.
void displayAccessKeys()
Displays the access keys.
void showIcon()
Displays the sizer icon.
bool eventFilter(TQObject *o, TQEvent *e)
Event filter installed on kapp object.
virtual ~KKbdAccessExtensions()
Destructor.
KKbdAccessExtensions(TDEMainWindow *parent, const char *name=0)
Constructor.
Provides a way to sort TQLabelss using a TQValueList based on their screen position.
virtual TDEActionCollection * actionCollection() const
virtual TDEActionPtrList actions(const TQString &group) const
virtual const TDEShortcut & shortcut() const
This file is part of the KDE/KOffice project.