GChemPaint application base class.
More...
#include <gcp/application.h>
List of all members.
Public Member Functions |
| Application (gcugtk::CmdContextGtk *cc=NULL) |
virtual | ~Application () |
void | ActivateTool (const std::string &toolname, bool activate) |
void | ActivateWindowsActionWidget (const char *path, bool activate) |
virtual void | ClearStatus () |
virtual void | SetStatusText (const char *text) |
virtual GtkWindow * | GetWindow ()=0 |
Tool * | GetActiveTool () |
gcp::Document * | GetActiveDocument () |
void | SetActiveDocument (gcp::Document *pDoc) |
Tool * | GetTool (const std::string &name) |
void | SetTool (const std::string &toolname, Tool *tool) |
GtkWidget * | GetToolItem (const std::string &name) |
void | SetToolItem (const std::string &name, GtkWidget *w) |
void | SetCurZ (int Z) |
int | GetCurZ () |
void | OnSaveAs () |
bool | FileProcess (const gchar *filename, const gchar *mime_type, bool bSave, GtkWindow *window, gcu::Document *pDoc=NULL) |
void | SaveGcp (std::string const &filename, gcp::Document *pDoc) |
void | OpenGcp (std::string const &filename, gcp::Document *pDoc) |
xmlDocPtr | GetXmlDoc () |
void | OnSaveAsImage () |
bool | HaveInChI () |
int | GetDocsNumber () |
void | Zoom (double zoom) |
void | AddActions (GtkRadioActionEntry const *entries, int nb, char const *ui_description, IconDesc const *icons) |
void | RegisterToolbar (char const *name, int index) |
void | OnToolChanged (GtkAction *current) |
void | AddTarget (Target *target) |
void | DeleteTarget (Target *target) |
void | NotifyIconification (bool iconified) |
void | NotifyFocus (bool has_focus, Target *target=NULL) |
void | CloseAll () |
std::list< std::string > & | GetSupportedMimeTypes () |
void | OnConfigChanged (GOConfNode *node, gchar const *name) |
std::list< std::string > & | GetExtensions (std::string &mime_type) |
void | OnThemeNamesChanged () |
void | AddMenuCallback (BuildMenuCb cb) |
void | BuildMenu (gcu::UIManager *manager) |
gcu::Document * | CreateNewDocument () |
virtual void | OnFileNew (char const *Theme=NULL)=0 |
GdkCursor * | GetCursor (CursorId id) |
GtkStyle const * | GetStyle (void) const |
bool | GetHaveGhemical (void) const |
Protected Member Functions |
void | InitTools () |
void | BuildTools () throw (std::runtime_error) |
void | ShowTools (bool visible) |
Protected Attributes |
gcp::Document * | m_pActiveDoc |
Target * | m_pActiveTarget |
unsigned | m_NumWindow |
Detailed Description
GChemPaint application base class.
This class is used to represent a GChemPaint application. It is a virtual class since at least one method is pure virtual (gcp::Application::GetWindow)
Definition at line 92 of file gcp/application.h.
Constructor & Destructor Documentation
gcp::Application::Application |
( |
gcugtk::CmdContextGtk * |
cc = NULL | ) |
|
virtual gcp::Application::~Application |
( |
| ) |
[virtual] |
Member Function Documentation
void gcp::Application::ActivateTool |
( |
const std::string & |
toolname, |
|
|
bool |
activate |
|
) |
| |
- Parameters:
-
toolname | the name of the tool. |
activate | whether to activate or deactivate. |
Activates or deactivates a tool in the GChempaint tool box.
To activate the selection tool:
void gcp::Application::ActivateWindowsActionWidget |
( |
const char * |
path, |
|
|
bool |
activate |
|
) |
| |
- Parameters:
-
path | the path to activate. |
activate | whether to activate or deactivate. |
Activates or deactivates the menu item corresponding to path according to the value of activate.
To deactivate the "Paste" menu item, use:
Calls gcp::Window::ActivateActionWidget.
void gcp::Application::AddActions |
( |
GtkRadioActionEntry const * |
entries, |
|
|
int |
nb, |
|
|
char const * |
ui_description, |
|
|
IconDesc const * |
icons |
|
) |
| |
- Parameters:
-
entries | an array of GtkRadioActionEntry structures. |
nb | the number of entries. |
ui_description | an xml like text describing the user interface. |
icons | an array of IconDesc structures for the icons used by the buttons. |
Adds new buttons in the tools box. The code used in the selection plugin is:
static gcp::IconDesc icon_descs[] = {
{"gcp_Selection", gcp_selection_24},
{"gcp_Eraser", gcp_eraser_24},
{NULL, NULL}
};
static GtkRadioActionEntry entries[] = {
{ "Select", "gcp_Selection", N_("Select"), NULL,
N_("Select one or more objects"),
0 },
{ "Erase", "gcp_Eraser", N_("Erase"), NULL,
N_("Eraser"),
0 }
};
static const char *ui_description =
"<ui>"
" <toolbar name='SelectToolbar'>"
" <placeholder name='Select1'>"
" <toolitem action='Select'/>"
" <toolitem action='Erase'/>"
" </placeholder>"
" <placeholder name='Select2'/>"
" <placeholder name='Select3'/>"
" </toolbar>"
"</ui>";
void gcpSelectionPlugin::Populate (gcp::Application* App)
{
App->AddActions (entries, G_N_ELEMENTS (entries), ui_description, icon_descs);
App->RegisterToolbar ("SelectToolbar", 0);
new gcpSelectionTool (App);
new gcpEraserTool (App);
App->ActivateTool ("Select", true);
}
void gcp::Application::AddMenuCallback |
( |
BuildMenuCb |
cb | ) |
|
- Parameters:
-
cb,: | the BuildMenuCb callback to call when building the menu. |
adds a callback for adding entries to the windows menus.
void gcp::Application::AddTarget |
( |
Target * |
target | ) |
|
- Parameters:
-
Adds a Target to the list of known Targets and displays the tools box next to the Target.
void gcp::Application::BuildMenu |
( |
gcu::UIManager * |
manager | ) |
|
- Parameters:
-
manager,: | the gcu::UIManager to populate. |
Populates the user interface by calling all callbacks registered with AddMenuCallback.
void gcp::Application::BuildTools |
( |
| ) |
throw (std::runtime_error) [protected] |
Builds the tools box. This method is called only once after startup by the framework.
virtual void gcp::Application::ClearStatus |
( |
| ) |
[virtual] |
Clears the message in the status bar.
void gcp::Application::CloseAll |
( |
| ) |
|
Closes all open documents and ends the application.
Creates a new document using the default theme.
- Returns:
- the newly created document.
void gcp::Application::DeleteTarget |
( |
Target * |
target | ) |
|
- Parameters:
-
Deletes a Target from the list of known Targets. The tools box will be hidden if no Target remains active.
bool gcp::Application::FileProcess |
( |
const gchar * |
filename, |
|
|
const gchar * |
mime_type, |
|
|
bool |
bSave, |
|
|
GtkWindow * |
window, |
|
|
gcu::Document * |
pDoc = NULL |
|
) |
| |
- Parameters:
-
filename | the URI of the file to save or open. |
mime_type | the mime type. |
bSave | true when saving and false when opening. |
window | a parent GtkWindow which is used for messabe boxes if any. |
pDoc | a document (might be NULL when loading. |
Callback called when the user clicks on the Save or Open button in the file chooser to process the file.
- Returns:
- false on success, true otherwise.
Tool* gcp::Application::GetActiveTool |
( |
| ) |
[inline] |
GdkCursor* gcp::Application::GetCursor |
( |
CursorId |
id | ) |
[inline] |
- Parameters:
-
- Returns:
- the corresponding GdkCursor if any.
Definition at line 404 of file gcp/application.h.
int gcp::Application::GetCurZ |
( |
| ) |
[inline] |
int gcp::Application::GetDocsNumber |
( |
| ) |
[inline] |
std::list<std::string>& gcp::Application::GetExtensions |
( |
std::string & |
mime_type | ) |
|
- Parameters:
-
- Returns:
- the list of file name extensions corresponding to the mime type.
gcp::Application::GetHaveGhemical |
( |
void |
| ) |
const [inline] |
gcp::Application::GetStyle |
( |
void |
| ) |
const [inline] |
std::list<std::string>& gcp::Application::GetSupportedMimeTypes |
( |
| ) |
[inline] |
Tool* gcp::Application::GetTool |
( |
const std::string & |
name | ) |
[inline] |
GtkWidget* gcp::Application::GetToolItem |
( |
const std::string & |
name | ) |
[inline] |
- Parameters:
-
- Returns:
- the GtkWidget corresponding to the Tool named name.
Definition at line 179 of file gcp/application.h.
virtual GtkWindow* gcp::Application::GetWindow |
( |
| ) |
[pure virtual] |
This pure virtual method must be overloaded by derived classes.
- Returns:
- the current active top level window if any, or NULL.
xmlDocPtr gcp::Application::GetXmlDoc |
( |
| ) |
[inline] |
- Returns:
- a xmlDocPtr used for some undo/redo related operations. The text tools use it.
Definition at line 232 of file gcp/application.h.
bool gcp::Application::HaveInChI |
( |
| ) |
[inline] |
- Returns:
- true if InChIs can be evaluated for molecules.
Definition at line 240 of file gcp/application.h.
void gcp::Application::InitTools |
( |
| ) |
[protected] |
Initialize the tools box so that the selection tool is active. This method is called only once aafter startup by the framework.
void gcp::Application::NotifyFocus |
( |
bool |
has_focus, |
|
|
Target * |
target = NULL |
|
) |
| |
- Parameters:
-
has_focus | whether the Target has focus or not. |
target | the Target for which the event occured. |
Shows the tools box next to target if has_focus is true and if target is not NULL.
void gcp::Application::NotifyIconification |
( |
bool |
iconified | ) |
|
- Parameters:
-
iconified | whether the currently active Target is iconified or not. |
If iconified is true, the tools box will be hidden if no Target remains active, otherwise it will be displayed next to the active Target.
void gcp::Application::OnConfigChanged |
( |
GOConfNode * |
node, |
|
|
gchar const * |
name |
|
) |
| |
- Parameters:
-
node | the GONode which changed. |
name | the name of the key. |
Called by the framework when the configuration entry has changed to update a running application preferences if the system allows such callbacks.
virtual void gcp::Application::OnFileNew |
( |
char const * |
Theme = NULL | ) |
[pure virtual] |
- Parameters:
-
Creates a new document using the ginev theme or the default theme if Theme is NULL. This method must be overloaded by derived classes since it is pure virtual.
void gcp::Application::OnSaveAs |
( |
| ) |
|
Open the file save as dialog to save the current document with a new name.
void gcp::Application::OnSaveAsImage |
( |
| ) |
|
Saves the active view as an image.
void gcp::Application::OnThemeNamesChanged |
( |
| ) |
|
Called by the framework after a change of a theme name. Ensure evrything is correctly updated.
void gcp::Application::OnToolChanged |
( |
GtkAction * |
current | ) |
|
- Parameters:
-
current | the GtkAction for the activated tool. |
Call by the framework when the active tool changed.
void gcp::Application::OpenGcp |
( |
std::string const & |
filename, |
|
|
gcp::Document * |
pDoc |
|
) |
| |
- Parameters:
-
filename | the URI of the file to load. |
pDoc | a document or NULL. |
Loads a GChemPaint document.
void gcp::Application::RegisterToolbar |
( |
char const * |
name, |
|
|
int |
index |
|
) |
| |
- Parameters:
-
name | the name of the toolbar. |
index | the rank of the toolbar in the toolbox. |
Adds a new toolbar to the tools box. See the documentation of gcp::Application::AddActions() for a case use.
void gcp::Application::SaveGcp |
( |
std::string const & |
filename, |
|
|
gcp::Document * |
pDoc |
|
) |
| |
- Parameters:
-
filename | the URI of the file to save. |
pDoc | the document to save. |
Saves the active document in the native GChemPaint format.
void gcp::Application::SetActiveDocument |
( |
gcp::Document * |
pDoc | ) |
[inline] |
void gcp::Application::SetCurZ |
( |
int |
Z | ) |
[inline] |
- Parameters:
-
Z | the new current atomic number. |
Sets the new current atomic number. This number is used for new atoms.
Definition at line 193 of file gcp/application.h.
virtual void gcp::Application::SetStatusText |
( |
const char * |
text | ) |
[virtual] |
- Parameters:
-
Displays text in the status bar.
void gcp::Application::SetTool |
( |
const std::string & |
toolname, |
|
|
Tool * |
tool |
|
) |
| [inline] |
- Parameters:
-
toolname | the name of a new tool. |
tool | the new Tool. |
Adds a new tool to the tools box. This method is called from the Tool constructor.
Definition at line 174 of file gcp/application.h.
void gcp::Application::SetToolItem |
( |
const std::string & |
name, |
|
|
GtkWidget * |
w |
|
) |
| [inline] |
- Parameters:
-
name | the name of a new tool. |
w | a GtkWidget. |
Associates w to the Tool named name. SetTool() will return this widget when its argument is name.
Definition at line 187 of file gcp/application.h.
void gcp::Application::ShowTools |
( |
bool |
visible | ) |
[protected] |
- Parameters:
-
visible | whether the tools box should be visible or not |
Shows or hides the tools box.
void gcp::Application::Zoom |
( |
double |
zoom | ) |
|
- Parameters:
-
Sets the zoom level for the active document window.
Member Data Documentation
The documentation for this class was generated from the following file: