1 /** \file
2 * A convenience class for working with MessageStacks.
3 */
5 /*
6 * Authors:
7 * MenTaLguY <mental@rydia.net>
8 *
9 * Copyright (C) 2004 MenTaLguY
10 *
11 * Released under GNU GPL, read the file 'COPYING' for more information
12 */
14 #ifndef SEEN_INKSCAPE_MESSAGE_CONTEXT_H
15 #define SEEN_INKSCAPE_MESSAGE_CONTEXT_H
17 #include <stdarg.h>
18 #include <glib/gtypes.h>
19 #include "message.h"
21 namespace Inkscape {
23 class MessageStack;
25 /** A convenience class for working with MessageStacks.
26 *
27 * In general, a particular piece of code will only want to display
28 * one status message at a time. This class takes care of tracking
29 * a "current" message id in a particular stack for us, and provides
30 * a convenient means to remove or replace it.
31 *
32 * @see Inkscape::MessageStack
33 */
34 class MessageContext {
35 public:
36 /** Constructs an Inkscape::MessageContext referencing a particular
37 * Inkscape::MessageStack, which will be used for our messages
38 *
39 * MessageContexts retain references to the MessageStacks they use.
40 *
41 * @param stack the Inkscape::MessageStack to use for our messages
42 */
43 MessageContext(MessageStack *stack);
44 ~MessageContext();
46 /** @brief pushes a message on the stack, replacing our old message
47 *
48 * @param type the message type
49 * @param message the message text
50 */
51 void set(MessageType type, gchar const *message);
53 /** @brief pushes a message on the stack using prinf-style formatting,
54 * and replacing our old message
55 *
56 * @param type the message type
57 * @param format a printf-style formatting string
58 */
59 void setF(MessageType type, gchar const *format, ...);
61 /** @brief pushes a message on the stack using printf-style formatting,
62 * and a stdarg argument list
63 *
64 * @param type the message type
65 * @param format a printf-style formatting string
66 * @param args printf-style arguments
67 */
68 void setVF(MessageType type, gchar const *format, va_list args);
70 /** @brief pushes a message onto the stack for a brief period of time
71 * without disturbing our "current" message
72 *
73 * @param type the message type
74 * @param message the message text
75 */
76 void flash(MessageType type, gchar const *message);
78 /** @brief pushes a message onto the stack for a brief period of time
79 * using printf-style formatting, without disturbing our current
80 * message
81 *
82 * @param type the message type
83 * @param format a printf-style formatting string
84 */
85 void flashF(MessageType type, gchar const *format, ...);
87 /** @brief pushes a message onto the stack for a brief period of time
88 * using printf-style formatting and a stdarg argument list;
89 * it does not disturb our "current" message
90 *
91 * @param type the message type
92 * @param format a printf-style formatting string
93 * @param args printf-style arguments
94 */
95 void flashVF(MessageType type, gchar const *format, va_list args);
97 /** @brief removes our current message from the stack */
98 void clear();
100 private:
101 MessageStack *_stack; ///< the message stack to use
102 MessageId _message_id; ///< our current message id, or 0
103 MessageId _flash_message_id; ///< current flashed message id, or 0
104 };
106 }
108 #endif
109 /*
110 Local Variables:
111 mode:c++
112 c-file-style:"stroustrup"
113 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
114 indent-tabs-mode:nil
115 fill-column:99
116 End:
117 */
118 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :