From 03d1428a293c9abdddfed2d5faa1984901932384 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 18 Dec 1999 18:02:33 +0000 Subject: Changed warning level to -Wall under Linux and Level 4 for Windows git-svn-id: http://svn.leocad.org/trunk@37 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/camera.cpp | 16 ++++---- common/camera.h | 2 +- common/file.cpp | 2 +- common/im_bmp.cpp | 7 ++-- common/im_png.cpp | 8 ++-- common/image.cpp | 4 +- common/piece.cpp | 2 +- common/pieceinf.cpp | 8 ++-- common/project.cpp | 69 +++++++++++++++++--------------- common/quant.cpp | 2 +- config.mk | 2 +- linux/dialogs.cpp | 8 ++-- linux/dlgpiece.cpp | 110 ++++++++++++++++++++++++++++++++++++---------------- linux/gtktools.cpp | 32 +++++++++++++++ linux/gtktools.h | 1 + linux/system.cpp | 6 +++ linux/toolbar.cpp | 5 --- win/Cadview.cpp | 20 +++++----- win/Clrpick.cpp | 4 +- win/Figdlg.cpp | 4 -- win/GrpTree.cpp | 2 +- win/LeoCAD.dsp | 9 ++++- win/Leocad.h | 2 +- win/Mfwnd.cpp | 2 +- win/Moddlg.cpp | 2 +- 25 files changed, 209 insertions(+), 120 deletions(-) diff --git a/common/camera.cpp b/common/camera.cpp index fa21983..e78d9d0 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -115,14 +115,16 @@ Camera::Camera() } // Start with a standard camera. -Camera::Camera(int nType, Camera* pPrev) +Camera::Camera(unsigned char nType, Camera* pPrev) { if (nType > 7) nType = 8; char names[8][7] = { "Front", "Back", "Top", "Under", "Left", "Right", "Main", "User" }; - float eyes[8][3] = { 50,0,0, -50,0,0, 0,0,50, 0,0,-50, 0,50,0, 0,-50,0, 10,10,5, 0,5,0 }; - float ups [8][3] = { 0,0,1, 0,0,1, 1,0, 0, -1,0, 0, 0,0,1, 0, 0,1, -0.2357f, -0.2357f, 0.94281f, 0,0,1 }; + float eyes[8][3] = { { 50,0,0 }, { -50,0,0 }, { 0,0,50 }, { 0,0,-50 }, + { 0,50,0 }, { 0,-50,0 }, { 10,10,5}, { 0,5,0 }}; + float ups [8][3] = { { 0,0,1 }, { 0,0,1 }, { 1,0,0 }, { -1,0,0 }, { 0,0,1 }, + { 0,0,1 }, {-0.2357f, -0.2357f, 0.94281f }, { 0,0,1 }}; CAMERA_KEY* node; Initialize(); @@ -304,10 +306,8 @@ void Camera::Initialize() m_nType = LC_CAMERA_USER; m_pTR = NULL; - for( int i = 0 ; i < sizeof(m_strName) ; i++ ) - { + for (unsigned char i = 0 ; i < sizeof(m_strName) ; i++ ) m_strName[i] = 0; - } } ///////////////////////////////////////////////////////////////////////////// @@ -490,7 +490,7 @@ void Camera::FileSave(File* file) unsigned char ch = 5; // LeoCAD 0.70 file->Write(&ch, 1); - ch = strlen(m_strName); + ch = (unsigned char)strlen(m_strName); file->Write(&ch, 1); file->Write(m_strName, ch); @@ -965,7 +965,7 @@ void Camera::DoPan(int dx, int dy, int mouse, unsigned short nTime, bool bAnimat UpdatePosition(nTime, bAnimation); } -void Camera::DoRotate(int dx, int dy, int mouse, unsigned short nTime, bool bAnimation, bool bAddKey, float* center) +void Camera::DoRotate(int dx, int dy, int mouse, unsigned short nTime, bool bAnimation, bool bAddKey, float* /*center*/) { Vector upvec(m_fUp), frontvec(m_fEye[0]-m_fTarget[0], m_fEye[1]-m_fTarget[1], m_fEye[2]-m_fTarget[2]), sidevec; sidevec.Cross(frontvec, upvec); diff --git a/common/camera.h b/common/camera.h index cb5a5cb..b492954 100644 --- a/common/camera.h +++ b/common/camera.h @@ -37,7 +37,7 @@ class Camera { public: Camera(); - Camera(int nType, Camera* pPrev); + Camera(unsigned char nType, Camera* pPrev); Camera(float ex, float ey, float ez, float tx, float ty, float tz, Camera* pCamera); Camera(float eye[3], float target[3], float up[3], Camera* pCamera); ~Camera(); diff --git a/common/file.cpp b/common/file.cpp index 598d352..d64b4fa 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -63,7 +63,7 @@ char* FileMem::ReadString(char* pBuf, unsigned long nMax) if (m_nPosition >= m_nFileSize) return NULL; - while (--nMax) + while ((--nMax)) { if (m_nPosition == m_nFileSize) break; diff --git a/common/im_bmp.cpp b/common/im_bmp.cpp index 0f6a175..4156701 100755 --- a/common/im_bmp.cpp +++ b/common/im_bmp.cpp @@ -176,7 +176,6 @@ LC_IMAGE* OpenBMP (char* filename) // set the output params image = (LC_IMAGE*)malloc(w*h*3 + sizeof(LC_IMAGE)); long row_size = w * 3; - long bufsize = (long)w * 3 * (long)h; if (image != NULL) { @@ -281,7 +280,7 @@ LC_IMAGE* OpenBMP (char* filename) else { int i, x = 0; - unsigned char c, c1, *pp; + unsigned char c, c1 = 0, *pp; row = 0; pp = outbuf + (bmHeight-1)*bmWidth*3; @@ -416,7 +415,7 @@ bool SaveBMP(char* filename, LC_IMAGE* image, bool quantize) unsigned short bits; unsigned long cmap, bfSize; - unsigned char pal[3][256], *colormappedbuffer; + unsigned char pal[3][256], *colormappedbuffer = NULL; if (quantize) { @@ -471,7 +470,7 @@ bool SaveBMP(char* filename, LC_IMAGE* image, bool quantize) for (int row = 0; row < image->height; row++) { - int pixbuf; + int pixbuf = 0; for (int col = 0; col < image->width; col++) { diff --git a/common/im_png.cpp b/common/im_png.cpp index 155afff..1fc3512 100755 --- a/common/im_png.cpp +++ b/common/im_png.cpp @@ -4,9 +4,9 @@ #include "typedefs.h" #define alpha_composite(composite, fg, alpha, bg) { \ - unsigned short temp = ((unsigned short)(fg)*(unsigned short)(alpha) + \ - (unsigned short)(bg)*(unsigned short)(255 - (unsigned short)(alpha)) + (unsigned short)128); \ - (composite) = (unsigned char)((temp + (temp >> 8)) >> 8); \ + unsigned short temp = ((unsigned short)(fg)*(unsigned short)(alpha) + \ + (unsigned short)(bg)*(unsigned short)(255 - (unsigned short)(alpha)) + (unsigned short)128); \ + (composite) = (unsigned char)((temp + (temp >> 8)) >> 8); \ } // ======================================================== @@ -104,6 +104,8 @@ LC_IMAGE* OpenPNG(char* filename) blue = (unsigned char)pBackground->blue; } } + else + red = green = blue = 0; // decode the image, all at once if (setjmp(png_ptr->jmpbuf)) diff --git a/common/image.cpp b/common/image.cpp index 7c624a9..9d7fe50 100644 --- a/common/image.cpp +++ b/common/image.cpp @@ -517,8 +517,10 @@ static LC_IMAGE* OpenGIF(File* file) if (c == '!') { - int extlabel = source->input_file->GetChar(); + int extlabel; char buf[256]; + + extlabel = source->input_file->GetChar(); while (GetDataBlock(source, buf) > 0) ; // skip continue; diff --git a/common/piece.cpp b/common/piece.cpp index 348c1d8..b63c401 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -450,7 +450,7 @@ void Piece::CreateName(Piece* pPiece) if (i > max) max = i; - sprintf (m_strName, "%s #%0.2d", m_pPieceInfo->m_strDescription, max+1); + sprintf (m_strName, "%s #%.2d", m_pPieceInfo->m_strDescription, max+1); } void Piece::LineFacet(float* p1, float* p2, float* p3, float* p4, CLICKLINE* pLine) diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp index b123403..b44c833 100644 --- a/common/pieceinf.cpp +++ b/common/pieceinf.cpp @@ -1746,14 +1746,14 @@ void PieceInfo::WriteWavefront(FILE* file, unsigned char color, unsigned long* s for (count = *info, info++; count; count -= 4) { - fprintf(file, "f %d %d %d %d\n", + fprintf(file, "f %ld %ld %ld %ld\n", *info+*start, info[1]+*start, info[2]+*start, info[3]+*start); info += 4; } for (count = *info, info++; count; count -= 3) { - fprintf(file, "f %d %d %d\n", + fprintf(file, "f %ld %ld %ld\n", *info+*start, info[1]+*start, info[2]+*start); info += 3; } @@ -1796,14 +1796,14 @@ void PieceInfo::WriteWavefront(FILE* file, unsigned char color, unsigned long* s for (count = *info, info++; count; count -= 4) { - fprintf(file, "f %d %d %d %d\n", + fprintf(file, "f %ld %ld %ld %ld\n", *info+*start, info[1]+*start, info[2]+*start, info[3]+*start); info += 4; } for (count = *info, info++; count; count -= 3) { - fprintf(file, "f %d %d %d\n", + fprintf(file, "f %ld %ld %ld\n", *info+*start, info[1]+*start, info[2]+*start); info += 3; } diff --git a/common/project.cpp b/common/project.cpp index a3c0cc5..d77c8f3 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -33,20 +33,20 @@ typedef struct } VIEWPORT; static VIEWPORT viewports[14] = { - { 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 1 - { 2, 0, 0, 0.5f, 1, 0.5f, 0, 0.5f, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, // 2V - { 2, 0, 0, 1, 0.5f, 0, 0.5f, 1, 0.5f, 0, 0, 0, 0, 0, 0, 0, 0 }, // 2H - { 2, 0, 0, 1, 0.7f, 0, 0.7f, 1, 0.3f, 0, 0, 0, 0, 0, 0, 0, 0 }, // 2HT - { 2, 0, 0, 1, 0.3f, 0, 0.3f, 1, 0.7f, 0, 0, 0, 0, 0, 0, 0, 0 }, // 2HB - { 3, 0, 0, 0.5f, 0.5f, 0, 0.5f, 0.5f, 0.5f, 0.5f, 0, 0.5f, 1, 0, 0, 0, 0 }, // 3VL - { 3, 0, 0, 0.5f, 1, 0.5f, 0, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0, 0, 0, 0 }, // 3VR - { 3, 0, 0, 1, 0.5f, 0, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0, 0, 0, 0 }, // 3HB - { 3, 0, 0, 0.5f, 0.5f, 0.5f, 0, 0.5f, 0.5f, 0, 0.5f, 1, 0.5f, 0, 0, 0, 0 }, // 3HT - { 4, 0, 0, 0.3f, 0.3f, 0, 0.3f, 0.3f, 0.4f, 0, 0.7f, 0.3f, 0.3f, 0.3f, 0, 0.7f, 1 }, // 4VL - { 4, 0, 0, 0.7f, 1, 0.7f, 0, 0.3f, 0.3f, 0.7f, 0.3f, 0.3f, 0.4f, 0.7f, 0.7f, 0.3f, 0.3f }, // 4VR - { 4, 0, 0, 1, 0.7f, 0, 0.7f, 0.3f, 0.3f, 0.3f, 0.7f, 0.4f, 0.3f, 0.7f, 0.7f, 0.3f, 0.3f }, // 4HT - { 4, 0, 0, 0.3f, 0.3f, 0.3f, 0, 0.4f, 0.3f, 0.7f, 0, 0.3f, 0.3f, 0, 0.3f, 1, 0.7f }, // 4HB - { 4, 0, 0, 0.5f, 0.5f, 0.5f, 0, 0.5f, 0.5f, 0, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f }};// 4 + { 1, {{0, 0, 1, 1}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 1 + { 2, {{0, 0, 0.5f, 1}, { 0.5f, 0, 0.5f, 1}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 2V + { 2, {{0, 0, 1, 0.5f}, { 0, 0.5f, 1, 0.5f}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 2H + { 2, {{0, 0, 1, 0.7f}, { 0, 0.7f, 1, 0.3f}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 2HT + { 2, {{0, 0, 1, 0.3f}, { 0, 0.3f, 1, 0.7f}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 2HB + { 3, {{0, 0, 0.5f, 0.5f}, { 0, 0.5f, 0.5f, 0.5f}, { 0.5f, 0, 0.5f, 1}, { 0, 0, 0, 0} }}, // 3VL + { 3, {{0, 0, 0.5f, 1}, { 0.5f, 0, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 0.5f}, { 0, 0, 0, 0} }}, // 3VR + { 3, {{0, 0, 1, 0.5f}, { 0, 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 0.5f}, { 0, 0, 0, 0} }}, // 3HB + { 3, {{0, 0, 0.5f, 0.5f}, { 0.5f, 0, 0.5f, 0.5f}, { 0, 0.5f, 1, 0.5f}, { 0, 0, 0, 0} }}, // 3HT + { 4, {{0, 0, 0.3f, 0.3f}, { 0, 0.3f, 0.3f, 0.4f}, { 0, 0.7f, 0.3f, 0.3f}, { 0.3f, 0, 0.7f, 1} }}, // 4VL + { 4, {{0, 0, 0.7f, 1}, { 0.7f, 0, 0.3f, 0.3f}, { 0.7f, 0.3f, 0.3f, 0.4f}, { 0.7f, 0.7f, 0.3f, 0.3f} }}, // 4VR + { 4, {{0, 0, 1, 0.7f}, { 0, 0.7f, 0.3f, 0.3f}, { 0.3f, 0.7f, 0.4f, 0.3f}, { 0.7f, 0.7f, 0.3f, 0.3f} }}, // 4HT + { 4, {{0, 0, 0.3f, 0.3f}, { 0.3f, 0, 0.4f, 0.3f}, { 0.7f, 0, 0.3f, 0.3f}, { 0, 0.3f, 1, 0.7f} }}, // 4HB + { 4, {{0, 0, 0.5f, 0.5f}, { 0.5f, 0, 0.5f, 0.5f}, { 0, 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 0.5f} }}};// 4 typedef struct { @@ -653,7 +653,7 @@ bool Project::FileLoad(File* file, bool bUndo, bool bMerge) char id[32]; unsigned long rgb; float fv = 0.4f; - unsigned char ch, action; + unsigned char ch, action = m_nCurAction; unsigned short sh; file->Seek(0, SEEK_SET); @@ -2639,7 +2639,7 @@ bool Project::RemoveSelectedObjects() } // Cameras can't be removed while being used or default - for (pCamera = m_pCameras; pCamera; pPrev = pCamera, pCamera = pCamera->m_pNext) + for (pPrev = NULL, pCamera = m_pCameras; pCamera; pPrev = pCamera, pCamera = pCamera->m_pNext) { if (pCamera->IsSelected() && pCamera->IsUser()) { @@ -2653,7 +2653,10 @@ bool Project::RemoveSelectedObjects() if (bCanDelete) { - ((Camera*)pPrev)->m_pNext = pCamera->m_pNext; + if (pPrev) + ((Camera*)pPrev)->m_pNext = pCamera->m_pNext; + else + m_pCameras = pCamera->m_pNext; delete pCamera; pCamera = (Camera*)pPrev; removed = true; @@ -2752,7 +2755,8 @@ void Project::CheckAutoSave() m_nSaveTimer += 5; if (m_nAutosave & LC_AUTOSAVE_FLAG) { - int nInterval = m_nAutosave & ~LC_AUTOSAVE_FLAG; + int nInterval; + nInterval = m_nAutosave & ~LC_AUTOSAVE_FLAG; if (m_nSaveTimer >= (m_nAutosave*60)) { @@ -3221,7 +3225,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (SystemDoDialog(LC_DLG_HTML, &opts)) { FILE* f; - char* ext, fn[LC_MAXPATH]; + char* ext = ".bmp", fn[LC_MAXPATH]; int i; unsigned short last = GetLastStep(); @@ -3458,7 +3462,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) while (fread(&bt, 4, 1, f)) { u = (((unsigned char)(bt[3])|((unsigned short)(bt[2]) << 8))|(((unsigned long)(bt[1])) << 16)) + bt[0] * 16581375; - sprintf(tmp, "%d", u); + sprintf(tmp, "%d", (int)u); pInfo = FindPieceInfo(tmp); fread(&tmp, 9, 1, f); @@ -3507,7 +3511,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) } strcpy(fn, opts.outpath); - if (ptr = strrchr (fn, '.')) + if ((ptr = strrchr (fn, '.'))) *ptr = 0; strcat (fn, ".inc"); f = fopen(fn, "wt"); @@ -3568,7 +3572,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) { char name[20]; strcpy(name, pInfo->m_strName); - while (ptr = strchr(name, '-')) + while ((ptr = strchr(name, '-'))) *ptr = '_'; fprintf(f, "#declare lc_%s = union {\n", name); @@ -3683,12 +3687,12 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) } fclose(f); - if (ptr = strrchr (fn, '.')) + if ((ptr = strrchr (fn, '.'))) *ptr = 0; strcat (fn, ".pov"); f = fopen(fn, "wt"); - if (ptr = strrchr (fn, '.')) + if ((ptr = strrchr (fn, '.'))) *ptr = 0; ptr = strrchr (fn, '\\'); if (!ptr) @@ -3719,7 +3723,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) { char* ptr; sprintf(name, "lc_%s", pPiece->GetPieceInfo()->m_strName); - while (ptr = strchr(name, '-')) + while ((ptr = strchr(name, '-'))) *ptr = '_'; } else @@ -4164,7 +4168,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (a > max) max = a; - sprintf(groups[j]->m_strName, "Pasted Group #%0.2d", max+1); + sprintf(groups[j]->m_strName, "Pasted Group #%.2d", max+1); groups[j]->m_pNext = m_pGroups; m_pGroups = groups[j]; } @@ -4497,7 +4501,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (i > max) max = i; pGroup = new Group; - sprintf(pGroup->m_strName, "Minifig #%0.2d", max+1); + sprintf(pGroup->m_strName, "Minifig #%.2d", max+1); pGroup->m_pNext = m_pGroups; m_pGroups = pGroup; @@ -4519,6 +4523,10 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) SetModifiedFlag(true); CheckPoint("Minifig"); } + + for (i = 0; i < 15; i++) + if (opts.info[i]) + opts.info[i]->DeRef(); } break; case LC_PIECE_ARRAY: @@ -4554,7 +4562,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) opts.fMove[2] *= 0.96f; } - Piece *pPiece, *pFirst, *pLast = NULL; + Piece *pPiece, *pFirst = NULL, *pLast = NULL; float bs[6] = { 10000, 10000, 10000, -10000, -10000, -10000 }; int sel = 0; unsigned long i, j, k; @@ -4703,7 +4711,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (sscanf(pGroup->m_strName, "Group #%d", &i) == 1) if (i > max) max = i; - sprintf(name, "Group #%0.2d", max+1); + sprintf(name, "Group #%.2d", max+1); if (SystemDoDialog(LC_DLG_GROUP, name)) { @@ -6240,8 +6248,7 @@ bool Project::OnKeyDown(char nKey, bool bControl, bool bShift) if (bShift) { // Focus the previous visible piece. - Piece* pBest; - pPiece = pFocus; + Piece* pBest = pPiece = pFocus; for (;;) { if (pPiece->IsVisible(m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation)) diff --git a/common/quant.cpp b/common/quant.cpp index f32cc68..63a5719 100644 --- a/common/quant.cpp +++ b/common/quant.cpp @@ -396,7 +396,7 @@ static int quantize_image(unsigned char *in, unsigned char *out, int width, int long i = 0, j = 0; long r_pix = 0, g_pix = 0, b_pix = 0; long offset = 0, dir = 0; - long two_val = 0, odd_scanline = 0; + long odd_scanline = 0; long err_len = (width + 2) * 3; unsigned char *range_tbl = NULL, *range = NULL; short *lookup = NULL, *erowerr = NULL, *orowerr = NULL; diff --git a/config.mk b/config.mk index 9852c1f..76979c2 100644 --- a/config.mk +++ b/config.mk @@ -9,7 +9,7 @@ OS := -D_LINUX OSDIR := linux # (Add a -g for debugging) -CPPFLAGS += -O2 +CPPFLAGS += -O2 -Wall # Add compile options, such as -I option to include jpeglib's headers # CPPFLAGS += -I/home/fred/jpeglib diff --git a/linux/dialogs.cpp b/linux/dialogs.cpp index ab2f422..9ba6c57 100644 --- a/linux/dialogs.cpp +++ b/linux/dialogs.cpp @@ -190,7 +190,7 @@ int msgbox_execute(char* text, int flags) gtk_widget_show (w); ret = LC_CANCEL; } - else if (mode == LC_MB_YESNO) + else /* if (mode == LC_MB_YESNO) */ { w = gtk_button_new_with_label ("Yes"); gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); @@ -1937,7 +1937,7 @@ int propertiesdlg_execute(void* param) gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 2, 3, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), 0, 0); - sprintf(text, "%.1fKB (%d bytes)", (float)buf.st_size/1024, buf.st_size); + sprintf(text, "%.1fKB (%d bytes)", (float)buf.st_size/1024, (int)buf.st_size); label = gtk_label_new (text); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); @@ -2230,8 +2230,8 @@ typedef struct static void groupeditdlg_ok(GtkWidget *widget, gpointer data) { - LC_GROUPEDITDLG_STRUCT* s = (LC_GROUPEDITDLG_STRUCT*)data; - LC_GROUPEDITDLG_OPTS* opts = (LC_GROUPEDITDLG_OPTS*)s->data; + // LC_GROUPEDITDLG_STRUCT* s = (LC_GROUPEDITDLG_STRUCT*)data; + // LC_GROUPEDITDLG_OPTS* opts = (LC_GROUPEDITDLG_OPTS*)s->data; *cur_ret = LC_OK; } diff --git a/linux/dlgpiece.cpp b/linux/dlgpiece.cpp index 722d276..62d1ac1 100755 --- a/linux/dlgpiece.cpp +++ b/linux/dlgpiece.cpp @@ -14,6 +14,7 @@ #include #include #include "gtkglarea.h" +#include "gtktools.h" #include "system.h" #include "typedefs.h" #include "globals.h" @@ -95,7 +96,7 @@ static gint minifigdlg_redraw (GtkWidget *widget, GdkEventExpose *event) return TRUE; } -// Save the new size of the window. +// Setup the OpenGL projection static gint minifigdlg_resize (GtkWidget *widget, GdkEventConfigure *event) { if (!gtk_gl_area_make_current(GTK_GL_AREA(widget))) @@ -124,34 +125,42 @@ static gint minifigdlg_resize (GtkWidget *widget, GdkEventConfigure *event) return TRUE; } +// User wants to add the minifig to the project static void minifigdlg_ok(GtkWidget *widget, gpointer data) { - // LC_GROUPDLG_STRUCT* s = (LC_GROUPDLG_STRUCT*)data; + // LC_MINIFIGDLG_STRUCT* s = (LC_MINIFIGDLG_STRUCT*)data; // LC_MINIFIGDLG_OPTS* opts = (LC_MINIFIGDLG_OPTS*)s->data; dlg_end (LC_OK); } -// Create a combo box with a color selection control -static void minifigdlg_createpair (LC_MINIFIGDLG_STRUCT* info, int num, GtkWidget* vbox) +// A new color was selected from the menu +static void minifigdlg_color_response (GtkWidget *widget, gpointer data) { - GtkWidget *hbox, *combo, *color, *menu, *menuitem; + LC_MINIFIGDLG_STRUCT* info; + GtkWidget* button; int i; - hbox = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); + button = (GtkWidget*)gtk_object_get_data (GTK_OBJECT (widget), "button"); + info = (LC_MINIFIGDLG_STRUCT*)gtk_object_get_data (GTK_OBJECT (button), "info"); - combo = info->pieces[num] = gtk_combo_new (); - gtk_widget_show (combo); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, TRUE, 0); - gtk_widget_set_usize (combo, 75, 25); - gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (combo)->entry), FALSE); + if (!info) + return; - color = info->colors[num] = gtk_option_menu_new (); + for (i = 0; i < 15; i++) + if (info->colors[i] == button) + break; - gtk_widget_show (color); - gtk_box_pack_start (GTK_BOX (hbox), color, FALSE, FALSE, 0); + info->opts->colors[i] = (int)data; + gtk_widget_draw (info->preview, NULL); + set_button_pixmap2 (button, FlatColorArray[(int)data]); +} + +// A color button was clicked +static void minifigdlg_color_clicked (GtkWidget *widget, gpointer data) +{ + int i; + GtkWidget *menu, *menuitem; menu = gtk_menu_new (); @@ -160,13 +169,54 @@ static void minifigdlg_createpair (LC_MINIFIGDLG_STRUCT* info, int num, GtkWidge menuitem = gtk_menu_item_new_with_label (colornames[i]); gtk_widget_show (menuitem); gtk_menu_append (GTK_MENU (menu), menuitem); + + gtk_object_set_data (GTK_OBJECT (menuitem), "button", widget); + gtk_signal_connect (GTK_OBJECT (menuitem), "activate", + GTK_SIGNAL_FUNC (minifigdlg_color_response), (void*)i); } - gtk_option_menu_set_menu (GTK_OPTION_MENU (color), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (color), info->opts->colors[num]); + + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, 0); +} + +// A color button was exposed, draw the pixmap +static gint minifigdlg_color_expose (GtkWidget *widget) +{ + int* data = (int*)gtk_object_get_data (GTK_OBJECT (widget), "color"); + set_button_pixmap2 (widget, FlatColorArray[*data]); + return TRUE; +} + +// Create a combo box with a color selection control +static void minifigdlg_createpair (LC_MINIFIGDLG_STRUCT* info, int num, GtkWidget* vbox) +{ + GtkWidget *hbox, *combo, *color; + + hbox = gtk_hbox_new (FALSE, 5); + gtk_widget_show (hbox); + gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0); + + combo = info->pieces[num] = gtk_combo_new (); + gtk_widget_show (combo); + gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0); + gtk_widget_set_usize (combo, 60, 25); + gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (combo)->entry), FALSE); + + color = info->colors[num] = gtk_button_new_with_label (""); + gtk_widget_set_events (color, GDK_EXPOSURE_MASK); + gtk_widget_show (color); + gtk_object_set_data (GTK_OBJECT (color), "color", &info->opts->colors[num]); + gtk_object_set_data (GTK_OBJECT (color), "info", info); + gtk_widget_set_usize (color, 40, 25); + gtk_signal_connect (GTK_OBJECT (color), "expose_event", + GTK_SIGNAL_FUNC (minifigdlg_color_expose), NULL); + gtk_signal_connect (GTK_OBJECT (color), "clicked", + GTK_SIGNAL_FUNC (minifigdlg_color_clicked), info); + gtk_box_pack_start (GTK_BOX (hbox), color, FALSE, TRUE, 0); } int minifigdlg_execute(void* param) { + int attrlist[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 16, 0 }; LC_MINIFIGDLG_STRUCT s; GtkWidget *dlg; GtkWidget *vbox1, *vbox2, *hbox; @@ -180,12 +230,12 @@ int minifigdlg_execute(void* param) GTK_SIGNAL_FUNC (dlg_delete_callback), NULL); gtk_signal_connect (GTK_OBJECT (dlg), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL); - gtk_widget_set_usize (dlg, 600, 400); + gtk_widget_set_usize (dlg, 600, 360); gtk_window_set_title (GTK_WINDOW (dlg), "Minifig Wizard"); gtk_window_set_policy (GTK_WINDOW (dlg), FALSE, FALSE, FALSE); gtk_widget_realize (dlg); - vbox1 = gtk_vbox_new (FALSE, 0); + vbox1 = gtk_vbox_new (FALSE, 10); gtk_widget_show (vbox1); gtk_container_add (GTK_CONTAINER (dlg), vbox1); gtk_container_border_width (GTK_CONTAINER (vbox1), 5); @@ -194,9 +244,9 @@ int minifigdlg_execute(void* param) gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox1), hbox, FALSE, TRUE, 0); - vbox2 = gtk_vbox_new (FALSE, 0); + vbox2 = gtk_vbox_new (FALSE, 5); gtk_widget_show (vbox2); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0); minifigdlg_createpair (&s, MFW_HAT, vbox2); minifigdlg_createpair (&s, MFW_NECK, vbox2); @@ -207,8 +257,6 @@ int minifigdlg_execute(void* param) minifigdlg_createpair (&s, MFW_RIGHT_LEG, vbox2); minifigdlg_createpair (&s, MFW_RIGHT_SHOE, vbox2); - int attrlist[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 16, 0 }; - // Create new OpenGL widget. s.preview = gtk_gl_area_share_new (attrlist, GTK_GL_AREA (drawing_area)); gtk_widget_set_events (GTK_WIDGET (s.preview), GDK_EXPOSURE_MASK); @@ -223,9 +271,9 @@ int minifigdlg_execute(void* param) gtk_widget_show (GTK_WIDGET (s.preview)); gtk_object_set_data (GTK_OBJECT (s.preview), "minifig", &s); - vbox2 = gtk_vbox_new (FALSE, 0); + vbox2 = gtk_vbox_new (FALSE, 5); gtk_widget_show (vbox2); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0); minifigdlg_createpair (&s, MFW_HEAD, vbox2); minifigdlg_createpair (&s, MFW_TORSO, vbox2); @@ -284,6 +332,8 @@ int minifigdlg_execute(void* param) case MF_LEGL: id = MFW_LEFT_LEG; break; case MF_LEGR: id = MFW_RIGHT_LEG; break; case MF_SHOE: id = MFW_LEFT_SHOE; break; + default: + continue; } if (i != 29) @@ -308,15 +358,7 @@ int minifigdlg_execute(void* param) } } - - - return dlg_domodal(dlg, LC_CANCEL); - /* - for (int i = 0; i < 15; i++) - if (m_pMFWnd->m_pFig->info[i]) - m_pMFWnd->m_pFig->info[i]->DeRef(); -*/ } diff --git a/linux/gtktools.cpp b/linux/gtktools.cpp index d7f27f3..c7edbe9 100644 --- a/linux/gtktools.cpp +++ b/linux/gtktools.cpp @@ -76,4 +76,36 @@ void set_button_pixmap (GtkWidget* widget, float* color) gdk_gc_destroy(gc); } +void set_button_pixmap2 (GtkWidget* widget, unsigned char* color) +{ + GdkColor c; + GdkGC* gc; + GdkPixmap* pixmap; + + if (widget->window == NULL) + return; + + if ((widget->allocation.width < 10) || (widget->allocation.height < 10)) + return; + + gc = gdk_gc_new (widget->window); + pixmap = gdk_pixmap_new (widget->window, widget->allocation.width - 10, + widget->allocation.height - 10, -1); + + c.red = color[0]*256; + c.green = color[1]*256; + c.blue = color[2]*256; + gdk_color_alloc (gtk_widget_get_colormap(widget), &c); + gdk_gc_set_foreground(gc, &c); + + gdk_draw_rectangle (pixmap, gc, TRUE, 0, 0, + widget->allocation.width - 5, widget->allocation.height - 5); + + GtkWidget* pixmapwid = gtk_pixmap_new (pixmap, (GdkBitmap*)NULL); + gtk_widget_show (pixmapwid); + + gtk_container_remove (GTK_CONTAINER(widget), GTK_BIN(widget)->child); + gtk_container_add (GTK_CONTAINER(widget), pixmapwid); + gdk_gc_destroy(gc); +} diff --git a/linux/gtktools.h b/linux/gtktools.h index dd09b91..e524500 100644 --- a/linux/gtktools.h +++ b/linux/gtktools.h @@ -6,6 +6,7 @@ GtkWidget* new_pixmap (GtkWidget *widget, char **data); GtkWidget* clist_title_with_arrow (GtkWidget* clist, char col, char* label_text); void set_notebook_tab (GtkWidget *notebook, gint page_num, GtkWidget *widget); void set_button_pixmap (GtkWidget* widget, float* color); +void set_button_pixmap2 (GtkWidget* widget, unsigned char* color); #endif // _GTKTOOLS_H_ diff --git a/linux/system.cpp b/linux/system.cpp index 3769dd1..bda9063 100644 --- a/linux/system.cpp +++ b/linux/system.cpp @@ -23,6 +23,8 @@ char* strupr(char* string) if ('a' <= *cp && *cp <= 'z') *cp += 'A' - 'a'; } + + return string; } char* strlwr(char* string) @@ -33,6 +35,8 @@ char* strlwr(char* string) if ('A' <= *cp && *cp <= 'Z') *cp += 'a' - 'A'; } + + return string; } @@ -163,6 +167,8 @@ void SystemUpdateAction(int new_action, int old_action) button = tool_toolbar.rotview; xpm = cr_rotv; x = 15; y = 15; break; case LC_ACTION_ROLL: button = tool_toolbar.roll; xpm = cr_roll; x = 15; y = 15; break; + default: + return; } GdkBitmap *bitmap; diff --git a/linux/toolbar.cpp b/linux/toolbar.cpp index 7282685..d82d80d 100644 --- a/linux/toolbar.cpp +++ b/linux/toolbar.cpp @@ -635,7 +635,6 @@ void colorlist_set(int new_color) // Create what is the pieces toolbar in the Windows version as fixed items. void create_piecebar(GtkWidget *window, GtkWidget *hbox) { - GtkWidget *vbox; gchar *titles[2] = { "Description", "Number" }; int attrlist[] = { @@ -697,10 +696,6 @@ void create_piecebar(GtkWidget *window, GtkWidget *hbox) gtk_clist_set_vadjustment (GTK_CLIST (piecelist), NULL); */ - // Piece toolbar - GtkWidget* icon; - int i; - #include "pixmaps/pi-acces.xpm" #include "pixmaps/pi-plate.xpm" #include "pixmaps/pi-tile.xpm" diff --git a/win/Cadview.cpp b/win/Cadview.cpp index 5eeb2d6..9a3f1cd 100644 --- a/win/Cadview.cpp +++ b/win/Cadview.cpp @@ -120,7 +120,7 @@ BOOL CCADView::PreCreateWindow(CREATESTRUCT& cs) ///////////////////////////////////////////////////////////////////////////// // CCADView drawing -void CCADView::OnDraw(CDC* pDC) +void CCADView::OnDraw(CDC* /*pDC*/) { project->Render(false); /* @@ -746,7 +746,7 @@ CCADDoc* CCADView::GetDocument() // non-debug version is inline ///////////////////////////////////////////////////////////////////////////// // CCADView message handlers -BOOL CCADView::OnEraseBkgnd(CDC* pDC) +BOOL CCADView::OnEraseBkgnd(CDC* /*pDC*/) { return TRUE; } @@ -858,32 +858,32 @@ void CCADView::OnSize(UINT nType, int cx, int cy) CView::OnSize(nType, cx, cy); } -void CCADView::OnMouseMove(UINT nFlags, CPoint point) +void CCADView::OnMouseMove(UINT /*nFlags*/, CPoint point) { project->OnMouseMove(point.x, m_szView.cy - point.y - 1); } -void CCADView::OnLButtonUp(UINT nFlags, CPoint point) +void CCADView::OnLButtonUp(UINT /*nFlags*/, CPoint point) { project->OnLeftButtonUp(point.x, m_szView.cy - point.y - 1); } -void CCADView::OnLButtonDown(UINT nFlags, CPoint point) +void CCADView::OnLButtonDown(UINT /*nFlags*/, CPoint point) { project->OnLeftButtonDown(point.x, m_szView.cy - point.y - 1); } -void CCADView::OnLButtonDblClk(UINT nFlags, CPoint point) +void CCADView::OnLButtonDblClk(UINT /*nFlags*/, CPoint point) { project->OnLeftButtonDoubleClick(point.x, m_szView.cy - point.y - 1); } -void CCADView::OnRButtonDown(UINT nFlags, CPoint point) +void CCADView::OnRButtonDown(UINT /*nFlags*/, CPoint point) { project->OnRightButtonDown(point.x, m_szView.cy - point.y - 1); } -void CCADView::OnRButtonUp(UINT nFlags, CPoint point) +void CCADView::OnRButtonUp(UINT /*nFlags*/, CPoint point) { project->OnRightButtonUp(point.x, m_szView.cy - point.y - 1); } @@ -914,7 +914,7 @@ void CCADView::OnDropDown (NMHDR* pNotifyStruct, LRESULT* pResult) *pResult = TBDDRET_DEFAULT; } -LONG CCADView::OnChangeCursor(UINT lParam, LONG wParam) +LONG CCADView::OnChangeCursor(UINT lParam, LONG /*wParam*/) { UINT c; @@ -1010,7 +1010,7 @@ void CCADView::OnTimer(UINT nIDEvent) } // lParam -> new step/frame -LONG CCADView::OnSetStep(UINT lParam, LONG wParam) +LONG CCADView::OnSetStep(UINT lParam, LONG /*wParam*/) { if (lParam > 0) project->HandleCommand(LC_VIEW_STEP_SET, lParam); diff --git a/win/Clrpick.cpp b/win/Clrpick.cpp index 496a48e..1d920fa 100644 --- a/win/Clrpick.cpp +++ b/win/Clrpick.cpp @@ -60,7 +60,7 @@ END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CColorPicker message handlers -LONG CColorPicker::OnSelEndOK(UINT lParam, LONG wParam) +LONG CColorPicker::OnSelEndOK(UINT /*lParam*/, LONG wParam) { m_bActive = FALSE; SetColorIndex(wParam); @@ -72,7 +72,7 @@ LONG CColorPicker::OnSelEndOK(UINT lParam, LONG wParam) return TRUE; } -LONG CColorPicker::OnSelEndCancel(UINT lParam, LONG wParam) +LONG CColorPicker::OnSelEndCancel(UINT /*lParam*/, LONG wParam) { m_bActive = FALSE; diff --git a/win/Figdlg.cpp b/win/Figdlg.cpp index 312305d..b209b4e 100644 --- a/win/Figdlg.cpp +++ b/win/Figdlg.cpp @@ -139,10 +139,6 @@ BOOL CMinifigDlg::OnInitDialog() BOOL CMinifigDlg::DestroyWindow() { - for (int i = 0; i < 15; i++) - if (m_pMFWnd->m_pFig->info[i]) - m_pMFWnd->m_pFig->info[i]->DeRef(); - m_pMFWnd->DestroyWindow(); delete m_pMFWnd; diff --git a/win/GrpTree.cpp b/win/GrpTree.cpp index e1b92ca..3102606 100644 --- a/win/GrpTree.cpp +++ b/win/GrpTree.cpp @@ -239,7 +239,7 @@ BOOL CGroupEditTree::PreTranslateMessage(MSG* pMsg) return CTreeCtrl::PreTranslateMessage(pMsg); } -BOOL CGroupEditTree::IsDropSource(HTREEITEM hItem) +BOOL CGroupEditTree::IsDropSource(HTREEITEM /*hItem*/) { return TRUE; } diff --git a/win/LeoCAD.dsp b/win/LeoCAD.dsp index 460bcbd..133c659 100644 --- a/win/LeoCAD.dsp +++ b/win/LeoCAD.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "../common" /I "../win" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W4 /GX /O2 /I "../common" /I "../win" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -207,6 +207,13 @@ InputPath=.\hlp\LeoCAD.hpj # Begin Source File SOURCE=.\Leocad.rc + +!IF "$(CFG)" == "LeoCAD - Win32 Release" + +!ELSEIF "$(CFG)" == "LeoCAD - Win32 Debug" + +!ENDIF + # End Source File # Begin Source File diff --git a/win/Leocad.h b/win/Leocad.h index f353f5e..1641322 100644 --- a/win/Leocad.h +++ b/win/Leocad.h @@ -33,7 +33,7 @@ public: //}}AFX_VIRTUAL // Implementation - void OnUpdateRecentFileMenu(CCmdUI* pCmdUI) {}; + void OnUpdateRecentFileMenu(CCmdUI* /*pCmdUI*/) {}; //{{AFX_MSG(CCADApp) afx_msg void OnHelpUpdates(); diff --git a/win/Mfwnd.cpp b/win/Mfwnd.cpp index 63315e6..258e9a9 100644 --- a/win/Mfwnd.cpp +++ b/win/Mfwnd.cpp @@ -113,7 +113,7 @@ int CMinifigWnd::InitGL() return 0; } -BOOL CMinifigWnd::OnEraseBkgnd(CDC* pDC) +BOOL CMinifigWnd::OnEraseBkgnd(CDC* /*pDC*/) { return TRUE; } diff --git a/win/Moddlg.cpp b/win/Moddlg.cpp index 632cffd..52fec77 100644 --- a/win/Moddlg.cpp +++ b/win/Moddlg.cpp @@ -131,7 +131,7 @@ void CModifyDialog::DoDataExchange(CDataExchange* pDX) //}}AFX_DATA_MAP } -void CModifyDialog::OnUpdateCmdUI(CFrameWnd * pTarget, BOOL bDisableIfNoHndler) +void CModifyDialog::OnUpdateCmdUI(CFrameWnd * pTarget, BOOL /*bDisableIfNoHndler*/) { UpdateDialogControls(pTarget, FALSE); } -- cgit v1.2.3