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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
/* File: gui_attributes_editor.h; Copyright and License: see below */
#ifndef GUI_ATTRIBUTES_EDITOR_H
#define GUI_ATTRIBUTES_EDITOR_H
/* public file for the doxygen documentation: */
/*! \file
* \brief Provides data to editing widgets and reacts on user events
*/
#include "gui_simple_message_to_user.h"
#include "gui_resources.h"
#include "gui_attributes_editor_types.h"
#include "storage/data_database_reader.h"
#include "storage/data_database.h"
#include "storage/data_change_message.h"
#include "data_classifier.h"
#include "data_diagram.h"
#include "data_feature.h"
#include "data_relationship.h"
#include "ctrl_controller.h"
#include "data_id.h"
#include <gtk/gtk.h>
/*!
* \brief enumeration on tools
*/
enum gui_attributes_editor_sync_dir_enum {
GUI_ATTRIBUTES_EDITOR_SYNC_DIR_DB_TO_GUI = 0, /*!< default sync direction: data changes update gui widgets */
GUI_ATTRIBUTES_EDITOR_SYNC_DIR_GUI_TO_DB, /*!< gui widgets must not be updated till user changes are written back to db */
};
typedef enum gui_attributes_editor_sync_dir_enum gui_attributes_editor_sync_dir_t;
/*!
* \brief attributes of the gui_attributes_editor_t
*/
struct gui_attributes_editor_struct {
data_database_reader_t *db_reader; /*!< pointer to external database reader */
ctrl_controller_t *controller; /*!< pointer to external controller */
data_database_t *database; /*!< pointer to external data_database_t */
gui_simple_message_to_user_t *message_to_user; /*!< pointer to external gui_simple_message_to_user_t */
gui_attributes_editor_sync_dir_t sync_dir; /*!< flag that indicates if changes to database shall overwrite user input */
data_id_t selected_object_id; /*!< id of the object which is currently edited */
data_diagram_t private_diagram_cache; /*!< own instance of a diagram cache */
data_classifier_t private_classifier_cache; /*!< own instance of a classifier cache */
data_feature_t private_feature_cache; /*!< own instance of a feature cache */
data_relationship_t private_relationship_cache; /*!< own instance of a relationship cache */
data_id_t latest_created_id; /*!< id of the latest created object, allows to check if the selected object is new */
data_id_t second_latest_id; /*!< id of the second latest created object, needed if a classifier and a containment relation are created together. */
gui_attributes_editor_types_t type_lists; /*!< own instance of type lists */
GtkLabel *id_label; /*!< pointer to external id label widget */
GtkEntry *name_entry; /*!< pointer to external text entry widget */
GtkEntry *stereotype_entry; /*!< pointer to external text entry widget */
GtkComboBox *type_combo_box; /*!< pointer to external combo box widget */
GtkIconView *type_icon_grid; /*!< pointer to external icon view widget */
GtkTextView *description_text_view; /*!< pointer to external text view widget */
GtkButton *commit_button; /*!< pointer to external button widget */
};
typedef struct gui_attributes_editor_struct gui_attributes_editor_t;
/*!
* \brief initializes the gui_attributes_editor_t struct
*
* \param this_ pointer to own object attributes
* \param id_label pointer to id-label widget
* \param name_entry pointer to text entry widget
* \param stereotype_entry pointer to external text entry widget
* \param type_combo_box pointer to external combo box widget
* \param type_icon_grid pointer to external type-icons view widget
* \param description_text_view pointer to text entry widget
* \param commit_button pointer to button widget
* \param resources pointer to a resource provider
* \param controller pointer to the controller object to use
* \param db_reader pointer to the database reader object to use
* \param database pointer to the database object to use, used to flush the database if requested
* \param message_to_user pointer to the message_to_user object to use
*/
void gui_attributes_editor_init ( gui_attributes_editor_t *this_,
GtkLabel *id_label,
GtkEntry *name_entry,
GtkEntry *stereotype_entry,
GtkComboBox *type_combo_box,
GtkIconView *type_icon_grid,
GtkTextView *description_text_view,
GtkButton *commit_button,
gui_resources_t *resources,
ctrl_controller_t *controller,
data_database_reader_t *db_reader,
data_database_t *database,
gui_simple_message_to_user_t *message_to_user
);
/*!
* \brief destroys the gui_attributes_editor_t struct
*
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_destroy ( gui_attributes_editor_t *this_ );
/*!
* \brief redraws the textedit widgets.
*
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_update_widgets ( gui_attributes_editor_t *this_ );
/*!
* \brief commits changed properties to the database.
*
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_commit_changes ( gui_attributes_editor_t *this_ );
/*!
* \brief prints the gui_attributes_editor_t struct to the trace output
*
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_trace ( const gui_attributes_editor_t *this_ );
/* ================================ USER INPUT CALLBACKS ================================ */
/*!
* \brief callback that informs that the focus of a widget is lost
*/
#if ( GTK_MAJOR_VERSION >= 4 )
void gui_attributes_editor_name_focus_left_callback( GtkEventControllerFocus* self, gpointer user_data );
#else
gboolean gui_attributes_editor_name_focus_lost_callback ( GtkWidget *widget, GdkEvent *event, gpointer user_data );
#endif
/*!
* \brief callback that informs that enter was pressed
*/
void gui_attributes_editor_name_enter_callback ( GtkEntry *widget, gpointer user_data );
/*!
* \brief callback that informs that the focus of a widget is lost
*/
#if ( GTK_MAJOR_VERSION >= 4 )
void gui_attributes_editor_stereotype_focus_left_callback( GtkEventControllerFocus* self, gpointer user_data );
#else
gboolean gui_attributes_editor_stereotype_focus_lost_callback ( GtkWidget *widget, GdkEvent *event, gpointer user_data );
#endif
/*!
* \brief callback that informs that enter was pressed
*/
void gui_attributes_editor_stereotype_enter_callback ( GtkEntry *widget, gpointer user_data );
/*!
* \brief callback that informs that the type in the combo box changed
*/
void gui_attributes_editor_type_changed_callback ( GtkComboBox *widget, gpointer user_data );
/*!
* \brief callback that informs that an entry of the shortlist of type icons was activated
*/
void gui_attributes_editor_type_shortlist_callback ( GtkIconView *iconview, GtkTreePath *path, gpointer user_data );
/*!
* \brief callback that informs that the focus of a widget is lost
*/
#if ( GTK_MAJOR_VERSION >= 4 )
void gui_attributes_editor_description_focus_left_callback( GtkEventControllerFocus* self, gpointer user_data );
#else
gboolean gui_attributes_editor_description_focus_lost_callback( GtkWidget *widget, GdkEvent *event, gpointer user_data );
#endif
/* ================================ SELECTION or MODEL CHANGED CALLBACKS ================================ */
/*!
* \brief callback that informs that another object was focused
*/
void gui_attributes_editor_focused_object_changed_callback( GtkWidget *widget, data_id_t *id, gpointer user_data );
/*!
* \brief callback that informs that the data of an object changed
*/
void gui_attributes_editor_data_changed_callback( GtkWidget *widget, data_change_message_t *msg, gpointer user_data );
/* ================================ PRIVATE METHODS ================================ */
/*!
* \brief loads an object into cache (even if this object is already cached).
*
* \param this_ pointer to own object attributes
* \param id identifier of the object to be loaded
*/
void gui_attributes_editor_private_load_object ( gui_attributes_editor_t *this_, data_id_t id );
/*!
* \brief commits changes to the objects name to the controller.
*
* If the name is not modified, nothing happens.
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_private_name_commit_changes ( gui_attributes_editor_t *this_ );
/*!
* \brief commits changes to the objects stereotype to the controller.
*
* If the stereotype is not modified, nothing happens.
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_private_stereotype_commit_changes ( gui_attributes_editor_t *this_ );
/*!
* \brief commits changes to the objects type to the controller.
*
* If the type is not modified, nothing happens.
* \param this_ pointer to own object attributes
* \param obj_type obj_type new object type to be set. This has to be read out from the type selection widgets by the caller
*/
void gui_attributes_editor_private_type_commit_changes ( gui_attributes_editor_t *this_, int obj_type );
/*!
* \brief commits changes to the objects description to the controller.
*
* If the description is not modified, nothing happens.
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_private_description_commit_changes ( gui_attributes_editor_t *this_ );
/*!
* \brief redraws the widget using the cached data loaded by gui_attributes_editor_private_load_object from the database.
*
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_private_id_update_view ( gui_attributes_editor_t *this_ );
/*!
* \brief redraws the widget using the cached data loaded by gui_attributes_editor_private_load_object from the database.
*
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_private_name_update_view ( gui_attributes_editor_t *this_ );
/*!
* \brief redraws the widget using the cached data loaded by gui_attributes_editor_private_load_object from the database.
*
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_private_stereotype_update_view ( gui_attributes_editor_t *this_ );
/*!
* \brief redraws the widget using the cached data loaded by gui_attributes_editor_private_load_object from the database.
*
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_private_type_update_view ( gui_attributes_editor_t *this_ );
/*!
* \brief redraws the widget using the cached data loaded by gui_attributes_editor_private_load_object from the database.
*
* \param this_ pointer to own object attributes
*/
void gui_attributes_editor_private_description_update_view ( gui_attributes_editor_t *this_ );
#endif /* GUI_ATTRIBUTES_EDITOR_H */
/*
Copyright 2016-2023 Andreas Warnke
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
|