//--------------------------------------------------------------------------- #include #include #include #include #include #include #include #pragma hdrstop #include "Common.h" #include "Define.h" #include "Exception.h" #include "LeadToolsFileOption.h" #if defined(TEXTILE) #include "VecDraw.h" // By GreenFish ÀÎŬ·çµå ¾ÈÇϰí´Â ¹æ¹ýÀÌ ¾ø³×...ToT #endif //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- TStringTable CommonStringTable; AnsiString Language; //===============================//2001.4.10. by lhskys congi¿¡¼­ Á¾ÀÌ size, unit ³Ö±â AnsiString Size_Type; AnsiString TUnits, WUnits, KUnits; AnsiString Select; //========================= #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC int Password[4]; #endif #endif AnsiString DirectoryBin; AnsiString DirectoryItem; AnsiString DirectoryTemp; AnsiString DirectoryColor; AnsiString DirectoryTexture; AnsiString DirectoryTextileOpen; //2001.4.11. by lhskys Congi¿¡ Open Ãß°¡ AnsiString DirectoryWeaveOpen; //2001.4.11. by lhskys Congi¿¡ Open Ãß°¡ AnsiString DirectoryKnitOpen; //2001.4.11. by lhskys Congi¿¡ Open Ãß°¡ #if defined(TEXTILE) AnsiString DirectoryStyle; AnsiString DirectoryTreatment; #elif defined(WEAVE) AnsiString DirectoryYarn; AnsiString DirectorySucker; #elif defined(PILE) AnsiString DirectoryYarn; #elif defined (KNIT) AnsiString DirectoryStitch; #endif AnsiString DefaultFontName; TFont *SmallFont; AnsiString AppDataBin; TPrinterColor *PrinterColor; TStandardColor *StandardColor; TTextileColor *TextileColor; TPantone1000 *Pantone1000; // k3dogs 20001211 TPantoneTextile *PantoneTextile; TTablet *Tablet; #if defined(KNIT) TDesignMode DesignMode = D_YARN; #endif #if defined(TEXTILE) || defined(KNIT) //--------------------------------------------------------------------------- // TPlaneVertex //--------------------------------------------------------------------------- __fastcall TPlaneVertex::TPlaneVertex() { bit = new TPBitmap; } //--------------------------------------------------------------------------- __fastcall TPlaneVertex::~TPlaneVertex() { if (bit) delete bit; } //--------------------------------------------------------------------------- // Reivate Method //--------------------------------------------------------------------------- void __fastcall TPlaneVertex::Angle(int a, int b, int x, int y, double &sum) { double dx1, dy1, dx2, dy2; dx1 = p[a].x - x; dy1 = p[a].y - y; dx2 = p[b].x - x; dy2 = p[b].y - y; if (dx1 * dy2 - dx2 * dy1 > 0) { sum += acos((dx1 * dx2 + dy1 * dy2) / (sqrt(dx1 * dx1 + dy1 * dy1) * sqrt(dx2 * dx2 + dy2 * dy2))); } else { sum -= acos((dx1 * dx2 + dy1 * dy2) / (sqrt(dx1 * dx1 + dy1 * dy1) * sqrt(dx2 * dx2 + dy2 * dy2))); } } //--------------------------------------------------------------------------- // Rublic Method //--------------------------------------------------------------------------- void __fastcall TPlaneVertex::Create(TPoint a, TPoint b, TPoint c, TPoint d) { double s; int sx, sy, ex, ey, x, y, xx[4]; int i, j; p[0].x = a.x; p[0].y = a.y; p[1].x = b.x; p[1].y = b.y; p[2].x = c.x; p[2].y = c.y; p[3].x = d.x; p[3].y = d.y; start.x = p[0].x; start.y = p[0].y; end.x = p[0].x; end.y = p[0].y; for (i = 1; i < 4; i++) { if (start.x > p[i].x) start.x = p[i].x; if (end.x < p[i].x) end.x = p[i].x; if (start.y > p[i].y) start.y = p[i].y; if (end.y < p[i].y) end.y = p[i].y; } if (bit) { if (!bit->Create(end.x - start.x + 1, end.y - start.y + 1, 1)) goto fail; if (!bit->Lock()) goto fail; for (i = 0; i < 4; i++) { sx = p[i].x - start.x; ex = p[(i + 1) % 4].x - start.x; sy = p[i].y - start.y; ey = p[(i + 1) % 4].y - start.y; if (ex - sx && ey - sy) { s = (double)(ey - sy) / (ex - sx); if (ey > sy) { for (y = sy; y <= ey; y++) { x = (double)(y - sy) / s + sx + 0.5; #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } else { for (y = ey; y <= sy; y++) { x = (double)(y - sy) / s + sx + 0.5; #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } } else if (ex - sx) { #ifdef TPDEBUG if (sx>=0 && sxWidth && sy>=0 && syHeight) { BWSetX(bit->ScanLine(sy), sx); } else { SHOWDEBUG; } if (ex>=0 && exWidth && sy>=0 && syHeight) { BWSetX(bit->ScanLine(sy), ex); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(sy), sx); BWSetX(bit->ScanLine(sy), ex); #endif } else { if (ey > sy) { for (y = sy; y <= ey; y++) { #ifdef TPDEBUG if (sx>=0 && sxWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), sx); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), sx); #endif } } else { for (y = ey; y <= sy; y++) { #ifdef TPDEBUG if (sx>=0 && sxWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), sx); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), sx); #endif } } } } for (y = 1; y < end.y - start.y; y++) { sx = -1; for (x = i = 0; x <= end.x - start.x; x++) { if (BWGetX(bit->ScanLine(y), x)) { for (j = 0; j < 4; j++) { if (start.x + x == p[j].x && start.y + y == p[j].y) { sx = i; break; } } xx[i++] = x; } } if (i && (i % 2) == 0) { for (x = xx[0]; x <= xx[1]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } if (i == 4) { for (x = xx[2]; x <= xx[3]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } } else if (i == 3) { if (sx == 0) { for (x = xx[1]; x <= xx[2]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } else if (sx == 1) { for (x = xx[0]; x <= xx[2]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } else if (sx == 2) { for (x = xx[0]; x <= xx[1]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } else if (i) { for (x = xx[0]; x <= xx[i - 1]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } } } for (i = 0; i < 4; i++) { sx = p[i].x - start.x; ex = p[(i + 1) % 4].x - start.x; sy = p[i].y - start.y; ey = p[(i + 1) % 4].y - start.y; if (ex - sx && ey == sy) { if (ex > sx) { for (x = sx + 1; x < ex; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && sy>=0 && syHeight) { BWSetX(bit->ScanLine(sy), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(sy), x); #endif } } else { for (x = ex + 1; x < sx; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && sy>=0 && syHeight) { BWSetX(bit->ScanLine(sy), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(sy), x); #endif } } } } } return; fail: ::doDestroy(bit); } //--------------------------------------------------------------------------- bool __fastcall TPlaneVertex::Check(int x, int y) { int dis_x, dis_y; double sum = 0.0; if (bit) return BWGetX(bit->ScanLine(y - start.y), x - start.x); for (int i = 0; i < 4; i++) { if (i) { dis_x = abs(p[i].x - p[i - 1].x); dis_y = abs(p[i].y - p[i - 1].y); if (abs(x - p[i].x) <= dis_x && abs(x - p[i - 1].x) <= dis_x && abs(y - p[i].y) <= dis_y && abs(y - p[i - 1].y) <= dis_y && (y - p[i].y) * (p[i - 1].x - p[i].x) == (x - p[i].x) * (p[i - 1].y - p[i].y)) return true; } else { dis_x = abs(p[0].x - p[3].x); dis_y = abs(p[0].y - p[3].y); if (abs(x - p[0].x) <= dis_x && abs(x - p[3].x) <= dis_x && abs(y - p[0].y) <= dis_y && abs(y - p[3].y) <= dis_y && (y - p[0].y) * (p[3].x - p[0].x) == (x - p[0].x) * (p[3].y - p[0].y)) return true; } } Angle(0, 3, x, y, sum); Angle(3, 2, x, y, sum); Angle(2, 1, x, y, sum); Angle(1, 0, x, y, sum); if (2.0 * M_PI - fabs(sum) < 0.0000000001) { if (fabs(sum) - 2.0 * M_PI < 0.0000000001) return true; } return false; } #endif //--------------------------------------------------------------------------- // TPCanvasInfor //--------------------------------------------------------------------------- void __fastcall TPCanvasInfor::SetSize(TPCanvasSizeType st, int w, int h) { SizeType = st; if (st==cstFree) { Width = w; Height = h; } else { Width = GetWidth(); Height = GetHeight(); } } //--------------------------------------------------------------------------- int __fastcall TPCanvasInfor::GetWidth() { if (SizeType==cstFree) return Width; if (Orientation==coPortrait) { switch (SizeType) { case cstTabloid: return 10.3 * DotsPerInch; case cstLetter: return 8.0 * DotsPerInch; //k3dogs letter case cstLegal: return 8.0 * DotsPerInch; case cstA0: return 31.2 * DotsPerInch; case cstA1: return 22.0 * DotsPerInch; case cstA2: return 15.6 * DotsPerInch; case cstA3: return 11.0 * DotsPerInch; default: return 7.8 * DotsPerInch; } } else { switch (SizeType) { case cstTabloid: return 16.0 * DotsPerInch; case cstLetter: return 10.3 * DotsPerInch; //k3dogs letter case cstLegal: return 13.2 * DotsPerInch; case cstA0: return 44.0 * DotsPerInch; case cstA1: return 31.2 * DotsPerInch; case cstA2: return 22.0 * DotsPerInch; case cstA3: return 15.6 * DotsPerInch; default: return 11.0 * DotsPerInch; } } } //--------------------------------------------------------------------------- int __fastcall TPCanvasInfor::GetHeight() { if (SizeType==cstFree) return Height; if (Orientation==coPortrait) { switch (SizeType) { case cstTabloid: return 16.0 * DotsPerInch; case cstLetter: return 10.3 * DotsPerInch; //k3dogs letter case cstLegal: return 13.2 * DotsPerInch; case cstA0: return 44.0 * DotsPerInch; case cstA1: return 31.2 * DotsPerInch; case cstA2: return 22.0 * DotsPerInch; case cstA3: return 15.6 * DotsPerInch; default: return 11.0 * DotsPerInch; } } else { switch (SizeType) { case cstTabloid: return 10.3 * DotsPerInch; case cstLetter: return 8.0 * DotsPerInch; //k3dogs letter case cstLegal: return 8.0 * DotsPerInch; case cstA0: return 31.2 * DotsPerInch; case cstA1: return 22.0 * DotsPerInch; case cstA2: return 15.6 * DotsPerInch; case cstA3: return 11.0 * DotsPerInch; default: return 7.8 * DotsPerInch; } } } //--------------------------------------------------------------------------- void __fastcall TPCanvasInfor::SetExtFileOption() { LoadFileOption.XResolution = DotsPerInch; LoadFileOption.YResolution = DotsPerInch; } //--------------------------------------------------------------------------- AnsiString __fastcall TPCanvasInfor::Name(TUnit Unit, int w, int h) { switch (SizeType) { case cstA4: return "A4"; case cstA3: return "A3"; case cstA2: return "A2"; case cstA1: return "A1"; case cstA0: return "A0"; case cstLetter: return "Letter"; //k3dogs letter case cstLegal: return "Legal"; case cstTabloid: return "Tabloid"; default: /*if(w == 1247 && h == 1760) return "A4"; //qe »çÀÌÁî°¡ ±Ô°Ý »çÀÌÁî¶û ¶È°°À¸¸é »çÀÌÁîÀÇ Å©±â¸¦ if(w == 1760 && h == 2496) return "A3"; //º¸¿©ÁÖ´Â°Í ´ë½Å¿¡ »çÀÌÁîÀ̸§À» º¸¿©ÁÖ°Ô Çß´Ù..(½ÃÄѼ­..) if(w == 2496 && h == 3520) return "A2"; //´Ù½Ã ¸·¾Ò´Ù...»çÀÌÁîÀÇ Å©±â°¡ ÀÏÁ¤ÇÏÁö ¾Ê´Ù...ÇѵµÆ®Á¤µµ Â÷À̰¡ ³­´Ù. if(w == 3520 && h == 4992) return "A1"; if(w == 4992 && h == 7040) return "A0"; if(w == 1280 && h == 1648) return "Letter"; if(w == 1280 && h == 2112) return "Legal"; */ if (Unit == uDot) { return Format("%d x %d", OPENARRAY(TVarRec, (w, h))); } else if (Unit == uInch) { return Format("%f x %f", OPENARRAY(TVarRec, ((double)w/DotsPerInch, (double)h/DotsPerInch))); } else if (Unit == uCm) { return Format("%f x %f", OPENARRAY(TVarRec, (2.54*w/DotsPerInch, 2.54*h/DotsPerInch))); } break; } return (AnsiString)""; } //--------------------------------------------------------------------------- // External Function //--------------------------------------------------------------------------- void __fastcall LoadFromMainRegIniFile() { /* This table has been assembled from Usenet postings, personal observations, and reading other people's code. Please feel free to add to it or correct it. dwPlatFormID dwMajorVersion dwMinorVersion dwBuildNumber 95 1 4 0 950 95 SP1 1 4 0 >950 && <=1080 95 OSR2 1 4 <10 >1080 98 1 4 10 1998 98 SP1 1 4 10 >1998 && <2183 98 SE 1 4 10 >=2183 ME 1 4 90 3000 NT 3.51 2 3 51 NT 4 2 4 0 1381 2000 2 5 0 2195 XP 2 5 1 Vista 6 0 Server 2008 6 0 Server 2008 R2 6 1 Windows 7 6 1 Windows 8 6 2 CE 3 */ TRegIniFile *RegIniFile; char tp[MAX_PATH+1]; AnsiString pw; OSVERSIONINFO osinfo; osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osinfo); AppDataBin = UserAppDataDir + "YoungWoo"; if (!DirectoryExists(AppDataBin)) { if (!CreateDir(AppDataBin)) throw Exception("Cannot create " + AppDataBin); } #ifdef NETHASP AppDataBin = AppDataBin + "\\NetTexWork" + TexWorkVersion; #else AppDataBin = AppDataBin + "\\TexWork" + TexWorkVersion; #endif if (!DirectoryExists(AppDataBin)) { if (!CreateDir(AppDataBin)) throw Exception("Cannot create " + AppDataBin); } GetTempPath(MAX_PATH, tp); if (tp[strlen(tp)-1]=='\\') tp[strlen(tp)-1] = 0; DirectoryTemp = tp; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); if (RegIniFile) { Language = RegIniFile->ReadString("Common", "Language", "English"); DefaultFontName = RegIniFile->ReadString("Common", "DefaultFontName", "Tahoma"); Select = RegIniFile->ReadString("Common", "Select", "READ" ); //2001.4.11. by lhskys congi¿¡¼­ Select ³Ö±â #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC #ifdef TEXWORK #ifdef NETHASP pw = RegIniFile->ReadString("Common", "Serial", ""); #else pw = RegIniFile->ReadString("Common", "Serial", ""); #endif sscanf(pw.c_str(), "%d-%d-%d-%d", &Password[0], &Password[1], &Password[2], &Password[3]); #else pw = RegIniFile->ReadString("Common", "Serial", ""); sscanf(pw.c_str(), "%d-%d-%d-%d", &Password[0], &Password[1], &Password[2], &Password[3]); #endif #endif #endif DirectoryBin = RegIniFile->ReadString("Directory", "Bin", DefaultDir + "\\Bin"); DirectoryColor = RegIniFile->ReadString("Directory", "Color", DefaultDir + "\\Color"); DirectoryTexture = RegIniFile->ReadString("Directory", "Texture", DefaultDir + "\\Texture"); DirectoryTextileOpen = RegIniFile->ReadString("Directory", "TextileOpen", DefaultDir ); //2001.4.11. by lhskys congi¿¡¼­ Open ³Ö±â DirectoryWeaveOpen = RegIniFile->ReadString("Directory", "WeaveOpen", DefaultDir ); //2001.4.11. by lhskys congi¿¡¼­ Open ³Ö±â DirectoryKnitOpen = RegIniFile->ReadString("Directory", "KnitOpen", DefaultDir ); //2001.4.11. by lhskys congi¿¡¼­ Open ³Ö±â #if defined(TEXTILE) DirectoryStyle = RegIniFile->ReadString("Directory", "Style", DefaultDir + "\\Style"); DirectoryTreatment = RegIniFile->ReadString("Directory", "Treatment", DefaultDir + "\\Treatment"); Size_Type = RegIniFile->ReadString("Common", "TREG_Size", "cstA4" ); //2001.4.24. by lhskys congi¿¡¼­ Á¾ÀÌ size ³Ö±â TUnits = RegIniFile->ReadString("Common", "TUnits", "uCm" ); //2001.4.10. by lhskys congi¿¡¼­ unit ³Ö±â #elif defined(WEAVE) DirectoryYarn = RegIniFile->ReadString("Directory", "Yarn", DefaultDir + "\\Yarn"); DirectorySucker = RegIniFile->ReadString("Directory", "Sucker", DefaultDir + "\\Sucker"); Size_Type = RegIniFile->ReadString("Common", "WREG_Size", "cstA4" ); //2001.4.24. by lhskys congi¿¡¼­ Á¾ÀÌ size ³Ö±â WUnits = RegIniFile->ReadString("Common", "WUnits", "uCm" ); //2001.4.10. by lhskys congi¿¡¼­ unit ³Ö±â #elif defined(PILE) DirectoryYarn = RegIniFile->ReadString("Directory", "Yarn", DefaultDir + "\\Yarn"); Size_Type = RegIniFile->ReadString("Common", "WREG_Size", "cstA4" ); //2001.4.24. by lhskys congi¿¡¼­ Á¾ÀÌ size ³Ö±â WUnits = RegIniFile->ReadString("Common", "WUnits", "uCm" ); //2001.4.10. by lhskys congi¿¡¼­ unit ³Ö±â #elif defined(KNIT) DirectoryStitch = RegIniFile->ReadString("Directory", "Stitch", DefaultDir + "\\Stitch"); Size_Type = RegIniFile->ReadString("Common", "KREG_Size", "cstA4" ); //2001.4.24. by lhskys congi¿¡¼­ Á¾ÀÌ size ³Ö±â KUnits = RegIniFile->ReadString("Common", "KUnits", "uCm" ); //2001.4.10. by lhskys congi¿¡¼­ unit ³Ö±â #endif delete RegIniFile; } else { Language = "English"; //DefaultFontName = "Tahoma"; TFont *DefaultFont = NULL; if (DefaultFont) { DefaultFont->Handle = (HFONT) GetStockObject(DEFAULT_GUI_FONT); // À©µµ¿ì ±âº» ±Û²ÃÀ» °¡Á®¿È - by monkman (2010.06.04) DefaultFontName = DefaultFont->Name; delete DefaultFont; } DirectoryBin = DefaultDir + "\\Bin"; DirectoryColor = DefaultDir + "\\Color"; DirectoryTexture = DefaultDir + "\\Texture"; DirectoryTextileOpen = DefaultDir; //2001.4.11. by lhskys congi¿¡¼­ Open ³Ö±â DirectoryWeaveOpen = DefaultDir; //2001.4.11. by lhskys congi¿¡¼­ Open ³Ö±â DirectoryKnitOpen = DefaultDir; //2001.4.11. by lhskys congi¿¡¼­ Open ³Ö±â #if defined(TEXTILE) DirectoryStyle = DefaultDir + "\\Style"; DirectoryTreatment = DefaultDir + "\\Treatment"; #elif defined(WEAVE) DirectoryYarn = DefaultDir + "\\Yarn"; DirectorySucker = DefaultDir + "\\Sucker"; #elif defined(PILE) DirectoryYarn = DefaultDir + "\\Yarn"; #elif defined(KNIT) DirectoryStitch = DefaultDir + "\\Stitch"; #endif } #if defined(TEXTILE) DirectoryItem = DirectoryBin + "\\Textile"; #elif defined(WEAVE) DirectoryItem = DirectoryBin + "\\Weave"; #elif defined(KNIT) DirectoryItem = DirectoryBin + "\\Knit"; #elif defined(PILE) DirectoryItem = DirectoryBin + "\\Pile"; #endif } //--------------------------------------------------------------------------- AnsiString __fastcall GetTextileParh() { ///// ÀÌ ºÎºÐÀº ÇÁ·Î±×·¥À» ã´Â ÇÔ¼ö // Textile ÀÌ ÀÖ´Â Áö È®ÀÎÇ϶ó. // Registry¸¦ Àоî¶ó! AnsiString RegFilename = "\\Software\\YoungWoo\\TexPro"; AnsiString Regeditdir; int Items; TRegIniFile *RegIniFile = NULL; AnsiString textileDir, rtDir; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename, true); TStringList* subKeys = new TStringList; RegIniFile->ReadSections(subKeys); subKeys->Sort(); int count = subKeys->Count; bool bProgramFound=false; for(int i=count-1; i>=0; i--) { RegIniFile->OpenKey(RegFilename + "\\" + (*subKeys)[i], true); Regeditdir = RegIniFile->ReadString("Directory", "Bin", "" ); if (!Regeditdir.IsEmpty()) { if ((*subKeys)[i] == "11.0") { textileDir = Regeditdir + "\\Textile.exe"; rtDir = Regeditdir; } else { textileDir = Regeditdir + "\\Textile\\Textile.exe"; rtDir = Regeditdir + "\\Textile"; } if (GetFileAttributes(textileDir.c_str()) != 0xFFFFFFFF ) { bProgramFound = true; break; } } } delete subKeys; if (bProgramFound) return rtDir; else return ""; } //--------------------------------------------------------------------------- AnsiString __fastcall GetIllustParh() { ///// ÀÌ ºÎºÐÀº ÇÁ·Î±×·¥À» ã´Â ÇÔ¼ö // Textile ÀÌ ÀÖ´Â Áö È®ÀÎÇ϶ó. // Registry¸¦ Àоî¶ó! AnsiString RegFilename = "\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths"; AnsiString Regeditdir; int Items; bool bProgramFound = false; TRegIniFile *RegIniFile = NULL; AnsiString IllustDir; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename, true); Regeditdir = RegIniFile->ReadString("Illustrator.exe", "Path", "" ); if (!Regeditdir.IsEmpty()) { IllustDir = Regeditdir + "\\Illustrator.exe"; if (GetFileAttributes(IllustDir.c_str()) != 0xFFFFFFFF ) { bProgramFound = true; } } if (bProgramFound) return IllustDir; } //--------------------------------------------------------------------------- void *memset24(void *s, DWORD c, size_t n) { asm { mov edx,n cmp edx,0 jz label5 mov edi,s test edx,0xfffffffc jz label4 mov eax,c mov [edi+0x02],al mov [edi+0x05],al mov [edi+0x08],al mov [edi+0x0B],al shr eax,0x08 mov [edi+0x01],al mov [edi+0x04],al mov [edi+0x07],al mov [edi+0x0A],al shr eax,0x08 mov [edi],al mov [edi+0x03],al mov [edi+0x06],al mov [edi+0x09],al mov eax,[edi] mov ebx,[edi+0x04] mov ecx,[edi+0x08] shr edx,0x02 label1: mov [edi],eax mov [edi+0x04],ebx mov [edi+0x08],ecx add edi,0x0c dec edx jz label2 mov [edi],eax mov [edi+0x04],ebx mov [edi+0x08],ecx add edi,0x0c dec edx jz label2 mov [edi],eax mov [edi+0x04],ebx mov [edi+0x08],ecx add edi,0x0c dec edx jz label2 mov [edi],eax mov [edi+0x04],ebx mov [edi+0x08],ecx add edi,0x0c dec edx jnz label1 label2: mov edx,n and edx,0x03 jz label5 label4: mov ebx,c mov [edi+2],bl shr ebx,0x08 mov [edi+1],bl shr ebx,0x08 mov [edi],bl add edi,0x03 dec edx jnz label4 label5: mov eax,s } } //--------------------------------------------------------------------------- Graphics::TBitmap* __fastcall GetRegion(int ws, int hs) { #ifndef UNIT #define UNIT 4 #endif int i; POINT Start, End; Graphics::TBitmap *bm; POINT *pt; HDC dc; BYTE *p; long temp; long Garo, Sero; int VertexCount[4]; bm = new Graphics::TBitmap; bm->PixelFormat = pf16bit; bm->Width = ws -2; // ºñÆ®¸ÊÀÇ ³ÐÀÌ ¼³Á¤ bm->Height = hs -2; // ºñÆ®¸ÊÀÇ ³ôÀÌ ¼³Á¤ bm->Canvas->Brush->Color = clWhite; bm->Canvas->FillRect(Rect(0,0,bm->Width,bm->Height)); // Èò»öÀ¸·Î Bitmap À» ä¿ò bm->Canvas->Pen->Color = clBlack; bm->Canvas->Brush->Color = clBlack; End.x = bm->Width - 3; End.y = bm->Height - 3; Start.x = Start.y = 2; Garo = abs(End.x - Start.x -UNIT); // Polygon ÀÇ °¡·Î ±æÀÌ Sero = abs(End.y - Start.y -UNIT); // Polygon ÀÇ ¼¼·Î ±æÀÌ // ¼¼·Î º¯ÀÇ VerTex ¼ö ±¸Çϱâ VertexCount[0] = VertexCount[2] = Sero / UNIT ; // °¡·Î º¯ÀÇ VerTex ¼ö ±¸Çϱâ VertexCount[1] = VertexCount[3] = Garo / UNIT; int Total = VertexCount[0] + VertexCount[1] + VertexCount[2] + VertexCount[3]; pt = new POINT[Total]; bm->Canvas->MoveTo(Start.x + UNIT,Start.y + UNIT); // Polygon ÀÇ ½ÃÀÛÁ¡ int ValueX ,ValueY; // Áº¯ÀÇ ÁÂÇ¥ ±¸Çϱâ ValueY = Start.y; for(i = 0; i < VertexCount[0] ; i++) { if( i %2 == 1){ pt[i].x = Start.x ; } if (i %2 == 0){ pt[i].x = Start.x +UNIT; } pt[i].y = ValueY = ValueY + UNIT; if(pt[i].y > End.y - UNIT){ if(abs(pt[i].y - pt[i-1].y) < 4) pt[i].x = Start.x +UNIT; pt[i].y = End.y - UNIT; } } // ¹Øº¯ÀÇ ÁÂÇ¥ ±¸Çϱâ ValueX = Start.x; int RoopStart; RoopStart = VertexCount[0]; for (i = RoopStart ; i < RoopStart + VertexCount[1];i++) { if(i % 2 == 1) pt[i].y = End.y; if(i % 2 == 0) pt[i].y = End.y - UNIT; pt[i].x = ValueX = ValueX + UNIT; if(pt[i].x > End.x - UNIT){ if(abs(pt[i].x - pt[i-1].x) < 4) pt[i].y = Start.y +UNIT; pt[i].x = End.x - UNIT; } } // ¿ìº¯ÀÇ ÁÂÇ¥ ±¸Çϱâ RoopStart = RoopStart + VertexCount[1]; ValueY = End.y; for(i = RoopStart; i < RoopStart + VertexCount[2]; i++) { if( i %2 == 1){ pt[i].x = End.x ; } if (i %2 == 0){ pt[i].x = End.x -UNIT; } pt[i].y = ValueY = ValueY - UNIT; if(pt[i].y < Start.y + UNIT){ if(abs(pt[i].y - pt[i-1].y) < 4) pt[i].x = End.x -UNIT; pt[i].y = Start.y + UNIT; } } // À­º¯ÀÇ ÁÂÇ¥ ±¸Çϱâ ValueX = End.x; RoopStart = RoopStart + VertexCount[2]; for(i = RoopStart ; i < RoopStart + VertexCount[3];i++) { if(i % 2 == 1) pt[i].y = Start.y; if(i % 2 == 0) pt[i].y = Start.y + UNIT; pt[i].x = ValueX = ValueX - UNIT; if(pt[i].x < Start.x + UNIT){ if(abs(pt[i].x - pt[i-1].x) < 4) pt[i].y = Start.y +UNIT; pt[i].x = Start.x + UNIT; } } bm->Canvas->Polygon((TPoint *)pt, Total -1); // ±¸ÇÑ ÁÂÇ¥·Î Polygon ±×¸®±â delete[] pt; return bm; } /*--------------------------------------------------------------------------- void __fastcall PrintColorChip8(Graphics::TBitmap *Pattern, TRect rect, BYTE pi, Graphics::TBitmap * BitMask) { WORD *p; BYTE *q; int by,py,x; if (BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ for (by = 0, py=rect.Top; by < BitMask->Height; py++,by++) { p = (WORD * ) BitMask->ScanLine[by]; // BitMask ÀÇ À̹ÌÁö Á¤º¸ q = (BYTE *) Pattern->ScanLine[py] + rect.Left; // Pattern ÀÇ À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++,p++,q++){ if(*p == 0 ){ // polygon ÀÇ ³»ºÎÀÎÁö¸¦ üũ *q = pi; // »ö°ªÀ» ¼³Á¤ } } } } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. for( py = rect.Top ; py < rect.Bottom ; py++) { memset((BYTE *)Pattern->ScanLine[py] + rect.Left, pi, rect.Right - rect.Left); } } } */ //--------------------------------------------------------------------------- void __fastcall PrintColorChip8(TTexpiaBitmap *Pattern, TRect rect, BYTE pi, Graphics::TBitmap * BitMask) { WORD *p; BYTE *q; int by,py,x; if (BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ Pattern->StartScanLine(); for (by=0, py=rect.Top; byHeight; py++,by++) { p = (WORD * ) BitMask->ScanLine[by]; // BitMask ÀÇ À̹ÌÁö Á¤º¸ q = Pattern->GetScanLine(py) + rect.Left; // Pattern ÀÇ À̹ÌÁö Á¤º¸ for (x=0; xWidth; x++,p++,q++) { if(*p == 0) { // polygon ÀÇ ³»ºÎÀÎÁö¸¦ üũ *q = pi; // »ö°ªÀ» ¼³Á¤ } } Pattern->PutScanLine(py); } Pattern->StopScanLine(); } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. Pattern->StartScanLine(); for(py=rect.Top; pyGetScanLine(py) + rect.Left; memset(q, pi, rect.Right - rect.Left); Pattern->PutScanLine(py); } Pattern->StopScanLine(); } } /*--------------------------------------------------------------------------- void __fastcall PrintColorChip15(Graphics::TBitmap *Pattern, TRect rect, BYTE red, BYTE green, BYTE blue, Graphics::TBitmap *BitMask) { WORD *p; WORD *q; int by,py,x; WORD color = ((red & 0xF8) << 7) | ((green & 0xF8) << 2) | (blue >> 3); if(BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ for (by = 0, py=rect.Top; by < BitMask->Height; py++,by++) { p = (WORD *)BitMask->ScanLine[by]; // BitMask ÀÇ À̹ÌÁö Á¤º¸ q = (WORD *) Pattern->ScanLine[py] + rect.Left; // Pattern ÀÇ À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++,p++,q++){ if((*p == 0)) { // polygon ÀÇ ³»ºÎÀÎÁö¸¦ üũ *q = color; // »ö°ªÀ» ¼³Á¤ } } } } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. for (int py=rect.Top; pyScanLine[py] + rect.Left; for (int x=rect.Left; x> 3); if(BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ Pattern->StartScanLine(); for (by=0, py=rect.Top; byHeight; py++, by++) { p = (WORD *)BitMask->ScanLine[by]; // BitMask ÀÇ À̹ÌÁö Á¤º¸ q = (WORD *)Pattern->GetScanLine(py) + rect.Left; // Pattern ÀÇ À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++, p++, q++) { if((*p == 0)) { // polygon ÀÇ ³»ºÎÀÎÁö¸¦ üũ *q = color; // »ö°ªÀ» ¼³Á¤ } } Pattern->PutScanLine(py); } Pattern->StopScanLine(); } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. Pattern->StartScanLine(); for (py=rect.Top; pyGetScanLine(py) + rect.Left; for (x=rect.Left; xPutScanLine(py); } Pattern->StopScanLine(); } } /*--------------------------------------------------------------------------- void __fastcall PrintColorChip24(Graphics::TBitmap *Pattern, TRect rect, BYTE red, BYTE green, BYTE blue, Graphics::TBitmap *BitMask ) { WORD *p; BYTE *q; int by,py,x; int i,j; int color = 0x00000000; if( BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ for (by = 0, py=rect.Top; by < BitMask->Height; py++,by++) { p = (WORD *) BitMask->ScanLine[by]; // Mask À̹ÌÁö Á¤º¸ q = (BYTE *) Pattern->ScanLine[py] + 3 * rect.Left; // Ãâ·Â À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++, p++, q+=3) { if((*p == 0)) { // BitMask üũ *q = blue; // Ä®¶ó°ª ¼³Á¤ *(q + 1) = green; *(q + 2) = red; } } } } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. color = (blue << 16) + (green << 8) + red; for (int py=rect.Top; pyScanLine[py] + 3 * rect.Left, color, rect.Right - rect.Left); } } } */ //--------------------------------------------------------------------------- void __fastcall PrintColorChip24(TTexpiaBitmap *Pattern, TRect rect, BYTE red, BYTE green, BYTE blue, Graphics::TBitmap *BitMask ) { WORD *p; BYTE *q; int by,py,x; COLORREF color; // int color = 0x00000000; if( BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ Pattern->StartScanLine(); for (by = 0, py=rect.Top; by < BitMask->Height; py++,by++) { p = (WORD *) BitMask->ScanLine[by]; // Mask À̹ÌÁö Á¤º¸ q = Pattern->GetScanLine(py) + 3*rect.Left; // Ãâ·Â À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++, p++, q+=3) { if((*p == 0)) { // BitMask üũ *q = blue; // Ä®¶ó°ª ¼³Á¤ *(q + 1) = green; *(q + 2) = red; } } Pattern->PutScanLine(py); } Pattern->StopScanLine(); } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. color = (blue << 16) + (green << 8) + red; Pattern->StartScanLine(); for (int py=rect.Top; pyGetScanLine(py) + 3*rect.Left; memset24(q, color, rect.Right - rect.Left); Pattern->PutScanLine(py); } Pattern->StopScanLine(); } } //--------------------------------------------------------------------------- /* bool __fastcall SendToPrinter(Graphics::TBitmap *Pattern, int dpi, AnsiString title, int page, int method) { HDC hPrintDC = NULL, hDC = NULL; // Test Version by kjs TRect Src, Dst; int WidthRes, HeightRes, x, y, cnt; TSize Area, n, s; RGBQUAD rgb[256]; AnsiString str; TTexpiaBitmap Bitmap; hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if (Pattern->PixelFormat == pf8bit) { GetDIBColorTable(Pattern->Canvas->Handle, 0, 256, rgb); } cnt=0; str = "/"+IntToStr(n.cy*n.cx); if (method == 2) { Dst.Left = 0; Dst.Top = 0; for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { cnt++; Printer()->Title = title+IntToStr(cnt)+str; Printer()->Copies = page; Printer()->BeginDoc(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (Pattern->PixelFormat == pf8bit) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; Printer()->Canvas->CopyMode = cmSrcCopy; Printer()->Canvas->CopyRect(Dst, Pattern->Canvas, Src); Printer()->EndDoc(); } } } else { switch (Pattern->PixelFormat) { case pf8bit: if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) return false; break; case pf15bit: if (!Bitmap.Create(Area.cx, Area.cy, 16)) return false; break; case pf24bit: if (!Bitmap.Create(Area.cx, Area.cy, 24)) return false; break; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { cnt++; Printer()->Title = title+IntToStr(cnt)+str; Printer()->Copies = page; Printer()->BeginDoc(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { Bitmap.Resize(s.cx, s.cy, clWhite); } hDC = Bitmap.CreateDC(); BitBlt(hDC, 0, 0, s.cx, s.cy, Pattern->Canvas->Handle, Src.Left, Src.Top, SRCCOPY); Bitmap.DeleteDC(hDC); if (method) { L_PrintBitmapExt(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } else { L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } Printer()->EndDoc(); } } } return true; } */ /* bool __fastcall SendToPrinter(Graphics::TBitmap *Pattern, int dpi, AnsiString title, int page, int method) { HDC hPrintDC = NULL, hDC = NULL; TRect Src, Dst; int WidthRes, HeightRes, x, y; TSize Area, n, s; RGBQUAD rgb[256]; TTexpiaBitmap Bitmap; Printer()->Title = title; Printer()->Copies = page; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if (Pattern->PixelFormat == pf8bit) { GetDIBColorTable(Pattern->Canvas->Handle, 0, 256, rgb); } if (method == 2) { Dst.Left = 0; Dst.Top = 0; for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (Pattern->PixelFormat == pf8bit) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; Printer()->Canvas->CopyMode = cmSrcCopy; Printer()->Canvas->CopyRect(Dst, Pattern->Canvas, Src); } } } else { switch (Pattern->PixelFormat) { case pf8bit: if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) return false; break; case pf15bit: if (!Bitmap.Create(Area.cx, Area.cy, 16)) return false; break; case pf24bit: if (!Bitmap.Create(Area.cx, Area.cy, 24)) return false; break; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { Bitmap.Resize(s.cx, s.cy, clWhite); } hDC = Bitmap.CreateDC(); BitBlt(hDC, 0, 0, s.cx, s.cy, Pattern->Canvas->Handle, Src.Left, Src.Top, SRCCOPY); Bitmap.DeleteDC(hDC); if (method) { L_PrintBitmapExt(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } else { L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } } } } Printer()->EndDoc(); return true; } */ bool __fastcall SendToPrinter(TTexpiaBitmap *Pattern, double dpi, AnsiString title, int page, int method) { HDC hPrintDC, hDC = NULL, phDC = NULL; TRect Src, Dst; int WidthRes, HeightRes, x, y; TSize Area, n, s; RGBQUAD rgb[256]; TTexpiaBitmap Bitmap; Printer()->Title = title; Printer()->Copies = page; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); //ÀåÄ¡°íÀ¯Á¤º¸¸¦ ±¸ÇÔ. LOGPIXELSX=È­¸éÆø¹æÇâÀ¸·Î ·ÎÁöÄà ÀÎÄ¡´ç Çȼ¿ °³¼ö. -k3dogs HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; //HORXRES=½ºÅ©¸°ÀÇ Æø(Çȼ¿ ´ÜÀ§). Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if ((phDC = Pattern->CreateDC()) == NULL) goto fail; if (Pattern->BitsPerPixel == 8) { GetDIBColorTable(phDC, 0, 256, rgb); } if (method == 2) { //Ãʱ⠹öÀü... À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â ¹æ¹ýÀÌ¿ë. Dst.Left = 0; Dst.Top = 0; if (Pattern->BitsPerPixel == 8) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; // if (Pattern->BitsPerPixel == 8) { // SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); // } Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; // Printer()->Canvas->CopyMode = cmSrcCopy; // Printer()->Canvas->CopyRect(Dst, Pattern->Canvas, Src); //which is right? SetStretchBltMode(Printer()->Canvas->Handle, COLORONCOLOR); StretchBlt(Printer()->Canvas->Handle, Dst.Left, Dst.Top, Dst.Right, Dst.Bottom, phDC, Src.Left, Src.Top, Src.Right-Src.Left, Src.Bottom-Src.Top, SRCCOPY); //==========GreenFish Vector ÇÁ¸°Æ® #if defined(TEXTILE) VecDraw->PrintDraw(Printer()->Canvas->Handle, Src.Left, Src.Top, WidthRes, HeightRes, dpi); #endif } } } else { //ÇÁ¸°ÅÍ ±âÁ¾¿¡ µû¶ó¼­ À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â if (Pattern->BitsPerPixel == 8) { //ÇÔ¼ö¸¸À¸·Î ÇÁ¸°Æ®Çϱ⿡´Â ¹®Á¦°¡ ¹ß»ýÇÏ¿© Ãß°¡ if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) goto fail; } else { if (!Bitmap.Create(Area.cx, Area.cy, Pattern->BitsPerPixel)) goto fail; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { if (!Bitmap.Resize(s.cx, s.cy, clWhite)) goto fail; } if ((hDC = Bitmap.CreateDC()) == NULL) goto fail; if (!BitBlt(hDC, 0, 0, s.cx, s.cy, phDC, Src.Left, Src.Top, SRCCOPY)) goto fail; Bitmap.DeleteDC(hDC); hDC = NULL; if (method) { if (!L_PrintBitmap(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false)) goto fail; } else { if (!L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false)) goto fail; } //==========GreenFish Vector ÇÁ¸°Æ® #if defined(TEXTILE) VecDraw->PrintDraw(hPrintDC, Src.Left, Src.Top, WidthRes, HeightRes, dpi); #endif } } } Pattern->DeleteDC(phDC); Printer()->EndDoc(); return true; fail: if (hDC) Bitmap.DeleteDC(hDC); if (phDC) Pattern->DeleteDC(phDC); Printer()->EndDoc(); return false; } /* bool __fastcall SendToPrinter(Graphics::TBitmap *Pattern, int dpi, AnsiString title, int page) { HDC hPrintDC = NULL, hDC = NULL; TRect Src, Dst; int WidthRes, HeightRes, x, y; TSize Area, n, s; RGBQUAD rgb[256]; BITMAPHANDLE Bitmap; Printer()->Title = title; Printer()->Copies = page; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if (Pattern->PixelFormat == pf8bit) { GetDIBColorTable(Pattern->Canvas->Handle, 0, 256, rgb); } switch (Pattern->PixelFormat) { case pf8bit: if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) return false; break; case pf15bit: if (!Bitmap.Create(Area.cx, Area.cy, 16)) return false; break; case pf24bit: if (!Bitmap.Create(Area.cx, Area.cy, 24)) return false; break; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { Bitmap.Resize(s.cx, s.cy, clWhite); } hDC = Bitmap.CreateDC(); BitBlt(hDC, 0, 0, s.cx, s.cy, Pattern->Canvas->Handle, Src.Left, Src.Top, SRCCOPY); Bitmap.DeleteDC(hDC); L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } } Printer()->EndDoc(); return true; } */ //--------------------------------------------------------------------------- void __fastcall LoadFont(TIniFile *IniFile, TFont *Font, AnsiString Section) { Font->Name = IniFile->ReadString(Section, "Name", DefaultFontName); /* Font->Size = IniFile->ReadInteger(Section, "Size", 8); int Style = IniFile->ReadInteger(Section, "Style", 0); if (Style&1) Font->Style << fsBold; else if (Style&2) Font->Style << fsItalic; else if (Style&4) Font->Style << fsUnderline; */ } //--------------------------------------------------------------------- void __fastcall SaveFont(TIniFile *IniFile, TFont *Font, AnsiString Section) { IniFile->WriteString(Section, "Name", Font->Name); /* IniFile->WriteInteger(Section, "Size", Font->Size); int Style = 0; if (Font->Style.Contains(fsBold)) Style |= 1; else if (Font->Style.Contains(fsItalic)) Style |= 2; else if (Font->Style.Contains(fsUnderline)) Style |= 4; IniFile->WriteInteger(Section, "Style", Style); */ } //--------------------------------------------------------------------- void __fastcall SetSmallFont(TFont *Font, int size) { if (SmallFont) Font->Name = SmallFont->Name; Font->Size = size; } //--------------------------------------------------------------------------- AnsiString __fastcall GetColorName(TColorData *cd) { switch (cd->Kind) { case 0: if (cd->Page==0) return Format("%d-%d-%d", OPENARRAY(TVarRec, (255-cd->RGB.rgbRed, 255-cd->RGB.rgbGreen, 255-cd->RGB.rgbBlue))); else return PrinterColor->PN2Code(cd->Page, cd->Number); case 1: ////////////k3dogs 20001211 return Pantone1000->PN2Code(cd->Page, cd->Number); // case 2: // return PantoneTextile->PN2Code(cd->Page, cd->Number); case 3: return StandardColor->PN2Code(cd->Page, cd->Number); case 4: return TextileColor->PN2Code(cd->Page, cd->Number); case 5: //20050518 by lhskys pantone Color return PantoneTextile->PN2Code(cd->Page, cd->Number); case 6: return cd->PantoneColor; //080408 default: return cd->ColorName; } } //--------------------------------------------------------------------------- AnsiString __fastcall GetTexpiaVersion() { AnsiString Version = "None"; TRegIniFile *RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); if (RegIniFile) { Version = RegIniFile->ReadString("Common", "Version", "None"); delete RegIniFile; } return Version; } //--------------------------------------------------------------------------- TGrid __fastcall StrToGrid(AnsiString str) { char *tok = ")x ", *s, *p; TGrid g; s = strdup(str.c_str()); p = strtok(s, tok); if (strcmp(p, "Cm")==0) g.Unit = uCm; else if (strcmp(p, "Inch")==0) g.Unit = uInch; else g.Unit = uDot; p = strtok(NULL, tok); g.X = atof(p); p = strtok(NULL, tok); g.Y = atof(p); free(s); return g; } //--------------------------------------------------------------------------- AnsiString __fastcall GridToStr(TUnit u, double x, double y) { char *unit[3] = { "Dot", "Inch", "Cm" }; return Format("%s) %f x %f", OPENARRAY(TVarRec, (unit[(int)u], x, y))); } //--------------------------------------------------------------------------- AnsiString __fastcall ReadRegistry(AnsiString Name, bool bPath) { TRegistry *Registry = new TRegistry; AnsiString Value; if (Registry) { Registry->RootKey = HKEY_LOCAL_MACHINE; #ifdef NETHASP if(bPath == true) Registry->OpenKey("SOFTWARE\\Youngwoo\\NetTexWork\\" + TexWorkVersion + "\\Directory",TRUE); else Registry->OpenKey("SOFTWARE\\Youngwoo\\NetTexWork\\" + TexWorkVersion + "\\Common",TRUE); #else #ifdef LABEL_EDITABLE_READ_ONLY if(bPath == true) Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork Editor\\" + TexWorkVersion + "\\Directory",TRUE); else Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork Editor\\" + TexWorkVersion + "\\Common",TRUE); #else if(bPath == true) Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork\\" + TexWorkVersion + "\\Directory",TRUE); else Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork\\" + TexWorkVersion + "\\Common",TRUE); #endif #endif Value = Registry->ReadString(Name); delete Registry; return Value; } return NULL; } //--------------------------------------------------------------------------- void __fastcall WriteRegistry(AnsiString Name, AnsiString Value, bool bPath) { TRegistry *Registry = new TRegistry; if (Registry) { Registry->RootKey = HKEY_LOCAL_MACHINE; #ifdef NETHASP if(bPath == true) Registry->OpenKey("SOFTWARE\\Youngwoo\\NetTexWork\\" + TexWorkVersion + "\\Directory",TRUE); else Registry->OpenKey("SOFTWARE\\Youngwoo\\NetTexWork\\" + TexWorkVersion + "\\Common",TRUE); #else #ifdef LABEL_EDITABLE_READ_ONLY if(bPath == true) Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork Editor\\" + TexWorkVersion + "\\Directory",TRUE); else Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork Editor\\" + TexWorkVersion + "\\Common",TRUE); #else if(bPath == true) Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork\\" + TexWorkVersion + "\\Directory",TRUE); else Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork\\" + TexWorkVersion + "\\Common",TRUE); #endif #endif Registry->WriteString(Name, Value); delete Registry; } } //--------------------------------------------------------------------------- bool __fastcall IsFocused(TWinControl *WControl, AnsiString ControlType, AnsiString ControlName) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ÇØ´ç ControlÀÇ ÀÚ½Ä Control Áß¿¡ Focus°¡ ÀÖ´ÂÁö¸¦ Á¶»çÇÑ´Ù - by monkman(2005.03.02) TWinControl *FocusControl = NULL; AnsiString FindControlName = ""; bool Focused = false; if (WControl == NULL) return Focused; if (ControlName.IsEmpty()) { // ControlNameÀÌ ÁÖ¾îÁöÁö ¾Ê¾ÒÀ» °æ¿ì for (int i = 0; i < WControl->ComponentCount; i++) { // ÇØ´ç Control¾È¿¡ ¸ðµç ÀÚ½Ä ControlÀ» ã¾ÆÁ¶»ç // ControlTypeÀÌ ¾ø´Ù¸é ¸ðµÎ Á¶»ç, ÀÖ´Ù¸é ÇØ´çµÇ´Â ControlÀÇ Type¸¸ ã¾Æ Á¶»ç if (!ControlType.IsEmpty() && CompareStr(WControl->Components[i]->ClassName(), ControlType)) continue; FindControlName = WControl->Components[i]->Name; FocusControl = dynamic_cast(WControl->FindComponent(FindControlName)); if (FocusControl) { Focused = FocusControl->Focused(); // ÇØ´ç Control¿¡ Focus°¡ ÀÖ´ÂÁö } if (Focused) break; // Focus°¡ ÀÖ´Ù¸é ¹Ù·Î ReturnÀÌ µÇµµ·Ï ÇÑ´Ù } } else { FocusControl = dynamic_cast(WControl->FindComponent(ControlName)); // Control NameÀÌ ÁÖ¾îÁ³´Ù¸é Á÷Á¢ ¹Ù·Î ã´Â´Ù if (FocusControl) { Focused = FocusControl->Focused(); } } return Focused; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- }