tab.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
  2. /*
  3. * tab.h
  4. * Copyright (C) 2017 Fanch <francois@gautrais.eu>
  5. *
  6. * histodexc is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * histodexc is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. * See the GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _TAB_H_
  20. #define _TAB_H_
  21. #include "main.h"
  22. #include <iostream>
  23. #include <vector>
  24. #include <json/json.h>
  25. class Data;
  26. #define TAB_TYPE_NONE 0
  27. #define TAB_TYPE_GENERAL 1
  28. #define TAB_TYPE_RESOURCE 2
  29. #define TAB_TYPE_STAGE 3
  30. #define TAB_TYPE_ZONE 4
  31. #define CONNECT(a, s, c, d) \
  32. g_signal_connect (G_OBJECT (a), s, \
  33. G_CALLBACK (c), d);
  34. typedef int tab_type_t;
  35. std::string gtk_tree_view_get_str_selected(GtkTreeView* gt, bool* valid=NULL);
  36. bool gtk_tree_view_set_str_selected(GtkTreeView* gt, const std::string& str);
  37. char* gtk_text_view_get_text(GtkTextView* tv);
  38. void gtk_text_view_set_text(GtkTextView* tv, const char*);
  39. void gtk_tree_model_get_iter_last(GtkTreeModel* tm, GtkTreeIter* iter);
  40. class Tab
  41. {
  42. public:
  43. Tab(GtkWidget *window, GtkBuilder *builder);
  44. virtual ~Tab();
  45. virtual const Tab& operator=(const Tab&);
  46. virtual void write(const std::string& file)=0;
  47. virtual Json::Value getJson(bool genFinal=false)=0;
  48. virtual void open(Json::Value& val)=0;
  49. virtual void on_save_clicked()=0;
  50. virtual void setupTab(Data& a)=0;
  51. virtual Data& getTab(bool& genFinal)=0;
  52. void clearModified();
  53. void setModified();
  54. bool getModified();
  55. protected:
  56. tab_type_t m_tab_type;
  57. GtkWidget *m_window;
  58. GtkBuilder *m_builder;
  59. Data *m_data;
  60. bool m_isModified;
  61. protected:
  62. void dialog_error(const char* str);
  63. private:
  64. };
  65. class CallbackArg
  66. {
  67. public:
  68. CallbackArg(void* t, void* d=NULL) { tab=t; data=d; }
  69. virtual ~CallbackArg(){}
  70. void* tab;
  71. void* data;
  72. };
  73. #endif // _TAB_H_