summaryrefslogtreecommitdiffstats
path: root/kicker/kicker/ui/flipscrollview.h
blob: d2de2ab5ee43d945241278b35a2f03ed1a62dda7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*****************************************************************

Copyright (c) 2006 Will Stephenson <wstephenson@novell.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

******************************************************************/

/*
 * Flip scroll menu
 * Each level of the menu is a separate TQListView
 * Child items are added to their own TQListView.
 * When a parent is clicked, we look up its child menu and insert
 * that in a TQScrollView, then scroll to it.
 *
 * Need to intercept TQListViewItems' parent param and instead of
 * inserting directly into parent, insert into parent item's listview
 *
 * So need
 * - adapted QLVI
 * - wrap QLV and offer same interface
 */

#ifndef FLIPSCROLLVIEW_H
#define FLIPSCROLLVIEW_H

#include <tqscrollview.h>
#include <tqlistview.h>
#include <tqframe.h>
#include <tqtimer.h>
#include <tqpainter.h>
#include <kstandarddirs.h>
#include "service_mnu.h"

class ItemView;

class BackFrame : public TQFrame
{
    Q_OBJECT

public:
    BackFrame( TQWidget *parent );
    virtual void drawContents( TQPainter *p );

    void enterEvent ( TQEvent * );
    void leaveEvent( TQEvent * );
    void mousePressEvent ( TQMouseEvent * e );

signals:
    void clicked();

private:
    TQPixmap left_triangle;
    bool mouse_inside;
};

class FlipScrollView : public TQScrollView
{
    Q_OBJECT
public:
    enum State{ StoppedLeft, StoppedRight, ScrollingLeft, ScrollingRight };
    FlipScrollView( TQWidget * parent = 0, const char * name = 0 );
    ~FlipScrollView();

    ItemView *currentView() const;
    ItemView *leftView() const;
    ItemView *rightView() const;
    ItemView *prepareLeftMove(bool clear=true);
    ItemView *prepareRightMove();

    void flipScroll(const TQString& selectMenuPath = TQString::null);
    void showBackButton(bool enable);
    bool showsBackButton() const {return mShowBack;}

protected slots:
    void slotScrollTimer();

signals:
    void startService(KService::Ptr kservice);
    void startURL(const TQString& u);
    void rightButtonPressed(TQListViewItem*,const TQPoint&,int);
    void backButtonClicked();

protected:
    void viewportResizeEvent ( TQResizeEvent * );

private:
    ItemView * mLeftView;
    ItemView * mRightView;
//  ItemView * mCurrentView;
    int mStepsRemaining;
    State mState;
    TQTimer * mTimer;
    BackFrame *mBackrow;
    TQString mSelectMenuPath;
    int mScrollDirection;
    bool mShowBack;
};




#endif