Automatically update file extension in the image dialog.

This commit is contained in:
leo 2013-08-13 22:17:25 +00:00
parent 677bb573e2
commit 50027f8a07
15 changed files with 56 additions and 3833 deletions

View file

@ -4052,6 +4052,13 @@ void Project::HandleCommand(LC_COMMANDS id)
{
lcImageDialogOptions Options;
int ImageOptions = lcGetProfileInt(LC_PROFILE_IMAGE_OPTIONS);
Options.Format = (LC_IMAGE_FORMAT)(ImageOptions & ~(LC_IMAGE_MASK));
Options.Transparent = (ImageOptions & LC_IMAGE_TRANSPARENT) != 0;
Options.Width = lcGetProfileInt(LC_PROFILE_IMAGE_WIDTH);
Options.Height = lcGetProfileInt(LC_PROFILE_IMAGE_HEIGHT);
if (m_strPathName[0])
strcpy(Options.FileName, m_strPathName);
else if (m_strTitle[0])
@ -4078,13 +4085,6 @@ void Project::HandleCommand(LC_COMMANDS id)
}
}
int ImageOptions = lcGetProfileInt(LC_PROFILE_IMAGE_OPTIONS);
Options.Format = (LC_IMAGE_FORMAT)(ImageOptions & ~(LC_IMAGE_MASK));
Options.Transparent = (ImageOptions & LC_IMAGE_TRANSPARENT) != 0;
Options.Width = lcGetProfileInt(LC_PROFILE_IMAGE_WIDTH);
Options.Height = lcGetProfileInt(LC_PROFILE_IMAGE_HEIGHT);
if (m_bAnimation)
{
Options.Start = 1;
@ -4112,60 +4112,60 @@ void Project::HandleCommand(LC_COMMANDS id)
strcpy(Options.FileName, "Image");
char* Ext = strrchr(Options.FileName, '.');
if (Ext)
{
if (Ext)
{
if (!strcmp(Ext, ".jpg") || !strcmp(Ext, ".jpeg") || !strcmp(Ext, ".bmp") || !strcmp(Ext, ".png"))
*Ext = 0;
}
*Ext = 0;
}
const char* ext;
const char* ext;
switch (Options.Format)
{
{
case LC_IMAGE_BMP: ext = ".bmp";
break;
case LC_IMAGE_JPG: ext = ".jpg";
break;
default:
default:
case LC_IMAGE_PNG: ext = ".png";
break;
}
}
if (m_bAnimation)
if (m_bAnimation)
Options.End = lcMin(Options.End, m_nTotalFrames);
else
else
Options.End = lcMin(Options.End, 255);
Options.Start = lcMax(1, Options.Start);
if (Options.Start > Options.End)
{
{
if (Options.Start > Options.End)
{
{
int Temp = Options.Start;
Options.Start = Options.End;
Options.End = Temp;
}
}
}
Image* images = new Image[Options.End - Options.Start + 1];
CreateImages(images, Options.Width, Options.Height, Options.Start, Options.End, false);
for (int i = 0; i <= Options.End - Options.Start; i++)
{
char filename[LC_MAXPATH];
{
char filename[LC_MAXPATH];
if (Options.Start != Options.End)
{
{
sprintf(filename, "%s%02d%s", Options.FileName, i+1, ext);
}
else
{
}
else
{
strcat(Options.FileName, ext);
strcpy(filename, Options.FileName);
}
}
images[i].FileSave(filename, Options.Format, Options.Transparent);
}
delete []images;
}
delete []images;
} break;
case LC_FILE_EXPORT_3DS:

View file

@ -96,3 +96,29 @@ void lcQImageDialog::on_fileNameBrowse_clicked()
if (!result.isEmpty())
ui->fileName->setText(QDir::toNativeSeparators(result));
}
void lcQImageDialog::on_format_currentIndexChanged(int index)
{
QString fileName = ui->fileName->text();
QString extension = QFileInfo(fileName).suffix().toLower();
QString newExtension;
switch (index)
{
case LC_IMAGE_BMP: newExtension = "bmp";
break;
case LC_IMAGE_JPG: newExtension = "jpg";
break;
default:
case LC_IMAGE_PNG: newExtension = "png";
break;
}
if (extension == newExtension)
return;
if (extension == "bmp" || extension == "png" || extension == "jpg" || extension == "jpeg")
fileName = fileName.left(fileName.length() - extension.length()) + newExtension;
ui->fileName->setText(fileName);
}

View file

@ -21,6 +21,7 @@ public:
public slots:
void accept();
void on_fileNameBrowse_clicked();
void on_format_currentIndexChanged(int index);
private:
Ui::lcQImageDialog *ui;

View file

@ -1,119 +0,0 @@
#include "lc_global.h"
#include "leocad.h"
#include "TerOpDlg.h"
#include "Terrain.h"
#include "Tools.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTerrainOptionsDlg dialog
CTerrainOptionsDlg::CTerrainOptionsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTerrainOptionsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTerrainOptionsDlg)
m_nXPatches = 0;
m_nYPatches = 0;
m_fXSize = 0.0f;
m_fYSize = 0.0f;
m_bFlat = FALSE;
m_bTexture = FALSE;
m_strTexture = _T("");
m_bSmooth = FALSE;
//}}AFX_DATA_INIT
}
void CTerrainOptionsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTerrainOptionsDlg)
DDX_Control(pDX, IDC_TEROPT_COLOR, m_btnColor);
DDX_Text(pDX, IDC_TEROPT_XPAT, m_nXPatches);
DDV_MinMaxInt(pDX, m_nXPatches, 1, 1024);
DDX_Text(pDX, IDC_TEROPT_YPAT, m_nYPatches);
DDV_MinMaxInt(pDX, m_nYPatches, 1, 1024);
DDX_Text(pDX, IDC_TEROPT_XSIZE, m_fXSize);
DDV_MinMaxFloat(pDX, m_fXSize, 1.f, 1024.f);
DDX_Text(pDX, IDC_TEROPT_YSIZE, m_fYSize);
DDV_MinMaxFloat(pDX, m_fYSize, 1.f, 1024.f);
DDX_Check(pDX, IDC_TEROPT_FLAT, m_bFlat);
DDX_Check(pDX, IDC_TEROPT_TEXTURE, m_bTexture);
DDX_Text(pDX, IDC_TEROPT_TEXTURENAME, m_strTexture);
DDX_Check(pDX, IDC_TEROPT_SMOOTH, m_bSmooth);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTerrainOptionsDlg, CDialog)
//{{AFX_MSG_MAP(CTerrainOptionsDlg)
ON_BN_CLICKED(IDC_TEROPT_COLOR, OnTeroptColor)
ON_BN_CLICKED(IDC_TEROPT_TEXTUREBROWSE, OnTeroptTexturebrowse)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTerrainOptionsDlg message handlers
void CTerrainOptionsDlg::OnTeroptColor()
{
CColorDialog dlg(m_crTerrain);
if (dlg.DoModal() == IDOK)
{
m_crTerrain = dlg.GetColor();
DeleteObject(m_btnColor.SetBitmap(CreateColorBitmap (20, 10, m_crTerrain)));
}
}
void CTerrainOptionsDlg::OnTeroptTexturebrowse()
{
CFileDialog dlg(TRUE, NULL, m_strTexture, 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)
{
UpdateData(TRUE);
m_strTexture = dlg.GetPathName();
UpdateData(FALSE);
}
}
void CTerrainOptionsDlg::SetOptions(Terrain* pTerrain)
{
pTerrain->GetPatchCount(&m_nXPatches, &m_nYPatches);
pTerrain->GetSize(&m_fXSize, &m_fYSize);
m_crTerrain = RGB(pTerrain->m_fColor[0]*255, pTerrain->m_fColor[1]*255, pTerrain->m_fColor[2]*255);
m_strTexture = pTerrain->m_strTexture;
m_bFlat = (pTerrain->m_nOptions & LC_TERRAIN_FLAT) != 0;
m_bTexture = (pTerrain->m_nOptions & LC_TERRAIN_TEXTURE) != 0;
m_bSmooth = (pTerrain->m_nOptions & LC_TERRAIN_SMOOTH) != 0;
}
void CTerrainOptionsDlg::GetOptions(Terrain* pTerrain)
{
pTerrain->SetSize(m_fXSize, m_fYSize);
pTerrain->SetPatchCount(m_nXPatches, m_nYPatches);
pTerrain->m_fColor[0] = (float)GetRValue(m_crTerrain)/255;
pTerrain->m_fColor[1] = (float)GetGValue(m_crTerrain)/255;
pTerrain->m_fColor[2] = (float)GetBValue(m_crTerrain)/255;
pTerrain->m_nOptions = 0;
strcpy(pTerrain->m_strTexture, m_strTexture);
if (m_bFlat) pTerrain->m_nOptions |= LC_TERRAIN_FLAT;
if (m_bTexture) pTerrain->m_nOptions |= LC_TERRAIN_TEXTURE;
if (m_bSmooth) pTerrain->m_nOptions |= LC_TERRAIN_SMOOTH;
}
BOOL CTerrainOptionsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
DeleteObject(m_btnColor.SetBitmap(CreateColorBitmap (20, 10, m_crTerrain)));
return TRUE;
}

