summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/worktoolbar.h
blob: 63522b05925354e6cd573fb29ce62dbb6a630c9d (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   copyright (C) 2002-2007                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

#ifndef WORKTOOLBAR_H
#define WORKTOOLBAR_H

#include <tqmap.h>
#include <tqpixmap.h>
#include <tqcursor.h>
#include <tdetoolbar.h>

#include "umlnamespace.h"

class TQMainWindow;


/**
 * This is the toolbar that is displayed on the right-hand side of the program
 * window.  For each type of diagram it will change to suit that document.
 *
 * To add a new tool button do the following:
 * - create a button pixmap (symbol)
 * - create a cursor pixmap
 * - add an element to the ToolBar_Buttons enum
 * - adjust function loadPixmaps
 * - adjust function slotCheckToolBar
 *
 * @short The toolbar that is different for each type of diagram.
 * @author Paul Hensgen <phensgen@techie.com>
 * Bugs and comments to uml-devel@lists.sf.net or http://bugs.trinitydesktop.org
 */


class WorkToolBar : public TDEToolBar {
    Q_OBJECT
  
public:

    /**
     * Creates a work tool bar.
     *
     * @param parentWindow      The parent of the toolbar.
     */
    WorkToolBar(TQMainWindow *parentWindow, const char *name);

    /**
     * Standard deconstructor.
     */
    ~WorkToolBar();

    /**
     * Sets the current tool to the previously used Tool. This is just
     * as if the user had pressed the button for the other tool.
     */
    void setOldTool();

    /**
     * Sets the current tool to the default tool. (select tool)
     * Calling this function is as if the user had pressed the "arrow"
     * button on the toolbar.
     */
    void setDefaultTool();

    /**
     * Enumeration of all available toolbar buttons.
     */
    enum ToolBar_Buttons
    {
        tbb_Undefined = -1,
        tbb_Arrow,
        tbb_Generalization,
        tbb_Aggregation,
        tbb_Dependency,
        tbb_Association,
        tbb_Containment,
        tbb_Coll_Message,
        tbb_Seq_Message_Synchronous,
        tbb_Seq_Message_Asynchronous,
        tbb_Composition,
        tbb_Relationship,
        tbb_UniAssociation,
        tbb_State_Transition,
        tbb_Activity_Transition,
        tbb_Anchor,//keep anchor as last association until code uses better algorithm for testing
        tbb_Note,
        tbb_Box,
        tbb_Text,
        tbb_Actor,
        tbb_UseCase,
        tbb_Class,
        tbb_Interface,
        tbb_Datatype,
        tbb_Enum,
        tbb_Entity,
        tbb_Package,
        tbb_Component,
        tbb_Node,
        tbb_Artifact,
        tbb_Object,
        tbb_Initial_State,
        tbb_State,
        tbb_End_State,
        tbb_Initial_Activity,
        tbb_Activity,
        tbb_End_Activity,
        tbb_Branch,
        tbb_Fork,
        tbb_DeepHistory,
        tbb_ShallowHistory,
        tbb_Join,
        tbb_StateFork,
        tbb_Junction,
        tbb_Choice,
        tbb_Andline
    };

private:

    typedef TQMap<Uml::Diagram_Type,ToolBar_Buttons> OldToolMap;

    /**
     * This inner class holds label, symbol, and cursor of a tool button.
     */
    class ToolButton {
    public:
        TQString Label;
        TQPixmap Symbol;
        TQCursor Cursor;
        ToolButton() : Label(TQString("?")), Symbol(TQPixmap()), Cursor(TQCursor()) { }
        ToolButton(const TQString& lbl, const TQPixmap& smb, const TQCursor& cur) :
        Label(lbl), Symbol(smb), Cursor(cur) { }
    };

    typedef TQMap<ToolBar_Buttons, ToolButton> ToolButtonMap;

    ToolBar_Buttons     m_CurrentButtonID;
    OldToolMap          m_map;
    Uml::Diagram_Type   m_Type;
    ToolButtonMap       m_ToolButtons;

    /**
     * Loads a pixmap from file
     */
    TQPixmap load(const TQString &fileName);

    /**
     * Loads toolbar icon and mouse cursor images from disk
     */
    void loadPixmaps();

    /**
     * Returns the current cursor depending on m_CurrentButtonID
     */
    TQCursor currentCursor();

    /**
     * Inserts the button corresponding to the tbb value given
     * and activates the toggle.
     */
    void insertHotBtn(ToolBar_Buttons tbb);

    /**
     * Inserts most associations, just reduces some string
     * duplication (nice to translators)
     */
    void insertBasicAssociations();

signals:
    void sigButtonChanged(int);
public slots:
    void slotCheckToolBar(Uml::Diagram_Type dt);
    void buttonChanged(int b);
    void slotResetToolBar();
};

#endif