gcp/application.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef GCHEMPAINT_APPLICATION_H
00026 #define GCHEMPAINT_APPLICATION_H
00027
00028 #include <gcu/application.h>
00029 #include <gcu/dialog.h>
00030 #include <gcu/macros.h>
00031 #include <gcu/object.h>
00032 #include <goffice/app/go-conf.h>
00033 #include <set>
00034 #include <string>
00035 #include <map>
00036 #include <list>
00037 #include <stdexcept>
00038
00046 namespace gcp {
00047
00052 typedef struct
00053 {
00057 char const *name;
00061 unsigned char const *data_24;
00062 } IconDesc;
00063
00064 class Target;
00065 class NewFileDlg;
00066 class Tool;
00067 class Document;
00068 struct option_data;
00069 typedef void (*BuildMenuCb) (GtkUIManager *UIManager);
00070
00071 typedef enum {
00072 CursorUnallowed,
00073 CursorPencil,
00074 CursorMax
00075 } CursorId;
00076
00083 class Application: public gcu::Application
00084 {
00085 public:
00089 Application ();
00093 virtual ~Application ();
00094
00106 void ActivateTool (const std::string& toolname, bool activate);
00107
00122 void ActivateWindowsActionWidget (const char *path, bool activate);
00126 virtual void ClearStatus ();
00132 virtual void SetStatusText (const char* text);
00137 virtual GtkWindow* GetWindow () = 0;
00141 Tool* GetActiveTool () {return m_pActiveTool;}
00145 gcp::Document* GetActiveDocument () {return m_pActiveDoc;}
00151 void SetActiveDocument (gcp::Document* pDoc) {m_pActiveDoc = pDoc;}
00156 Tool* GetTool (const std::string& name) {return m_Tools[name];}
00164 void SetTool (const std::string& toolname, Tool* tool) {m_Tools[toolname] = tool;}
00169 GtkWidget* GetToolItem(const std::string& name) {return ToolItems[name];}
00177 void SetToolItem (const std::string& name, GtkWidget* w) {ToolItems[name] = w;}
00183 void SetCurZ (int Z) {m_CurZ = Z;}
00187 int GetCurZ () {return m_CurZ;}
00191 void OnSaveAs ();
00203 bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, gcu::Document *pDoc = NULL);
00211 void SaveWithBabel (std::string const &filename, const gchar *mime_type, gcp::Document* pDoc);
00219 void OpenWithBabel (std::string const &filename, const gchar *mime_type, gcp::Document* pDoc);
00226 void SaveGcp (std::string const &filename, gcp::Document* pDoc);
00233 void OpenGcp (std::string const &filename, gcp::Document* pDoc);
00238 xmlDocPtr GetXmlDoc () {return XmlDoc;}
00242 void OnSaveAsImage ();
00246 bool HaveGhemical () {return m_Have_Ghemical;}
00250 bool HaveInChI () {return m_Have_InChI;}
00254 int GetDocsNumber () {return m_Docs.size ();}
00260 void Zoom (double zoom);
00306 void AddActions (GtkRadioActionEntry const *entries, int nb, char const *ui_description, IconDesc const *icons);
00314 void RegisterToolbar (char const *name, int index);
00320 void OnToolChanged (GtkAction *current);
00327 void AddTarget (Target *target);
00334 void DeleteTarget (Target *target);
00341 void NotifyIconification (bool iconified);
00349 void NotifyFocus (bool has_focus, Target *target = NULL);
00353 void CloseAll ();
00357 std::list<std::string> &GetSupportedMimeTypes () {return m_SupportedMimeTypes;}
00365 void OnConfigChanged (GOConfNode *node, gchar const *name);
00370 std::list<std::string> &GetExtensions(std::string &mime_type);
00371
00376 void OnThemeNamesChanged ();
00377
00383 void AddMenuCallback (BuildMenuCb cb);
00384
00391 void BuildMenu (GtkUIManager *manager);
00392
00400 void RegisterOptions (GOptionEntry const *entries, char const *translation_domain = GETTEXT_PACKAGE);
00401
00408 void AddOptions (GOptionContext *context);
00409
00414 gcu::Document *CreateNewDocument ();
00415
00416
00424 virtual void OnFileNew (char const *Theme = NULL) = 0;
00425
00426 GdkCursor *GetCursor (CursorId id) {return m_Cursors[id];}
00427
00428 protected:
00433 void InitTools();
00438 void BuildTools () throw (std::runtime_error);
00444 void ShowTools (bool visible);
00445
00446 private:
00447 void TestSupportedType (char const *mime_type);
00448 void AddMimeType (std::list<std::string> &l, std::string const& mime_type);
00449
00450 protected:
00454 gcp::Document *m_pActiveDoc;
00458 Target *m_pActiveTarget;
00462 unsigned m_NumWindow;
00463
00464 private:
00465 int m_CurZ;
00466 std::map <std::string, GtkWidget*> ToolItems;
00467 std::map <std::string, GtkWidget*> Toolbars;
00468 std::map <std::string, Tool*> m_Tools;
00469 Tool* m_pActiveTool;
00470 static bool m_bInit;
00471 static bool m_Have_Ghemical;
00472 static bool m_Have_InChI;
00473 xmlDocPtr XmlDoc;
00474 GtkIconFactory *IconFactory;
00475 std::list<char const*> UiDescs;
00476 GtkRadioActionEntry* RadioActions;
00477 int m_entries;
00478 std::map<int, std::string> ToolbarNames;
00479 unsigned m_NumDoc;
00480 std::set<Target*> m_Targets;
00481 int visible_windows;
00482 std::list<std::string> m_SupportedMimeTypes;
00483 std::list<std::string> m_WriteableMimeTypes;
00484 GOConfNode *m_ConfNode;
00485 guint m_NotificationId;
00486 gcu::Object *m_Dummy;
00487 std::list<BuildMenuCb> m_MenuCbs;
00488 std::list<option_data> m_Options;
00489 GdkCursor *m_Cursors[CursorMax];
00490
00491 GCU_RO_POINTER_PROP (GtkStyle, Style)
00492 };
00493
00494 }
00495
00496 #endif //GCHEMPAINT_APPLICATION_H