View file

@ -1,60 +0,0 @@
#if !defined(AFX_TEROPDLG_H__16D85803_DBE0_11D2_8204_C46524CA8617__INCLUDED_)
#define AFX_TEROPDLG_H__16D85803_DBE0_11D2_8204_C46524CA8617__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// TerOpDlg.h : header file
//
class Terrain;
/////////////////////////////////////////////////////////////////////////////
// CTerrainOptionsDlg dialog
class CTerrainOptionsDlg : public CDialog
{
// Construction
public:
void GetOptions(Terrain* pTerrain);
void SetOptions(Terrain* pTerrain);
CTerrainOptionsDlg(CWnd* pParent = NULL); // standard constructor
COLORREF m_crTerrain;
// Dialog Data
//{{AFX_DATA(CTerrainOptionsDlg)
enum { IDD = IDD_TERRAIN_OPTIONS };
CButton m_btnColor;
int m_nXPatches;
int m_nYPatches;
float m_fXSize;
float m_fYSize;
BOOL m_bFlat;
BOOL m_bTexture;
CString m_strTexture;
BOOL m_bSmooth;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTerrainOptionsDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CTerrainOptionsDlg)
afx_msg void OnTeroptColor();
afx_msg void OnTeroptTexturebrowse();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TEROPDLG_H__16D85803_DBE0_11D2_8204_C46524CA8617__INCLUDED_)

View file

