summaryrefslogtreecommitdiff
path: root/win/texdlg.cpp
diff options
context:
space:
mode:
authorleo2002-10-10 20:39:12 +0000
committerleo2002-10-10 20:39:12 +0000
commit89a11141852de0a6c66a8065faf6454fb7d382be (patch)
tree840eb5b4bd2786bb8f258692897a23fb2ee5c341 /win/texdlg.cpp
parentd82784547a0f37e21c3b6e4a402009655fc531bf (diff)
Added functions to manage textures.
git-svn-id: http://svn.leocad.org/trunk@301 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'win/texdlg.cpp')
-rw-r--r--win/texdlg.cpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/win/texdlg.cpp b/win/texdlg.cpp
new file mode 100644
index 0000000..49b13dc
--- /dev/null
+++ b/win/texdlg.cpp
@@ -0,0 +1,116 @@
+// texdlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "leocad.h"
+#include "texdlg.h"
+#include "library.h"
+#include "project.h"
+#include "globals.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CTexturesDlg dialog
+
+
+CTexturesDlg::CTexturesDlg(CWnd* pParent /*=NULL*/)
+ : CDialog(CTexturesDlg::IDD, pParent)
+{
+ //{{AFX_DATA_INIT(CTexturesDlg)
+ // NOTE: the ClassWizard will add member initialization here
+ //}}AFX_DATA_INIT
+}
+
+
+void CTexturesDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CTexturesDlg)
+ DDX_Control(pDX, ID_LIBTEX_LIST, m_List);
+ //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CTexturesDlg, CDialog)
+ //{{AFX_MSG_MAP(CTexturesDlg)
+ ON_BN_CLICKED(ID_LIBTEX_ADD, OnLibtexAdd)
+ ON_BN_CLICKED(ID_LIBTEX_REMOVE, OnLibtexRemove)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CTexturesDlg message handlers
+
+BOOL CTexturesDlg::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ UpdateList();
+
+ return TRUE;
+}
+
+void CTexturesDlg::OnOK()
+{
+ CDialog::OnOK();
+}
+
+void CTexturesDlg::OnLibtexAdd()
+{
+ CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+ "All Image Files|*.bmp;*.gif;*.jpg;*.png|JPEG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|BMP Files (*.bmp)|*.bmp|PNG Files (*.png)|*.png|All Files (*.*)|*.*||", this);
+
+ if (dlg.DoModal() == IDOK)
+ {
+ project->GetPiecesLibrary ()->ImportTexture (dlg.GetPathName());
+ UpdateList();
+ }
+}
+
+void CTexturesDlg::OnLibtexRemove()
+{
+ int i, selected = 0;
+
+ for (i = 0; i < m_List.GetCount(); i++)
+ if (m_List.GetSel(i))
+ selected++;
+
+ // Nothing to be done
+ if (selected == 0)
+ return;
+
+ char** names = (char**)malloc(selected*sizeof(char**));
+
+ for (selected = 0, i = 0; i < m_List.GetCount(); i++)
+ {
+ if (m_List.GetSel(i))
+ {
+ names[selected] = (char*)m_List.GetItemDataPtr (i);;
+ selected++;
+ }
+ }
+
+ project->GetPiecesLibrary ()->DeleteTextures (names, selected);
+
+ free (names);
+
+ UpdateList();
+}
+
+void CTexturesDlg::UpdateList()
+{
+ PiecesLibrary *pLib = project->GetPiecesLibrary ();
+
+ m_List.ResetContent ();
+
+ for (int i = 0; i < pLib->GetTextureCount (); i++)
+ {
+ int index = m_List.AddString (pLib->GetTexture(i)->m_strName);
+ m_List.SetItemDataPtr (index, pLib->GetTexture(i)->m_strName);
+ }
+}