//--------------------------------------------------------------------------- #include "lzw.hpp" #include #pragma hdrstop //#include #include "Define.h" #include "TexWork_F.h" #include "MainImage.h" #include "Main.h" #include "TexWorkPrint_F.h" #include "MainMenu.h" //lhskys shTexWork ºÐºÐÀ» À§Çؼ­ #include "LogData.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPDocument" #pragma resource "*.dfm" TTexWork *TexWork; //--------------------------------------------------------------------------- typedef struct { TPDocSheet *Sheet; } TPOpenSheet; //--------------------------------------------------------------------------- __fastcall TTexWork::TTexWork(TComponent* Owner) : TForm(Owner) { BEGIN_LOG(""); TPOpenSheet *os; String dir, opendir; Timer1->Enabled = false; if(Report->Sheet){ Report->Sheet->DeleteBitmap(); delete Report->Sheet; Report->Sheet=NULL; } TPDocSheet *stp=new TPDocSheet; int cnt, index, tabindex, i; TRegistry *Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename+"\\Directory",TRUE); dir = Registry->ReadString("TexWorkStart"); delete Registry; if (FileExists(dir)) { if (!(stp->LoadFromFile(dir))) goto fail; Report->Sheet=stp; if (!AddSheet(stp)) goto fail; } else { ShowMessage("Cannot find the file"); } StatusBar1->Panels->Items[3]->Text = dir; OnChangeScroll(); Timer1->Enabled = true; END_LOG; return; fail: ShowMessage("Failed to open files"); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::FormCreate(TObject *Sender) { BEGIN_LOG(""); /* 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 CE 3 */ OSVERSIONINFO osinfo; osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osinfo); Timer1->Enabled=true; Panel1->Align=alClient; Height=MainForm->Height - 70; Width=MainForm->Width; Top=0; Left=0; if(Left<0)Left=0; if(Top<0)Top=0; if(Left>MainForm->Width)Left=MainForm->Width; if(Top>MainForm->Height)Top=MainForm->Height; DefaultFont = new TFont; // Vista¿¡´Â "MS Sans Serif"°¡ "Microsoft Sans Serif"·Î ¹Ù²î¾ú´Ù - by monkman (2007.05.10) if ((osinfo.dwMajorVersion == 6) && (osinfo.dwMinorVersion >= 0)) { DefaultFont->Name = "Microsoft Sans Serif"; // Vista } else { DefaultFont->Name = "MS Sans Serif"; // Etc (!Vista) } DefaultFont->Size = 13; DefaultFont->Charset = DEFAULT_CHARSET; DefaultFont->Color = clBlack; SaveDialog->FileName = "Noname.fst"; OldName = "Noname.fst"; #ifdef TRIAL ImageDialog->Filter = L"Texpro Textile 256 Colors Trial File (*.ttex) | *.ttex|" L"Texpro Textile FullColors Trial File (*.ttfc) | *.ttfc|" L"Texpro Textile 3D Trial File (*.tt3d) | *.tt3d|" L"Texpro Weave Trial File (*.twea) | *.twea|" L"Texpro Knit Trial File (*.tknt) | *.tknt|" L"Texpro Textile 256 Colors File (*.tex) | *.tex|" L"Texpro Textile FullColors File (*.tfc) | *.tfc|" L"Texpro Textile 3D File (*.t3d) | *.t3d|" L"Texpro Weave File (*.wea, *wav) | *.wea; *.wav|" L"Texpro Knit File (*.knt) | *.knt|" L"BMP Image File (*.bmp) | *.bmp|" L"JPEG Image File (*.jpg) | *.jpg"; #else ImageDialog->Filter = L"Texpro Textile 256 Colors File (*.tex) | *.tex|" L"Texpro Textile FullColors File (*.tfc) | *.tfc|" L"Texpro Textile 3D File (*.t3d) | *.t3d|" L"Texpro Weave File (*.wea, *wav) | *.wea; *.wav|" L"Texpro Knit File (*.knt) | *.knt|" L"BMP Image File (*.bmp) | *.bmp|" L"JPEG Image File (*.jpg) | *.jpg"; #endif END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::FormResize(TObject *Sender) { BEGIN_LOG(""); if (WindowState == wsMinimized) { MoveWindow(Handle,Left,Parent->Top+Parent->Height,Width,Height,false); UpdataMenu(); } Report->Left=0; Report->Top=0; Report->Height=Panel1->Height-ScrollBarH->Height; Report->Width=Panel1->Width-ScrollBarV->Width; ScrollBarH->Left=0; ScrollBarH->Top=Report->Height; ScrollBarH->Width=Report->Width; ScrollBarV->Top=0; ScrollBarV->Left=Report->Width; ScrollBarV->Height=Report->Height; Memo->Left=0; Memo->Width=Panel3->Width-sbOK->Width-sbCancel->Width; sbOK->Left=Memo->Width; sbCancel->Left=sbOK->Left+sbOK->Width; OnChangeScroll(); END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TTexWork::AddSheet(TPDocSheet *stp) { BEGIN_LOG(""); int i; TPOpenSheet *os; if (!(stp->MakeBitmap(Report->ZoomIn, Report->ZoomOut))) goto fail; Report->Repaint(); END_LOG; return true; fail: if (os) delete os; END_LOG; return false; } //--------------------------------------------------------------------------- void __fastcall TTexWork::ScrollBarHChange(TObject *Sender) { Report->PosX = ScrollBarH->Position; } //--------------------------------------------------------------------------- void __fastcall TTexWork::ScrollBarVChange(TObject *Sender) { Report->PosY = ScrollBarV->Position; } //--------------------------------------------------------------------------- void __fastcall TTexWork::OnChangeScroll(void) { BEGIN_LOG(""); int w,h; if (Report->Sheet) { w = Report->Sheet->Range.right * Report->ZoomIn / Report->ZoomOut - Report->Width; h = Report->Sheet->Range.bottom * Report->ZoomIn / Report->ZoomOut - Report->Height; } else { w = 0; h = 0; } if(w <= 0) { ScrollBarH->Max = 0; ScrollBarH->Enabled = false; }else { ScrollBarH->Max = w + 8; ScrollBarH->Enabled = true; } if(h <= 0){ ScrollBarV->Max = 0; ScrollBarV->Enabled = false; } else { ScrollBarV->Max = h + 8; ScrollBarV->Enabled = true; } ScrollBarH->Position = 0; ScrollBarV->Position = 0; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::ReportMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); TPDocElement *sep; TPDocElementType et; TPDocInput *ip; TPDocSheet *st = Report->Sheet; AnsiString str; RECT rt; int index; bool binput = false; if (Report->Sheet) { if (EType == E_ARROW) { if(CountArrow() >= 3) { //Arrow Á¦ÇÑ tbArrow->Down = false; EType = E_NONE; END_LOG; return; } if (step) { if (AType != dat3Point) { switch (AType) { case datSingle: case datBoth_Normal: pt[1] = Point(X, Y); break; case datBoth_Hor_Over: case datBoth_Hor_Below: pt[1] = Point(X, pt[0].y); break; case datBoth_Ver_Left: case datBoth_Ver_Right: pt[1] = Point(pt[0].x, Y); break; } str = Memo->Text; rt = FindRect(false); st->AddArrow(rt, AType, pt[0], pt[1], Point(0, 0), daCenter2, str, Shape->Brush->Color); ((TPDocText *)st->Element->Items[Report->Sheet->Element->Count-1])->SetFont(DefaultFont, DefaultFont->Color); tp = pt[1]; // need here?? //==================================== Replace with UpdataMenu?? // EType = E_NONE; k3dogs step = 0; Memo->Enabled = false; Memo->Visible = false; //==================================== // if (!(os->Sheet->MakeBitmap(Report->ZoomIn, Report->ZoomOut))) goto fail; Report->Repaint(); } else { if (step == 2) { pt[2] = Point(X, pt[1].y); str = Memo->Text; rt = FindRect(true); st->AddArrow(rt, AType, pt[0], pt[1], pt[2], daCenter2, str, Shape->Brush->Color); ((TPDocText *)st->Element->Items[Report->Sheet->Element->Count-1])->SetFont(DefaultFont, DefaultFont->Color); tp = pt[2]; // need here?? // EType = E_NONE; k3dogs step = 0; Memo->Enabled = false; Memo->Visible = false; // if (!(os->Sheet->MakeBitmap(Report->ZoomIn, Report->ZoomOut))) goto fail; Report->Repaint(); } else { pt[1] = Point(X, Y); tp = pt[1]; // need here?? step = 2; } } } else { pt[0] = Point(X, Y); tp = pt[0]; step = 1; } } else if (EType == E_SHEAFIMAGE) { if (step == 1) { ep = Point(X, Y); pt[1] = ep; rt = FindRect(false); st->AddSheafImage(rt); Report->Repaint(); step = 0; EType = E_NONE; } else if (step == 0) { sp = Point(X, Y); pt[0] = sp; tp = sp; step = 1; } } else if (EType == E_SHEAFLABEL) { // ¶óº§ÀԷ¹öư(tbLabel)À» Ŭ¸¯ÇسõÀº°æ¿ì if (step == 1) { ep = Point(X, Y); pt[1] = ep; rt = FindRect(false); st->AddSheafLabel(rt, daLeftTop, Memo->Text); ((TPDocText *)st->Element->Items[Report->Sheet->Element->Count-1])->SetFont(DefaultFont, DefaultFont->Color); Report->Repaint(); //================================= replace with updatamenu step = 0; EType = E_NONE; Memo->Text = ""; Memo->Enabled = false; Memo->Visible = false; //================================= } else if (step == 0) { sp = Point(X, Y); pt[0] = sp; tp = sp; step = 1; } } else if (EType == E_SHEAFLINE) { if (step == 1) { ep = Point(X, Y); pt[1] = ep; rt = FindRect(false); st->AddSheafLine(rt, LType, pt[0], pt[1], Shape->Brush->Color); Report->Repaint(); step = 0; // EType = E_NONE; k3dogs } else if (step == 0) { sp = Point(X, Y); pt[0] = sp; tp = sp; step = 1; } } else if (EType == E_NONE) { sp = Point(X, Y); UpdataMenu(); if (Report->Select(sp)) { sep = Report->GetSelectElement(); if (sep->Type == detInput) { binput = true; sep = Report->GetSelectElement(true); } else if (sep->Type == detChart) { sep = Report->GetSelectElement(true); } et = sep->Type; if (et == detSignature) { if (Button == mbLeft) { if (((TPDocSignature *)sep)->Image == NULL) { if(!(((TPDocSignature *)sep)->MakeBitmap())) goto fail; } EType = E_SIGNATURE; } else if (Button == mbRight) { if (((TPDocSignature *)sep)->Image != NULL) { // DataClear1->Enabled = true; } } } else if (et == detArrow) { sbOK->Enabled = true; sbCancel->Enabled = true; Memo->Enabled = true; Memo->Visible = true; // bstr = ((TPDocArrow *)sep)->Text; // bstr = ((TPDocArrow *)sep)->GetText(); ((TPDocArrow *)sep)->GetText(bstr, ebstr, ibstr, cbstr, jbstr); Memo->Font->Assign(sep->GetFont()); Memo->Text = bstr; Memo->SetFocus(); bcursor = true; Shape->Brush->Color = ((TPDocArrow *)sep)->Color; // DataClear1->Enabled = true; // SewingTerm1->Enabled = true; } else if (et == detImage) { if (((TPDocImage *)sep)->Image) { // Image->Enabled = true; // DataClear1->Enabled = true; // DataView1->Enabled = true; // DataEdit1->Enabled = true; } } else if (et == detSheafImage) { // DataClear1->Enabled = true; if (((TPDocSheafImage *)sep)->Image) { // Image->Enabled = true; // DataView1->Enabled = true; // DataEdit1->Enabled = true; } // Shape->Brush->Color = ((TPDocSheafImage *)sep)->Color; } else if (et == detSheafLabel) { Memo->Enabled = true; Memo->Visible = true; // bstr = ((TPDocSheafLabel *)sep)->Text; // bstr = ((TPDocSheafLabel *)sep)->GetText(); ((TPDocSheafLabel *)sep)->GetText(bstr, ebstr, ibstr, cbstr, jbstr); Memo->Font->Assign(sep->GetFont()); Memo->Text = bstr; Memo->SetFocus(); bcursor = true; sbOK->Enabled = true; sbCancel->Enabled = true; // DataClear1->Enabled = true; // SewingTerm1->Enabled = true; //==============================================DBClick-->MouseDown } else if (et == detEdit) { if (binput) { ip = (TPDocInput *)Report->GetSelectElement(); if (ip->Method == dimFix) { END_LOG; return; } } Memo->Enabled = true; Memo->Visible = true; // bstr = ((TPDocEdit *)sep)->Text; // bstr = ((TPDocEdit *)sep)->GetText(); ((TPDocEdit *)sep)->GetText(bstr, ebstr, ibstr, cbstr, jbstr); Memo->Font->Assign(sep->GetFont()); Memo->Text = bstr; Memo->SetFocus(); bcursor = true; sbOK->Enabled = true; sbCancel->Enabled = true; // SewingTerm1->Enabled = true; } else if (et == detColorChip) { /* if (ColorDialog1->Execute()) { ((TPDocColorChip *)sep)->Color = ColorDialog1->Color; Report->Repaint(); }*/ } else if (et == detNumber) { Memo->Enabled = true; Memo->Visible = true; bstr = ((TPDocNumber *)sep)->Number; Memo->Font->Assign(sep->GetFont()); Memo->Text = bstr; Memo->SetFocus(); bcursor = true; sbOK->Enabled = true; sbCancel->Enabled = true; } else if (et == detFormula) { Memo->Enabled = true; Memo->Visible = true; bstr = ((TPDocFormula *)sep)->ANumber; Memo->Font->Assign(sep->GetFont()); Memo->Text = bstr; Memo->SetFocus(); bcursor = true; sbOK->Enabled = true; sbCancel->Enabled = true; } else if (et == detMemo) { Memo->Enabled = true; Memo->Visible = true; bstr = ((TPDocMemo *)sep)->Text; // Memo->Font->Assign(sep->GetFont()); Memo->Font->Assign(((TPDocMemo *)sep)->GetFont()); Memo->Text = bstr; Memo->SetFocus(); bcursor = true; sbOK->Enabled = true; sbCancel->Enabled = true; } else if (et == detDate) { Memo->Enabled = true; Memo->Visible = true; bstr = ((TPDocDate *)sep)->Date; Memo->Font->Assign(sep->GetFont()); Memo->Text = bstr; Memo->SetFocus(); bcursor = true; sbOK->Enabled = true; sbCancel->Enabled = true; } else if (et == detSheafLine) { // DataClear1->Enabled = true; Shape->Brush->Color = ((TPDocSheafLine *)sep)->Color; } } } } Modify = true; //lhskys Modify üũ END_LOG; return; fail: ShowMessage("Failed to make a bitmap"); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::ArrowMenuClick(TObject *Sender) { BEGIN_LOG(""); if (CountArrow() >= 3) { END_LOG; return; } TMenuItem *Item = (TMenuItem *)Sender; UpdataMenu(); switch (Item->Tag) { case 0: AType = datSingle; break; case 1: AType = datBoth_Normal; break; case 2: AType = datBoth_Hor_Over; break; case 3: AType = datBoth_Hor_Below; break; case 4: AType = datBoth_Ver_Left; break; case 5: AType = datBoth_Ver_Right; break; case 6: AType = dat3Point; break; } tbArrow->Down = true; EType = E_ARROW; if (DefaultFont) Memo->Font->Assign(DefaultFont); Memo->Enabled = true; Memo->Visible = true; Memo->Text = ""; END_LOG; } //--------------------------------------------------------------------------- int __fastcall TTexWork::CountArrow() { BEGIN_LOG(""); TPDocElement *dp; int ArrowCnt = 0; if (Report->Sheet) { //Arrow Á¦ÇÑ for (int i = 0; i < Report->Sheet->Element->Count; i++) { dp = (TPDocElement *)Report->Sheet->Element->Items[i]; if (dp->Type == detArrow) ArrowCnt++; } } END_LOG; return ArrowCnt; } //--------------------------------------------------------------------------- RECT __fastcall TTexWork::FindRect(bool bthreepoint) { BEGIN_LOG(""); long tx, ty; RECT rt; if (bthreepoint) { tx = min(pt[0].x, pt[1].x); tx = min(pt[2].x, tx); ty = min(pt[0].y, pt[1].y); ty = min(pt[2].y, ty); rt.left = tx; rt.top = ty; tx = max(pt[0].x, pt[1].x); tx = max(pt[2].x, tx); ty = max(pt[0].y, pt[1].y); ty = max(pt[2].y, ty); rt.right = tx; rt.bottom = ty; } else { if (pt[0].x < pt[1].x) { rt.left = pt[0].x; rt.right = pt[1].x; } else { rt.left = pt[1].x; rt.right = pt[0].x; } if (pt[0].y < pt[1].y) { rt.top = pt[0].y; rt.bottom = pt[1].y; } else { rt.top = pt[1].y; rt.bottom = pt[0].y; } rt = Rect(rt.left -5, rt.top -5, rt.right +5, rt.bottom + 5); //qe } END_LOG; return rt; } //--------------------------------------------------------------------------- void __fastcall TTexWork::DrawLine() { BEGIN_LOG(""); HDC hDC = Report->GetHandle(); HPEN hPen = NULL, hOldPen = NULL; int nOldROP = 0; POINT sp; RECT rt; try { if (step == 2) { sp = pt[1]; } else if (step == 1) { sp = pt[0]; } hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); nOldROP = SetROP2(hDC, R2_NOT); rt = Rect(sp.x, sp.y, tp.x, tp.y); rt = Report->ChangeRect(rt); MoveToEx(hDC, rt.left, rt.top, NULL); LineTo(hDC, rt.right, rt.bottom); SetROP2(hDC, R2_NOT); rt = Rect(sp.x, sp.y, ep.x, ep.y); rt = Report->ChangeRect(rt); MoveToEx(hDC, rt.left, rt.top, NULL); LineTo(hDC, rt.right, rt.bottom); } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::DrawRect() { BEGIN_LOG(""); HDC hDC = Report->GetHandle(); HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int nOldROP = 0; RECT rt; try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); nOldROP = SetROP2(hDC, R2_NOT); rt = Rect(sp.x, sp.y, tp.x, tp.y); rt = Report->ChangeRect(rt); Rectangle(hDC, rt.left, rt.top, rt.right, rt.bottom); SetROP2(hDC, R2_NOT); rt = Rect(sp.x, sp.y, ep.x, ep.y); rt = Report->ChangeRect(rt); Rectangle(hDC, rt.left, rt.top, rt.right, rt.bottom); } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::UpdataMenu(void) { BEGIN_LOG(""); step = 0; bstr = ""; EType = E_NONE; bcursor = false; Report->ResetSelectElement(); Memo->Text = ""; Memo->Enabled = false; Memo->Visible = false; sbOK->Enabled = false; sbCancel->Enabled = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::MemoChange(TObject *Sender) { BEGIN_LOG(""); TPDocElement *sep; if(!Memo->Modified) { END_LOG; return; } sep = Report->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { sep = Report->GetSelectElement(true); } if (sep->Type == detEdit) { ((TPDocEdit *)sep)->SetK_Text(Memo->Text); } else if (sep->Type == detArrow) { ((TPDocArrow *)sep)->SetK_Text(Memo->Text); } else if (sep->Type == detMemo) { ((TPDocMemo *)sep)->Text = Memo->Text; } else if (sep->Type == detSheafLabel) { ((TPDocSheafLabel *)sep)->SetK_Text(Memo->Text); } else if (sep->Type == detDate) { ((TPDocDate *)sep)->Date = Memo->Text; } else if (sep->Type == detNumber) { ((TPDocNumber *)sep)->SetNumber(Memo->Lines->Strings[0]); } else if (sep->Type == detFormula) { ((TPDocFormula *)sep)->SetNumber(Memo->Lines->Strings[0]); #ifdef KIDO } else if (sep->Type == detTextImage) { #else } else { #endif END_LOG; return; } Report->Repaint(); //======================================= // Report->SelectElement->PaintReport(Report->SelectElement, Report->GetHandle(), // Report->GetViewStatus(), false, true, 0); //======================================== } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::MemoKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { BEGIN_LOG(""); TPDocElement *sep; POINT mp; bool notarrow; RECT rt; int th; sep = Report->GetSelectElement(); Modify = true; //lhskys Modify üũ if (Key == VK_RETURN) { if (sep) { if (sep->Type == detInput || sep->Type == detChart) { sep = Report->GetSelectElement(true); } if (sep->Type == detEdit || sep->Type == detDate || sep->Type == detNumber || sep->Type == detFormula) { UpdataMenu(); } } Report->Repaint(); } else if (Key == VK_F1) { FindNextItem(); } cp = Memo->CaretPos; notarrow = GetTextStartPoint(); if (notarrow) { if(sep->Type == detMemo){ rt = sep->Range; rt = Report->ChangeRect(rt); th = rt.bottom - rt.top + H/3; while (th < (cp.y+1)*H) { cp.y--; } } mp = Report->ChangePoint(Point(tsp.x+W+4, tsp.y+(cp.y)*H)); if(Key == VK_RETURN) mp = Report->ChangePoint(Point(tsp.x+4, tsp.y +(cp.y+1)*H)); mp.y += 24; } else { mp = Report->ChangePoint(Point(tsp.x+4, tsp.y+H)); mp.y += 24; } if (mp.x > Report->Width - 10) { if(notarrow && (Key != VK_RETURN)) {Report->PosX = tsp.x +W - 300;} else {Report->PosX = tsp.x -200;} if (Report->PosX >= Report->Sheet->Bitmap->Width - Report->Width) Report->PosX = Report->Sheet->Bitmap->Width - Report->Width; ScrollBarH->Position = Report->PosX; } else if(mp.x < 20) { if(notarrow && (Key != VK_RETURN)) {Report->PosX = tsp.x + W - 200;} else {Report->PosX = tsp.x - 200;} ScrollBarH->Position = Report->PosX; } if (mp.y > Report->Height) { if(notarrow) {Report->PosY = tsp.y +(cp.y +1)*H -200;} else {Report->PosY = tsp.y +H -200;} if (Report->PosY >= Report->Sheet->Bitmap->Height - Report->Height) Report->PosY = Report->Sheet->Bitmap->Height- Report->Height; ScrollBarV->Position = Report->PosY; } else if(mp.y <20) { if(notarrow) {Report->PosY = tsp.y +(cp.y)*H - 200;} else {Report->PosY = tsp.y + H -200;} ScrollBarV->Position = Report->PosY; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::sbOKClick(TObject *Sender) { BEGIN_LOG(""); UpdataMenu(); Report->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::sbCancelClick(TObject *Sender) { BEGIN_LOG(""); TPDocElement *sep; sep = Report->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { sep = Report->GetSelectElement(true); } if (sep->Type == detEdit) { ((TPDocEdit *)sep)->SetText(bstr, ebstr, ibstr, cbstr, jbstr); } else if (sep->Type == detMemo) { ((TPDocMemo *)sep)->Text = bstr; } else if (sep->Type == detArrow) { ((TPDocArrow *)sep)->SetText(bstr, ebstr, ibstr, cbstr, jbstr); } else if (sep->Type == detSheafLabel) { ((TPDocSheafLabel *)sep)->SetText(bstr, ebstr, ibstr, cbstr, jbstr); } else if (sep->Type == detDate) { ((TPDocDate *)sep)->Date = bstr; } else if (sep->Type == detNumber) { ((TPDocNumber *)sep)->Number = bstr; } else if (sep->Type == detFormula) { ((TPDocFormula *)sep)->ANumber = bstr; } } UpdataMenu(); Report->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::ShapeMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); TPDocElement *sep = NULL; if (ColorDialog1->Execute()) { Shape->Brush->Color = ColorDialog1->Color; if (Report->Sheet) { sep = Report->GetSelectElement(); if (sep) { if (sep->Type == detArrow) { ((TPDocArrow *)sep)->Color = Shape->Brush->Color; } else if (sep->Type == detSheafLine) { ((TPDocSheafLine *)sep)->Color = Shape->Brush->Color; } } } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::Timer1Timer(TObject *Sender) { BEGIN_LOG(""); if (bcursor) { //modified by k3dogs(20001026) TPDocEdit¿¡ ÀÔ·ÂÇÒ °æ¿ì //bcursorÀÌ ÂüÀÌ µÇ°í, truefalse °ªÀ» ¹ÝÀü½ÃÄѼ­ Ä¿¼­¸¦ ±ôºýÀÌ°Ô Çß´Ù. static bool truefalse=false; truefalse = !truefalse; HBRUSH hOldBrush; HPEN hOldPen, hPen; int nDrawMode; int th; POINT tp, mp; RECT rt; bool notarrow; Report->Refresh(); if (truefalse) { HDC hDC = Report->GetHandle(); hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); hOldPen = (HPEN)SelectObject(hDC, GetStockObject(WHITE_PEN)); nDrawMode = GetROP2(hDC); SetROP2(hDC, R2_NOT); cp = Memo->CaretPos; GetTextHeight(); // Çѹø¸¸ ±¸ÇÏ¸é µÈ´Ù. ±×·±µ¥..... rt = GetTextLength(); // GetTextHeight¿¡ ³ÖÀ¸¸é ÀÌ»óÇÑ °á°ú°¡ ³ªÅ¸³²... notarrow = GetTextStartPoint(); // edit, sheafedit¿¡¼­ center Á¤·ÄÀ̳ª right Á¤·ÄÀÇ °æ¿ì..¹®Á¦°¡ µÊ... if (notarrow) { rt = Report->ChangeRect(rt); //???? th = rt.bottom - rt.top + H/3; // H/3 --->¿©À¯ºÐÀ» À§Çؼ­... while (th < (cp.y+1)*H) { cp.y--; } mp = Report->ChangePoint(Point(tsp.x+W/*+4*/, tsp.y+(cp.y)*H)); tp = Report->ChangePoint(Point(tsp.x+W/*+4*/, tsp.y+(cp.y+1)*H)); // mp.y += 24; // 24->tab control¿¡¼­ tabÀÇ ³ôÀÌ // tp.y += 24; } else { mp = Report->ChangePoint(Point(tsp.x/*+4*/, tsp.y)); tp = Report->ChangePoint(Point(tsp.x/*+4*/, tsp.y+H)); // mp.y += 24; // tp.y += 24; } // if (mp.x < 4) return; // Report->Left // if (mp.y < 24) mp.y = 24; // Report->Top // if (tp.y < 24) return; Rectangle(hDC, mp.x, mp.y, tp.x+2, tp.y); //MoveToEx->LineTo SetROP2(hDC, nDrawMode); SelectObject(hDC, hOldPen); SelectObject(hDC, hOldBrush); } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::GetTextHeight() { BEGIN_LOG(""); HDC hDC; HFONT hOldFont; TPDocElement *sep; TFont *SFont; TEXTMETRIC tm; AnsiString str, text; RECT rt; SIZE size; sep = Report->GetSelectElement(); if (sep&&sep->Type) { if (sep->Type == detInput ||sep->Type == detChart) sep = Report->GetSelectElement(true); } hDC = Report->GetHandle(); SFont = sep->GetFont(); hOldFont = (HFONT)SelectObject(hDC, SFont->Handle); GetTextMetrics(hDC, &tm); H = tm.tmHeight; SelectObject(hDC, hOldFont); /* GetTextMetrics(Memo->Handle, &tm); H = tm.tmHeight; */ END_LOG; } //--------------------------------------------------------------------------- RECT __fastcall TTexWork::GetTextLength() { BEGIN_LOG(""); int i; SIZE size; HDC hDC = NULL; AnsiString str, text; RECT rt, pt; TFont *SF; TPDocElement *sep; HFONT hOldFont; sep = Report->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { pt = sep->Range; sep = Report->GetSelectElement(true); rt = sep->Range; rt = Rect(pt.left+rt.left, pt.top+rt.top, pt.left+rt.right, pt.top+rt.bottom); } else { rt = sep->Range; } } SF = sep->GetFont(); hDC = Report->GetHandle(); text = Memo->Lines->Strings[cp.y]; hOldFont = (HFONT)SelectObject(hDC, SF->Handle); GetTextExtentPoint32A(hDC, text.c_str(), text.Length(), &size); LW = size.cx; if (cp.x > 0) { str = text.SubString(1, cp.x); GetTextExtentPoint32A(hDC, str.c_str(), str.Length(), &size); W = size.cx; if (sep->Type != detArrow) { if (W > (rt.right - rt.left)) W = rt.right - rt.left - 4; // 4-->¿©À¯ºÐ.. } } else { W = 0; } SelectObject(hDC, hOldFont); END_LOG; return rt; } //--------------------------------------------------------------------------- bool __fastcall TTexWork::GetTextStartPoint() { BEGIN_LOG(""); TPDocElement *sep; TPDocArrow *saw; RECT rt, pt; TPDocAlign al; AnsiString text; int mm = 0, mcnt; bool notarrow = true; sep = Report->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { pt = sep->Range; sep = Report->GetSelectElement(true); rt = sep->Range; rt = Rect(pt.left+rt.left, pt.top+rt.top, pt.left+rt.right, pt.top+rt.bottom); } else { rt = sep->Range; } al = ((TPDocText *)sep)->Align; if (sep->Type == detEdit || sep->Type == detDate || sep->Type == detNumber || sep->Type == detFormula) { switch (al) { case daLeftCenter: tsp = Point(rt.left+2, (rt.top+rt.bottom-H)/2); break; case daCenter2: tsp = Point((rt.left+rt.right-LW)/2, (rt.top+rt.bottom-H)/2); break; case daRightCenter: tsp = Point(rt.right-2-LW, (rt.top+rt.bottom-H)/2); break; default: tsp = Point((rt.left+rt.right-LW)/2, (rt.top+rt.bottom-H)/2); break; } } else if (sep->Type == detMemo) { if (((TPDocMemo *)sep)->Title.Length() > 0) { mm = ((TPDocMemo *)sep)->TitleHeight; } tsp = Point(rt.left+2, rt.top+mm+2); } else if (sep->Type == detArrow) { //È­»ìÇ¥ÀÇ °æ¿ì¸¸ °è»êÀÌ º¹ÀâÇϰí, saw = (TPDocArrow *)sep; //´Ù¸¥ ¾ÆÀÌÅÛ°ú »óÀÌÇÏ¿© Ä¿¼­ÀÇ Á¤È®ÇÑ // mcnt = saw->FindLineCount(saw->GetText()); //À§Ä¡ °è»êÀ» ¿©±â¼­ ÇÔ... saw->GetK_Text(text); mcnt = saw->FindLineCount(text); //À§Ä¡ °è»êÀ» ¿©±â¼­ ÇÔ... notarrow = false; if (saw->AType == datSingle) { if (saw->asp.x == saw->aep.x) { if (saw->asp.y < saw->aep.y) { tsp = Point(saw->aep.x-LW/2+W, saw->aep.y+2+cp.y*H); } else { tsp = Point(saw->aep.x-LW/2+W, saw->aep.y-(mcnt-cp.y)*H); } } else { if (saw->asp.x < saw->aep.x) { tsp = Point(saw->aep.x+2+W, saw->aep.y-H/2 - (mcnt/2-cp.y)*H); // base point } else { tsp = Point(saw->aep.x-2-LW+W, saw->aep.y-H/2 - (mcnt/2-cp.y)*H); } } } else if (saw->AType == datBoth_Normal) { tsp = Point((saw->asp.x+saw->aep.x)/2, (saw->asp.y+saw->aep.y)/2); // base point tsp = Point(tsp.x-LW/2+W, tsp.y - (mcnt/2-cp.y)*H); } else if (saw->AType == datBoth_Hor_Over) { tsp = Point((saw->asp.x+saw->aep.x)/2, saw->asp.y); // base point tsp = Point(tsp.x-LW/2+W, tsp.y - (mcnt-cp.y)*H); } else if (saw->AType == datBoth_Hor_Below) { tsp = Point((saw->asp.x+saw->aep.x)/2, saw->asp.y); // base point tsp = Point(tsp.x-LW/2+W, tsp.y + cp.y*H + 2); } else if (saw->AType == datBoth_Ver_Left) { tsp = Point(saw->asp.x, (saw->asp.y+saw->aep.y - H)/2); // base point tsp = Point(tsp.x-2-LW+W, tsp.y - (mcnt/2 - cp.y)*H); } else if (saw->AType == datBoth_Ver_Right) { tsp = Point(saw->asp.x, (saw->asp.y+saw->aep.y - H)/2); // base point tsp = Point(tsp.x+2+W, tsp.y - (mcnt/2 - cp.y)*H); } else if (saw->AType == dat3Point) { if (saw->aep.x < saw->atp.x) { tsp = Point(saw->aep.x+W, saw->aep.y-(mcnt-cp.y)*H); //base point } else { tsp = Point(saw->aep.x-LW+W, saw->aep.y-(mcnt-cp.y)*H); //base point } } } else if (sep->Type == detSheafLabel) { // tsp = Point((rt.left+rt.right-LW)/2, (rt.top+rt.bottom-H)/2); tsp = Point(rt.left+2, rt.top+2); } } END_LOG; return notarrow; } //--------------------------------------------------------------------------- void __fastcall TTexWork::ReportDblClick(TObject *Sender) { BEGIN_LOG(""); TPDocElement *sep; TPDocElementType et; TPDocInput *ip; bool binput = false, bchart = false; RGBQUAD rgb[256]; RECT rt; int w, h; TPException ec = EC_NONE; bcursor = false; // cursor is not to be expressed.... Memo->Enabled = false; Memo->Visible = false; sbOK->Enabled = false; sbCancel->Enabled = false; if (Report->Sheet) { if (Report->Select(sp)) { sep = Report->GetSelectElement(); if (sep) { if (sep->Type == detInput) { binput = true; sep = Report->GetSelectElement(true); } else if (sep->Type == detChart) { sep = Report->GetSelectElement(true); } et = sep->Type; if (et == detImage) { if (ImageDialog->Execute()) { if (((TPDocImage *)sep)->Image != NULL) { delete ((TPDocImage *)sep)->Image; ((TPDocImage *)sep)->Image = NULL; } if ((((TPDocImage *)sep)->Image = new TTexpiaBitmap) == NULL) goto fail; if (!LoadImage(ImageDialog->FileName)) goto fail; ((TPDocImage *)sep)->ImgDir = ImageDialog->FileName; if (binput) { ip = (TPDocInput *)Report->GetSelectElement(); if (ip->Method == dimAuto) { //ReadSubText(ip, ImageDialog->FileName); // textile¿¡¼­´Â º°·Î ¾µ¸ð¾øÀ»µí.. } } Report->Repaint(); Modify = true; //lhskys Modify üũ } } else if (et == detSheafImage) { if (ImageDialog->Execute()) { // µð¹ö°Å ¸ðµå¿¡¼­´Â ¿¹¿Ü°¡ ¹ß»ýÇÑ´Ù(an EInvalidGraphic exception) if (((TPDocSheafImage *)sep)->Image != NULL) { delete ((TPDocSheafImage *)sep)->Image; ((TPDocSheafImage *)sep)->Image = NULL; } if ((((TPDocSheafImage *)sep)->Image = new TTexpiaBitmap) == NULL) goto fail; if (!LoadImage(ImageDialog->FileName)) goto fail; ((TPDocSheafImage *)sep)->ImgDir = ImageDialog->FileName; Report->Repaint(); Modify = true; //lhskys Modify üũ } #ifdef KIDO } else if (et == detTextImage) { OpenDialog1->Filter = "Data Text File (*.kdo)|*.kdo"; OpenDialog1->FileName = ""; if (OpenDialog1->Execute()) { if (FileExists(OpenDialog1->FileName)) { if (((TPDocTextImage *)sep)->Image != NULL) { delete ((TPDocTextImage *)sep)->Image; ((TPDocTextImage *)sep)->Image = NULL; } if ((((TPDocTextImage *)sep)->Image = new TTexpiaBitmap) == NULL) goto fail; if (ReadDataText(OpenDialog1->FileName)) { DrawDataText(sep->Range, ((TPDocTextImage *)sep)->Image); } else { delete ((TPDocTextImage *)sep)->Image; } Report->Repaint(); Modify = true; //lhskys Modify üũ } else { ShowMessage("Cannot find the file"); } } #endif } //if (ViewForm->Visible) ViewForm->ShowBitmap(); } } } END_LOG; return; fail: ShowMessage("Cannot make a image"); END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TTexWork::LoadImage(String str, TTexpiaBitmap *tbmp) { BEGIN_LOG(""); String ext, fn, dn; WORD bpp; TGraphicFileFormat ExtIndex; TPException ec = EC_NONE; dn = ExtractFileDir(str); fn = ExtractFileName(str); ext = LowerCase(ExtractFileExt(str)); ExtIndex = FindExtension(AnsiString(ext)); if (ExtIndex == gffNON) { dn = fn + String(" is not supported"); ShowMessage(dn); END_LOG; return false; } if (ExtIndex == gffTEX || ExtIndex == gffKNT #ifdef TRIAL || ExtIndex == gffTEX_TRIAL || ExtIndex == gffKNT_TRIAL #endif ) { bpp = 8; } else { bpp = 24; } ec = InitFormFile(dn, fn, ExtIndex, bpp, tbmp); if (ec != EC_NONE) { EXCEPTION_MESSAGE_OK(ec); END_LOG; return false; } END_LOG; return true; } //--------------------------------------------------------------------------- void __fastcall TTexWork::ReadSubText(TPDocInput *ip, String fn) { /* AnsiString dir, filename, expression, expdir; TIniFile *TExpressionIni = NULL; expdir = "C:\\Kido\\Report"; //by jeegeo ¼öÁ¤µÇ¾îÁ®¾ßÇÑ´Ù....Àû´çÇÑ µð·ºÅ丮¸¦ ã¾Æ¾ß.. dir = ExtractFileDir(fn); filename = ExtractFileName(fn); TExpressionIni = new TIniFile(expdir + "\\Expression.ini"); // expdir --->define directory..... expression = TExpressionIni->ReadString(dir, filename, ""); ip->SetInputText(expression);*/ } //--------------------------------------------------------------------------- TPException __fastcall TTexWork::InitFormFile(String dn, String fn, TGraphicFileFormat ExtIndex, WORD bpp, TTexpiaBitmap *tbmp) { BEGIN_LOG(""); int pw, ph, sw, sh, x, y; RGBQUAD rgb[256]; TTexpiaBitmap *tb = NULL; TPCanvasInfor ci; Byte c[256], *bp, *sp, *dp; TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; bool layer = false; HANDLE hFile = INVALID_HANDLE_VALUE; TPDocElement *sep; TPalette *Palette = new TPalette; TGraphicFileFormat gff; if (tbmp == NULL) { // Load data in ReportTool sep = Report->GetSelectElement(); if ((sep->Type == detChart) || (sep->Type == detInput)) { sep = Report->GetSelectElement(true); } if (sep->Type == detImage) { tbmp = ((TPDocImage *)sep)->Image; } else if (sep->Type == detSheafImage) { tbmp = ((TPDocSheafImage *)sep)->Image; } } // Make image title if ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (ExtIndex==gffT3D #ifdef TRIAL ||ExtIndex == gffT3D_TRIAL #endif ) { if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } gff = ExtIndex; #ifdef TRIAL if(ExtIndex == gffT3D_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, tpfh, tb, gff, true, true))!=EC_NONE) goto fail; }else { if ((ec = LoadFromTexpiaFile(hFile, tpfh, tb, gff))!=EC_NONE) goto fail; } #else if ((ec = LoadFromTexpiaFile(hFile, tpfh, tb, gff))!=EC_NONE) goto fail; #endif ci = tpfh.CanvasInfor; if (!(tbmp->Copy(tb, SRCCOPY))) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } CloseHandle(hFile); } else { if ((ec = LoadFromFile(fn, ExtIndex, tb, ci, layer, bpp))!=EC_NONE) goto fail; if (layer == false) { if (bpp==8) { if (tb->BitsPerPixel==8) { if (ExtIndex == gffTEX || ExtIndex == gffTFC || ExtIndex == gffWEA || ExtIndex == gffWAV || ExtIndex == gffKNT /*|| ExtIndex == gffPIL*/ #ifdef TRIAL || ExtIndex == gffTEX_TRIAL || ExtIndex == gffTFC_TRIAL || ExtIndex == gffWEA_TRIAL || ExtIndex == gffKNT_TRIAL #endif ){ if (!(tbmp->Copy(tb, SRCCOPY))) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { bpp = bpp; goto next; } } else { tb->ColorResolution(8, CRF_OPTIMIZEDPALETTE, NULL, 250); tb->GetColors(0, 256, rgb); next: //Palette->ToRGBQUAD(rgb, 256); if (!tbmp->Create(tb->Width, tb->Height, tb->BitsPerPixel, rgb)) goto fail; tbmp->PutColors(0, 256, rgb); memset(c, 0, 256); if (!tb->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!tbmp->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yHeight; y++) { sp = tb->GetScanLine(y); dp = tbmp->GetScanLine(y); for (x=0; xWidth; x++, sp++, dp++) { *dp = *sp+2; c[*dp] = 1; } tbmp->PutScanLine(y); } tb->StopScanLine(); tbmp->StopScanLine(); } } else { if (!(tbmp->Copy(tb, SRCCOPY))) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } } } } if (Palette) {delete Palette; Palette = NULL;} if (tb) {delete tb; tb = NULL;} END_LOG; return EC_NONE; fail: if (Palette) {delete Palette; Palette = NULL;} if (tb) {delete tb; tb = NULL;} END_LOG; return ec; } //--------------------------------------------------------------------------- TPException __fastcall TTexWork::LoadFromTexpiaFile(HANDLE fh, TEXPIAFILEHEADER &tpfh, TTexpiaBitmap *pBitmap, TGraphicFileFormat gff, bool bTopLeft, bool bTrialVersion) { BEGIN_LOG(""); TTexVersion Tex; TTexColor TexPal[225]; int x, y, iw, ih, scan, offset; short ww, wh; HGLOBAL hMem = NULL; char *src = NULL, *sp; long attr, packsize; RGBQUAD rgb[256]; bool sw; Byte *bp; WORD BitCount; int w; TPMemory *memory = NULL; TPException ec = EC_NONE; DWORD dwRead; TPalette *pPalette = new TPalette; TUnionBitmap *tempBitmap; // by celberus RGBQUAD tempRGB[256]; // by celberus WORD checkVersion; #ifdef TRIAL //TrialVersion ó¸® if(bTrialVersion == true) { TEXPIAFILEHEADER_TRIAL temp; if (!ReadFile(fh, &temp, sizeof(TEXPIAFILEHEADER), &dwRead, NULL)) goto fail; tpfh.Version = temp.Version; tpfh.CanvasInfor = temp.CanvasInfor; tpfh.BitsPerPixel = temp.BitsPerPixel; tpfh.Compress = temp.Compress; }else { if (!ReadFile(fh, &tpfh, sizeof(TEXPIAFILEHEADER), &dwRead, NULL)) goto fail; } #else if (!ReadFile(fh, &tpfh, sizeof(TEXPIAFILEHEADER), &dwRead, NULL)) goto fail; #endif if (tpfh.Version.Texpia=='P' && tpfh.Version.Method=='T' && tpfh.Version.Number>=210) { checkVersion = GetHigherCheckVersion(gff); if (tpfh.Version.Number > checkVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } // 090527 upper version Word useColor; if (!ReadFile(fh, &useColor, sizeof(Word), &dwRead, NULL)) goto fail; pPalette->UseColor = useColor; checkVersion = GetHigherCheckVersion(gff); if (tpfh.Version.Number < checkVersion) pPalette->LoadFromFileHandle(fh, 1); else pPalette->LoadFromFileHandle(fh, 2); if (!ReadFile(fh, &BitCount, sizeof(WORD), &dwRead, NULL)) goto fail; if (SetFilePointer(fh, BitCount==8 ? 8000 : 24000, NULL, FILE_CURRENT)== 0xFFFFFFFF) goto fail; #ifdef TRIAL if(bTrialVersion == true) { char garbage[6]; for(int i = 0; i < 10; i++) if (!ReadFile(fh, garbage, sizeof(char) * 6, &dwRead, NULL)) { END_LOG; return false; } } #endif if (pBitmap) { if (!pBitmap->Create(tpfh.CanvasInfor.Width, tpfh.CanvasInfor.Height, tpfh.BitsPerPixel)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (tpfh.BitsPerPixel==8) { pPalette->ToRGBQUAD(rgb, 256); pBitmap->PutColors(0, 256, rgb); if (tpfh.Version.Number<220) { scan = ((pBitmap->Width+3)/4)*4; if ((hMem = GlobalAlloc(GHND, scan*pBitmap->Height))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((src = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, src, scan*pBitmap->Height, &dwRead, NULL)) goto fail; if (!pBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } sp = src; for (y=0; yHeight; y++) { bp = pBitmap->GetScanLine(y); memcpy(bp, sp, pBitmap->Width); pBitmap->PutScanLine(y); sp += scan; } pBitmap->StopScanLine(); GlobalUnlock(hMem); src = NULL; GlobalFree(hMem); hMem = NULL; } else { if (tpfh.Version.Number<222) { w = pBitmap->Width; switch (pBitmap->BitsPerPixel) { case 16: w *= 2; break; case 24: w *= 3; break; } if ((memory = new TPMemory(w*pBitmap->Height))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (memory->lock()==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!memory->LoadFromFile(fh, tpfh.Compress)) goto fail; pBitmap->LoadFromMemory(memory->pointer(), w); delete memory; memory = NULL; } else if (tpfh.Version.Number < 300 || gff == gffWEA || gff == gffKNT) { if (!(pBitmap->LoadFromTexpiaFile(fh, tpfh.Compress))) goto fail; } else { // by celberus tempBitmap = new TUnionBitmap; tempBitmap->Create(pBitmap->Width, pBitmap->Height, pBitmap->BitsPerPixel); if (tempBitmap->BitsPerPixel == 8) tempBitmap->PutColors(0, 256, rgb); if (!tempBitmap->LoadFromTexpiaFile(fh, tpfh.Compress)) goto fail; tempBitmap->CopyToTexpia(pBitmap, 0, 0, tempBitmap->Width, tempBitmap->Height, 0, 0, SRCCOPY); delete tempBitmap; } } } else { if (tpfh.Version.Number<220) { scan = ((3*pBitmap->Width+3)/4)*4; if ((hMem = GlobalAlloc(GHND, scan*pBitmap->Height))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((src = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, src, scan*pBitmap->Height, &dwRead, NULL)) goto fail; if (!pBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } sp = src; for (y=0; yHeight; y++) { bp = pBitmap->GetScanLine(y); memcpy(bp, sp, 3*pBitmap->Width); pBitmap->PutScanLine(y); sp += scan; } pBitmap->StopScanLine(); GlobalUnlock(hMem); src = NULL; GlobalFree(hMem); hMem = NULL; } else { if (tpfh.Version.Number<222) { w = pBitmap->Width; switch (pBitmap->BitsPerPixel) { case 16: w *= 2; break; case 24: w *= 3; break; } if ((memory = new TPMemory(w*pBitmap->Height))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (memory->lock()==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!memory->LoadFromFile(fh, tpfh.Compress)) goto fail; pBitmap->LoadFromMemory(memory->pointer(), w); delete memory; memory = NULL; } else if (tpfh.Version.Number < 300 || gff == gffWEA || gff == gffKNT) { if (!(pBitmap->LoadFromTexpiaFile(fh, tpfh.Compress))) goto fail; } else { // by celberus tempBitmap = new TUnionBitmap; tempBitmap->Create(pBitmap->Width, pBitmap->Height, pBitmap->BitsPerPixel); if (tempBitmap->BitsPerPixel == 8) tempBitmap->PutColors(0, 256, rgb); if (!tempBitmap->LoadFromTexpiaFile(fh, tpfh.Compress)) goto fail; tempBitmap->CopyToTexpia(pBitmap, 0, 0, tempBitmap->Width, tempBitmap->Height, 0, 0, SRCCOPY); delete tempBitmap; } } } } } else { if (SetFilePointer(fh, 0, NULL, FILE_BEGIN)== 0xFFFFFFFF) goto fail; if (!ReadFile(fh, &Tex, sizeof(TTexVersion), &dwRead, NULL)) goto fail; if (SetFilePointer(fh, 8000, NULL, FILE_CURRENT)== 0xFFFFFFFF) goto fail; Word useColor; if (!ReadFile(fh, &useColor, sizeof(Word), &dwRead, NULL)) goto fail; pPalette->UseColor = useColor; if (pBitmap) { if (Tex.Method=='T') { if (Tex.Number<200) { if (!ReadFile(fh, TexPal, sizeof(TexPal), &dwRead, NULL)) goto fail; pPalette->SetTexPalette(TexPal, 225); sw = true; if (!ReadFile(fh, &attr, sizeof(long), &dwRead, NULL)) goto fail; tpfh.Compress = attr&0xF ? cmLZW : cmNone; if (!ReadFile(fh, &tpfh.CanvasInfor.DotsPerInch, sizeof(short), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &ww, sizeof(short), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &wh, sizeof(short), &dwRead, NULL)) goto fail; tpfh.CanvasInfor.SetSize(cstFree, ww, wh); //????????? } else if (Tex.Number<201) { pPalette->LoadFromFileHandle(fh, 0); if (!ReadFile(fh, &attr, sizeof(long), &dwRead, NULL)) goto fail; tpfh.Compress = attr&0xF ? cmLZW : cmNone; if (!ReadFile(fh, &tpfh.CanvasInfor.DotsPerInch, sizeof(short), &dwRead, NULL)) goto fail; sw = false; if (!ReadFile(fh, &iw, sizeof(int), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &ih, sizeof(int), &dwRead, NULL)) goto fail; tpfh.CanvasInfor.SetSize(cstFree, iw, ih); //????????? } else { pPalette->LoadFromFileHandle(fh, 0); sw = false; if (!ReadFile(fh, &attr, sizeof(long), &dwRead, NULL)) goto fail; tpfh.Compress = attr&0xF ? cmLZW : cmNone; if (!ReadFile(fh, &tpfh.CanvasInfor, sizeof(TPCanvasInfor), &dwRead, NULL)) goto fail; } } else { if (!ReadFile(fh, TexPal, sizeof(TexPal), &dwRead, NULL)) goto fail; pPalette->SetTexPalette(TexPal, 225); sw = true; if (Tex.Method == 'C') { tpfh.Compress = cmLZW; attr = 1; } else { tpfh.Compress = cmNone; attr = 0; } tpfh.CanvasInfor.DotsPerInch = 160; if (!ReadFile(fh, &ww, sizeof(short), &dwRead, NULL)) goto fail; if (!ReadFile(fh, &wh, sizeof(short), &dwRead, NULL)) goto fail; tpfh.CanvasInfor.SetSize(cstFree, ww, wh); //????????? } pPalette->ToRGBQUAD(rgb, 256); if (pBitmap->Create(tpfh.CanvasInfor.Width, tpfh.CanvasInfor.Height, 8, rgb)==false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (attr&0x10) { scan = ((pBitmap->Width+3)/4)*4; if ((hMem = GlobalAlloc(GHND, scan*pBitmap->Height))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((src = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, src, scan*pBitmap->Height, &dwRead, NULL)) goto fail; } else { scan = pBitmap->Width; if ((hMem = GlobalAlloc(GHND, scan*pBitmap->Height))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((src = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (tpfh.Compress==cmLZW) { if ((offset = SetFilePointer(fh, 0, NULL, FILE_CURRENT))==0xFFFFFFFF) goto fail; if (Tex.Method=='T' && Tex.Number>100) { if (!ReadFile(fh, &packsize, sizeof(long), &dwRead, NULL)) goto fail; if (LZWdecoder_1((int)fh, src, packsize)!=scan*pBitmap->Height) goto fail; offset += 4+packsize; } else { offset += LZWdecoder((int)fh, src); } if (SetFilePointer(fh, offset, NULL, FILE_BEGIN)==0xFFFFFFFF) goto fail; } else { if (!ReadFile(fh, src, scan*pBitmap->Height, &dwRead, NULL)) goto fail; } } if (sw) { sp = src; for (y=0; yHeight; y++) { for (x=0; xWidth; x++) *(sp+x) += 1; sp += pBitmap->Width; } pPalette->UseColor++; } if (!pBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (bTopLeft) { sp = src; for (y=0; yHeight; y++) { memcpy(pBitmap->GetScanLine(y), sp, pBitmap->Width); pBitmap->PutScanLine(y); sp += scan; } } else { sp = src+(pBitmap->Height-1)*scan; for (y=0; yHeight; y++) { memcpy(pBitmap->GetScanLine(y), sp, pBitmap->Width); pBitmap->PutScanLine(y); sp -= scan; } } pBitmap->StopScanLine(); GlobalUnlock(hMem); src = NULL; GlobalFree(hMem); hMem = NULL; } else { if (Tex.Method=='V') { if (SetFilePointer(fh, (int)sizeof(TTexColor), NULL, FILE_CURRENT)==0xFFFFFFFF) goto fail; if (!ReadFile(fh, TexPal, sizeof(TTexColor)*pPalette->UseColor, &dwRead, NULL)) goto fail; pPalette->SetTexPalette(TexPal, 225); } else { pPalette->LoadFromFileHandle(fh, 0); if (SetFilePointer(fh, 6, NULL, FILE_CURRENT)==0xFFFFFFFF) goto fail; } } } if (pPalette) {delete pPalette; pPalette = NULL;} END_LOG; return EC_NONE; fail: if (hMem) { if (src) { pBitmap->StopScanLine(); GlobalUnlock(hMem); } GlobalFree(hMem); } if (memory) delete memory; if (pPalette) {delete pPalette; pPalette = NULL;} if (ec == EC_NONE) ec = EC_FILE_NOT_READ; END_LOG; return ec; } //--------------------------------------------------------------------------- TPException __fastcall TTexWork::LoadFromFile(String FileName, TGraphicFileFormat Index, TTexpiaBitmap *pBitmap, TPCanvasInfor &ci, bool &layer, WORD bpp) { BEGIN_LOG(""); TEXPIAFILEHEADER tpfh; int x, y; RGBQUAD rgb[256]; Byte c[256], *bp; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; Modify = false; //lhskys Modify ÃʱâÈ­ TGraphicFileFormat gff = Index; if (Index==gffTEX || Index==gffTFC #ifdef TRIAL || Index == gffTEX_TRIAL || Index == gffTFC_TRIAL #endif ) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TRIAL if(Index == gffTEX_TRIAL || Index == gffTFC_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, tpfh, pBitmap, gff, true, true))!= EC_NONE) goto fail; }else { if ((ec = LoadFromTexpiaFile(hFile, tpfh, pBitmap, gff))!= EC_NONE) goto fail; } #else if ((ec = LoadFromTexpiaFile(hFile, tpfh, pBitmap, gff))!= EC_NONE) goto fail; #endif ci = tpfh.CanvasInfor; // for lower sentence, move file pointer?? if (SetFilePointer(hFile, sizeof(bool), NULL, FILE_CURRENT)==0xFFFFFFFF) goto fail; /* if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T'&& tpfh.Version.Number >= 230) { if (!ReadFile(hFile, &layer, sizeof(bool), &dwRead, NULL)) goto fail; if (layer) { if (bpp == pBitmap->BitsPerPixel) { if (bpp == 8) { pPalette->ToRGBQUAD(rgb, 256); iMainImage->LoadFromLayerFile(hFile, rgb); } else { iMainImage->LoadFromLayerFile(hFile); } } else { layer = false; } } } */ CloseHandle(hFile); } else if (Index==gffWEA || Index==gffWAV || Index==gffKNT /*|| Index == gffPIL*/ #ifdef TRIAL || Index == gffWEA_TRIAL || Index == gffKNT_TRIAL #endif ) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TIRAL if(Index == gffWEA_TRIAL || Index == gffKNT_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, tpfh, pBitmap, gff, false, true))!= EC_NONE) goto fail; }else { if ((ec = LoadFromTexpiaFile(hFile, tpfh, pBitmap, gff, false))!= EC_NONE) goto fail; } #else if ((ec = LoadFromTexpiaFile(hFile, tpfh, pBitmap, gff, false))!= EC_NONE) goto fail; #endif ci = tpfh.CanvasInfor; CloseHandle(hFile); } else { if (!pBitmap->LoadFromFile(FileName.c_str())) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } // ci.DotsPerInch = CanvasInfor.DotsPerInch ? CanvasInfor.DotsPerInch : 160; // CanvasInfor is not defined......... ci.SetSize(cstFree, pBitmap->Width, pBitmap->Height); if (pBitmap->BitsPerPixel==8) { pBitmap->GetColors(0, 256, rgb); // pPalette->SetNormal(0, 0, 0, 0); // for (x = 0; x < 250; x++) { // pPalette->SetNormal(x+2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); // } // pPalette->SetNormal(255, 255, 255, 255); } } END_LOG; return EC_NONE; fail: if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } //--------------------------------------------------------------------------- void __fastcall TTexWork::ReportMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); TPDocElement *sep; StatusBar1->Panels->Items[1]->Text = "(" + IntToStr(X) + ", " + IntToStr(Y) + ")"; if (Report->Sheet) { ep = Point(X, Y); switch (EType) { case E_SIGNATURE: // sep = Report->GetSelectElement(); // if (XRange.left || X>sep->Range.right || YRange.top || Y>sep->Range.bottom // || !Shift.Contains(ssLeft)) if (!Shift.Contains(ssLeft)) EType = E_NONE; sep = Report->GetSelectElement(); ((TPDocSignature *)sep)->DrawLine(sp, ep); Report->Repaint(); sp = ep; Modify = true; //lhskys Modify üũ break; case E_ARROW: if (step == 1) { switch (AType) { case datSingle: case datBoth_Normal: case dat3Point: ep = Point(X, Y); Modify = true; //lhskys Modify üũ break; case datBoth_Hor_Over: case datBoth_Hor_Below: ep = Point(X, pt[0].y); Modify = true; //lhskys Modify üũ break; case datBoth_Ver_Left: case datBoth_Ver_Right: ep = Point(pt[0].x, Y); Modify = true; //lhskys Modify üũ break; } DrawLine(); tp = ep; } else if (step == 2) { ep = Point(X, pt[1].y); DrawLine(); tp = ep; } Modify = true; //lhskys Modify üũ break; case E_SHEAFIMAGE: if (step == 1) { DrawRect(); tp = ep; } Modify = true; //lhskys Modify üũ break; case E_SHEAFLABEL: // ¶óº§ÀԷ¹öư(tbLabel)À» Ŭ¸¯ÇسõÀº°æ¿ì if (step == 1) { DrawRect(); tp = ep; } Modify = true; //lhskys Modify üũ break; case E_SHEAFLINE: if (step == 1) { DrawLine(); tp = ep; } Modify = true; //lhskys Modify üũ break; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::tbNewClick(TObject *Sender) { BEGIN_LOG(""); int cnt, index, tabindex, i; TPOpenSheet *os; TRegistry *Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename+"\\Directory",TRUE); OpenDialog1->InitialDir=Registry->ReadString("Bin"); delete Registry; OldName = OpenDialog1->FileName; OpenDialog1->Filter = "Order Sheet File (*.fst)|*.fst"; OpenDialog1->FileName = ""; Timer1->Enabled = false; if (OpenDialog1->Execute()) { //============================================================================== lhskys newfile if (Modify){ //== À» ¿­¾úÀ»¶§ String msg; //== save ???? if(OldName.IsEmpty() == false) msg = OldName; //== else msg = "Noname.fst"; //== int Btn = MessageDlg(IDS_MESSAGE_SAVECHANGE + " " + msg, mtWarning, TMsgDlgButtons()<Sheet){ UpdataMenu(); //qe delete Report->Sheet; Report->Sheet=NULL; } TPDocSheet *stp=new TPDocSheet; if (FileExists(OpenDialog1->FileName)) { TRegistry *Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename+"\\Directory",TRUE); Registry->WriteString("TexWorkStart",OpenDialog1->FileName); delete Registry; if (!(stp->LoadFromFile(OpenDialog1->FileName))) goto fail; Report->Sheet=stp; if (!AddSheet(stp)) goto fail; } else { ShowMessage("Cannot find the file"); } StatusBar1->Panels->Items[3]->Text = OpenDialog1->FileName; OnChangeScroll(); tbArrow->Down = false; //lhskys Arrow ¹öư ÃʱâÈ­ OpenDialog1->FileName = ""; } Timer1->Enabled = true; END_LOG; return; fail: ShowMessage("Failed to open files"); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::tbOpenClick(TObject *Sender) { BEGIN_LOG(""); TPOpenSheet *os; TRegistry *Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename+"\\Directory",TRUE); OpenDialog1->InitialDir=Registry->ReadString("TexWork"); delete Registry; OldName = OpenDialog1->FileName; OpenDialog1->Filter = "Order Sheet File (*.fst)|*.fst"; OpenDialog1->FileName = ""; Timer1->Enabled = false; if (OpenDialog1->Execute()) { //============================================================================== lhskys openfile if (Modify){ //== À» ¿­¾úÀ»¶§ String msg; //== save ???? if(OldName.IsEmpty() == false) msg = OldName; //== else msg = "Noname.fst"; //== int Btn = MessageDlg(IDS_MESSAGE_SAVECHANGE + " " + msg, mtWarning, TMsgDlgButtons()<Sheet){ UpdataMenu(); //qe Report->Sheet->DeleteBitmap(); delete Report->Sheet; Report->Sheet=NULL; } TPDocSheet *stp=new TPDocSheet; int cnt, index, tabindex, i; if (FileExists(OpenDialog1->FileName)) { if (!(stp->LoadFromFile(OpenDialog1->FileName))) goto fail; Report->Sheet=stp; if (!AddSheet(stp)) goto fail; TRegistry *Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename+"\\Directory",TRUE); Registry->WriteString("TexWork", ExtractFileDir(OpenDialog1->FileName)); delete Registry; } else { ShowMessage("Cannot find the file"); } StatusBar1->Panels->Items[3]->Text = OpenDialog1->FileName; OnChangeScroll(); tbArrow->Down = false; //lhskys Arrow ¹öư ÃʱâÈ­ } Timer1->Enabled = true; END_LOG; return; fail: ShowMessage("Failed to open files"); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::tbSaveClick(TObject *Sender) { #ifdef TRIAL Application->MessageBox(IDS_TRIAL_NOT_SUPPORTED.c_str(), L"", MB_OK); return; #endif BEGIN_LOG(""); if(!Report->Sheet) { END_LOG; return; } TRegistry *Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename+"\\Directory",TRUE); SaveDialog->InitialDir=Registry->ReadString("TexWork"); delete Registry; SaveDialog->Filter = "Order Sheet File (*.fst)|*.fst"; SaveDialog->FileName = ExtractFileName(OpenDialog1->FileName); //qe if (SaveDialog->Execute()) { if (!(Report->Sheet->SaveToFile(SaveDialog->FileName))) goto fail; TRegistry *Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename+"\\Directory",TRUE); Registry->WriteString("TexWork",ExtractFileDir(SaveDialog->FileName)); delete Registry; Modify = false; OldName = SaveDialog->FileName; OpenDialog1->FileName = SaveDialog->FileName; StatusBar1->Panels->Items[3]->Text = SaveDialog->FileName; } END_LOG; return; fail: ShowMessage("Failed to save files"); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::rbPrintClick(TObject *Sender) { BEGIN_LOG(""); if(!Report->Sheet) { END_LOG; return; } TTexWorkPrintForm *Form = NULL; TPDocSheet *tempSheet=Report->Sheet; int i, j; bool bMake = false; if ((Form = new TTexWorkPrintForm(this)) == NULL) goto fail; Form->InitForm(); if (Form->ShowModal()==mrOk) { if (Form->rbOne->Checked) { j = 1; } else { j = Form->seMany->Value; } if (Form->rbWhole->Checked) { //for (i = 0 ; i < SheafManagerForm->Sheaf->GetCount() ; i++) { //tempSheet = SheafManagerForm->Sheaf->GetSheet(i); if (!tempSheet->Bitmap) { if (!(tempSheet->MakeBitmap(1, 1))) goto fail; bMake = true; } #ifdef TRIAL DocSheetSendToPrinter(tempSheet, j, Form->cbCenter->Checked, Form->rgLanguage->ItemIndex); #else if (!(tempSheet->SendToPrinter(j, Form->cbCenter->Checked, Form->rgLanguage->ItemIndex ))) goto fail; #endif if (bMake) { tempSheet->DeleteBitmap(); bMake = false; } //} } else { //for (i = Form->seFrom->Value ; i <= Form->seTo->Value ; i++) { //tempSheet = SheafManagerForm->Sheaf->GetSheet(i-1); if (!tempSheet->Bitmap) { if (!(tempSheet->MakeBitmap(1, 1))) goto fail; bMake = true; } #ifdef TRIAL DocSheetSendToPrinter(tempSheet, j, Form->cbCenter->Checked, Form->rgLanguage->ItemIndex); #else if (!(tempSheet->SendToPrinter(j, Form->cbCenter->Checked, Form->rgLanguage->ItemIndex))) goto fail; #endif if (bMake) { tempSheet->DeleteBitmap(); bMake = false; } //} } } delete Form; END_LOG; return; fail : if (Form) delete Form; ShowMessage("Cannot print the sheet"); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::FindNextItem() { BEGIN_LOG(""); int index = -1, indexcnt, cnt, ccnt, k, i, gp; POINT np; TShiftState Shift; TPDocElement *sep, *ip, *cp; TPDocInput *iep; TPDocChart *cep; gp = Report->GridSpace; cnt = Report->Sheet->Element->Count; indexcnt = Report->Sheet->IndexCount; sep = Report->GetSelectElement(); if (sep->Type == detInput || sep->Type == detChart) sep = Report->GetSelectElement(true); switch (sep->Type) { case detEdit: index = ((TPDocEdit *)sep)->Index; break; case detDate: index = ((TPDocEdit *)sep)->Index; break; case detMemo: index = ((TPDocEdit *)sep)->Index; break; case detNumber: index = ((TPDocNumber *)sep)->Index; break; case detFormula: index = ((TPDocFormula *)sep)->Index; break; } if (index < 0) { END_LOG; return; } if (index == (indexcnt-1)) index = 0; else index++; for (i=0; iSheet->Element->Items[i]; if (i >= cnt-1) i = 0; //by k3dogs F1À¸·Î focus°¡ ¸¶Áö¸·±îÁö °¬À» ¶§ óÀ½À¸·Î °¡µµ·Ï. if (sep->Type == detEdit) { if (((TPDocEdit *)sep)->Index == index) { np = Point(sep->Range.left+gp, sep->Range.top+gp); goto next; } } else if (sep->Type == detDate) { if (((TPDocDate *)sep)->Index == index) { np = Point(sep->Range.left+gp, sep->Range.top+gp); goto next; } } else if (sep->Type == detMemo) { if (((TPDocMemo *)sep)->Index == index) { np = Point(sep->Range.left+gp, sep->Range.top+gp); goto next; } } else if (sep->Type == detNumber) { if (((TPDocNumber *)sep)->Index == index) { np = Point(sep->Range.left+gp, sep->Range.top+gp); goto next; } } else if (sep->Type == detFormula) { if (((TPDocFormula *)sep)->Index == index) { np = Point(sep->Range.left+gp, sep->Range.top+gp); goto next; } } else if (sep->Type == detInput) { ip = ((TPDocInput *)sep)->IPElement; if (ip->Type == detEdit) { if (((TPDocEdit *)ip)->Index == index) { np = Point(sep->Range.left+ip->Range.left+gp, sep->Range.top+ip->Range.top+gp); goto next; } } else if (ip->Type == detDate) { if (((TPDocDate *)ip)->Index == index) { np = Point(sep->Range.left+ip->Range.left+gp, sep->Range.top+ip->Range.top+gp); goto next; } } else if (ip->Type == detNumber) { if (((TPDocNumber *)ip)->Index == index) { np = Point(sep->Range.left+ip->Range.left+gp, sep->Range.top+ip->Range.top+gp); goto next; } } else if (ip->Type == detFormula) { if (((TPDocFormula *)ip)->Index == index) { np = Point(sep->Range.left+ip->Range.left+gp, sep->Range.top+ip->Range.top+gp); goto next; } } } else if (sep->Type == detChart) { cep = (TPDocChart *)sep; ccnt = cep->Cell->Count; for (k=0; kCell->Items[k]; if (cp->Type == detEdit) { if (((TPDocEdit *)cp)->Index == index) { np = Point(cep->Range.left+cp->Range.left+gp, cep->Range.top+cp->Range.top+gp); goto next; } } else if (cp->Type == detDate) { if (((TPDocDate *)cp)->Index == index) { np = Point(cep->Range.left+cp->Range.left+gp, cep->Range.top+cp->Range.top+gp); goto next; } } else if (cp->Type == detNumber) { if (((TPDocNumber *)cp)->Index == index) { np = Point(cep->Range.left+cp->Range.left+gp, cep->Range.top+cp->Range.top+gp); goto next; } } else if (cp->Type == detFormula) { if (((TPDocFormula *)cp)->Index == index) { np = Point(cep->Range.left+cp->Range.left+gp, cep->Range.top+cp->Range.top+gp); goto next; } } } } } ShowMessage("Can't find next item!"); END_LOG; return; next: ReportMouseDown(Report, mbLeft, Shift, np.x, np.y); MoveFocus(np, Report->Width, Report->Height, //by k3dogs(2000/10/26) Report->Sheet->Bitmap->Width, Report->Sheet->Bitmap->Height); //F1 Key ´­·¶À» ¶§ È­¸éÀ̵¿ END_LOG; } //--------------------------------------------------------------------------- //---------------------------------------------------------------------------Made by k3dogs(2000/10/25) F1Ű ´©¸¦¶§ Æ÷Ä¿½º(È­¸é) À̵¿. void __fastcall TTexWork::MoveFocus(POINT np, int ReportWidth, int ReportHeight, int SheetWidth, int SheetHeight) { BEGIN_LOG(""); // long x, y; if ((np.x + 100 > Report->PosX + ReportWidth ) || (np.x < Report->PosX)) { Report->PosX = np.x - 50; if (Report->PosX >= SheetWidth - ReportWidth) { Report->PosX = SheetWidth - ReportWidth; } else if (Report->PosX <= 500) { Report->PosX = 0; } else { Report->PosX = np.x - 50; } ScrollBarH->Position = Report->PosX; } if ((np.y + 100 > Report->PosY + ReportHeight) || (np.y < Report->PosY)) { Report->PosY = np.y - 50; if (Report->PosY >= SheetHeight - ReportHeight){ Report->PosY = SheetHeight- ReportHeight; } else if (Report->PosY <= 500) { Report->PosY = 0; } else { Report->PosY = np.y - 50; } ScrollBarV->Position = Report->PosY; } // ScrollHorz->Position = np.x; // ScrollVert->Position = np.y; // TabControl1Resize(NULL); END_LOG; } //-------------------------------------------------------------------------- void __fastcall TTexWork::tbArrowMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); EType = E_NONE; tbArrow->Down = false; if (Report->Sheet) Report->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::tbFontClick(TObject *Sender) { BEGIN_LOG(""); TPDocElement *sep = NULL; sep = Report->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { sep = Report->GetSelectElement(true); } if ((sep->Type == detNumber) || (sep->Type == detFormula) || (sep->Type == detEdit) || (sep->Type == detMemo) || (sep->Type == detArrow) || (sep->Type == detSheafLabel) || (sep->Type == detDate)) { if (FontDialog1->Execute()) { if (sep->Type == detMemo) ((TPDocMemo *)sep)->SetFont(FontDialog1->Font, FontDialog1->Font->Color); else ((TPDocText *)sep)->SetFont(FontDialog1->Font, FontDialog1->Font->Color); Memo->Font->Assign(FontDialog1->Font); Report->Repaint(); } } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::DataClear1Click(TObject *Sender) { BEGIN_LOG(""); TPDocSheet *st; TPDocElement *sep; TPDocSignature *sig; TPDocArrow *arr; TPOpenSheet *os; if (Report->Select(sp)) { sep = Report->GetSelectElement(); if (sep->Type == detInput || sep->Type == detChart) { sep = Report->GetSelectElement(true); } if (sep->Type == detSignature) { sig = (TPDocSignature *)sep; sig->Image->FillRect(Rect(0, 0, sig->Image->Width, sig->Image->Height), clWhite); } else if (sep->Type == detArrow || sep->Type == detSheafImage || sep->Type == detSheafLabel || sep->Type == detSheafLine) { Report->RemoveSelect(); } else if (sep->Type == detImage) { if (((TPDocImage *)sep)->Image != NULL) { delete ((TPDocImage *)sep)->Image; ((TPDocImage *)sep)->Image = NULL; } } Report->Repaint(); } UpdataMenu(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::FormCloseQuery(TObject *Sender, bool &CanClose) { BEGIN_LOG(""); //============================================================================== lhskys Modify È®ÀÎ #ifdef TRIAL CanClose = true; #else if (Modify){ String msg; if(OpenDialog1->FileName.IsEmpty() == false) msg = OpenDialog1->FileName; else msg = "Noname.fst"; int Btn = MessageDlg(IDS_MESSAGE_SAVECHANGE + " " + msg, mtWarning, TMsgDlgButtons()<Sheet){ Report->Sheet->DeleteBitmap(); delete Report->Sheet; Report->Sheet=NULL; } if (DefaultFont){ delete DefaultFont; DefaultFont = NULL; } //TexWork=NULL; Timer1->Enabled=false; //MainMenuForm->shTexWork->Brush->Color = clBlack; //lhskys ÆûÀÌ »ç¶óÁö¸é // MainMenuForm->shTexWork->Pen->Color = clBtnShadow; //by bomchun ¹öư »ö ³²´Â ¹®Á¦ //MainMenuForm->sbTexWork->Down = false; //lhskys »¡°£»öÀ» °ËÁ¤»öÀ¸·Î Modify = false; if(Report->Sheet){ Report->Sheet->DeleteBitmap(); delete Report->Sheet; Report->Sheet=NULL; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TTexWork::SaveFiles(String OldName) { #ifdef TRIAL return; #endif BEGIN_LOG(""); if(!Report->Sheet) { END_LOG; return; } TRegistry *Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename+"\\Directory",TRUE); SaveDialog->InitialDir = Registry->ReadString("TexWork"); delete Registry; SaveDialog->Filter = "Order Sheet File (*.fst)|*.fst"; if(OldName.IsEmpty()) OldName = "Noname.fst"; SaveDialog->FileName = ExtractFileName(OldName); if (SaveDialog->Execute()) { if (!(Report->Sheet->SaveToFile(SaveDialog->FileName))) goto fail; TRegistry *Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename+"\\Directory",TRUE); Registry->WriteString("TexWork", ExtractFileDir(SaveDialog->FileName)); delete Registry; } END_LOG; return; fail: ShowMessage("Failed to save files"); END_LOG; } //---------------------------------------------------------------------------