leocad/common/lc_mainwindow.cpp

61 lines
1.4 KiB
C++
Raw Normal View History

#include "lc_global.h"
2013-08-16 03:25:51 +02:00
#include "lc_mainwindow.h"
2013-08-09 06:57:18 +02:00
#include "lc_profile.h"
#include "preview.h"
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
lcMainWindow* gMainWindow;
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
lcMainWindow::lcMainWindow()
2011-09-07 23:06:51 +02:00
{
2013-08-09 06:57:18 +02:00
mColorIndex = 0;
mPreviewWidget = NULL;
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
strcpy(mRecentFiles[FileIdx], lcGetProfileString((LC_PROFILE_KEY)(LC_PROFILE_RECENT_FILE1 + FileIdx)));
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
gMainWindow = this;
2011-09-07 23:06:51 +02:00
}
2013-08-09 06:57:18 +02:00
lcMainWindow::~lcMainWindow()
2011-09-07 23:06:51 +02:00
{
2013-08-09 06:57:18 +02:00
for (int FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
lcSetProfileString((LC_PROFILE_KEY)(LC_PROFILE_RECENT_FILE1 + FileIdx), mRecentFiles[FileIdx]);
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
gMainWindow = NULL;
}
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
void lcMainWindow::SetColorIndex(int ColorIndex)
2011-09-07 23:06:51 +02:00
{
2013-08-09 06:57:18 +02:00
mColorIndex = ColorIndex;
if (mPreviewWidget)
mPreviewWidget->Redraw();
2011-09-07 23:06:51 +02:00
}
2013-08-09 06:57:18 +02:00
void lcMainWindow::AddRecentFile(const char* FileName)
2011-09-07 23:06:51 +02:00
{
2013-08-09 06:57:18 +02:00
int FileIdx;
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
for (FileIdx = 0; FileIdx < LC_MAX_RECENT_FILES; FileIdx++)
if (!strcmp(mRecentFiles[FileIdx], FileName))
2011-09-07 23:06:51 +02:00
break;
2013-08-09 06:57:18 +02:00
for (FileIdx = lcMin(FileIdx, LC_MAX_RECENT_FILES - 1); FileIdx > 0; FileIdx--)
strcpy(mRecentFiles[FileIdx], mRecentFiles[FileIdx - 1]);
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
strcpy(mRecentFiles[0], FileName);
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
UpdateRecentFiles();
2011-09-07 23:06:51 +02:00
}
2013-08-09 06:57:18 +02:00
void lcMainWindow::RemoveRecentFile(int FileIndex)
2011-09-07 23:06:51 +02:00
{
2013-08-09 06:57:18 +02:00
for (int FileIdx = FileIndex; FileIdx < LC_MAX_RECENT_FILES - 1; FileIdx++)
strcpy(mRecentFiles[FileIdx], mRecentFiles[FileIdx + 1]);
2011-09-07 23:06:51 +02:00
2013-08-09 06:57:18 +02:00
mRecentFiles[LC_MAX_RECENT_FILES - 1][0] = 0;
UpdateRecentFiles();
2011-09-07 23:06:51 +02:00
}
2013-08-09 06:57:18 +02:00