@ -1,571 +0,0 @@
#include "lc_global.h"
#include "opengl.h"
#include "glwindow.h"
#include "system.h"
#include "tools.h"
#include "resource.h"
#ifndef WGL_ARB_extensions_string
#define WGL_ARB_extensions_string 1
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = NULL;
#endif // WGL_ARB_extensions_string
#ifndef WGL_ARB_multisample
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#endif
#ifndef WGL_ARB_pixel_format
#define WGL_ARB_pixel_format 1
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
#define WGL_ACCELERATION_ARB 0x2003
#define WGL_NEED_PALETTE_ARB 0x2004
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
#define WGL_SWAP_METHOD_ARB 0x2007
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
#define WGL_TRANSPARENT_ARB 0x200A
#define WGL_SHARE_DEPTH_ARB 0x200C
#define WGL_SHARE_STENCIL_ARB 0x200D
#define WGL_SHARE_ACCUM_ARB 0x200E
#define WGL_SUPPORT_GDI_ARB 0x200F
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_STEREO_ARB 0x2012
#define WGL_PIXEL_TYPE_ARB 0x2013
#define WGL_COLOR_BITS_ARB 0x2014
#define WGL_RED_BITS_ARB 0x2015
#define WGL_RED_SHIFT_ARB 0x2016
#define WGL_GREEN_BITS_ARB 0x2017
#define WGL_GREEN_SHIFT_ARB 0x2018
#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_BLUE_SHIFT_ARB 0x201A
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_ALPHA_SHIFT_ARB 0x201C
#define WGL_ACCUM_BITS_ARB 0x201D
#define WGL_ACCUM_RED_BITS_ARB 0x201E
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
#define WGL_AUX_BUFFERS_ARB 0x2024
#define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
#define WGL_SWAP_EXCHANGE_ARB 0x2028
#define WGL_SWAP_COPY_ARB 0x2029
#define WGL_SWAP_UNDEFINED_ARB 0x202A
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues);
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = NULL;
PFNWGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB = NULL;
PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB = NULL;
#endif // WGL_ARB_pixel_format
struct GLWindowPrivate
{
HGLRC m_hrc;
CDC* m_pDC;
CPalette* m_pPal;
HWND m_hWnd;
HCURSOR Cursor;
bool Multisample;
};
// ============================================================================
BOOL GLWindowPreTranslateMessage(GLWindow *wnd, MSG *pMsg)
{
switch (pMsg->message)
{
case WM_PAINT:
{
GLWindowPrivate* prv = (GLWindowPrivate*)wnd->GetData();
PAINTSTRUCT ps;
BeginPaint(prv->m_hWnd, &ps);
wnd->MakeCurrent();
wnd->OnDraw();
SwapBuffers(prv->m_pDC->m_hDC);
EndPaint(prv->m_hWnd, &ps);
} break;
case WM_SIZE:
wnd->OnSize(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam));
break;
case WM_LBUTTONDOWN:
wnd->OnLeftButtonDown((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_LBUTTONUP:
wnd->OnLeftButtonUp((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_LBUTTONDBLCLK:
wnd->OnLeftButtonDoubleClick((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_MBUTTONDOWN:
wnd->OnMiddleButtonDown((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_MBUTTONUP:
wnd->OnMiddleButtonUp((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_RBUTTONDOWN:
wnd->OnRightButtonDown((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_RBUTTONUP:
wnd->OnRightButtonUp((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_MOUSEMOVE:
wnd->OnMouseMove((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_MOUSEWHEEL:
wnd->OnMouseWheel((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1, (float)(short)HIWORD(pMsg->wParam) / (float)WHEEL_DELTA,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_ERASEBKGND:
return TRUE;
case WM_CREATE:
wnd->OnInitialUpdate();
break;
case WM_DESTROY:
wnd->DestroyContext();
return FALSE;
break;
case WM_SETCURSOR:
{
GLWindowPrivate *prv = (GLWindowPrivate*)wnd->GetData();
if (prv->Cursor)
{
SetCursor(prv->Cursor);
return TRUE;
}
return FALSE;
} break;
case WM_PALETTECHANGED:
if ((HWND)pMsg->wParam == pMsg->hwnd) // Responding to own message.
break;
case WM_QUERYNEWPALETTE:
{
GLWindowPrivate *prv = (GLWindowPrivate*)wnd->GetData();
if (prv->m_pPal)
{
prv->m_pDC->SelectPalette(prv->m_pPal, FALSE);
if (prv->m_pDC->RealizePalette() != 0)
{
// Some colors changed, so we need to do a repaint.
InvalidateRect(prv->m_hWnd, NULL, TRUE);
}
}
} break;
default:
return FALSE;
}
return TRUE;
}
LRESULT CALLBACK GLWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static CMapPtrToPtr WindowMap;
GLWindow *wnd;
if (uMsg == WM_CREATE)
{
LPCREATESTRUCT cs = (LPCREATESTRUCT)lParam;
wnd = (GLWindow*)cs->lpCreateParams;
wnd->CreateFromWindow(hwnd);
WindowMap.SetAt(hwnd, wnd);
}
wnd = (GLWindow*)WindowMap[hwnd];
if (wnd)
{
MSG msg;
msg.hwnd = hwnd;
msg.message = uMsg;
msg.wParam = wParam;
msg.lParam = lParam;
GLWindowPreTranslateMessage(wnd, &msg);
if (uMsg == WM_DESTROY)
{
WindowMap.RemoveKey(hwnd);
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
static LRESULT CALLBACK TempWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg != WM_CREATE)
return DefWindowProc(hWnd, uMsg, wParam, lParam);
HDC hDC = GetDC(hWnd);
PIXELFORMATDESCRIPTOR pfd;
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 24;
pfd.iLayerType = PFD_MAIN_PLANE;
int PixelFormat = ChoosePixelFormat(hDC, &pfd);
if (PixelFormat == 0)
return 0;
if (!SetPixelFormat(hDC, PixelFormat, &pfd))
return 0;
HGLRC hGLRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hGLRC);
const GLubyte* Extensions;
wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
if (wglGetExtensionsStringARB)
Extensions = (GLubyte*)wglGetExtensionsStringARB(wglGetCurrentDC());
else
Extensions = glGetString(GL_EXTENSIONS);
GL_InitializeSharedExtensions();
if (GL_ExtensionSupported(Extensions, "WGL_ARB_pixel_format"))
{
wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribfvARB");
wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB");
}
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hGLRC);
ReleaseDC(hWnd, hDC);
return 0;
}
void GL_InitializeExtensions()
{
HINSTANCE hInstance;
WNDCLASS wc;
hInstance = GetModuleHandle(NULL);
wc.style = CS_OWNDC;
wc.lpfnWndProc = TempWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "LeoCADGLTempWindow";
RegisterClass(&wc);
HWND hWnd = CreateWindow(wc.lpszClassName, "LeoCAD Temp Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
if (hWnd)
DestroyWindow(hWnd);
}
// ============================================================================
// GLWindow class
GLWindow::GLWindow(GLWindow *share)
{
m_pShare = share;
m_pData = (GLWindowPrivate*)malloc(sizeof(GLWindowPrivate));
memset(m_pData, 0, sizeof(GLWindowPrivate));
}
GLWindow::~GLWindow()
{
GLWindowPrivate *prv = (GLWindowPrivate*)m_pData;
delete prv->m_pDC;
free(m_pData);
}
bool GLWindow::CreateFromWindow(void* data)
{
GLWindowPrivate* prv = (GLWindowPrivate*)m_pData;
prv->m_hWnd = (HWND)data;
prv->m_pDC = new CClientDC(CWnd::FromHandle(prv->m_hWnd));
ASSERT(prv->m_pDC != NULL);
// Fill in the Pixel Format Descriptor
PIXELFORMATDESCRIPTOR pfd;
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 24;
pfd.iLayerType = PFD_MAIN_PLANE;
int PixelFormat = 0;
int AASamples = Sys_ProfileLoadInt("Default", "AASamples", 1);
if (wglChoosePixelFormatARB && AASamples > 1)
{
// Choose a Pixel Format Descriptor (PFD) with multisampling support.
int iAttributes[] =
{
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB, 24,
WGL_DEPTH_BITS_ARB, 24,
WGL_STENCIL_BITS_ARB, 0,
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
WGL_SAMPLES_ARB, AASamples,
0, 0
};
float fAttributes[] = {0,0};
UINT NumFormats;
int MultisamplePixelFormat;
int Status = wglChoosePixelFormatARB(prv->m_pDC->m_hDC, iAttributes, fAttributes, 1, &MultisamplePixelFormat, &NumFormats);
if (Status && NumFormats > 0)
{
PixelFormat = MultisamplePixelFormat;
prv->Multisample = true;
}
}
if (!PixelFormat)
PixelFormat = ChoosePixelFormat(prv->m_pDC->m_hDC, &pfd);
if (!PixelFormat)
return false;
if (!SetPixelFormat(prv->m_pDC->m_hDC, PixelFormat, &pfd))
return false;
prv->m_pPal = new CPalette;
if (CreateRGBPalette(prv->m_pDC->m_hDC, &prv->m_pPal))
{
prv->m_pDC->SelectPalette(prv->m_pPal, FALSE);
prv->m_pDC->RealizePalette();
}
else
{
delete prv->m_pPal;
prv->m_pPal = NULL;
}
// Create a rendering context.
prv->m_hrc = wglCreateContext(prv->m_pDC->m_hDC);
if (!prv->m_hrc)
return false;
if (m_pShare)
{
GLWindowPrivate *share = (GLWindowPrivate*)m_pShare->m_pData;
wglShareLists(share->m_hrc, prv->m_hrc);
}
return true;
}
bool GLWindow::CreateFromBitmap(void* Data)
{
GLWindowPrivate* prv = (GLWindowPrivate*)m_pData;
prv->m_pDC = new CDC;
prv->m_pDC->Attach((HDC)Data);
ASSERT(prv->m_pDC != NULL);
// Fill in the Pixel Format Descriptor
PIXELFORMATDESCRIPTOR pfd;
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
int nPixelFormat = ChoosePixelFormat(prv->m_pDC->m_hDC, &pfd);
if (nPixelFormat == 0)
return false;
if (!SetPixelFormat(prv->m_pDC->m_hDC, nPixelFormat, &pfd))
return false;
prv->m_pPal = new CPalette;
if (CreateRGBPalette(prv->m_pDC->m_hDC, &prv->m_pPal))
{
prv->m_pDC->SelectPalette(prv->m_pPal, FALSE);
prv->m_pDC->RealizePalette();
}
else
{
delete prv->m_pPal;
prv->m_pPal = NULL;
}
// Create a rendering context.
prv->m_hrc = wglCreateContext(prv->m_pDC->m_hDC);
if (!prv->m_hrc)
return false;
if (m_pShare)
{
GLWindowPrivate *share = (GLWindowPrivate*)m_pShare->m_pData;
wglShareLists(share->m_hrc, prv->m_hrc);
}
return true;
}
void GLWindow::DestroyContext()
{
GLWindowPrivate *prv = (GLWindowPrivate*)m_pData;
if (prv->m_pPal)
{
CPalette palDefault;
palDefault.CreateStockObject(DEFAULT_PALETTE);
prv->m_pDC->SelectPalette(&palDefault, FALSE);
delete prv->m_pPal;
prv->m_pPal = NULL;
}
if (prv->m_hrc)
wglDeleteContext(prv->m_hrc);
prv->m_hrc = NULL;
if (prv->m_pDC)
delete prv->m_pDC;
prv->m_pDC = NULL;
}
void GLWindow::OnInitialUpdate()
{
GLWindowPrivate *prv = (GLWindowPrivate*)m_pData;
MakeCurrent();
if (prv->Multisample)
glEnable(GL_MULTISAMPLE_ARB);
}
bool GLWindow::MakeCurrent()
{
GLWindowPrivate *prv = (GLWindowPrivate*)m_pData;
if (prv->m_pPal)
{
prv->m_pDC->SelectPalette(prv->m_pPal, FALSE);
prv->m_pDC->RealizePalette();
}
return (wglMakeCurrent(prv->m_pDC->m_hDC, prv->m_hrc) != 0);
}
void GLWindow::Redraw(bool ForceRedraw)
{
GLWindowPrivate *prv = (GLWindowPrivate*)m_pData;
InvalidateRect(prv->m_hWnd, NULL, FALSE);
if (ForceRedraw)
UpdateWindow(prv->m_hWnd);
}
void GLWindow::CaptureMouse()
{
GLWindowPrivate* prv = (GLWindowPrivate*)m_pData;
SetCapture(prv->m_hWnd);
}
void GLWindow::ReleaseMouse()
{
ReleaseCapture();
}
void GLWindow::SetCursor(LC_CURSOR_TYPE Cursor)
{
const UINT CursorResources[LC_CURSOR_COUNT] =
{
0, // LC_CURSOR_DEFAULT
IDC_BRICK, // LC_CURSOR_BRICK
IDC_LIGHT, // LC_CURSOR_LIGHT
IDC_SPOTLIGHT, // LC_CURSOR_SPOTLIGHT
IDC_CAMERA, // LC_CURSOR_CAMERA
IDC_SELECT, // LC_CURSOR_SELECT
IDC_SELECT_GROUP, // LC_CURSOR_SELECT_GROUP
IDC_MOVE, // LC_CURSOR_MOVE
IDC_ROTATE, // LC_CURSOR_ROTATE
IDC_ROTX, // LC_CURSOR_ROTATEX
IDC_ROTY, // LC_CURSOR_ROTATEY
IDC_ERASER, // LC_CURSOR_DELETE
IDC_PAINT, // LC_CURSOR_PAINT
IDC_ZOOM, // LC_CURSOR_ZOOM
IDC_ZOOM_REGION, // LC_CURSOR_ZOOM_REGION
IDC_PAN, // LC_CURSOR_PAN
IDC_ROLL, // LC_CURSOR_ROLL
IDC_ANGLE, // LC_CURSOR_ROTATE_VIEW
};
GLWindowPrivate *prv = (GLWindowPrivate*)m_pData;
if (CursorResources[Cursor])
prv->Cursor = AfxGetApp()->LoadCursor(CursorResources[Cursor]);
else
prv->Cursor = NULL;
::SetCursor(prv->Cursor);
}

View file

@ -1,222 +0,0 @@
#include "lc_global.h"
#include "IPEdit.h"
#include "TerrCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit
CInPlaceEdit::CInPlaceEdit(CWnd* pParent, CRect& rect, DWORD dwStyle, UINT nID,
float* pHeight, CString sInitText,
UINT nFirstChar)
{
m_sInitText = sInitText;
m_pHeight = pHeight;
m_nLastChar = 0;
// If mouse click brought us here,
// then no exit on arrows
m_bExitOnArrows = (nFirstChar != VK_LBUTTON);
DWORD dwEditStyle = WS_BORDER|WS_CHILD|WS_VISIBLE| ES_AUTOHSCROLL //|ES_MULTILINE
| dwStyle;
if (!Create(dwEditStyle, rect, pParent, nID)) return;
SetFont(pParent->GetFont());
SetWindowText(sInitText);
SetFocus();
ResizeControl();
switch (nFirstChar)
{
case VK_LBUTTON:
case VK_RETURN: SetSel((int)_tcslen(m_sInitText), -1); return;
case VK_BACK: SetSel((int)_tcslen(m_sInitText), -1); break;
case VK_DOWN:
case VK_UP:
case VK_RIGHT:
case VK_LEFT:
case VK_NEXT:
case VK_PRIOR:
case VK_HOME:
case VK_SPACE:
case VK_END: SetSel(0,-1); return;
default: SetSel(0,-1);
}
SendMessage(WM_CHAR, nFirstChar);
}
CInPlaceEdit::~CInPlaceEdit()
{
}
BEGIN_MESSAGE_MAP(CInPlaceEdit, CEdit)
//{{AFX_MSG_MAP(CInPlaceEdit)
ON_WM_KILLFOCUS()
ON_WM_CHAR()
ON_WM_KEYDOWN()
ON_WM_KEYUP()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit message handlers
// If an arrow key (or associated) is pressed, then exit if
// a) The Ctrl key was down, or
// b) m_bExitOnArrows == TRUE
void CInPlaceEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if ((nChar == VK_PRIOR || nChar == VK_NEXT ||
nChar == VK_DOWN || nChar == VK_UP ||
nChar == VK_RIGHT || nChar == VK_LEFT) &&
(m_bExitOnArrows || GetKeyState(VK_CONTROL) < 0))
{
m_nLastChar = nChar;
GetParent()->SetFocus();
return;
}
if (nChar == VK_ESCAPE)
{
SetWindowText(m_sInitText); // restore previous text
m_nLastChar = nChar;
GetParent()->SetFocus();
return;
}
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
// Need to keep a lookout for Tabs, Esc and Returns. These send a
// "KeyUp" message, but no "KeyDown". That's why I didn't put their
// code in OnKeyDown. (I will never understand windows...)
void CInPlaceEdit::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == VK_TAB || nChar == VK_RETURN || nChar == VK_ESCAPE)
{
m_nLastChar = nChar;
GetParent()->SetFocus(); // This will destroy this window
return;
}
CEdit::OnKeyUp(nChar, nRepCnt, nFlags);
}
// As soon as this edit loses focus, kill it.
void CInPlaceEdit::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
EndEdit();
}
void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// Prevent beeping
if (nChar != VK_TAB && nChar != VK_RETURN && nChar != VK_ESCAPE)
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
// Resize edit control if needed
ResizeControl();
}
}
////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit overrides
// Stoopid win95 accelerator key problem workaround - Matt Weagle.
BOOL CInPlaceEdit::PreTranslateMessage(MSG* pMsg)
{
// Make sure that the keystrokes continue to the appropriate handlers
if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP)
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return TRUE;
}
// Catch the Alt key so we don't choke if focus is going to an owner drawn button
if (pMsg->message == WM_SYSCHAR)
return TRUE;
return CWnd::PreTranslateMessage(pMsg);
}
// Auto delete
void CInPlaceEdit::PostNcDestroy()
{
CEdit::PostNcDestroy();
delete this;
}
////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit implementation
void CInPlaceEdit::EndEdit()
{
CString str;
GetWindowText(str);
BOOL bModified = FALSE;
float f;
if (sscanf(str, "%f", &f))
{
if (*m_pHeight != f)
{
*m_pHeight = f;
bModified = TRUE;
}
}
CWnd* pOwner = GetOwner();
if (pOwner)
pOwner->SendMessage(WM_LC_EDIT_CLOSED, m_nLastChar, bModified);
// Close this window (PostNcDestroy will delete this)
PostMessage(WM_CLOSE, 0, 0);
}
void CInPlaceEdit::ResizeControl()
{
// Get text extent
CString str;
GetWindowText(str);
str += "0";
CWindowDC dc(this);
CFont *pFontDC = dc.SelectObject(GetFont());
CSize size = dc.GetTextExtent(str);
dc.SelectObject(pFontDC);
size.cx += 5; // add some extra buffer
// Get client rect
CRect rect, parentrect;
GetClientRect(&rect);
GetParent()->GetClientRect(&parentrect);
// Transform rect to parent coordinates
ClientToScreen(&rect);
GetParent()->ScreenToClient(&rect);
// Check whether control needs to be resized
// and whether there is space to grow
if (size.cx > rect.Width())
{
if (size.cx + rect.left < parentrect.right)
rect.right = rect.left + size.cx;
else
rect.right = parentrect.right;
rect.bottom = rect.top + size.cy + 4;
MoveWindow(&rect);
}
}

View file

@ -1,64 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// InPlaceEdit.h : header file
#if !defined(AFX_INPLACEEDIT_H__ECD42821_16DF_11D1_992F_895E185F9C72__INCLUDED_)
#define AFX_INPLACEEDIT_H__ECD42821_16DF_11D1_992F_895E185F9C72__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
/////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit window
class CInPlaceEdit : public CEdit
{
// Construction
public:
CInPlaceEdit(CWnd* pParent, CRect& rect, DWORD dwStyle, UINT nID,
float* pHeight, CString sInitText, UINT nFirstChar);
// Attributes
public:
// Operations
public:
void EndEdit();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CInPlaceEdit)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void PostNcDestroy();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CInPlaceEdit();
// Generated message map functions
protected:
void ResizeControl();
//{{AFX_MSG(CInPlaceEdit)
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
float* m_pHeight;
CString m_sInitText;
UINT m_nLastChar;
BOOL m_bExitOnArrows;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_INPLACEEDIT_H__ECD42821_16DF_11D1_992F_895E185F9C72__INCLUDED_)

View file

@ -1,206 +0,0 @@
#include "lc_global.h"
#include "lc_colors.h"
#include "propertiesgridctrl.h"
#include "clrpopup.h"
#include "globals.h"
void CLeoCADMFCPropertyGridCtrl::SetColor(int ColorIndex)
{
ASSERT_VALID(this);
ASSERT_VALID(m_pSel);
CLeoCADMFCPropertyGridColorProperty* pColorProp = DYNAMIC_DOWNCAST(CLeoCADMFCPropertyGridColorProperty, m_pSel);
if (pColorProp == NULL)
{
ASSERT(FALSE);
return;
}
BOOL bChanged = ColorIndex != pColorProp->GetColor();
pColorProp->SetColor(ColorIndex, false);
if (bChanged)
{
OnPropertyChanged(pColorProp);
}
}
void CLeoCADMFCPropertyGridCtrl::UpdateColor(COLORREF color)
{
ASSERT_VALID(this);
ASSERT_VALID(m_pSel);
CLeoCADMFCPropertyGridColorProperty* pColorProp = DYNAMIC_DOWNCAST(CLeoCADMFCPropertyGridColorProperty, m_pSel);
if (pColorProp == NULL)
{
ASSERT(FALSE);
return;
}
int ColorIdx;
for (ColorIdx = 0; ColorIdx < gNumUserColors; ColorIdx++)
if (color == RGB(gColorList[ColorIdx].Value[0] * 255, gColorList[ColorIdx].Value[1] * 255, gColorList[ColorIdx].Value[2] * 255))
break;
if (ColorIdx == gNumUserColors)
return;
BOOL bChanged = ColorIdx != pColorProp->GetColor();
pColorProp->SetColor(ColorIdx, false);
if (bChanged)
{
OnPropertyChanged(pColorProp);
}
}
void CLeoCADMFCPropertyGridCtrl::CloseColorPopup()
{
ASSERT_VALID(this);
ASSERT_VALID(m_pSel);
CLeoCADMFCPropertyGridColorProperty* pColorProp = DYNAMIC_DOWNCAST(CLeoCADMFCPropertyGridColorProperty, m_pSel);
if (pColorProp == NULL)
{
ASSERT(FALSE);
return;
}
pColorProp->m_pPopup = NULL;
pColorProp->m_bButtonIsDown = FALSE;
pColorProp->Redraw();
if (pColorProp->m_pWndInPlace != NULL)
{
pColorProp->m_pWndInPlace->SetFocus();
}
}
IMPLEMENT_DYNAMIC(CLeoCADMFCPropertyGridColorProperty, CMFCPropertyGridProperty)
CLeoCADMFCPropertyGridColorProperty::CLeoCADMFCPropertyGridColorProperty(const CString& strName, LPCTSTR lpszDescr, DWORD_PTR dwData)
: CMFCPropertyGridProperty(strName, COleVariant(), lpszDescr, dwData)
{
m_Color = 0;
m_ColorOrig = 0;
m_varValue = (_variant_t)(UINT)m_Color;
m_varValueOrig = (_variant_t)(UINT)m_ColorOrig;
m_dwFlags = 1; // AFX_PROP_HAS_LIST
m_pPopup = NULL;
}
CLeoCADMFCPropertyGridColorProperty::~CLeoCADMFCPropertyGridColorProperty()
{
}
void CLeoCADMFCPropertyGridColorProperty::OnDrawValue(CDC* pDC, CRect rect)
{
CRect rectColor = rect;
rect.left += rect.Height();
CMFCPropertyGridProperty::OnDrawValue(pDC, rect);
rectColor.right = rectColor.left + rectColor.Height();
rectColor.DeflateRect(1, 1);
rectColor.top++;
rectColor.left++;
CBrush br(RGB(gColorList[m_Color].Value[0] * 255, gColorList[m_Color].Value[1] * 255, gColorList[m_Color].Value[2] * 255));
pDC->FillRect(rectColor, &br);
pDC->Draw3dRect(rectColor, 0, 0);
if (lcIsColorTranslucent(m_Color))
{
rectColor.DeflateRect(1, 1);
rectColor.bottom -= 1;
for (int x = rectColor.left; x < rectColor.right; x++)
{
for (int y = rectColor.top + x % 4; y < rectColor.bottom; y+=4)
pDC->SetPixel(x, y, RGB(255,255,255));
for (int y = rectColor.bottom - x % 4; y > rectColor.top; y-=4)
pDC->SetPixel(x, y, RGB(255,255,255));
}
}
}
void CLeoCADMFCPropertyGridColorProperty::OnClickButton(CPoint /*point*/)
{
ASSERT_VALID(this);
ASSERT_VALID(m_pWndList);
m_bButtonIsDown = TRUE;
Redraw();
CPoint pt(m_pWndList->GetListRect().left + m_pWndList->GetLeftColumnWidth() + 1, m_rectButton.bottom + 1);
m_pWndList->ClientToScreen(&pt);
new CColorPopup(pt, m_Color, m_pWndList, true);
}
BOOL CLeoCADMFCPropertyGridColorProperty::OnEdit(LPPOINT /*lptClick*/)
{
m_pWndInPlace = NULL;
CRect rectEdit;
CRect rectSpin;
rectEdit.SetRectEmpty();
rectSpin.SetRectEmpty();
CMFCMaskedEdit* pWndEdit = new CMFCMaskedEdit;
pWndEdit->Create(WS_CHILD, rectEdit, m_pWndList, AFX_PROPLIST_ID_INPLACE);
m_pWndInPlace = pWndEdit;
m_pWndInPlace->SetWindowText(FormatProperty());
m_pWndInPlace->SetFocus();
m_bInPlaceEdit = TRUE;
return TRUE;
}
void CLeoCADMFCPropertyGridColorProperty::ResetOriginalValue()
{
CMFCPropertyGridProperty::ResetOriginalValue();
m_Color = m_ColorOrig;
}
CString CLeoCADMFCPropertyGridColorProperty::FormatProperty()
{
ASSERT_VALID(this);
return gColorList[m_Color].Name;
}
void CLeoCADMFCPropertyGridColorProperty::SetColor(int color, bool original)
{
ASSERT_VALID(this);
if (m_Color == color)
return;
m_Color = color;
m_varValue = (_variant_t)(UINT)m_Color;
if (original)
{
m_ColorOrig = color;
m_varValueOrig = (_variant_t)(UINT)m_ColorOrig;
}
if (::IsWindow(m_pWndList->GetSafeHwnd()))
{
CRect rect = m_Rect;
rect.DeflateRect(0, 1);
m_pWndList->InvalidateRect(rect);
m_pWndList->UpdateWindow();
}
}

View file

@ -1,51 +0,0 @@
#ifndef _PROPERTIESGRIDCTRL_H_
#define _PROPERTIESGRIDCTRL_H_
class CLeoCADMFCPropertyGridCtrl : public CMFCPropertyGridCtrl
{
public:
virtual void CloseColorPopup();
virtual void UpdateColor(COLORREF color);
void SetColor(int ColorIndex);
};
class CLeoCADMFCPropertyGridColorProperty : public CMFCPropertyGridProperty
{
friend class CLeoCADMFCPropertyGridCtrl;
DECLARE_DYNAMIC(CLeoCADMFCPropertyGridColorProperty)
// Construction
public:
CLeoCADMFCPropertyGridColorProperty(const CString& strName, LPCTSTR lpszDescr = NULL, DWORD_PTR dwData = 0);
virtual ~CLeoCADMFCPropertyGridColorProperty();
// Overrides
public:
virtual void OnDrawValue(CDC* pDC, CRect rect);
virtual void OnClickButton(CPoint point);
virtual BOOL OnEdit(LPPOINT lptClick);
virtual CString FormatProperty();
protected:
virtual BOOL OnKillFocus(CWnd* pNewWnd) { return pNewWnd->GetSafeHwnd() != m_pPopup->GetSafeHwnd(); }
virtual BOOL OnEditKillFocus() { return m_pPopup == NULL; }
virtual BOOL IsValueChanged() const { return m_Color != m_ColorOrig; }
virtual void ResetOriginalValue();
// Attributes
public:
int GetColor() const { return m_Color; }
void SetColor(int color, bool original);
// Attributes
protected:
int m_Color;
int m_ColorOrig;
CMFCColorPopupMenu* m_pPopup;
CArray<COLORREF, COLORREF> m_Colors;
};
#endif // _PROPERTIESGRIDCTRL_H_

View file

@ -1,458 +0,0 @@
#include "lc_global.h"
#include "propertiespane.h"
#include "project.h"
#include "piece.h"
#include "camera.h"
#include "light.h"
#include "lc_application.h"
BEGIN_MESSAGE_MAP(CPropertiesPane, CDockablePane)
ON_WM_CREATE()
ON_WM_SIZE()
ON_REGISTERED_MESSAGE(AFX_WM_PROPERTY_CHANGED, OnPropertyChanged)
END_MESSAGE_MAP()
inline void UpdateProperty(CMFCPropertyGridProperty* Property, float Value)
{
const COleVariant& Var = Property->GetValue();
if (Var.vt != VT_EMPTY && Var.vt != VT_R4)
{
ASSERT(FALSE);
return;
}
if ((float)Var.fltVal != Value)
Property->SetValue((_variant_t)Value);
}
inline void UpdateProperty(CMFCPropertyGridProperty* Property, lcuint32 Value)
{
const COleVariant& Var = Property->GetValue();
if (Var.vt != VT_EMPTY && Var.vt != VT_UINT)
{
ASSERT(FALSE);
return;
}
if (Var.ulVal != Value)
Property->SetValue((_variant_t)Value);
}
inline void UpdateProperty(CMFCPropertyGridProperty* Property, bool Value)
{
const COleVariant& Var = Property->GetValue();
if (Var.vt != VT_EMPTY && Var.vt != VT_BOOL)
{
ASSERT(FALSE);
return;
}
if (Var.boolVal != (VARIANT_BOOL)Value)
Property->SetValue((_variant_t)Value);
}
CPropertiesPane::CPropertiesPane()
{
mObject = NULL;
}
CPropertiesPane::~CPropertiesPane()
{
}
void CPropertiesPane::AdjustLayout()
{
if (GetSafeHwnd() == NULL)
return;
CRect rectClient;
GetClientRect(rectClient);
m_wndPropList.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), rectClient.Height(), SWP_NOACTIVATE | SWP_NOZORDER);
}
int CPropertiesPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rectDummy;
rectDummy.SetRectEmpty();
if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2))
{
TRACE0("Failed to create Properties Grid \n");
return -1; // fail to create
}
InitPropList();
AdjustLayout();
return 0;
}
void CPropertiesPane::OnSize(UINT nType, int cx, int cy)
{
CDockablePane::OnSize(nType, cx, cy);
AdjustLayout();
}
void CPropertiesPane::InitPropList()
{
SetPropListFont();
m_wndPropList.EnableHeaderCtrl(FALSE);
m_wndPropList.EnableDescriptionArea();
m_wndPropList.SetVSDotNetLook();
m_wndPropList.MarkModifiedProperties();
SetEmpty(true);
}
void CPropertiesPane::Update(Object* Focus)
{
if (!Focus)
SetEmpty();
else
{
switch (Focus->GetType())
{
case LC_OBJECT_PIECE:
SetPiece(Focus);
break;
case LC_OBJECT_CAMERA:
SetCamera(Focus);
break;
case LC_OBJECT_CAMERA_TARGET:
SetCamera(((CameraTarget*)Focus)->GetParent());
break;
case LC_OBJECT_LIGHT:
SetLight(Focus);
break;
case LC_OBJECT_LIGHT_TARGET:
SetLight(((LightTarget*)Focus)->GetParent());
break;
}
}
}
void CPropertiesPane::SetEmpty(bool Force)
{
if (!mObject && !Force)
return;
mObject = NULL;
m_wndPropList.RemoveAll();
CMFCPropertyGridProperty* Empty = new CMFCPropertyGridProperty(_T("Nothing selected"));
m_wndPropList.AddProperty(Empty);
}
void CPropertiesPane::SetPiece(Object* Focus)
{
if (!mObject || mObject->GetType() != LC_OBJECT_PIECE)
{
mObject = NULL;
m_wndPropList.RemoveAll();
CMFCPropertyGridProperty* Position = new CMFCPropertyGridProperty(_T("Position"));
CMFCPropertyGridProperty* PosX = new CMFCPropertyGridProperty(_T("X"), (_variant_t)0.0f, _T("The object's X coordinate"));
Position->AddSubItem(PosX);
CMFCPropertyGridProperty* PosY = new CMFCPropertyGridProperty(_T("Y"), (_variant_t)0.0f, _T("The object's Y coordinate"));
Position->AddSubItem(PosY);
CMFCPropertyGridProperty* PosZ = new CMFCPropertyGridProperty(_T("Z"), (_variant_t)0.0f, _T("The object's Z coordinate"));
Position->AddSubItem(PosZ);
m_wndPropList.AddProperty(Position);
CMFCPropertyGridProperty* Rotation = new CMFCPropertyGridProperty(_T("Rotation"));
CMFCPropertyGridProperty* RotX = new CMFCPropertyGridProperty(_T("X"), (_variant_t)0.0f, _T("The object's rotation around the X axis"));
Rotation->AddSubItem(RotX);
CMFCPropertyGridProperty* RotY = new CMFCPropertyGridProperty(_T("Y"), (_variant_t)0.0f, _T("The object's rotation around the Y axis"));
Rotation->AddSubItem(RotY);
CMFCPropertyGridProperty* RotZ = new CMFCPropertyGridProperty(_T("Z"), (_variant_t)0.0f, _T("The object's rotation around the Z axis"));
Rotation->AddSubItem(RotZ);
m_wndPropList.AddProperty(Rotation);
CMFCPropertyGridProperty* Appearence = new CMFCPropertyGridProperty(_T("Appearance"));
CMFCPropertyGridProperty* Show = new CMFCPropertyGridProperty(_T("Show"), (_variant_t)(lcuint32)0, _T("The time when this object becomes visible"));
Appearence->AddSubItem(Show);
CMFCPropertyGridProperty* Hide = new CMFCPropertyGridProperty(_T("Hide"), (_variant_t)(lcuint32)0, _T("The time when this object is hidden"));
Appearence->AddSubItem(Hide);
CLeoCADMFCPropertyGridColorProperty* Color = new CLeoCADMFCPropertyGridColorProperty(_T("Color"), _T("The object's color"));
Appearence->AddSubItem(Color);
m_wndPropList.AddProperty(Appearence);
}
Piece* pPiece = (Piece*)Focus;
lcVector3 Pos = pPiece->mPosition;
lcVector3 Angles = lcMatrix44ToEulerAngles(pPiece->mModelWorld) * LC_RTOD;
lcGetActiveProject()->ConvertToUserUnits(Pos);
CMFCPropertyGridProperty* Position = m_wndPropList.GetProperty(0);
UpdateProperty(Position->GetSubItem(0), Pos[0]);
UpdateProperty(Position->GetSubItem(1), Pos[1]);
UpdateProperty(Position->GetSubItem(2), Pos[2]);
CMFCPropertyGridProperty* Rotation = m_wndPropList.GetProperty(1);
UpdateProperty(Rotation->GetSubItem(0), Angles[0]);
UpdateProperty(Rotation->GetSubItem(1), Angles[1]);
UpdateProperty(Rotation->GetSubItem(2), Angles[2]);
lcuint32 From, To;
if (lcGetActiveProject()->IsAnimation())
{
From = pPiece->GetFrameShow();
To = pPiece->GetFrameHide();
}
else
{
From = pPiece->GetStepShow();
To = pPiece->GetStepHide();
}
CMFCPropertyGridProperty* Appearence = m_wndPropList.GetProperty(2);
UpdateProperty(Appearence->GetSubItem(0), From);
UpdateProperty(Appearence->GetSubItem(1), To);
((CLeoCADMFCPropertyGridColorProperty*)Appearence->GetSubItem(2))->SetColor(pPiece->mColorIndex, true);
mObject = Focus;
}
void CPropertiesPane::ModifyPiece()
{
LC_PIECE_MODIFY Modify;
Modify.piece = (Piece*)mObject;
CMFCPropertyGridProperty* Position = m_wndPropList.GetProperty(0);
Modify.Position = lcVector3(Position->GetSubItem(0)->GetValue().fltVal, Position->GetSubItem(1)->GetValue().fltVal, Position->GetSubItem(2)->GetValue().fltVal);
lcGetActiveProject()->ConvertFromUserUnits(Modify.Position);
CMFCPropertyGridProperty* Rotation = m_wndPropList.GetProperty(1);
Modify.Rotation = lcVector3(Rotation->GetSubItem(0)->GetValue().fltVal, Rotation->GetSubItem(1)->GetValue().fltVal, Rotation->GetSubItem(2)->GetValue().fltVal);
CMFCPropertyGridProperty* Appearence = m_wndPropList.GetProperty(2);
Modify.from = Appearence->GetSubItem(0)->GetValue().ulVal;
Modify.to = Appearence->GetSubItem(1)->GetValue().ulVal;
Modify.hidden = false;
Modify.color = ((CLeoCADMFCPropertyGridColorProperty*)Appearence->GetSubItem(2))->GetColor();
strcpy(Modify.name, Modify.piece->GetName());
lcGetActiveProject()->HandleNotify(LC_PIECE_MODIFIED, (unsigned long)&Modify);
}
void CPropertiesPane::SetCamera(Object* Focus)
{
if (!mObject || mObject->GetType() != LC_OBJECT_CAMERA)
{
mObject = NULL;
m_wndPropList.RemoveAll();
CMFCPropertyGridProperty* Position = new CMFCPropertyGridProperty(_T("Position"));
CMFCPropertyGridProperty* PosX = new CMFCPropertyGridProperty(_T("X"), (_variant_t)0.0f, _T("The camera's X coordinate"));
Position->AddSubItem(PosX);
CMFCPropertyGridProperty* PosY = new CMFCPropertyGridProperty(_T("Y"), (_variant_t)0.0f, _T("The camera's Y coordinate"));
Position->AddSubItem(PosY);
CMFCPropertyGridProperty* PosZ = new CMFCPropertyGridProperty(_T("Z"), (_variant_t)0.0f, _T("The camera's Z coordinate"));
Position->AddSubItem(PosZ);
m_wndPropList.AddProperty(Position);
CMFCPropertyGridProperty* Target = new CMFCPropertyGridProperty(_T("Target"));
CMFCPropertyGridProperty* TargetX = new CMFCPropertyGridProperty(_T("X"), (_variant_t)0.0f, _T("The camera target's X coordinate"));
Target->AddSubItem(TargetX);
CMFCPropertyGridProperty* TargetY = new CMFCPropertyGridProperty(_T("Y"), (_variant_t)0.0f, _T("The camera target's Y coordinate"));
Target->AddSubItem(TargetY);
CMFCPropertyGridProperty* TargetZ = new CMFCPropertyGridProperty(_T("Z"), (_variant_t)0.0f, _T("The camera target's Z coordinate"));
Target->AddSubItem(TargetZ);
m_wndPropList.AddProperty(Target);
CMFCPropertyGridProperty* Up = new CMFCPropertyGridProperty(_T("Up"));
CMFCPropertyGridProperty* UpX = new CMFCPropertyGridProperty(_T("X"), (_variant_t)0.0f, _T("The camera's up vector X"));
Up->AddSubItem(UpX);
CMFCPropertyGridProperty* UpY = new CMFCPropertyGridProperty(_T("Y"), (_variant_t)0.0f, _T("The camera's up vector Y"));
Up->AddSubItem(UpY);
CMFCPropertyGridProperty* UpZ = new CMFCPropertyGridProperty(_T("Z"), (_variant_t)0.0f, _T("The camera's up vector Z"));
Up->AddSubItem(UpZ);
m_wndPropList.AddProperty(Up);
CMFCPropertyGridProperty* Settings = new CMFCPropertyGridProperty(_T("Settings"));
CMFCPropertyGridProperty* FOV = new CMFCPropertyGridProperty(_T("FOV"), (_variant_t)0.0f, _T("The camera's field of view"));
Settings->AddSubItem(FOV);
CMFCPropertyGridProperty* Near = new CMFCPropertyGridProperty(_T("Near"), (_variant_t)0.0f, _T("The camera's near plane"));
Settings->AddSubItem(Near);
CMFCPropertyGridProperty* Far = new CMFCPropertyGridProperty(_T("Far"), (_variant_t)0.0f, _T("The camera's far plane"));
Settings->AddSubItem(Far);
CMFCPropertyGridProperty* Visible = new CMFCPropertyGridProperty(_T("Visible"), (_variant_t)true, _T("Draw the camera"));
Settings->AddSubItem(Visible);
m_wndPropList.AddProperty(Settings);
}
Camera* pCamera = (Camera*)Focus;
lcVector3 Pos = pCamera->mPosition;
lcGetActiveProject()->ConvertToUserUnits(Pos);
CMFCPropertyGridProperty* Position = m_wndPropList.GetProperty(0);
UpdateProperty(Position->GetSubItem(0), Pos[0]);
UpdateProperty(Position->GetSubItem(1), Pos[1]);
UpdateProperty(Position->GetSubItem(2), Pos[2]);
lcVector3 Target = pCamera->mTargetPosition;
lcGetActiveProject()->ConvertToUserUnits(Target);
CMFCPropertyGridProperty* TargetProp = m_wndPropList.GetProperty(1);
UpdateProperty(TargetProp->GetSubItem(0), Target[0]);
UpdateProperty(TargetProp->GetSubItem(1), Target[1]);
UpdateProperty(TargetProp->GetSubItem(2), Target[2]);
lcVector3 Up = pCamera->mUpVector;
CMFCPropertyGridProperty* UpProp = m_wndPropList.GetProperty(2);
UpdateProperty(UpProp->GetSubItem(0), Up[0]);
UpdateProperty(UpProp->GetSubItem(1), Up[1]);
UpdateProperty(UpProp->GetSubItem(2), Up[2]);
CMFCPropertyGridProperty* SettingsProp = m_wndPropList.GetProperty(3);
UpdateProperty(SettingsProp->GetSubItem(0), pCamera->m_fovy);
UpdateProperty(SettingsProp->GetSubItem(1), pCamera->m_zNear);
UpdateProperty(SettingsProp->GetSubItem(2), pCamera->m_zFar);
UpdateProperty(SettingsProp->GetSubItem(3), pCamera->IsVisible());
mObject = Focus;
}
void CPropertiesPane::ModifyCamera()
{
LC_CAMERA_MODIFY Modify;
Modify.camera = (Camera*)mObject;
CMFCPropertyGridProperty* PositionProp = m_wndPropList.GetProperty(0);
Modify.Eye = lcVector3(PositionProp->GetSubItem(0)->GetValue().fltVal, PositionProp->GetSubItem(1)->GetValue().fltVal, PositionProp->GetSubItem(2)->GetValue().fltVal);
lcGetActiveProject()->ConvertFromUserUnits(Modify.Eye);
CMFCPropertyGridProperty* TargetProp = m_wndPropList.GetProperty(1);
Modify.Target = lcVector3(TargetProp->GetSubItem(0)->GetValue().fltVal, TargetProp->GetSubItem(1)->GetValue().fltVal, TargetProp->GetSubItem(2)->GetValue().fltVal);
lcGetActiveProject()->ConvertFromUserUnits(Modify.Target);
CMFCPropertyGridProperty* UpProp = m_wndPropList.GetProperty(2);
Modify.Up = lcVector3(UpProp->GetSubItem(0)->GetValue().fltVal, UpProp->GetSubItem(1)->GetValue().fltVal, UpProp->GetSubItem(2)->GetValue().fltVal);
CMFCPropertyGridProperty* SettingsProp = m_wndPropList.GetProperty(3);
Modify.fovy = SettingsProp->GetSubItem(0)->GetValue().fltVal;
Modify.znear = SettingsProp->GetSubItem(1)->GetValue().fltVal;
Modify.zfar = SettingsProp->GetSubItem(2)->GetValue().fltVal;
Modify.hidden = false;
lcGetActiveProject()->HandleNotify(LC_CAMERA_MODIFIED, (unsigned long)&Modify);
}
void CPropertiesPane::SetLight(Object* Focus)
{
if (!mObject || mObject->GetType() != LC_OBJECT_LIGHT)
{
m_wndPropList.RemoveAll();
CMFCPropertyGridProperty* Position = new CMFCPropertyGridProperty(_T("Position"));
CMFCPropertyGridProperty* PosX = new CMFCPropertyGridProperty(_T("X"), (_variant_t)0.0f, _T("The object's X coordinate"));
Position->AddSubItem(PosX);
CMFCPropertyGridProperty* PosY = new CMFCPropertyGridProperty(_T("Y"), (_variant_t)0.0f, _T("The object's Y coordinate"));
Position->AddSubItem(PosY);
CMFCPropertyGridProperty* PosZ = new CMFCPropertyGridProperty(_T("Z"), (_variant_t)0.0f, _T("The object's Z coordinate"));
Position->AddSubItem(PosZ);
m_wndPropList.AddProperty(Position);
}
}
void CPropertiesPane::ModifyLight()
{
}
void CPropertiesPane::SetPropListFont()
{
::DeleteObject(m_fntPropList.Detach());
LOGFONT lf;
afxGlobalData.fontRegular.GetLogFont(&lf);
NONCLIENTMETRICS info;
info.cbSize = sizeof(info);
afxGlobalData.GetNonClientMetrics(info);
lf.lfHeight = info.lfMenuFont.lfHeight;
lf.lfWeight = info.lfMenuFont.lfWeight;
lf.lfItalic = info.lfMenuFont.lfItalic;
m_fntPropList.CreateFontIndirect(&lf);
m_wndPropList.SetFont(&m_fntPropList);
}
LRESULT CPropertiesPane::OnPropertyChanged(WPARAM wParam, LPARAM lParam )
{
CMFCPropertyGridProperty* Property = (CMFCPropertyGridProperty*)lParam;
if (!mObject)
return 0;
switch (mObject->GetType())
{
case LC_OBJECT_PIECE:
ModifyPiece();
break;
case LC_OBJECT_CAMERA:
case LC_OBJECT_CAMERA_TARGET:
ModifyCamera();
break;
case LC_OBJECT_LIGHT:
case LC_OBJECT_LIGHT_TARGET:
ModifyLight();
break;
}
return 0;
}

View file

@ -1,43 +0,0 @@
#pragma once
#include "propertiesgridctrl.h"
class Object;
class CPropertiesPane : public CDockablePane
{
public:
CPropertiesPane();
virtual ~CPropertiesPane();
void Update(Object* Focus);
protected:
CFont m_fntPropList;
CLeoCADMFCPropertyGridCtrl m_wndPropList;
void AdjustLayout();
void InitPropList();
void SetPropListFont();
void SetEmpty(bool Force = false);
void SetPiece(Object* Focus);
void SetCamera(Object* Focus);
void SetLight(Object* Focus);
void ModifyPiece();
void ModifyCamera();
void ModifyLight();
Object* mObject;
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg LRESULT OnPropertyChanged(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
};

View file

@ -1,7 +0,0 @@
// Microsoft Developer Studio generated Help ID include file.
// Used by LeoCAD.rc
//
#define HIDC_POVDLG_LGEO 0x80c6047c // IDD_EXPORTPOV
#define HIDC_POVDLG_OUTPOV 0x80c60481 // IDD_EXPORTPOV
#define HIDC_POVDLG_POVRAY 0x80c6047d // IDD_EXPORTPOV
#define HIDC_POVDLG_RENDER 0x80c6047e // IDD_EXPORTPOV

File diff suppressed because it is too large Load diff

View file

@ -1,153 +0,0 @@
#if !defined(AFX_TERRCTRL_H__15B2D2A1_D2FF_11D2_8204_EEB0809D9016__INCLUDED_)
#define AFX_TERRCTRL_H__15B2D2A1_D2FF_11D2_8204_EEB0809D9016__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// TerrCtrl.h : header file
//
#include <afxtempl.h>
#define TERRAINCTRL_CLASSNAME _T("TerrainCtrl")
typedef struct {
UINT state; // Cell state (selected/focus etc)
// float height;
} GRIDCELL;
typedef struct CELLID {
int row, col;
CELLID(int nRow = -1, int nCol = -1)
: row(nRow), col(nCol) {}
BOOL operator==(const CELLID rhs)
{ return (row == rhs.row && col == rhs.col); }
BOOL operator!=(const CELLID rhs)
{ return (row != rhs.row || col != rhs.col); }
} CELLID;
// Cell states
#define GS_FOCUSED 0x0001
#define GS_SELECTED 0x0002
#define GS_DROPHILITED 0x0004
#define GS_READONLY 0x0008
// storage typedef for each row in the grid
typedef CArray<GRIDCELL, GRIDCELL> GRID_ROW;
/////////////////////////////////////////////////////////////////////////////
// CTerrainCtrl window
class CTerrainCtrl : public CWnd
{
// Construction
public:
CTerrainCtrl();
BOOL Create(const RECT& rect, CWnd* pParentWnd, UINT nID, DWORD dwStyle = WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VISIBLE);
BOOL SubclassWindow(HWND hWnd);
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTerrainCtrl)
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
void SetControlPoints(int uCount, int vCount, float** pControl);
virtual ~CTerrainCtrl();
// Generated message map functions
protected:
void EditCell(int nRow, int nCol, UINT nChar);
BOOL GetCellRect(int nRow, int nCol, LPRECT pRect);
BOOL GetCellRect(CELLID cell, LPRECT pRect);
BOOL GetCellOrigin(int nRow, int nCol, LPPOINT p);
BOOL GetCellOrigin(CELLID cell, LPPOINT p);
BOOL RedrawCell(int nRow, int nCol, CDC* pDC = NULL);
BOOL RedrawCell(CELLID cell, CDC* pDC = NULL);
BOOL IsValid(CELLID cell);
BOOL IsValid(int nRow, int nCol);
BOOL IsCellVisible(CELLID cell);
BOOL IsCellVisible(int nRow, int nCol);
void EnsureVisible(CELLID cell);
void EnsureVisible(int nRow, int nCol);
void SetFocusCell(CELLID cell);
void SetFocusCell(int nRow, int nCol);
BOOL SetRowCount(int nRows);
BOOL SetColumnCount(int nCols);
CELLID GetCellFromPt(CPoint point, BOOL bAllowFixedCellCheck = TRUE);
CELLID GetTopleftNonFixedCell();
BOOL RegisterWindowClass();
void OnDraw(CDC* pDC);
void EraseBkgnd(CDC* pDC);
BOOL DrawCell(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBk = FALSE);
BOOL DrawFixedCell(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBk = FALSE);
void ResetScrollBars();
int GetScrollPos32(int nBar, BOOL bGetTrackPos = FALSE);
BOOL SetScrollPos32(int nBar, int nPos, BOOL bRedraw = TRUE);
CFont m_Font;
COLORREF m_crFixedBkColour;
COLORREF m_crFixedTextColour;
COLORREF m_crTextBkColour;
// m_crTextColour, m_crGridColour;
int m_nRows;
int m_nCols;
int m_nVScrollMax;
int m_nHScrollMax;
float** m_pControl;
int m_MouseMode;
CELLID m_idCurrentCell;
CELLID m_LeftClickDownCell;
CPoint m_LeftClickDownPoint;
// Cell data
CArray<GRID_ROW, GRID_ROW> m_RowData;
//{{AFX_MSG(CTerrainCtrl)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg UINT OnGetDlgCode();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
afx_msg LRESULT OnGetFont(WPARAM hFont, LPARAM lParam);
afx_msg LRESULT OnEditClosed(WPARAM hFont, LPARAM lParam);
DECLARE_MESSAGE_MAP()
enum eMouseModes { MOUSE_NOTHING, MOUSE_SELECT_ALL, MOUSE_SELECT_COL, MOUSE_SELECT_ROW,
MOUSE_SELECT_CELLS, MOUSE_SCROLLING_CELLS,
MOUSE_PREPARE_EDIT, MOUSE_PREPARE_DRAG, MOUSE_DRAGGING };
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TERRCTRL_H__15B2D2A1_D2FF_11D2_8204_EEB0809D9016__INCLUDED_)