Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9c5c7a17

Von admin vor mehr als 16 Jahren hinzugefügt

  • ID 9c5c7a17affb48c513cbefc65e8b86d75c7c6704
  • Vorgänger bf1415ae
  • Nachfolger 914b39d4

Application closing fixed.

Unterschiede anzeigen:

.gitignore
po/*.mo
po/*.qm
aqfinance
aqfinance/*
ChangeLog
aqfinance-config
aqfinance-config.in
src/fox/af/icons/icons.cpp
src/fox/apps/aqfinance/aqfinance
src/fox/apps/aqfinance/Makefile.am
INCLUDES=-I$(top_builddir) $(gwenhywfar_includes) $(FOX_CFLAGS) \
-I../../lib \
-I../../lib/af \
-I../../lib/af/icons \
-I../../lib/af/modules \
-I../../lib/af/views \
-I../../lib/af/wodgets \
-I../../lib/af/dialogs \
-I../../lib/gui \
-I../../lib/html \
-I../../lib/widgets
bin_PROGRAMS=aqfinance
aqfinance_SOURCES=\
main.cpp \
mainwindow.cpp
aqfinance_LDADD=$(gwenhywfar_libs) $(FOX_LIBS) \
../../lib/libaffox.la \
../../../lib/libaqfinance.la
src/fox/apps/aqfinance/main.cpp
/****************************************************************************
* This file is part of the project AqFinance.
* AqFinance (c) by 2009 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "ff_app.hpp"
#include "ff_modulemanager.hpp"
#include "bankaccounts/fm_bankaccounts.hpp"
#include "mainwindow.hpp"
#include <gwenhywfar/configmgr.h>
#include <gwenhywfar/buffer.h>
#include <gwenhywfar/directory.h>
#include <gwenhywfar/gwenhywfarapi.h>
#include <gwenhywfar/debug.h>
#define AQFINANCE_USERDATADIR ".aqfinance"
static FXString g_dataFolder;
static void _determineDataFolder(const char *dname) {
char home[256];
if (GWEN_Directory_GetHomeDirectory(home, sizeof(home))) {
DBG_ERROR(0,
"Could not determine home directory, aborting.");
abort();
}
if (dname) {
/* setup data dir */
g_dataFolder=FXString(dname);
}
else {
const char *s;
GWEN_BUFFER *buf;
buf=GWEN_Buffer_new(0, 256, 0, 1);
s=getenv("AQFINANCE_HOME");
if (s && !*s)
s=0;
if (s)
GWEN_Buffer_AppendString(buf, s);
else {
/* use default */
GWEN_Buffer_AppendString(buf, home);
GWEN_Buffer_AppendString(buf, GWEN_DIR_SEPARATOR_S AQFINANCE_USERDATADIR);
}
/* as we are at it: store default data dir */
g_dataFolder=FXString(GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf);
}
}
static GWEN_CONFIGMGR *_getConfigManager() {
GWEN_BUFFER *buf;
GWEN_CONFIGMGR *cm;
buf=GWEN_Buffer_new(0, 256, 0, 1);
GWEN_Buffer_AppendString(buf, "dir://");
GWEN_Buffer_AppendString(buf, g_dataFolder.text());
GWEN_Buffer_AppendString(buf, GWEN_DIR_SEPARATOR_S "settings");
cm=GWEN_ConfigMgr_Factory(GWEN_Buffer_GetStart(buf));
if (cm==NULL) {
DBG_ERROR(0,
"Could not create ConfigMgr[%s]. "
"Maybe the gwenhywfar plugins are not installed?",
GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf);
return NULL;
}
/* done */
GWEN_Buffer_free(buf);
return cm;
}
int main(int argc, char **argv) {
FF_App app("AqFinance", "Martin Preuss");
GWEN_CONFIGMGR *cm;
MainWindow *mw;
FF_Module *m;
const char *s;
if (!GWEN_Logger_IsOpen(AE_LOGDOMAIN)) {
GWEN_Logger_Open(AE_LOGDOMAIN,
"aqfinance", 0,
GWEN_LoggerType_Console,
GWEN_LoggerFacility_User);
}
s=getenv("AE_LOGLEVEL");
if (s && *s) {
GWEN_LOGGER_LEVEL ll;
ll=GWEN_Logger_Name2Level(s);
GWEN_Logger_SetLevel(AE_LOGDOMAIN, ll);
}
else
GWEN_Logger_SetLevel(AE_LOGDOMAIN, GWEN_LoggerLevel_Notice);
app.init(argc, argv);
_determineDataFolder(NULL);
cm=_getConfigManager();
if (cm==NULL)
return 2;
app.setConfigMgr(cm);
mw=new MainWindow(&app, "AqFinance", NULL, NULL, DECOR_ALL);
app.create();
mw->openConfig();
m=new FM_BankAccounts(app.getModuleManager());
app.getModuleManager()->addModule(m);
mw->resize(600, 400);
mw->show();
app.runWhileEvents();
mw->dump(2);
app.run();
app.exit();
return 0;
}
src/fox/apps/aqfinance/mainwindow.cpp
/****************************************************************************
* This file is part of the project AqFinance.
* AqFinance (c) by 2009 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "mainwindow.hpp"
#include "ff_app.hpp"
#include "ff_modulemanager.hpp"
#include "ff_menucontainer.hpp"
#include "ff_action.hpp"
#include "ff_opendb.hpp"
#include <gwenhywfar/debug.h>
#include <gwenhywfar/i18n.h>
#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg)
FXDEFMAP(MainWindow) MainWindowMap[]={
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FILE_CREATE, MainWindow::onMenuFileCreate),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FILE_OPEN, MainWindow::onMenuFileOpen),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FILE_CLOSE, MainWindow::onMenuFileClose),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FILE_QUIT, MainWindow::onMenuFileQuit),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FILE_RECENT1, MainWindow::onMenuFileRecent1),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FILE_RECENT2, MainWindow::onMenuFileRecent2),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FILE_RECENT3, MainWindow::onMenuFileRecent3),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FILE_RECENT4, MainWindow::onMenuFileRecent4),
FXMAPFUNC(SEL_COMMAND, MainWindow::ID_FILE_RECENT5, MainWindow::onMenuFileRecent5),
};
FXIMPLEMENT(MainWindow, FXMainWindow,
MainWindowMap, ARRAYNUMBER(MainWindowMap))
MainWindow::MainWindow(FF_App* a, const FXString& name,
FXIcon *ic,
FXIcon *mi,
FXuint opts,
FXint x, FXint y, FXint w, FXint h,
FXint pl, FXint pr, FXint pt, FXint pb,
FXint hs,FXint vs)
:FXMainWindow(a, name, ic, mi, opts, x, y, w, h, pl, pr, pt, pb, hs, vs)
,m_app(a)
,m_moduleManager(NULL)
,m_mainConfig(NULL)
,m_menuBar(NULL)
,m_toolBar(NULL)
,m_menuFile(NULL)
,m_actionFileCreate(NULL)
,m_actionFileOpen(NULL)
,m_actionFileClose(NULL)
,m_actionFileQuit(NULL)
,m_menuFileRecent(NULL)
,m_actionFileRecent1(NULL)
,m_actionFileRecent2(NULL)
,m_actionFileRecent3(NULL)
,m_actionFileRecent4(NULL)
,m_actionFileRecent5(NULL)
{
FXVerticalFrame *vf;
flags|=FLAG_ENABLED | FLAG_SHOWN;
m_menuBar=FF_MenuContainer::createMenuBar(this,
LAYOUT_SIDE_TOP|
LAYOUT_FILL_X|
FRAME_RAISED);
m_menuFile=FF_MenuContainer::createMenuTitle(m_menuBar, "File", I18N("File"));
m_actionFileCreate=new FF_Action("fileCreate", I18N("Create Database"),
NULL, this, ID_FILE_CREATE);
m_actionFileOpen=new FF_Action("fileOpen", I18N("Open Database"),
NULL, this, ID_FILE_OPEN);
m_actionFileClose=new FF_Action("fileClose", I18N("Close Database"),
NULL, this, ID_FILE_CLOSE);
m_actionFileQuit=new FF_Action("fileQuit", I18N("Quit"),
NULL, this, ID_FILE_QUIT);
m_actionFileCreate->addToMenu(m_menuFile, 0, true, false);
m_actionFileOpen->addToMenu(m_menuFile, 0, true, false);
m_actionFileClose->addToMenu(m_menuFile, 0, true, false);
m_menuFileRecent=FF_MenuContainer::createMenuCascade(m_menuFile,
"fileRecent",
I18N("Recently Opened..."),
NULL,
0);
new FXSeparator(m_menuFile->getMenuPane(), LAYOUT_FILL_X | SEPARATOR_GROOVE);
m_actionFileQuit->addToMenu(m_menuFile, 0, true, false);
m_toolBar=new FXToolBar(this,
LAYOUT_SIDE_TOP|PACK_UNIFORM_WIDTH|
PACK_UNIFORM_HEIGHT|FRAME_RAISED|LAYOUT_FILL_X);
vf=new FXVerticalFrame(this, LAYOUT_FILL_X | LAYOUT_FILL_Y);
m_moduleManager=new FF_ModuleManager(a, vf, LAYOUT_FILL_X | LAYOUT_FILL_Y);
a->setModuleManager(m_moduleManager);
m_actionFileCreate->enable();
m_actionFileOpen->enable();
m_menuFileRecent->enable();
m_actionFileClose->disable();
}
MainWindow::MainWindow()
:FXMainWindow()
,m_app(NULL)
,m_moduleManager(NULL)
,m_mainConfig(NULL)
,m_menuBar(NULL)
,m_toolBar(NULL)
,m_menuFile(NULL)
,m_actionFileCreate(NULL)
,m_actionFileOpen(NULL)
,m_actionFileClose(NULL)
,m_actionFileQuit(NULL)
,m_menuFileRecent(NULL)
,m_actionFileRecent1(NULL)
,m_actionFileRecent2(NULL)
,m_actionFileRecent3(NULL)
,m_actionFileRecent4(NULL)
,m_actionFileRecent5(NULL)
{
}
MainWindow::~MainWindow() {
}
void MainWindow::create() {
FXMainWindow::create();
m_moduleManager->create();
}
void MainWindow::dump(int indent) {
int i;
for (i=0; i<indent; i++) fprintf(stderr, " ");
fprintf(stderr, "MainWindow: %d/%d %d/%d\n", getX(), getY(), getWidth(), getHeight());
m_moduleManager->dump(indent+2);
}
void MainWindow::layout() {
FXMainWindow::layout();
}
int MainWindow::openDb(const FXString &url) {
AEDB_DB *db=NULL;
AE_BOOK *b;
int rv;
DBG_ERROR(0, "Opening DB [%s]", url.text());
if (url.empty()) {
DBG_ERROR(0, "URL empty");
return GWEN_ERROR_INVALID;
}
rv=AE_DbFactory(url.text(), &db);
if (rv<0) {
DBG_ERROR(0, "Unable to instantiate db (%d)", rv);
return rv;
}
b=AE_Book_new(db);
rv=AE_Book_Open(b, AEDB_ACTION_FLAGS_READ | AEDB_ACTION_FLAGS_WRITE);
if (rv<0) {
DBG_ERROR(0, "Unable to open book (%d)", rv);
AE_Book_free(b);
return rv;
}
rv=AE_Book_OpenTable(b, AE_Book_TableType_IdCounter,
AEDB_ACTION_FLAGS_READ | AEDB_ACTION_FLAGS_WRITE);
if (rv<0) {
DBG_ERROR(0, "Unable to open table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_OpenTable(b, AE_Book_TableType_Commodity,
AEDB_ACTION_FLAGS_READ | AEDB_ACTION_FLAGS_WRITE);
if (rv<0) {
DBG_ERROR(0, "Unable to open table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_OpenTable(b, AE_Book_TableType_Account,
AEDB_ACTION_FLAGS_READ | AEDB_ACTION_FLAGS_WRITE);
if (rv<0) {
DBG_ERROR(0, "Unable to open table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_OpenTable(b, AE_Book_TableType_BankAccount,
AEDB_ACTION_FLAGS_READ | AEDB_ACTION_FLAGS_WRITE);
if (rv<0) {
DBG_ERROR(0, "Unable to open table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_OpenTable(b, AE_Book_TableType_BankAccountGroup,
AEDB_ACTION_FLAGS_READ | AEDB_ACTION_FLAGS_WRITE);
if (rv<0) {
DBG_ERROR(0, "Unable to open table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_OpenTable(b, AE_Book_TableType_BankStatement,
AEDB_ACTION_FLAGS_READ | AEDB_ACTION_FLAGS_WRITE);
if (rv<0) {
DBG_ERROR(0, "Unable to open table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_OpenTable(b, AE_Book_TableType_BankTransfer,
AEDB_ACTION_FLAGS_READ | AEDB_ACTION_FLAGS_WRITE);
if (rv<0) {
DBG_ERROR(0, "Unable to open table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
m_app->setBook(b);
m_app->signalDbOpened(b);
m_actionFileCreate->disable();
m_actionFileOpen->disable();
m_menuFileRecent->disable();
m_actionFileClose->enable();
return 0;
}
int MainWindow::createDb(const FXString &url) {
AEDB_DB *db=NULL;
AE_BOOK *b;
int rv;
DBG_ERROR(0, "Creating DB [%s]", url.text());
if (url.empty()) {
DBG_ERROR(0, "URL empty");
return GWEN_ERROR_INVALID;
}
rv=AE_DbFactory(url.text(), &db);
if (rv<0) {
DBG_ERROR(0, "Unable to instantiate db (%d)", rv);
return rv;
}
b=AE_Book_new(db);
rv=AE_Book_Create(b, 0);
if (rv<0) {
DBG_ERROR(0, "Unable to create book (%d)", rv);
AE_Book_free(b);
return rv;
}
rv=AE_Book_Open(b, AEDB_ACTION_FLAGS_READ | AEDB_ACTION_FLAGS_WRITE);
if (rv<0) {
DBG_ERROR(0, "Unable to open book (%d)", rv);
AE_Book_free(b);
return rv;
}
rv=AE_Book_CreateTable(b, AE_Book_TableType_IdCounter, 0);
if (rv<0) {
DBG_ERROR(0, "Unable to create table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_CreateTable(b, AE_Book_TableType_Commodity, 0);
if (rv<0) {
DBG_ERROR(0, "Unable to create table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_CreateTable(b, AE_Book_TableType_Account, 0);
if (rv<0) {
DBG_ERROR(0, "Unable to create table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_CreateTable(b, AE_Book_TableType_BankAccount, 0);
if (rv<0) {
DBG_ERROR(0, "Unable to create table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_CreateTable(b, AE_Book_TableType_BankAccountGroup, 0);
if (rv<0) {
DBG_ERROR(0, "Unable to create table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_CreateTable(b, AE_Book_TableType_BankStatement, 0);
if (rv<0) {
DBG_ERROR(0, "Unable to create table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_CreateTable(b, AE_Book_TableType_BankTransfer, 0);
if (rv<0) {
DBG_ERROR(0, "Unable to create table (%d)", rv);
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
AE_Book_free(b);
return rv;
}
rv=AE_Book_Close(b, 0);
if (rv<0) {
DBG_ERROR(0, "Error closing book");
AE_Book_Close(b, AEDB_ACTION_FLAGS_ABORT);
return rv;
}
return 0;
}
int MainWindow::closeDb() {
AE_BOOK *b;
int rv;
DBG_ERROR(0, "Closing DB");
b=m_app->getBook();
if (b==NULL) {
DBG_ERROR(0, "No database open");
return GWEN_ERROR_NOT_OPEN;
}
m_app->signalDbClosing();
rv=AE_Book_Close(b, 0);
if (rv<0) {
DBG_ERROR(0, "Error closing book");
}
m_app->signalDbClosed();
AE_Book_free(b);
m_app->setBook(NULL);
m_actionFileCreate->enable();
m_actionFileOpen->enable();
m_menuFileRecent->enable();
m_actionFileClose->disable();
return 0;
}
long MainWindow::onMenuFileCreate(FXObject*, FXSelector, void*) {
FXString path;
DBG_ERROR(0, "FileCreate");
path=FF_OpenDB::getCreateDbUrl(m_app, this, I18N("Create Database"),
"");
if (!path.empty()) {
int rv;
rv=createDb(path);
if (rv==0) {
rv=openDb(path);
if (rv==0)
addRecentFile(path);
}
}
return 1;
}
long MainWindow::onMenuFileOpen(FXObject*, FXSelector, void*) {
FXString path;
DBG_ERROR(0, "FileOpen");
path=FF_OpenDB::getOpenDbUrl(m_app, this, I18N("Open Existing Database"),
"");
if (!path.empty()) {
int rv;
rv=openDb(path);
if (rv==0)
addRecentFile(path);
}
return 1;
}
long MainWindow::onMenuFileClose(FXObject*, FXSelector, void*) {
closeDb();
return 1;
}
long MainWindow::onMenuFileQuit(FXObject*, FXSelector, void*) {
close(true);
return 1;
}
long MainWindow::onMenuFileRecent1(FXObject*, FXSelector, void*) {
if (!m_recentFiles[0].empty())
openDb(m_recentFiles[0]);
return 1;
}
long MainWindow::onMenuFileRecent2(FXObject*, FXSelector, void*) {
if (!m_recentFiles[1].empty())
openDb(m_recentFiles[1]);
return 1;
}
long MainWindow::onMenuFileRecent3(FXObject*, FXSelector, void*) {
if (!m_recentFiles[2].empty())
openDb(m_recentFiles[2]);
return 1;
}
long MainWindow::onMenuFileRecent4(FXObject*, FXSelector, void*) {
if (!m_recentFiles[3].empty())
openDb(m_recentFiles[3]);
return 1;
}
long MainWindow::onMenuFileRecent5(FXObject*, FXSelector, void*) {
if (!m_recentFiles[4].empty())
openDb(m_recentFiles[4]);
return 1;
}
FXbool MainWindow::close(FXbool notify) {
AE_BOOK *b;
DBG_ERROR(0, "Close");
b=m_app->getBook();
if (b!=NULL)
closeDb();
closeConfig();
return FXMainWindow::close(notify);
}
void MainWindow::addRecentFile(const FXString &url) {
int i;
int j;
FXString recent[5];
recent[0]=url;
for (i=0, j=1; i<5; i++) {
int k;
if (m_recentFiles[i].empty())
break;
for (k=0; k<j; k++) {
if (compare(recent[k], m_recentFiles[i])==0)
break;
}
if (k>=j) {
/* string not found, add it */
recent[j++]=m_recentFiles[i];
}
}
GWEN_DB_DeleteVar(m_mainConfig, "recentFiles");
for (i=0; i<5; i++) {
m_recentFiles[i]=recent[i];
}
rebuildRecentFiles();
}
void MainWindow::rebuildRecentFiles() {
if (m_actionFileRecent5) {
delete m_actionFileRecent5;
m_actionFileRecent5=NULL;
}
if (m_actionFileRecent4) {
delete m_actionFileRecent4;
m_actionFileRecent4=NULL;
}
if (m_actionFileRecent3) {
delete m_actionFileRecent3;
m_actionFileRecent3=NULL;
}
if (m_actionFileRecent2) {
delete m_actionFileRecent2;
m_actionFileRecent2=NULL;
}
if (m_actionFileRecent1) {
delete m_actionFileRecent1;
m_actionFileRecent1=NULL;
}
/* fill recent files menu */
if (!m_recentFiles[0].empty()) {
m_actionFileRecent1=new FF_Action("fileRecent1", m_recentFiles[0].text(),
NULL, this, ID_FILE_RECENT1);
m_actionFileRecent1->addToMenu(m_menuFileRecent, 0, true, false);
m_actionFileRecent1->create();
if (!m_recentFiles[1].empty()) {
m_actionFileRecent2=new FF_Action("fileRecent2", m_recentFiles[1].text(),
NULL, this, ID_FILE_RECENT2);
m_actionFileRecent2->addToMenu(m_menuFileRecent, 0, true, false);
m_actionFileRecent2->create();
if (!m_recentFiles[2].empty()) {
m_actionFileRecent3=new FF_Action("fileRecent3", m_recentFiles[2].text(),
NULL, this, ID_FILE_RECENT3);
m_actionFileRecent3->addToMenu(m_menuFileRecent, 0, true, false);
m_actionFileRecent3->create();
if (!m_recentFiles[3].empty()) {
m_actionFileRecent4=new FF_Action("fileRecent4", m_recentFiles[3].text(),
NULL, this, ID_FILE_RECENT4);
m_actionFileRecent4->addToMenu(m_menuFileRecent, 0, true, false);
m_actionFileRecent4->create();
if (!m_recentFiles[4].empty()) {
m_actionFileRecent5=new FF_Action("fileRecent5", m_recentFiles[4].text(),
NULL, this, ID_FILE_RECENT5);
m_actionFileRecent5->addToMenu(m_menuFileRecent, 0, true, false);
m_actionFileRecent5->create();
}
}
}
}
}
}
int MainWindow::openConfig() {
int rv;
int i;
rv=GWEN_ConfigMgr_GetGroup(m_app->getConfigMgr(),
"main",
"main",
&m_mainConfig,
0);
if (rv<0) {
DBG_ERROR(0, "Error getting main configuration group (%d)", rv);
return rv;
}
for (i=0; i<5; i++)
m_recentFiles[i].clear();
for (i=0; i<5; i++) {
const char *s;
s=GWEN_DB_GetCharValue(m_mainConfig, "recentFiles", i, NULL);
if (s==NULL)
break;
m_recentFiles[i]=FXString(s);
}
rebuildRecentFiles();
return 0;
}
void MainWindow::closeConfig() {
DBG_ERROR(0, "Closing configuration");
if (m_mainConfig) {
int rv;
int i;
rv=GWEN_ConfigMgr_LockGroup(m_app->getConfigMgr(),
"main",
"main",
0);
if (rv<0) {
DBG_ERROR(0, "Unable to lock main configuration group (%d)", rv);
}
else {
GWEN_DB_DeleteVar(m_mainConfig, "recentFiles");
for (i=0; i<5; i++) {
GWEN_DB_SetCharValue(m_mainConfig, GWEN_DB_FLAGS_DEFAULT,
"recentFiles", m_recentFiles[i].text());
}
rv=GWEN_ConfigMgr_SetGroup(m_app->getConfigMgr(),
"main",
"main",
m_mainConfig,
0);
if (rv<0) {
DBG_ERROR(0, "Error getting main configuration group (%d)", rv);
}
rv=GWEN_ConfigMgr_UnlockGroup(m_app->getConfigMgr(),
"main",
"main",
0);
}
GWEN_DB_Group_free(m_mainConfig);
m_mainConfig=NULL;
}
}
src/fox/apps/aqfinance/mainwindow.hpp
/****************************************************************************
* This file is part of the project AqFinance.
* AqFinance (c) by 2009 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include <fx.h>
#include <gwenhywfar/db.h>
class FF_App;
class FF_ModuleManager;
class FF_MenuContainer;
class FF_Action;
class MainWindow: public FXMainWindow {
FXDECLARE(MainWindow)
public:
enum {
ID_FILE_CREATE=FXMainWindow::ID_LAST,
ID_FILE_OPEN,
ID_FILE_CLOSE,
ID_FILE_QUIT,
ID_FILE_RECENT1,
ID_FILE_RECENT2,
ID_FILE_RECENT3,
ID_FILE_RECENT4,
ID_FILE_RECENT5,
ID_LAST
};
MainWindow(FF_App* a, const FXString& name,
FXIcon *ic=NULL,
FXIcon *mi=NULL,
FXuint opts=DECOR_ALL,
FXint x=0, FXint y=0, FXint w=0, FXint h=0,
FXint pl=0, FXint pr=0, FXint pt=0, FXint pb=0,
FXint hs=0,FXint vs=0);
~MainWindow();
FF_MenuContainer *getMenuBar() const { return m_menuBar;};
FXToolBar *getToolBar() const { return m_toolBar;};
int openConfig();
void closeConfig();
void create();
void dump(int indent);
void layout();
int openDb(const FXString &url);
int createDb(const FXString &url);
int closeDb();
long onMenuFileCreate(FXObject*, FXSelector, void*);
long onMenuFileOpen(FXObject*, FXSelector, void*);
long onMenuFileClose(FXObject*, FXSelector, void*);
long onMenuFileQuit(FXObject*, FXSelector, void*);
long onMenuFileRecent1(FXObject*, FXSelector, void*);
long onMenuFileRecent2(FXObject*, FXSelector, void*);
long onMenuFileRecent3(FXObject*, FXSelector, void*);
long onMenuFileRecent4(FXObject*, FXSelector, void*);
long onMenuFileRecent5(FXObject*, FXSelector, void*);
FXbool close(FXbool notify=FALSE);
protected:
MainWindow();
void rebuildRecentFiles();
void addRecentFile(const FXString &url);
FF_App *m_app;
FF_ModuleManager *m_moduleManager;
GWEN_DB_NODE *m_mainConfig;
FF_MenuContainer *m_menuBar;
FXToolBar *m_toolBar;
FF_MenuContainer *m_menuFile;
FF_Action *m_actionFileCreate;
FF_Action *m_actionFileOpen;
FF_Action *m_actionFileClose;
FF_Action *m_actionFileQuit;
FF_MenuContainer *m_menuFileRecent;
FF_Action *m_actionFileRecent1;
FF_Action *m_actionFileRecent2;
FF_Action *m_actionFileRecent3;
FF_Action *m_actionFileRecent4;
FF_Action *m_actionFileRecent5;
FXString m_recentFiles[5];
};
#endif
src/fox/lib/af/ff_menucontainer.cpp
FXPopup *FF_MenuContainer::getMenuPane() {
switch(typ) {
case TYPE_MENUBAR:
return NULL;
case TYPE_COMMAND:
return NULL;
case TYPE_TITLE:
return menuTitle->getMenu();
case TYPE_CASCADE:
return menuCascade->getMenu();
default:
return NULL;
}
}
FF_MenuContainer *FF_MenuContainer::createMenuBar(FXComposite *w, FXuint opts) {
return new FF_MenuContainer(w, opts);
}
src/fox/lib/af/ff_menucontainer.hpp
void disable();
void create();
FXPopup *getMenuPane();
};
src/fox/lib/widgets/fw_table.cpp
return ri;
}
else {
int i;
if (r>=m_nrows)
return NULL;
else {
int i;
/* create row info, fill it with columns */
ri=new RowInfo(this, r);
for (i=0; i<m_ncolumns; i++) {
ColumnInfo *ci;
/* create row info, fill it with columns */
ri=new RowInfo(this, r);
for (i=0; i<m_ncolumns; i++) {
ColumnInfo *ci;
ci=getColumnInfo(r, i);
assert(ci);
ri->addColumnInfo(ci);
}
ci=getColumnInfo(r, i);
assert(ci);
ri->addColumnInfo(ci);
}
m_rows.push_back(ri);
return ri;
m_rows.push_back(ri);
return ri;
}
}
}

Auch abrufbar als: Unified diff