//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include #include "lzw.hpp" #include "Main.h" #include "SheafManager.h" #include "PrintingForm.h" #include "about.h" //#include "Edit.h" #include "View.h" #include "Environment.h" #include "D_Environment.h" #include "Tool.h" //#include "MakeTitle.h" ?? #include "ViewImage.h" #include "SewingTerm.h" #include "ImageExpression.h" #include "NumberExpression.h" #include "ProtectCard.h" #include "Define.h" #include //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPDocument" #pragma resource "*.dfm" TMainForm *MainForm; //--------------------------------------------------------------------------- typedef struct { TPDocSheet *Sheet; } TPOpenSheet; //--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) { // RickyLevel = 0; // ReportDoc->ControlStyle = ReportDoc->ControlStyle<Enabled = false; CoolBar1->Visible = false; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); dir = Registry->ReadString("Path"); dirfst = Registry->ReadString("Pathfst"); dirfsf = Registry->ReadString("Pathfsf"); delete Registry; OpenDialog1->InitialDir = dirfsf; OpenDialog2->InitialDir = dirfst; SaveDialog1->InitialDir = dirfsf; TMainFormIni = new TIniFile(dir + "\\Program\\MainForm.ini"); Caption = "TexWork"; DefaultFont = new TFont; LoadFromMainRegIniFile(); //============================ LOCK_HASP Check ¸¦ À§ÇÑ ÄÚµå ProtectCard = new TProtectCard; #ifdef LOCK_HASP if (ProtectCard==NULL) goto fail; Items = ProtectCard->Init(Password); if ((((Items>>14)&3)==3) || Items<1 || (Items&PNC_RTool)!=PNC_RTool) goto fail; #else #ifdef LOCK_IFC #ifdef ACADEMY if (!ProtectCard->Init()) { ec = EC_INTERFACE_NONE; goto fail; } #else Items = ProtectCard->Init(RegFilename); if (Items==0 || (Items&PCN_TEXWORK)!=PCN_TEXWORK) { ec = EC_INTERFACE_NONE; goto fail; } #endif if (!ProtectCard->CheckPassword()) { ec = EC_INTERFACE_NONE; goto fail; } #endif #endif if (TMainFormIni) { //============================ // ȯ°æ¼³Á¤Ã¢¿¡¼­ º¯°æÇϱâÀ§ÇÑ º¯¼ö°ª ÃʱâÈ­ SewingTerm_Path = TMainFormIni->ReadString("Path", "SewingTerm", "C:\Program Files\Youngwoo\TexWork\Sewing Term"); ; Texpro_Path = TMainFormIni->ReadString("Path", "Texpro", "C:\\Program Files\\YoungWoo\\TexPro7.2\\Bin\\Textile"); ; //============================ WindowState = TMainFormIni->ReadInteger("Form","WindowState",wsNormal); ReportDoc->GridSpace = TMainFormIni->ReadInteger("GridSpace", "GridSpace", 1); Decimal = TMainFormIni->ReadBool("NumExpression", "Decimal", true); DefaultFont->Name = TMainFormIni->ReadString("Font", "Name", "Ms Sans Serif"); DefaultFont->Size = TMainFormIni->ReadInteger("Font", "Size", 13); delete TMainFormIni; } else { DefaultFont->Name = "MS Sans Serif"; DefaultFont->Size = 13; } DefaultFont->Charset = DEFAULT_CHARSET; DefaultFont->Color = clBlack; if (Width>Screen->Width) Left = 100; else Left = (Screen->Width-Width)/2; if (Height>Screen->Height) Top = 100; else Top = (Screen->Height-Height)/2; TabControl1->DoubleBuffered = true; TabControl1Resize(NULL); return; #ifdef LOCK_HASP fail: ::doDestroy(MainForm); ::doDestroy(ProtectCard); ShowMessage ("HASP NOT FOUND."); Application->Terminate(); #else #ifdef LOCK_IFC fail: ::doDestroy(MainForm); ::doDestroy(ProtectCard); ShowMessage("Interface card doesn't exist."); Application->Terminate(); #endif #endif } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormDestroy(TObject *Sender) { AnsiString dir; TIniFile *TMainFormIni; TPOpenSheet *os; TRegistry *Registry; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); dir = Registry->ReadString("Path"); delete Registry; TMainFormIni = new TIniFile(dir + "\\Program\\MainForm.ini"); if (TMainFormIni) { TMainFormIni->WriteInteger("Form", "WindowState", WindowState); TMainFormIni->WriteInteger("GridSpace", "GridSpace", ReportDoc->GridSpace); TMainFormIni->WriteBool("NumExpression", "Decimal", Decimal); if (DefaultFont) { TMainFormIni->WriteString("Font", "Name", DefaultFont->Name); TMainFormIni->WriteInteger("Font", "Size", DefaultFont->Size); } delete TMainFormIni; } if (OpenSheet) { while (OpenSheet->Count) { os = (TPOpenSheet *)OpenSheet->First(); OpenSheet->Remove(os); delete os; } delete OpenSheet; } if (DefaultFont) delete DefaultFont; if (MFont) delete MFont; if (DSheet) delete DSheet; ::doDestroy(ProtectCard); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormShow(TObject *Sender) { SheafManagerForm->HostDockSite = Panel1; } //--------------------------------------------------------------------------- void __fastcall TMainForm::FileNew1Execute(TObject *Sender) { #ifdef LOCK_HASP ProtectCard->Read(); ProtectCard->Check(); #endif #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #endif if (IsReport) { if (Modify){ AnsiString msg; msg = ReportFileName; int Btn = MessageDlg("Save Change to " + msg, mtWarning, TMsgDlgButtons()<CreateSheaf(); if (SheafManagerForm->HostDockSite == Panel1) { if (Panel1->Width == 1) Panel1->Width = 150; } else if (SheafManagerForm->HostDockSite == Panel2) { if (Panel2->Width == 1) Panel2->Width = 150; } if (ViewForm->Visible) ViewForm->Visible = false; SheafManagerForm->Visible = true; UpdateMenu(); StatusBar1->Panels->Items[0]->Text = ""; StatusBar1->Panels->Items[2]->Text = "No Title"; StatusBar1->Panels->Items[3]->Text = "Noname.fsf"; ReportFileName = "Noname.fsf"; Modify = false; } else { if (DModify){ AnsiString msg; msg = DesignFileName; int Btn = MessageDlg("Save Change to " + msg, mtWarning, TMsgDlgButtons()<RemoveData(); ResetDesign(); UpdateMenu(); DesignDoc->Repaint(); StatusBar1->Panels->Items[1]->Text = ""; StatusBar1->Panels->Items[2]->Text = "No Title"; StatusBar1->Panels->Items[3]->Text = "Noname.fst"; DesignFileName = "Noname.fst"; DModify = false; } #ifdef LOCK_IFC } else { ShowMessage("Interface card doesn't exist."); Application->Terminate(); } #endif #ifdef LOCK_HASP if (ProtectCard->isHacking) Application->Terminate(); #endif } //--------------------------------------------------------------------------- void __fastcall TMainForm::FileOpen1Execute(TObject *Sender) { #ifdef LOCK_HASP ProtectCard->Read(); ProtectCard->Check(); #endif #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #endif if (IsReport) { TTreeNode *RootNode; TPOpenSheet *os = NULL; int i, cnt; TRegistry *Registry; AnsiString dirfsf; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); dirfsf = Registry->ReadString("Pathfsf"); delete Registry; OpenDialog1->InitialDir = dirfsf; OpenDialog1->Filter = "Order Sheaf File (*.fsf)|*.fsf"; OpenDialog1->FileName = ""; if (OpenDialog1->Execute()) { if (FileExists(OpenDialog1->FileName)) { if (Modify){ AnsiString msg; msg = ReportFileName; int Btn = MessageDlg("Save Change to " + msg, mtWarning, TMsgDlgButtons()<CreateSheaf(); if (!(SheafManagerForm->Sheaf->LoadFromFile(OpenDialog1->FileName))) goto fail; cnt = SheafManagerForm->Sheaf->GetCount(); RootNode = SheafManagerForm->TreeView1->Items->Item[0]; for (i=0; iSheet = (TPDocSheet *)SheafManagerForm->Sheaf->GetSheet(i); OpenSheet->Add(os); SheafManagerForm->TreeView1->Items->AddChild(RootNode, os->Sheet->Title); TabControl1->TabIndex = TabControl1->Tabs->Add(os->Sheet->Title); SheafManagerForm->Sheaf->AddCommonData(TabControl1->TabIndex); SheafManagerForm->Sheaf->GetCommonData(TabControl1->TabIndex); } if (SheafManagerForm->Sheaf->Title != "") SheafManagerForm->TreeView1->Items->Item[0]->Text = SheafManagerForm->Sheaf->Title; if (!(os->Sheet->MakeBitmap(ReportDoc->ZoomIn, ReportDoc->ZoomOut))) goto fail; ReportDoc->Sheet = os->Sheet; TabControl1->TabIndex = cnt-1; if (SheafManagerForm->HostDockSite == Panel1) { if (Panel1->Width == 1) Panel1->Width = 150; } else if (SheafManagerForm->HostDockSite == Panel2) { if (Panel2->Width == 1) Panel2->Width = 150; } SheafManagerForm->Visible = true; StatusBar1->Panels->Items[2]->Text = SheafManagerForm->Sheaf->Title; StatusBar1->Panels->Items[3]->Text = OpenDialog1->FileName; ReportFileName = OpenDialog1->FileName; Modify = false; TabControl1Resize(NULL); if (ViewForm->Visible) ViewForm->ShowBitmap(); Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); Registry->WriteString("Pathfsf", ExtractFileDir(OpenDialog1->FileName)); delete Registry; } else { ShowMessage("Can't find file"); } } UpdateMenu(); } else { AnsiString dir; TRegistry *Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); dir = Registry->ReadString("Pathfst"); delete Registry; OpenDialog2->InitialDir = dir; OpenDialog2->Filter = "Order Sheet File (*.fst)|*.fst"; if (OpenDialog2->Execute()) { if (DModify){ AnsiString msg; msg = DesignFileName; int Btn = MessageDlg("Save Change to " + msg, mtWarning, TMsgDlgButtons()<RemoveData(); ResetDesign(); if (!(DesignDoc->Sheet->LoadFromFile(OpenDialog2->FileName))) goto fail; ChangeSize(); DesignDoc->Repaint(); StatusBar1->Panels->Items[2]->Text = DesignDoc->Sheet->Title; StatusBar1->Panels->Items[3]->Text = OpenDialog2->FileName; DesignFileName = OpenDialog2->FileName; DModify = false; //TitleEdit->Text = DesignDoc->Sheet->Title; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); Registry->WriteString("Pathfst",ExtractFileDir(OpenDialog2->FileName)); delete Registry; } } #ifdef LOCK_IFC } else { ShowMessage("Interface card doesn't exist."); Application->Terminate(); } #endif #ifdef LOCK_HASP if (ProtectCard->isHacking) Application->Terminate(); #endif return; fail: ShowMessage(" File open fail!"); UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FileSave1Execute(TObject *Sender) { TPDocSheet *dp = NULL; int index = -1; AnsiString str, fn; //fn = StatusBar1->Panels->Items[3]->Text; if (IsReport) { fn = ReportFileName; str = "Noname.fsf"; if (str == fn) { //ÆÄÀÏÀ̸§ÀÌ NonameÀ϶§... FileSaveAs1Execute(NULL); } else { //======================================= // commondata °ªÀÌ ¸ðµÎ µé¾î°¡µµ·Ï Çϱâ À§Çؼ­.. dp = FindOpenSheet(); if (dp) index = FindIndex(dp); if (SheafManagerForm->Sheaf->GetCount() > 1 && index >= 0) { SheafManagerForm->Sheaf->GetCommonData(index); PutCommonData(); } //======================================= if (!(SheafManagerForm->Sheaf->SaveToFile(fn))) goto fail; } Modify = false; } else { fn = DesignFileName; str = "Noname.fst"; if (str == fn) { //ÆÄÀÏÀ̸§ÀÌ NonameÀ϶§... FileSaveAs1Execute(NULL); } else { if (DesignDoc->Sheet->Title != "") { SetIndex(); if (!(DesignDoc->Sheet->SaveToFile(fn))) goto fail; DModify = false; StatusBar1->Panels->Items[3]->Text = fn; } else { ShowMessage("You must input Title Name!"); } } } return; fail: ShowMessage("Save fail!"); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FileSaveAs1Execute(TObject *Sender) { #ifdef READ_ONLY return; #endif if (IsReport) { TPDocSheet *dp = NULL; int index = -1; TRegistry *Registry; AnsiString dirfsf; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); dirfsf = Registry->ReadString("Pathfsf"); delete Registry; SaveDialog1->InitialDir = dirfsf; SaveDialog1->Filter = "Order Sheet File (*.fsf)|*.fsf"; SaveDialog1->FileName = ""; if (SaveDialog1->Execute()) { // ======================================= // commondata °ªÀÌ ¸ðµÎ µé¾î°¡µµ·Ï Çϱ⠿ìÇØ¼­.. dp = FindOpenSheet(); if (dp) index = FindIndex(dp); if (SheafManagerForm->Sheaf->GetCount() > 1 && index >= 0) { SheafManagerForm->Sheaf->GetCommonData(index); PutCommonData(); } // ======================================= if (!(SheafManagerForm->Sheaf->SaveToFile(SaveDialog1->FileName))) goto fail; StatusBar1->Panels->Items[3]->Text = SaveDialog1->FileName; ReportFileName = SaveDialog1->FileName; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); Registry->WriteString("Pathfsf", ExtractFileDir(SaveDialog1->FileName)); delete Registry; } } else { AnsiString dir; TRegistry *Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); dir = Registry->ReadString("Pathfst"); delete Registry; SaveDialog1->InitialDir = dir; SaveDialog1->Filter = "Order Sheet File (*.fst)|*.fst"; SaveDialog1->FileName = ""; if (SaveDialog1->Execute()) { if (DesignDoc->Sheet->Title != "") { SetIndex(); if (!(DesignDoc->Sheet->SaveToFile(SaveDialog1->FileName))) goto fail; StatusBar1->Panels->Items[3]->Text = SaveDialog1->FileName; DesignFileName = SaveDialog1->FileName; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); Registry->WriteString("Pathfst",ExtractFileDir(SaveDialog1->FileName)); delete Registry; } else { ShowMessage("You must input Title Name!"); } } } return; fail: ShowMessage("Save fail!"); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FileEnvironment1Execute(TObject *Sender) { //////////////////////////////////////////////////////////////////////////////////ReportTool if(IsReport){ int value; AnsiString dir ; TIniFile *TMainFormIni; TEnvironmentForm *Form = new TEnvironmentForm(this); TRegistry *Registry; if (Form->ShowModal() == mrOk) { //=========================================== SewingTerm_Path = Form->SewPathEdit->Text ; Texpro_Path = Form->TexPathEdit->Text ; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); dir = Registry->ReadString("Path"); delete Registry; TMainFormIni = new TIniFile(dir + "\\Program\\MainForm.ini"); if (TMainFormIni) { TMainFormIni->WriteString("Path", "SewingTerm", SewingTerm_Path ); TMainFormIni->WriteString("Path", "Texpro", Texpro_Path ); delete TMainFormIni; } else { TMainFormIni->WriteString("Path", "SewingTerm", "C:\Program Files\Youngwoo\TexWork\Sewing Term"); TMainFormIni->WriteString("Path", "Texpro", "C:\\Program Files\\YoungWoo\\TexPro7.2\\Bin\\Textile"); } //=========================================== if(SheafManagerForm && SheafManagerForm->Sheaf) { SheafManagerForm->Sheaf->Title = Form->Edit->Text; SheafManagerForm->TreeView1->Items->Item[0]->Text = Form->Edit->Text; } else { // SheafManagerForm->Sheaf->Title = ""; } value = Form->rxGrid->Value; if ((value < 1) || (IntToStr(value).Length() == 0)) ReportDoc->GridSpace = 1; else ReportDoc->GridSpace = value; if (Form->cbNumExp->ItemIndex == 0) Decimal = true; else Decimal = false; if (Form->bFont) DefaultFont->Assign(Form->FontDialog->Font); if(SheafManagerForm && SheafManagerForm->Sheaf) { StatusBar1->Panels->Items[2]->Text = SheafManagerForm->Sheaf->Title; } } delete Form; ///////////////////////////////////////////////////////////////////////////DesignTool }else{ int w, h, DPI; TPDocSheetType st; TD_EnvironmentForm *Form1 = new TD_EnvironmentForm(this); if (Form1->ShowModal() == mrOk) { DesignDoc->Sheet->Title = Form1->TitleEdit->Text; StatusBar1->Panels->Items[2]->Text = Form1->TitleEdit->Text; DesignDoc->GridSpace = Form1->grid; if (DesignDoc->Sheet->Element->Count == 0) { if (Form1->rbPortrait->Checked) DesignDoc->Sheet->Orientation = poPortrait; else DesignDoc->Sheet->Orientation = poLandscape; DPI = Form1->rxDPI->Value; if (Form1->cbSize->ItemIndex) st = dstA3; else st = dstA4; if ((st != DesignDoc->Sheet->SheetType) || (DPI != DesignDoc->Sheet->DotsPerInch)) { DesignDoc->Sheet->DotsPerInch = DPI; DesignDoc->Sheet->SheetType = st; switch(st) { case dstA4: // 7.8 * 11 inch 730*1036 w = 7.6*DPI; //¿©À¯ºÐÀ» À§ÇØ h = 10.8*DPI; break; case dstA3: // 11 * 15.6 inch 1036*1460 w = 10.8*DPI; h = 15.4*DPI; break; } if (DesignDoc->Sheet->Orientation == poPortrait) DesignDoc->Sheet->SetRange(w, h); else DesignDoc->Sheet->SetRange(h, w); } ChangeSize(); } DesignDoc->Repaint(); } delete Form1; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FilePrint1Execute(TObject *Sender) { #ifdef LOCK_HASP ProtectCard->Read(); ProtectCard->Check(); if (ProtectCard->isHacking) Application->Terminate(); #endif #ifdef LOCK_IFC if (!ProtectCard->CheckPassword()) { ShowMessage("Interface card doesn't exist."); Application->Terminate(); } #endif TPrintForm *Form = NULL; TPDocSheet *tempSheet; int i, j; bool bMake = false; if ((Form = new TPrintForm(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; } if (!(tempSheet->SendToPrinter(tempSheet, j, Form->cbCenter->Checked, Form->rgLanguage->ItemIndex ))) goto fail; 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; } if (!(tempSheet->SendToPrinter(tempSheet, j, Form->cbCenter->Checked, Form->rgLanguage->ItemIndex))) goto fail; if (bMake) { tempSheet->DeleteBitmap(); bMake = false; } } } } delete Form; return; fail : if (Form) delete Form; ShowMessage("Can't create printting form!"); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FileExit1Execute(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::MakeTitle1Execute(TObject *Sender) { #ifdef READ_ONLY return; #endif TMakeTitleForm *Form = new TMakeTitleForm(this); Form->ShowModal(); if (Form) delete Form; } //--------------------------------------------------------------------------- void __fastcall TMainForm::VeiwSheafManager1Execute(TObject *Sender) { SheafManagerForm->Visible = true; if (SheafManagerForm->HostDockSite) { if (SheafManagerForm->HostDockSite->Name == "Panel1") { Panel1DockDrop(Sender, NULL, 0, 0); } else if (SheafManagerForm->HostDockSite->Name == "Panel2") { Panel2DockDrop(Sender, NULL, 0, 0); } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::SheetAdd1Execute(TObject *Sender) { #ifdef READ_ONLY return; #endif TPOpenSheet *os; TPDocSheet *stp; int cnt, index, tabindex, i; int beforetabindex = TabControl1->TabIndex; TRegistry *Registry; AnsiString dirfst; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); dirfst = Registry->ReadString("Pathfst"); delete Registry; OpenDialog2->InitialDir = dirfst; OpenDialog2->Filter = "Order Sheet File (*.fst)|*.fst"; OpenDialog2->FileName = ""; if (OpenDialog2->Execute()) { if (FileExists(OpenDialog2->FileName)) { if((stp = SheafManagerForm->AddSheet(OpenDialog2->FileName)) == NULL) goto fail; if (!AddSheet(stp)) goto fail; if (SheafManagerForm->Sheaf->GetCount() == 1) { SheafManagerForm->TreeView1->Items->Item[0]->Expanded = true; UpdateMenu(); } tabindex = TabControl1->TabIndex; cnt = SheafManagerForm->Sheaf->GetCount(); SheafManagerForm->Sheaf->AddCommonData(cnt-1); if (tabindex > 0) { os = (TPOpenSheet *)OpenSheet->Items[tabindex - 1]; index = FindIndex(os->Sheet); SheafManagerForm->Sheaf->GetCommonData(index); //¿­·ÁÀÖ´ø sheetÀÇ °ªµéÀ» Commondata¿¡ ³Ö¾îÁØ´Ù. SheafManagerForm->Sheaf->GetCommonData(beforetabindex); //by k3dogs(20001027). »õ·Î¿î sheet¸¦ ¿­¾úÀ» ¶§ ±âÁ¸ÀÇ commondata°¡ Áö¿öÁö´Â °É ¹æÁö. } if (cnt > 1) { SheafManagerForm->Sheaf->SetCommonData(cnt-1); } if (ViewForm->Visible) ViewForm->ShowBitmap(); TabControl1Resize(NULL); //AddSheet()¿¡¼­ TabIndex¸¦ ¹Ù²ãÁÙ¶§ ÇÔ.... Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); Registry->WriteString("Pathfst", ExtractFileDir(OpenDialog2->FileName)); delete Registry; } else { ShowMessage("Can't find file"); } } return; fail: ShowMessage("Add failed"); } //--------------------------------------------------------------------------- void __fastcall TMainForm::SheetDelete1Execute(TObject *Sender) { #ifdef READ_ONLY return; #endif if (SheafManagerForm->TreeView1->Selected->Level > 0) { SheafManagerForm->DeleteSheet(SheafManagerForm->TreeView1->Selected); if (ViewForm->Visible) ViewForm->ShowBitmap(); TabControl1Resize(NULL); UpdateMenu(); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::HelpAbout1Execute(TObject *Sender) { AboutBox->ShowModal(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::Panel1DockDrop(TObject *Sender, TDragDockObject *Source, int X, int Y) { if (Panel1->DockClientCount == 1) { Panel1->Width = 150; Splitter1->Cursor = crHSplit; Splitter1->Width = 3; Splitter1->ResizeStyle = rsLine; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::Panel1DockOver(TObject *Sender, TDragDockObject *Source, int X, int Y, TDragState State, bool &Accept) { TPoint ptClient(0, 0), ptScreen; if (Panel1->DockClientCount == 0) { ptScreen = Panel1->ClientToScreen(ptClient); Source->DockRect = Rect(ptScreen.x, ptScreen.y, ptScreen.x + 150, ptScreen.y + Panel1->Height); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::Panel1UnDock(TObject *Sender, TControl *Client, TWinControl *NewTarget, bool &Allow) { if (Panel1->DockClientCount == 1) { Panel1->Width = 1; Splitter1->Cursor = crDefault; Splitter1->Width = 1; Splitter1->ResizeStyle = rsNone; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::Panel2DockDrop(TObject *Sender, TDragDockObject *Source, int X, int Y) { if (Panel2->DockClientCount == 1) { Panel2->Width = 150; Splitter2->Cursor = crVSplit; Splitter2->Width = 3; Splitter2->ResizeStyle = rsLine; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::Panel2DockOver(TObject *Sender, TDragDockObject *Source, int X, int Y, TDragState State, bool &Accept) { TPoint ptClient(0, 0), ptScreen; if (Panel2->DockClientCount == 0) { ptScreen = Panel2->ClientToScreen(ptClient); Source->DockRect = Rect(ptScreen.x - 150, ptScreen.y, ptScreen.x + 3, ptScreen.y + Panel2->Height); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::Panel2UnDock(TObject *Sender, TControl *Client, TWinControl *NewTarget, bool &Allow) { if (Panel2->DockClientCount == 1) { Panel2->Width = 1; Splitter2->Cursor = crDefault; Splitter2->Width = 1; Splitter2->ResizeStyle = rsNone; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::TabControl1Change(TObject *Sender) { TPOpenSheet *os; int index; os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; index = FindIndex(os->Sheet); SheafManagerForm->Sheaf->SetCommonData(index); if (ReportDoc->Sheet) ReportDoc->Sheet->DeleteBitmap(); if (!(os->Sheet->MakeBitmap(ReportDoc->ZoomIn, ReportDoc->ZoomOut))) goto fail; ReportDoc->Sheet = os->Sheet; if (ViewForm->Visible) ViewForm->ShowBitmap(); TabControl1Resize(NULL); StatusBar1->Panels->Items[0]->Text = "Index : " + IntToStr(index+1); return; fail: if (ReportDoc->Sheet) { ReportDoc->Sheet->DeleteBitmap(); ReportDoc->Sheet = NULL; } ShowMessage("MakeBitmap fail!"); } //--------------------------------------------------------------------------- void __fastcall TMainForm::TabControl1Changing(TObject *Sender, bool &AllowChange) { int index; TPDocElement *sep; TPOpenSheet *os; UpdateMenu(); os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; index = FindIndex(os->Sheet); SheafManagerForm->Sheaf->GetCommonData(index); } //--------------------------------------------------------------------------- void __fastcall TMainForm::TabControl1Resize(TObject *Sender) { int sx, sy; int w, h, gs; if (ReportDoc->Sheet) { w = ReportDoc->Sheet->Range.right * ReportDoc->ZoomIn / ReportDoc->ZoomOut; h = ReportDoc->Sheet->Range.bottom * ReportDoc->ZoomIn / ReportDoc->ZoomOut; } else { w = TabControl1->Width; h = TabControl1->Height; } sx = w - TabControl1->Width + ScrollVert->Width; if (sx > 0) { ReportDoc->Width = TabControl1->Width - ScrollVert->Width - 8; ScrollHorz->Enabled = true; ScrollHorz->Max = sx*ReportDoc->ZoomOut/ReportDoc->ZoomIn + 8; // ScrollHorz->SmallChange = ReportDoc->GridSpace; //gridspace°¡ ÀÛÀ»°æ¿ì ¼Óµµ°¡ ´À¸±¼ö ÀÖ´Ù. // ScrollHorz->LargeChange = ReportDoc->GridSpace; gs = 16; ScrollHorz->SmallChange = gs; ScrollHorz->LargeChange = gs; } else { ReportDoc->Width = w; ScrollHorz->Enabled = false; ScrollHorz->Max = 0; } sy = h - TabControl1->Height + ScrollHorz->Height + Panel4->Height;//Edit->Height; if (sy > 0) { ReportDoc->Height = TabControl1->Height - ScrollHorz->Height - 28 - Panel4->Height; ScrollVert->Enabled = true; ScrollVert->Max = sy*ReportDoc->ZoomOut/ReportDoc->ZoomIn + 28; // ScrollVert->SmallChange = ReportDoc->GridSpace; // ScrollVert->LargeChange = ReportDoc->GridSpace; gs = 16; ScrollVert->SmallChange = gs; ScrollVert->LargeChange = gs; } else { ReportDoc->Height = h; ScrollVert->Enabled = false; ScrollVert->Max = 0; } ScrollHorz->Top = TabControl1->Height - ScrollHorz->Height - 4 - Panel4->Height; ScrollHorz->Width = ReportDoc->Width; ScrollVert->Left = TabControl1->Width - ScrollVert->Width - 4; ScrollVert->Height = ReportDoc->Height; ScrollVert->Position = 0; ScrollHorz->Position = 0; ReportDoc->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::ReportDocDblClick(TObject *Sender) { #ifdef READ_ONLY return; #endif 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 (ReportDoc->Sheet) { Modify = true; if (ReportDoc->Select(sp)) { sep = ReportDoc->GetSelectElement(); if (sep) { if (sep->Type == detInput) { binput = true; sep = ReportDoc->GetSelectElement(true); } else if (sep->Type == detChart) { sep = ReportDoc->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 *)ReportDoc->GetSelectElement(); if (ip->Method == dimAuto) { ReadSubText(ip, ImageDialog->FileName); } } ReportDoc->Repaint(); } } else if (et == detSheafImage) { if (ImageDialog->Execute()) { 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; ReportDoc->Repaint(); } } else if (et == detTextImage) { OpenDialog1->Filter = "Text File (*.txt)|*.txt"; 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; } ReportDoc->Repaint(); } else { ShowMessage("Can't find file"); } } } if (ViewForm->Visible) ViewForm->ShowBitmap(); } } } return; fail: ShowMessage("Cannot make Image"); } //--------------------------------------------------------------------------- void __fastcall TMainForm::ReportDocMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { #ifdef READ_ONLY return; #endif TPDocElement *sep; TPDocElementType et; TPDocInput *ip; TPDocSheet *st; AnsiString str; RECT rt; TPOpenSheet *os; int index; bool binput = false; if (ReportDoc->Sheet) { Modify = true; if (EType == E_ARROW) { 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); os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; index = FindIndex(os->Sheet); st = (TPDocSheet *)SheafManagerForm->Sheaf->GetSheet(index); st->AddArrow(rt, AType, pt[0], pt[1], Point(0, 0), daCenter2, str, Shape->Brush->Color); ((TPDocText *)st->Element->Items[ReportDoc->Sheet->Element->Count-1])->SetFont(DefaultFont, DefaultFont->Color); tp = pt[1]; // need here?? //==================================== Replace with UpdateMenu?? // EType = E_NONE; k3dogs step = 0; Memo->Enabled = false; Memo->Visible = false; //==================================== // if (!(os->Sheet->MakeBitmap(ReportDoc->ZoomIn, ReportDoc->ZoomOut))) goto fail; ReportDoc->Repaint(); } else { if (step == 2) { pt[2] = Point(X, pt[1].y); str = Memo->Text; rt = FindRect(true); os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; index = FindIndex(os->Sheet); st = (TPDocSheet *)SheafManagerForm->Sheaf->GetSheet(index); st->AddArrow(rt, AType, pt[0], pt[1], pt[2], daCenter2, str, Shape->Brush->Color); ((TPDocText *)st->Element->Items[ReportDoc->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(ReportDoc->ZoomIn, ReportDoc->ZoomOut))) goto fail; ReportDoc->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); os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; index = FindIndex(os->Sheet); st = (TPDocSheet *)SheafManagerForm->Sheaf->GetSheet(index); st->AddSheafImage(rt); ReportDoc->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); os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; index = FindIndex(os->Sheet); st = (TPDocSheet *)SheafManagerForm->Sheaf->GetSheet(index); st->AddSheafLabel(rt, daLeftTop, Memo->Text); ((TPDocText *)st->Element->Items[ReportDoc->Sheet->Element->Count-1])->SetFont(DefaultFont, DefaultFont->Color); ReportDoc->Repaint(); //================================= replace with updatemenu 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); os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; index = FindIndex(os->Sheet); st = (TPDocSheet *)SheafManagerForm->Sheaf->GetSheet(index); st->AddSheafLine(rt, LType, pt[0], pt[1], Shape->Brush->Color); ReportDoc->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); UpdateMenu(); if (ReportDoc->Select(sp)) { sep = ReportDoc->GetSelectElement(); if (sep->Type == detInput) { binput = true; sep = ReportDoc->GetSelectElement(true); } else if (sep->Type == detChart) { sep = ReportDoc->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 *)ReportDoc->GetSelectElement(); if (ip->Method == dimFix) 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; ReportDoc->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; } } } } return; fail: ShowMessage("MakeBitmap fail"); } //--------------------------------------------------------------------------- void __fastcall TMainForm::ReportDocMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { #ifdef READ_ONLY return; #endif TPDocElement *sep; StatusBar1->Panels->Items[0]->Text = "(" + IntToStr(X) + ", " + IntToStr(Y) + ")"; if (ReportDoc->Sheet) { ep = Point(X, Y); switch (EType) { case E_SIGNATURE: // sep = ReportDoc->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 = ReportDoc->GetSelectElement(); ((TPDocSignature *)sep)->DrawLine(sp, ep); ReportDoc->Repaint(); sp = ep; Modify = true; break; case E_ARROW: if (step == 1) { switch (AType) { case datSingle: case datBoth_Normal: case dat3Point: ep = Point(X, Y); break; case datBoth_Hor_Over: case datBoth_Hor_Below: ep = Point(X, pt[0].y); break; case datBoth_Ver_Left: case datBoth_Ver_Right: ep = Point(pt[0].x, Y); break; } DrawLine(); tp = ep; } else if (step == 2) { ep = Point(X, pt[1].y); DrawLine(); tp = ep; } Modify = true; break; case E_SHEAFIMAGE: if (step == 1) { DrawRect(); tp = ep; } Modify = true; break; case E_SHEAFLABEL: // ¶óº§ÀԷ¹öư(tbLabel)À» Ŭ¸¯ÇسõÀº°æ¿ì if (step == 1) { DrawRect(); tp = ep; } Modify = true; break; case E_SHEAFLINE: if (step == 1) { DrawLine(); tp = ep; } Modify = true; break; } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ReportDocMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { #ifdef READ_ONLY return; #endif TPDocElement *sep; if (ReportDoc->Sheet && EType == E_SIGNATURE) { sep = ReportDoc->GetSelectElement(); // ep = Point(X, Y); // ((TPDocSignature *)sep)->DrawLine(sp, ep); ReportDoc->Repaint(); EType = E_NONE; // DefaultSetting À¸·Î ȯ¿ø } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ViewImage(TTexpiaBitmap *tmp) { TImageViewForm *Form; Form = new TImageViewForm(this); Form->MakeBitmap(tmp); Form->ShowModal(); delete Form; } //--------------------------------------------------------------------------- void __fastcall TMainForm::ScrollHorzChange(TObject *Sender) { ReportDoc->PosX = ScrollHorz->Position; } //--------------------------------------------------------------------------- void __fastcall TMainForm::ScrollVertChange(TObject *Sender) { ReportDoc->PosY = ScrollVert->Position; } //--------------------------------------------------------------------------- /*void __fastcall TMainForm::Delete1Click(TObject *Sender) { TPOpenSheet *os; TPDocSheet *ds; int n; n = TabControl1->TabIndex; os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; OpenSheet->Remove(os); delete os; TabControl1->Tabs->Delete(n); //// if n is less than 0???? Á¤È®ÇÑ check°¡ ÇÊ¿äÇÔ... if (OpenSheet->Count > 0) { if (TabControl1->TabIndex == -1) TabControl1->TabIndex = 0; ds = ((TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex])->Sheet; if (!(ds->MakeBitmap(ReportDoc->ZoomIn, ReportDoc->ZoomOut))) goto fail; ReportDoc->Sheet = ds; if (ViewForm->Visible) ViewForm->ShowBitmap(); } else { ReportDoc->Sheet = NULL; if (ViewForm->Visible) ViewForm->Visible = false; // Visible = false; } if (ViewForm->Visible) ViewForm->ShowBitmap(); TabControl1Resize(NULL); UpdateMenu(); return; fail: if (ReportDoc->Sheet) { ReportDoc->Sheet->DeleteBitmap(); ReportDoc->Sheet = NULL; } ShowMessage("Make Bitmap fail!"); } */ //--------------------------------------------------------------------------- // Privete Methods //--------------------------------------------------------------------------- void __fastcall TMainForm::UpdateMenu() { if (IsReport) { SheafManagerForm->Visible = true; FileSave1->Enabled = false; FileSaveAs1->Enabled = false; FilePrint1->Enabled = false; SheetAdd1->Enabled = false; SheetMove1->Enabled = false; SheetDelete1->Enabled = false; ViewSheafManager1->Enabled = false; ViewPreview1->Enabled = false; DataRemove1->Enabled = false; DataClear1->Enabled = false; SewingTerm1->Enabled = false; Image->Enabled = false; DataView1->Enabled = false; DataEdit1->Enabled = false; tbArrow->Enabled = false; tbFont->Enabled = false; tbImage->Enabled = false; tbLabel->Enabled = false; tbLine->Enabled = false; tbPrint->Enabled = false; tbPreView->Enabled = false; ArrowPopup->AutoPopup = false; Zoom1->Enabled = false; Label1->Caption = ""; EditNumberExp1->Enabled = false; step = 0; bstr = ""; EType = E_NONE; bcursor = false; ReportDoc->ResetSelectElement(); Memo->Text = ""; Memo->Enabled = false; Memo->Visible = false; sbOK->Enabled = false; sbCancel->Enabled = false; CoolBar1->Enabled = false; CoolBar1->Visible = false; Tool1Execute->Enabled = false; if (SheafManagerForm->Sheaf) { if (SheafManagerForm->Sheaf->GetCount()) { FileSave1->Enabled = true; FileSaveAs1->Enabled = true; FilePrint1->Enabled = true; SheetDelete1->Enabled = true; ViewPreview1->Enabled = true; ArrowPopup->AutoPopup = true; tbArrow->Enabled = true; tbArrow->Down = false; tbImage->Enabled = true; tbLabel->Enabled = true; tbLine->Enabled = true; tbLine->Down = false; tbPrint->Enabled = true; tbPreView->Enabled = true; DataRemove1->Enabled = true; Zoom1->Enabled = true; Label1->Caption = RZoom; /* DataClear1->Enabled = true; DataView1->Enabled = true; */ EditNumberExp1->Enabled = true; if (SheafManagerForm->Sheaf->GetCount() > 1) SheetMove1->Enabled = true; } SheetAdd1->Enabled = true; ViewSheafManager1->Enabled = true; tbFont->Enabled = true; } } else { Arrange(SheafManagerForm); SheafManagerForm->Visible = false; FileSave1->Enabled = false; FileSaveAs1->Enabled = false; FilePrint1->Enabled = false; SheetAdd1->Enabled = false; SheetMove1->Enabled = false; SheetDelete1->Enabled = false; ViewSheafManager1->Enabled = false; ViewPreview1->Enabled = false; DataRemove1->Enabled = false; DataClear1->Enabled = false; SewingTerm1->Enabled = false; Image->Enabled = false; DataView1->Enabled = false; DataEdit1->Enabled = false; tbArrow->Enabled = false; tbFont->Enabled = false; tbImage->Enabled = false; tbLabel->Enabled = false; tbLine->Enabled = false; tbPrint->Enabled = false; tbPreView->Enabled = false; ArrowPopup->AutoPopup = false; Zoom1->Enabled = false; Label1->Caption = ""; EditNumberExp1->Enabled = false; step = 0; bstr = ""; EType = E_NONE; bcursor = false; ReportDoc->ResetSelectElement(); Memo->Text = ""; Memo->Enabled = false; Memo->Visible = false; sbOK->Enabled = false; sbCancel->Enabled = false; CoolBar1->Enabled = true; CoolBar1->Visible = true; Tool1Execute->Enabled = true; if (DesignDoc->Sheet) { FileSave1->Enabled = true; FileSaveAs1->Enabled = true; ViewPreview1->Enabled = true; tbPreView->Enabled = true; Zoom1->Enabled = true; Label1->Caption = DZoom; DataClear1->Enabled = true; tbFont->Enabled = true; } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::DeleteSheaf() { TPOpenSheet *os; while(TabControl1->Tabs->Count) { TabControl1->Tabs->Delete(TabControl1->Tabs->Count-1); } if (ReportDoc->Sheet) ReportDoc->Sheet = NULL; SheafManagerForm->DeleteSheaf(); if (OpenSheet) { while (OpenSheet->Count) { os = (TPOpenSheet *)OpenSheet->Last(); OpenSheet->Remove(os); delete os; } } } //--------------------------------------------------------------------------- // Public Methods //--------------------------------------------------------------------------- void __fastcall TMainForm::Arrange(TObject *Sender) { if (Panel1->DockClientCount == 1) { if (Sender == Panel1->DockClients[0]) { Panel1->Width = 1; Splitter1->Cursor = crDefault; Splitter1->Width = 1; Splitter1->ResizeStyle = rsNone; } } if (Panel2->DockClientCount == 1) { if (Sender == Panel2->DockClients[0]) { Panel2->Width = 1; Splitter2->Cursor = crDefault; Splitter2->Width = 1; Splitter2->ResizeStyle = rsNone; } } } //--------------------------------------------------------------------------- bool __fastcall TMainForm::AddSheet(TPDocSheet *stp) { int i; TPOpenSheet *os; for (i = 0; i < OpenSheet->Count; i++) { os = (TPOpenSheet *)OpenSheet->Items[i]; if (os->Sheet == stp) break; } if (ReportDoc->Sheet) { if (ReportDoc->Sheet->Bitmap) ReportDoc->Sheet->DeleteBitmap(); } if (i >= OpenSheet->Count) { if ((os = new TPOpenSheet) == NULL) goto fail; if (!(stp->MakeBitmap(ReportDoc->ZoomIn, ReportDoc->ZoomOut))) goto fail; os->Sheet = stp; OpenSheet->Add(os); TabControl1->TabIndex = TabControl1->Tabs->Add(stp->Title); } else { if (!(os->Sheet->MakeBitmap(ReportDoc->ZoomIn, ReportDoc->ZoomOut))) goto fail; TabControl1->TabIndex = i; } ReportDoc->Sheet = os->Sheet; return true; fail: if (os) delete os; return false; } //--------------------------------------------------------------------------- void __fastcall TMainForm::DeleteSheet(TPDocSheet *stp) { int i; TPOpenSheet *os; for (i = 0; i < OpenSheet->Count; i++) { os = (TPOpenSheet *)OpenSheet->Items[i]; if (os->Sheet == stp) { TabControl1->Tabs->Delete(i); // tabindex¿¡ °üÇÑ Á¤È®ÇÑ check°¡ ÇÊ¿ä..(i°¡ ¸Â³ª??) OpenSheet->Remove(os); delete os; if (ReportDoc->Sheet) ReportDoc->Sheet->DeleteBitmap(); if (OpenSheet->Count > 0) { if (TabControl1->TabIndex == -1) TabControl1->TabIndex = 0; ReportDoc->Sheet = ((TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex])->Sheet; if (!(ReportDoc->Sheet->MakeBitmap(ReportDoc->ZoomIn, ReportDoc->ZoomOut))) goto fail; } else { ReportDoc->Sheet = NULL; } break; } } return; fail: ShowMessage("MakeBitmap Fail!"); ReportDoc->Sheet = NULL; } //--------------------------------------------------------------------------- void __fastcall TMainForm::Tool1ExecuteClick(TObject *Sender) { ToolForm->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TMainForm::VeiwPreview1Execute(TObject *Sender) { if (!ViewForm->Visible) { if(IsReport) ViewForm->ShowBitmap(); else ViewForm->spReviewClick(NULL); } ViewForm->Visible = !ViewForm->Visible; } //--------------------------------------------------------------------------- bool __fastcall TMainForm::LoadImage(AnsiString str, TTexpiaBitmap *tbmp) { AnsiString ext, fn, dn; WORD bpp; TGraphicFileFormat ExtIndex; TPException ec = EC_NONE; dn = ExtractFileDir(str); fn = ExtractFileName(str); ext = LowerCase(ExtractFileExt(str)); ExtIndex = FindExtension(ext); if (ExtIndex == gffNON) { dn = fn + " is not supported"; ShowMessage(dn); return false; } if (ExtIndex == gffTEX || ExtIndex == gffKNT) { bpp = 8; } else { bpp = 24; } ec = InitFormFile(dn, fn, ExtIndex, bpp, tbmp); if (ec != EC_NONE) { ShowMessage("Loading Image Error"); return false; } return true; } //--------------------------------------------------------------------------- TGraphicFileFormat __fastcall TMainForm::FindExtension(AnsiString ext) { TGraphicFileFormat ExtIndex = gffNON; if (ext == ".tex") ExtIndex = gffTEX; else if (ext == ".tfc") ExtIndex = gffTFC; else if (ext == ".t3d") ExtIndex = gffT3D; else if (ext == ".wea") ExtIndex = gffWEA; else if (ext == ".wav") ExtIndex = gffWAV; else if (ext == ".knt") ExtIndex = gffKNT; else if (ext == ".bmp") ExtIndex = gffBMP; else if (ext == ".jpg") ExtIndex = gffJPG; else if (ext == ".pct") ExtIndex = gffPCT; else if (ext == ".pcx") ExtIndex = gffPCX; else if (ext == ".png") ExtIndex = gffPNG; else if (ext == ".psd") ExtIndex = gffPSD; else if (ext == ".ras") ExtIndex = gffRAS; else if (ext == ".tga") ExtIndex = gffTGA; else if (ext == ".tif") ExtIndex = gffTIF; else if (ext == ".eps") ExtIndex = gffEPS; else ExtIndex = gffNON; return ExtIndex; } //--------------------------------------------------------------------------- TPException __fastcall TMainForm::InitFormFile(AnsiString dn, AnsiString fn, TGraphicFileFormat ExtIndex, WORD bpp, TTexpiaBitmap *tbmp) { 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; if (tbmp == NULL) { // Load data in ReportTool sep = ReportDoc->GetSelectElement(); if ((sep->Type == detChart) || (sep->Type == detInput)) { sep = ReportDoc->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; goto fail; } if (ExtIndex==gffT3D) { 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; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, tpfh, tb))!=EC_NONE) goto fail; ci = tpfh.CanvasInfor; if (!(tbmp->Copy(tb, SRCCOPY))) { ec = EC_RESOURCE_LACK; goto fail; } CloseHandle(hFile); } else { if ((ec = LoadFromFile(FullPathName(dn, 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){ if (!(tbmp->Copy(tb, SRCCOPY))) { ec = EC_RESOURCE_LACK; goto fail; } } else { goto next; } } else { tb->ColorResolution(8, CRF_OPTIMIZEDPALETTE, NULL, 250); tb->GetColors(0, 256, rgb); next: Palette->ToRGBQUAD(rgb, 256); tbmp->PutColors(0, 256, rgb); memset(c, 0, 256); if (!tb->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!tbmp->StartScanLine()) { ec = EC_MEMORY_LACK; 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; goto fail; } } } } if (Palette) {delete Palette; Palette = NULL;} if (tb) {delete tb; tb = NULL;} return EC_NONE; fail: if (Palette) {delete Palette; Palette = NULL;} if (tb) {delete tb; tb = NULL;} return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainForm::LoadFromTexpiaFile(HANDLE fh, TEXPIAFILEHEADER &tpfh, TTexpiaBitmap *pBitmap, bool bTopLeft) { 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; if (!ReadFile(fh, &tpfh, sizeof(TEXPIAFILEHEADER), &dwRead, NULL)) goto fail; if (tpfh.Version.Texpia=='P' && tpfh.Version.Method=='T' && tpfh.Version.Number>=210) { if (!ReadFile(fh, &pPalette->UseColor, sizeof(Word), &dwRead, NULL)) goto fail; pPalette->LoadFromFileHandle((int)fh, 1); if (!ReadFile(fh, &BitCount, sizeof(WORD), &dwRead, NULL)) goto fail; if (SetFilePointer(fh, BitCount==8 ? 8000 : 24000, NULL, FILE_CURRENT)== 0xFFFFFFFF) goto fail; if (pBitmap) { if (!pBitmap->Create(tpfh.CanvasInfor.Width, tpfh.CanvasInfor.Height, tpfh.BitsPerPixel)) { ec = EC_MEMORY_LACK; 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; goto fail; } if ((src = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!ReadFile(fh, src, scan*pBitmap->Height, &dwRead, NULL)) goto fail; if (!pBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; 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; goto fail; } if (memory->lock()==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!memory->LoadFromFile(fh, tpfh.Compress)) goto fail; pBitmap->LoadFromMemory(memory->pointer(), w); delete memory; memory = NULL; } else { if (!(pBitmap->LoadFromTexpiaFile(fh, tpfh.Compress))) goto fail; } } } 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; goto fail; } if ((src = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!ReadFile(fh, src, scan*pBitmap->Height, &dwRead, NULL)) goto fail; if (!pBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; 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; goto fail; } if (memory->lock()==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!memory->LoadFromFile(fh, tpfh.Compress)) goto fail; pBitmap->LoadFromMemory(memory->pointer(), w); delete memory; memory = NULL; } else { if (!(pBitmap->LoadFromTexpiaFile(fh, tpfh.Compress))) goto fail; } } } } } 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; if (!ReadFile(fh, &pPalette->UseColor, sizeof(Word), &dwRead, NULL)) goto fail; 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((int)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((int)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; 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; 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; goto fail; } if ((src = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; 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; 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((int)fh, 0); if (SetFilePointer(fh, 6, NULL, FILE_CURRENT)==0xFFFFFFFF) goto fail; } } } if (pPalette) {delete pPalette; pPalette = NULL;} 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; return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainForm::LoadFromFile(AnsiString FileName, TGraphicFileFormat Index, TTexpiaBitmap *pBitmap, TPCanvasInfor &ci, bool &layer, WORD bpp) { TEXPIAFILEHEADER tpfh; int x, y; RGBQUAD rgb[256]; Byte c[256], *bp; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; if (Index==gffTEX || Index==gffTFC) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, tpfh, pBitmap))!= EC_NONE) goto fail; 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) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, tpfh, pBitmap, false))!= EC_NONE) goto fail; ci = tpfh.CanvasInfor; CloseHandle(hFile); } else { if (!pBitmap->LoadFromFile(FileName.c_str())) { ec = EC_FILE_NOT_READ; 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); } } return EC_NONE; fail: if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile); return ec; } //--------------------------------------------------------------------------- AnsiString __fastcall TMainForm::FullPathName(AnsiString dn, AnsiString fn) { char *str = dn.c_str(); if (str[dn.Length()-1] == '\\') return dn + fn; return dn + "\\" + fn; } //--------------------------------------------------------------------------- void __fastcall TMainForm::ArrowMenuClick(TObject *Sender) { #ifdef READ_ONLY return; #endif #ifdef LOCK_IFC if (!ProtectCard->CheckPassword()) { ShowMessage("Interface card doesn't exist."); Application->Terminate(); } #endif #ifdef LOCK_HASP ProtectCard->Read(); ProtectCard->Check(); #endif TMenuItem *Item = (TMenuItem *)Sender; UpdateMenu(); 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 = ""; #ifdef LOCK_HASP if (ProtectCard->isHacking) Application->Terminate(); #endif #ifdef LOCK_IFC if (!ProtectCard->CheckPassword()) { ShowMessage("Interface card doesn't exist."); Application->Terminate(); } #endif } //--------------------------------------------------------------------------- RECT __fastcall TMainForm::FindRect(bool bthreepoint) { 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 } return rt; } //--------------------------------------------------------------------------- void __fastcall TMainForm::DrawLine() { HDC hDC = ReportDoc->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 = SelectObject(hDC, hPen); nOldROP = SetROP2(hDC, R2_NOT); rt = Rect(sp.x, sp.y, tp.x, tp.y); rt = ReportDoc->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 = ReportDoc->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); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::DrawRect() { if (IsReport) { HDC hDC = ReportDoc->GetHandle(); HPEN hPen = NULL, hOldPen = NULL; HBRUSH hOldBrush = NULL; int nOldROP = 0; RECT rt; try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = SelectObject(hDC, hPen); hOldBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH)); nOldROP = SetROP2(hDC, R2_NOT); rt = Rect(sp.x, sp.y, tp.x, tp.y); rt = ReportDoc->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 = ReportDoc->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); } } else { RECT rt, tt; HDC hDC = DesignDoc->GetHandle(); HPEN hPen = NULL, hOldPen = NULL; HBRUSH hBrush = NULL, hOldBrush = NULL; int nOldROP = 0; try { hPen = CreatePen(psSolid, 1, clBlack); hOldPen = SelectObject(hDC, hPen); hOldBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH)); nOldROP = SetROP2(hDC, R2_NOT); rt = Rect(sp.x, sp.y, tp.x, tp.y); // for Windows rt = DesignDoc->ChangeRect(rt); Rectangle(hDC, rt.left, rt.top, rt.right+1, rt.bottom+1); SetROP2(hDC, R2_NOT); rt = Rect(sp.x, sp.y, ep.x, ep.y); rt = DesignDoc->ChangeRect(rt); Rectangle(hDC, rt.left, rt.top, rt.right+1, rt.bottom+1); } __finally { if (nOldROP) SetROP2(hDC, nOldROP); if (hOldBrush) SelectObject(hDC, hOldBrush); if (hOldPen) SelectObject(hDC, hOldPen); if (hPen) DeleteObject(hPen); } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::Panel4Resize(TObject *Sender) { Memo->Left = 5; Memo->Top = 3; Memo->Height = Panel4->Height - 6; Memo->Width = Panel4->Width - 150; // TabControl1Resize(NULL); } //--------------------------------------------------------------------------- void __fastcall TMainForm::MemoChange(TObject *Sender) { TPDocElement *sep; if(!Memo->Modified) return; sep = ReportDoc->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { sep = ReportDoc->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]); } else if (sep->Type == detTextImage) { return; } ReportDoc->Repaint(); //======================================= // ReportDoc->SelectElement->PaintReport(ReportDoc->SelectElement, ReportDoc->GetHandle(), // ReportDoc->GetViewStatus(), false, true, 0); //======================================== } } //--------------------------------------------------------------------------- void __fastcall TMainForm::sbCancelClick(TObject *Sender) { TPDocElement *sep; sep = ReportDoc->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { sep = ReportDoc->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; } } UpdateMenu(); ReportDoc->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::sbOKClick(TObject *Sender) { UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::SheetMove1Execute(TObject *Sender) { #ifdef READ_ONLY return; #endif SheafManagerForm->Move = true; } //--------------------------------------------------------------------------- void __fastcall TMainForm::ShapeMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { #ifdef READ_ONLY return; #endif TPDocElement *sep = NULL; if (ColorDialog1->Execute()) { Shape->Brush->Color = ColorDialog1->Color; if (ReportDoc->Sheet) { sep = ReportDoc->GetSelectElement(); if (sep) { if (sep->Type == detArrow) { ((TPDocArrow *)sep)->Color = Shape->Brush->Color; } else if (sep->Type == detSheafLine) { ((TPDocSheafLine *)sep)->Color = Shape->Brush->Color; } } } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::tbFontClick(TObject *Sender) { #ifdef READ_ONLY return; #endif TPDocElement *sep = NULL; sep = ReportDoc->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { sep = ReportDoc->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); ReportDoc->Repaint(); } } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::tbImageClick(TObject *Sender) { #ifdef READ_ONLY return; #endif UpdateMenu(); EType = E_SHEAFIMAGE; } //--------------------------------------------------------------------------- void __fastcall TMainForm::tbLabelClick(TObject *Sender) { #ifdef READ_ONLY return; #endif UpdateMenu(); EType = E_SHEAFLABEL; // LabelÇüÅÂÀÓ.. EType ´Â SheafElementType (enum ŸÀÔ) º¯¼öÀÓ if (DefaultFont) Memo->Font->Assign(DefaultFont); Memo->Enabled = true; Memo->Visible = true; } //--------------------------------------------------------------------------- int __fastcall TMainForm::FindIndex(TPDocSheet *ts) { int i, cnt; TPDocSheet *sheet; cnt = SheafManagerForm->Sheaf->GetCount(); for (i = 0 ; i < cnt ; i++) { sheet = SheafManagerForm->Sheaf->GetSheet(i); if (sheet == ts) { return i; } } ShowMessage("Can't find sheet"); return -1; } //--------------------------------------------------------------------------- TPDocSheet * __fastcall TMainForm::FindOpenSheet() { TPOpenSheet *os; if (TabControl1->TabIndex >= 0) { os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; return os->Sheet; } else { return NULL; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ReadSubText(TPDocInput *ip, AnsiString fn) { AnsiString dir, filename, expression, expdir; TIniFile *TExpressionIni = NULL; TRegistry *Registry; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexWork",TRUE); expdir = Registry->ReadString("Path") + "\\Program"; delete Registry; dir = ExtractFileDir(fn); filename = ExtractFileName(fn); TExpressionIni = new TIniFile(expdir + "\\Expression.ini"); // expdir --->define directory..... expression = TExpressionIni->ReadString(dir, filename, ""); ip->SetInputText(expression); } //--------------------------------------------------------------------------- void __fastcall TMainForm::TabRemove1Execute(TObject *Sender) { TPDocSheet *st; TPDocElement *sep; TPDocSignature *sig; TPDocArrow *arr; TPOpenSheet *os; int index; os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; index = FindIndex(os->Sheet); SheafManagerForm->Sheaf->GetCommonData(index); OpenSheet->Remove(os); delete os; TabControl1->Tabs->Delete(TabControl1->TabIndex); if (OpenSheet->Count) { TabControl1->TabIndex = 0; TabControl1Change(NULL); } else { TabControl1->TabIndex = -1; ReportDoc->Sheet->DeleteBitmap(); ReportDoc->Sheet = NULL; } UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::SelectDataClearExecute(TObject *Sender) { #ifdef READ_ONLY return; #endif TPDocSheet *st; TPDocElement *sep; TPDocSignature *sig; TPDocArrow *arr; TPOpenSheet *os; if (ReportDoc->Select(sp)) { sep = ReportDoc->GetSelectElement(); if (sep->Type == detInput || sep->Type == detChart) { sep = ReportDoc->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) { ReportDoc->RemoveSelect(); } else if (sep->Type == detImage) { if (((TPDocImage *)sep)->Image != NULL) { delete ((TPDocImage *)sep)->Image; ((TPDocImage *)sep)->Image = NULL; } } ReportDoc->Repaint(); } UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::SewingTerm1Execute(TObject *Sender) { #ifdef READ_ONLY return; #endif int cnt, i, dk, sk; // AnsiString str; AnsiString tmp; AnsiString ktext, etext, itext, ctext, jtext; TPDocElement *sep; TSewingForm *Form; /* sep = ReportDoc->GetSelectElement(); if (sep->Type == detInput || sep->Type == detChart) { sep = ReportDoc->GetSelectElement(true); } if (sep->Type == detArrow || sep->Type == detEdit || sep->Type == detSheafLabel) { Form = new TSewingForm(this); if ((Form->ShowModal()) == mrOk){ cnt = Form->STListBox->Items->Count; // dk = Form->dk; // sk = Form->sk; for (i=0; iSTListBox->Selected[i]) { // str = Form->STListBox->Items->Strings[i]; ktext = Form->STListBox->Items->Strings[i]; // input value in etext, itext, ctext, jtext if (sep->Type == detArrow) { // ((TPDocArrow *)sep)->Text = str; ((TPDocArrow *)sep)->SetText(ktext, etext, itext, ctext, jtext); } else if (sep->Type == detEdit) { // ((TPDocEdit *)sep)->Text = str; ((TPDocEdit *)sep)->SetText(ktext, etext, itext, ctext, jtext); } else if (sep->Type == detSheafLabel) { // ((TPDocSheafLabel *)sep)->Text = str; ((TPDocSheafLabel *)sep)->SetText(ktext, etext, itext, ctext, jtext); } // Memo->Text = str; Memo->Text = ktext; break; } } } delete Form; } */ sep = ReportDoc->GetSelectElement(); if (sep->Type == detInput || sep->Type == detChart) { sep = ReportDoc->GetSelectElement(true); } if (sep->Type == detArrow || sep->Type == detEdit || sep->Type == detSheafLabel) { Form = new TSewingForm(this); if ((Form->ShowModal()) == mrOk){ // ============================================ Form->GetText( ktext , etext, itext, ctext, jtext); tmp = Memo->Text + ktext ; // ============================================ if (sep->Type == detArrow) { // ((TPDocArrow *)sep)->SetText(tmp , etext, itext, ctext, jtext); ((TPDocArrow *)sep)->SetText(tmp , Memo->Text + etext, Memo->Text + itext, Memo->Text + ctext, Memo->Text + jtext); } else if (sep->Type == detEdit) { ((TPDocEdit *)sep)->SetText(tmp , Memo->Text + etext, Memo->Text + itext, Memo->Text + ctext, Memo->Text + jtext); } else if (sep->Type == detSheafLabel) { ((TPDocSheafLabel *)sep)->SetText(tmp , Memo->Text + etext, Memo->Text + itext, Memo->Text + ctext, Memo->Text + jtext); } Memo->Text = tmp ; } delete Form; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ImageView1Execute(TObject *Sender) { TPDocElement *sep; TTexpiaBitmap *tmp = NULL; sep = ReportDoc->GetSelectElement(); if (sep->Type == detInput || sep->Type == detChart) { sep = ReportDoc->GetSelectElement(true); } if (sep->Type == detImage) { tmp = ((TPDocImage *)sep)->Image; } else if (sep->Type == detSheafImage) { tmp =((TPDocSheafImage *)sep)->Image; } if (tmp) ViewImage(tmp); } //--------------------------------------------------------------------------- void __fastcall TMainForm::DataEdit1Execute(TObject *Sender) { #ifdef READ_ONLY return; #endif AnsiString tdir, dir, fn, fndir, ext; TPDocElement *sep; SHELLEXECUTEINFO info; sep = ReportDoc->GetSelectElement(); if (sep->Type == detInput || sep->Type == detChart) { sep = ReportDoc->GetSelectElement(true); } if (sep->Type == detImage) fn = ((TPDocImage *)sep)->ImgDir; else if (sep->Type == detSheafImage) fn = ((TPDocSheafImage *)sep)->ImgDir; ext = LowerCase(ExtractFileExt(fn)); // dir = "C:\\Texpro_W\\Professional\\Textile"; // dir = "C:\\Program Files\\YoungWoo\\TexPro7.1\\Bin\\Textile"; // Professional dir = Texpro_Path ; // Academy fndir = "\"" + fn + "\""; memset(&info, 0, sizeof(info)); // ¸Þ¸ð¸® Å©±âÇÏ°í ¹«½¼ °ü°è°¡ ÀÖ´ÂÁö.... info.cbSize = sizeof(info); // Å©°Ô Àâ¾Æµµ µÇ³ª??? info.lpVerb = "open"; info.lpFile = "Textile.exe"; info.lpDirectory = dir.c_str(); info.lpParameters = fndir.c_str(); info.fMask = SEE_MASK_NOCLOSEPROCESS; info.nShow = SW_SHOWDEFAULT; if (!ShellExecuteEx(&info)) { ShowMessage("Could not Create Process"); return; } Application->Minimize(); WaitForSingleObject(info.hProcess, INFINITE); Application->Restore(); if (FileExists(fn)) { if (sep->Type == detImage) { if (((TPDocImage *)sep)->Image != NULL) { delete ((TPDocImage *)sep)->Image; ((TPDocImage *)sep)->Image = NULL; } if ((((TPDocImage *)sep)->Image = new TTexpiaBitmap) == NULL) goto fail; if (!LoadImage(fn)) goto fail; } else if (sep->Type == detSheafImage) { if (((TPDocSheafImage *)sep)->Image != NULL) { delete ((TPDocSheafImage *)sep)->Image; ((TPDocSheafImage *)sep)->Image = NULL; } if ((((TPDocSheafImage *)sep)->Image = new TTexpiaBitmap) == NULL) goto fail; if (!LoadImage(fn)) goto fail; } } else { ShowMessage("Can't find file"); } return; fail: if (sep->Type == detImage) { if (((TPDocImage *)sep)->Image != NULL) { delete ((TPDocImage *)sep)->Image; ((TPDocImage *)sep)->Image = NULL; } } else if (sep->Type == detSheafImage) { if (((TPDocSheafImage *)sep)->Image != NULL) { delete ((TPDocSheafImage *)sep)->Image; ((TPDocSheafImage *)sep)->Image = NULL; } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::MemoKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { TPDocElement *sep; TPDocElementType et; POINT mp; bool notarrow; RECT rt; int th; sep = ReportDoc->GetSelectElement(); if (Key == VK_RETURN) { if (sep) { if (sep->Type == detInput || sep->Type == detChart) { sep = ReportDoc->GetSelectElement(true); } if (sep->Type == detEdit || sep->Type == detDate || sep->Type == detNumber || sep->Type == detFormula) { UpdateMenu(); } } } else if (Key == VK_F1) { FindNextItem(); } /////////////////////////////////////////////////////////////////////////qe //text ÀԷ½à Ŀ¼­¸¦ µû¶ó focus°¡ À̵¿Çϵµ·Ï ÇÏ´Â ·ÎÁ÷..¾à°£ ÇãÁ¢^^; ³ª¿À´Â ¼ýÀÚµéÀº ´ëºÎºÐ °¨À¸·Î ¶§·ÁÀâ¾ÒÀ½ cp = Memo->CaretPos; if(sep->Type == detArrow || sep->Type == detSheafLine || sep->Type == detMemo){ GetTextHeight(); rt = GetTextLength(); } notarrow = GetTextStartPoint(); if (notarrow) { if(sep->Type == detMemo){ rt = ReportDoc->ChangeRect(rt); th = rt.bottom - rt.top + H/3; while (th < (cp.y+1)*H) { cp.y--; } } mp = ReportDoc->ChangePoint(Point(tsp.x+W+4, tsp.y+(cp.y)*H)); if(Key == VK_RETURN) mp = ReportDoc->ChangePoint(Point(tsp.x+4, tsp.y +(cp.y+1)*H)); mp.y += 24; } else { mp = ReportDoc->ChangePoint(Point(tsp.x+4, tsp.y+H)); mp.y += 24; } if (mp.x > ReportDoc->Width - 10) { if(notarrow &&(Key !=VK_RETURN)){ReportDoc->PosX = tsp.x +W - 300;} else {ReportDoc->PosX = tsp.x -300;} if (ReportDoc->PosX >= ReportDoc->Sheet->Bitmap->Width - ReportDoc->Width) ReportDoc->PosX = ReportDoc->Sheet->Bitmap->Width - ReportDoc->Width; ScrollHorz->Position = ReportDoc->PosX; } else if(mp.x < 10) { if(notarrow &&(Key !=VK_RETURN)) {ReportDoc->PosX = tsp.x + W - 200;} else {ReportDoc->PosX = tsp.x - 200;} ScrollHorz->Position = ReportDoc->PosX; } if (mp.y > ReportDoc->Height) { if(notarrow) {ReportDoc->PosY = tsp.y +(cp.y +1)*H -200;} else {ReportDoc->PosY = tsp.y +H -200;} if (ReportDoc->PosY >= ReportDoc->Sheet->Bitmap->Height - ReportDoc->Height) ReportDoc->PosY = ReportDoc->Sheet->Bitmap->Height- ReportDoc->Height; ScrollVert->Position = ReportDoc->PosY; } else if(mp.y <10) { if(notarrow) {ReportDoc->PosY = tsp.y +(cp.y)*H - 200;} else {ReportDoc->PosY = tsp.y + H -200;} ScrollVert->Position = ReportDoc->PosY; } ////////////////////////////////////////////////////////////////////////////////qe } //--------------------------------------------------------------------------- void __fastcall TMainForm::Timer1Timer(TObject *Sender) { /* HBRUSH hOldBrush; HPEN hOldPen, hPen; int nDrawMode; int th; POINT tp, mp; RECT rt; bool notarrow; if (bcursor) { HDC hDC = ReportDoc->GetHandle(); hOldBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH)); hOldPen = 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 = ReportDoc->ChangeRect(rt); //???? th = rt.bottom - rt.top + H/3; // H/3 --->¿©À¯ºÐÀ» À§Çؼ­... while (th < (cp.y+1)*H) { cp.y--; } mp = ReportDoc->ChangePoint(Point(tsp.x+W+4, tsp.y+cp.y*H)); tp = ReportDoc->ChangePoint(Point(tsp.x+W+4, tsp.y+(cp.y+1)*H)); mp.y += 24; // 24->tab control¿¡¼­ tabÀÇ ³ôÀÌ tp.y += 24; } else { mp = ReportDoc->ChangePoint(Point(tsp.x+4, tsp.y)); tp = ReportDoc->ChangePoint(Point(tsp.x+4, tsp.y+H)); mp.y += 24; tp.y += 24; } if (mp.x < 4) return; // ReportDoc->Left if (mp.y < 24) mp.y = 24; // ReportDoc->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); // for (th=0; th<8000; th++) // Ä¿¼­ ±ôºýÀÓÀ» Á¶ÀýÇϱâ À§Çؼ­.... // th++; Sleep(500); // ReportDoc->Repaint(); // for (th=0; th<8000; th++) // th++; // ReportDoc->Repaint(); ReportDoc->Refresh(); //======================================= // ReportDoc->SelectElement->PaintReport(ReportDoc->SelectElement, ReportDoc->GetHandle(), // ReportDoc->GetViewStatus(), false, true, 0); //======================================== } */ if (bcursor) { //modified by k3dogs(20001026) TPDocEdit¿¡ ÀÔ·ÂÇÒ °æ¿ì //bcursorÀÌ ÂüÀÌ µÇ°í, bCaretOn °ªÀ» ¹ÝÀü½ÃÄѼ­ Ä¿¼­¸¦ ±ôºýÀÌ°Ô Çß´Ù. bCaretOn = !bCaretOn; HBRUSH hOldBrush; HPEN hOldPen, hPen; int nDrawMode; int th; POINT tp, mp; RECT rt; bool notarrow; ReportDoc->Refresh(); if (bCaretOn) { HDC hDC = ReportDoc->GetHandle(); hOldBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH)); hOldPen = SelectObject(hDC, GetStockObject(WHITE_PEN)); nDrawMode = GetROP2(hDC); SetROP2(hDC, R2_NOT); cp = Memo->CaretPos; //Element³»ÀÇ Ä¿¼­ÀÇ »ó´ë ÁÂÇ¥, Áß½ÉÀÌ (0,0) GetTextHeight(); // Çѹø¸¸ ±¸ÇÏ¸é µÈ´Ù. ±×·±µ¥..... rt = GetTextLength(); // GetTextHeight¿¡ ³ÖÀ¸¸é ÀÌ»óÇÑ °á°ú°¡ ³ªÅ¸³²... notarrow = GetTextStartPoint(); // edit, sheafedit¿¡¼­ center Á¤·ÄÀ̳ª right Á¤·ÄÀÇ °æ¿ì..¹®Á¦°¡ µÊ... if (notarrow) { rt = ReportDoc->ChangeRect(rt); //½ºÅ©¸° »ó¿¡¼­ÀÇ ElementÀÇ ÁÂÇ¥ th = rt.bottom - rt.top + H/3; // H/3 --->¿©À¯ºÐÀ» À§Çؼ­... while (th < (cp.y+1)*H) { cp.y--; } mp = ReportDoc->ChangePoint(Point(tsp.x+W+4, tsp.y+cp.y*H)); tp = ReportDoc->ChangePoint(Point(tsp.x+W+4, tsp.y+(cp.y+1)*H)); mp.y += 24; // 24->tab control¿¡¼­ tabÀÇ ³ôÀÌ tp.y += 24; } else { mp = ReportDoc->ChangePoint(Point(tsp.x+4, tsp.y)); tp = ReportDoc->ChangePoint(Point(tsp.x+4, tsp.y+H)); mp.y += 24; tp.y += 24; } if (mp.x < 4) return; // ReportDoc->Left if (mp.y < 24) mp.y = 24; // ReportDoc->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); } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::GetTextHeight() { HDC hDC; HFONT hOldFont; TPDocElement *sep; TFont *SFont; TEXTMETRIC tm; AnsiString str, text; RECT rt; SIZE size; sep = ReportDoc->GetSelectElement(); if (sep) { if (sep->Type == detInput ||sep->Type == detChart) sep = ReportDoc->GetSelectElement(true); } hDC = ReportDoc->GetHandle(); SFont = sep->GetFont(); hOldFont = SelectObject(hDC, SFont->Handle); GetTextMetrics(hDC, &tm); H = tm.tmHeight; SelectObject(hDC, hOldFont); /* GetTextMetrics(Memo->Handle, &tm); H = tm.tmHeight; */ } //--------------------------------------------------------------------------- RECT __fastcall TMainForm::GetTextLength() { int i; SIZE size; HDC hDC = NULL; AnsiString str, text; RECT rt, pt; TFont *SF; TPDocElement *sep; HFONT hOldFont; sep = ReportDoc->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { pt = sep->Range; sep = ReportDoc->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 = ReportDoc->GetHandle(); text = Memo->Lines->Strings[cp.y]; hOldFont = SelectObject(hDC, SF->Handle); GetTextExtentPoint32(hDC, text.c_str(), text.Length(), &size); LW = size.cx; if (cp.x > 0) { str = text.SubString(1, cp.x); GetTextExtentPoint32(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); return rt; } //--------------------------------------------------------------------------- bool __fastcall TMainForm::GetTextStartPoint() { TPDocElement *sep; TPDocArrow *saw; RECT rt, pt; TPDocAlign al; AnsiString text; int mm = 0, mcnt; bool notarrow = true; sep = ReportDoc->GetSelectElement(); if (sep) { if (sep->Type == detInput || sep->Type == detChart) { pt = sep->Range; sep = ReportDoc->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); } } return notarrow; } //--------------------------------------------------------------------------- void __fastcall TMainForm::FindNextItem() { int index = -1, indexcnt, cnt, ccnt, k, i, gp; POINT np; TShiftState Shift; TPDocElement *sep, *ip, *cp; TPDocInput *iep; TPDocChart *cep; gp = ReportDoc->GridSpace; cnt = ReportDoc->Sheet->Element->Count; indexcnt = ReportDoc->Sheet->IndexCount; sep = ReportDoc->GetSelectElement(); if (sep->Type == detInput || sep->Type == detChart) sep = ReportDoc->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) 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!"); return; next: ReportDocMouseDown(ReportDoc, mbLeft, Shift, np.x, np.y); MoveFocus(np, ReportDoc->Width, ReportDoc->Height, //by k3dogs(2000/10/26) ReportDoc->Sheet->Bitmap->Width, ReportDoc->Sheet->Bitmap->Height); //F1 Key ´­·¶À» ¶§ È­¸éÀ̵¿ } //--------------------------------------------------------------------------- //---------------------------------------------------------------------------Made by k3dogs(2000/10/25) F1Ű ´©¸¦¶§ Æ÷Ä¿½º(È­¸é) À̵¿. void __fastcall TMainForm::MoveFocus(POINT np, int ReportWidth, int ReportHeight, int SheetWidth, int SheetHeight) { // long x, y; if ((np.x + 100 > ReportDoc->PosX + ReportWidth ) || (np.x < ReportDoc->PosX)) { ReportDoc->PosX = np.x - 50; if (ReportDoc->PosX >= SheetWidth - ReportWidth) { ReportDoc->PosX = SheetWidth - ReportWidth; } else if (ReportDoc->PosX <= 500) { ReportDoc->PosX = 0; } else { ReportDoc->PosX = np.x - 50; } ScrollHorz->Position = ReportDoc->PosX; } if ((np.y + 100 > ReportDoc->PosY + ReportHeight) || (np.y < ReportDoc->PosY)) { ReportDoc->PosY = np.y - 50; if (ReportDoc->PosY >= SheetHeight - ReportHeight){ ReportDoc->PosY = SheetHeight- ReportHeight; } else if (ReportDoc->PosY <= 500) { ReportDoc->PosY = 0; } else { ReportDoc->PosY = np.y - 50; } ScrollVert->Position = ReportDoc->PosY; } // ScrollHorz->Position = np.x; // ScrollVert->Position = np.y; // TabControl1Resize(NULL); } //--------------------------------------------------------------------------- bool __fastcall TMainForm::ReadDataText(AnsiString fn) { AnsiString ext, ss, temp, text; FILE *in; char *ch; int cnt; ext = LowerCase(ExtractFileExt(fn)); if (ext != ".kdo") return false; ss = "rt"; in = fopen(fn.c_str(), ss.c_str()); ch = temp.c_str(); Memo->Text = ""; while (fgets(ch, 10000, in) != NULL) { text = ch; cnt = text.Length(); text = text.SubString(1, cnt-1); Memo->Lines->Add(text); } fclose(in); return true; } //--------------------------------------------------------------------------- void __fastcall TMainForm::DrawDataText(RECT rt, TTexpiaBitmap *bmp) { int i, w, h, cnt, size = 14; SIZE s; HDC hDC = NULL; HFONT hOldFont = NULL; TFont *Font; TEXTMETRIC tm; AnsiString str; bool changesize = false; w = rt.right-rt.left - 6; // Image°¡ Ãà¼Ò ¶Ç´Â È®´ëµÇ´Â °ÍÀ» ¸·±â À§ÇØ Å©±â¸¦ °°°Ô ÇÔ.. h = rt.bottom-rt.top - 6; if (!bmp->Create(w, h, 24)) goto fail; if ((hDC = bmp->CreateDC()) == NULL) goto fail; bmp->FillRect(Rect(0, 0, w, h), clWhite); Font = new TFont; Font->Charset = DEFAULT_CHARSET; Font->Name = "¹ÙÅÁü"; // ¾î¶»°Ô ÇØ¾ß ÇÏ´ÂÁö.... Font->Size = size; hOldFont = SelectObject(hDC, Font->Handle); GetTextMetrics(hDC, &tm); cnt = Memo->Lines->Count; h -= 6; w -= 6; // gab is 3 (top and bottom); while (cnt*tm.tmHeight > h) { // check height size--; if (size < 8) goto fail; SelectObject(hDC, hOldFont); Font->Size = size; hOldFont = SelectObject(hDC, Font->Handle); GetTextMetrics(hDC, &tm); } for (i=0; iLines->Strings[i]; GetTextExtentPoint32(hDC, str.c_str(), str.Length(), &s); while (s.cx > w) { size--; if (size < 8) goto fail; changesize = true; SelectObject(hDC, hOldFont); Font->Size = size; hOldFont = SelectObject(hDC, Font->Handle); GetTextExtentPoint32(hDC, str.c_str(), str.Length(), &s); } } if (changesize) { GetTextMetrics(hDC, &tm); } rt = Rect(0, 0, w+6, h+6); for (i=0; iLines->Strings[i]; ExtTextOut(hDC, 3, 3+tm.tmHeight*i, ETO_CLIPPED, &rt, str.c_str(), str.Length(), NULL); } SelectObject(hDC, hOldFont); if (Font) delete Font; bmp->DeleteDC(hDC); return; fail: ShowMessage("Size is too small!"); if (hOldFont) SelectObject(hDC, hOldFont); if (Font) delete Font; if (bmp) { if (hDC)bmp->DeleteDC(hDC); delete bmp; bmp = NULL; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::LineItemClick(TObject *Sender) { #ifdef READ_ONLY return; #endif #ifdef LOCK_IFC if (!ProtectCard->CheckPassword()) { ShowMessage("Interface card doesn't exist."); Application->Terminate(); } #endif #ifdef LOCK_HASP ProtectCard->Read(); ProtectCard->Check(); #endif TMenuItem *Item = (TMenuItem *)Sender; UpdateMenu(); switch (Item->Tag) { case 0: LType = dsltNormal; break; case 1: LType = dsltDash; break; case 2: LType = dsltThick; break; } tbLine->Down = true; EType = E_SHEAFLINE; #ifdef LOCK_HASP if (ProtectCard->isHacking) Application->Terminate(); #endif } //--------------------------------------------------------------------------- void __fastcall TMainForm::ZoomClick(TObject *Sender) { AnsiString str; TMenuItem *Item = (TMenuItem *)Sender; UpdateMenu(); if (IsReport) { switch (Item->Tag) { case 0: ReportDoc->SetZoom(5, 4); str = " 125% "; break; case 1: ReportDoc->SetZoom(1, 1); str = " 100% "; break; case 2: ReportDoc->SetZoom(3, 4); str = " 75% "; break; case 3: ReportDoc->SetZoom(2, 4); str = " 50% "; break; } Label1->Caption = "Zoom " + str; RZoom = "Zoom " + str; ReportDoc->Sheet->MakeBitmap(ReportDoc->ZoomIn, ReportDoc->ZoomOut); TabControl1Resize(NULL); } else { switch (Item->Tag) { case 0: DesignDoc->SetZoom(5, 4); str = " 125% "; break; case 1: DesignDoc->SetZoom(1, 1); str = " 100% "; break; case 2: DesignDoc->SetZoom(3, 4); str = " 75% "; break; case 3: DesignDoc->SetZoom(2, 4); str = " 50% "; break; } Label1->Caption = "Zoom " + str; DZoom = "Zoom " + str; ChangeSize(); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::SetNumExpression(bool all) { int i, j, k, ocnt, scnt, ccnt; TPOpenSheet *os; TPDocElement *sep, *csep; TPDocChart *cep; TPDocInput *iep; if (!OpenSheet) return; if (all) { ocnt = OpenSheet->Count; for (i=0; iItems[i]; scnt = os->Sheet->Element->Count; for (j=0; jSheet->Element->Items[j]; switch (sep->Type) { case detNumber: ((TPDocNumber *)sep)->Decimal = Decimal; break; case detFormula: ((TPDocFormula *)sep)->Decimal = Decimal; break; case detInput: iep = (TPDocInput *)sep; if (iep->IPElement->Type == detNumber) { ((TPDocNumber *)iep->IPElement)->Decimal = Decimal; } else if (iep->IPElement->Type == detFormula) { ((TPDocFormula *)iep->IPElement)->Decimal = Decimal; } break; case detChart: cep = (TPDocChart *)sep; ccnt = cep->Cell->Count; for (k=0; kCell->Items[k]; if (csep->Type == detNumber) { ((TPDocNumber *)csep)->Decimal = Decimal; } else if (csep->Type == detFormula) { ((TPDocFormula *)csep)->Decimal = Decimal; } } break; } } } } else { os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; scnt = os->Sheet->Element->Count; for (j=0; jSheet->Element->Items[j]; switch (sep->Type) { case detNumber: ((TPDocNumber *)sep)->Decimal = Decimal; break; case detFormula: ((TPDocFormula *)sep)->Decimal = Decimal; break; case detInput: iep = (TPDocInput *)sep; if (iep->IPElement->Type == detNumber) { ((TPDocNumber *)iep->IPElement)->Decimal = Decimal; } else if (iep->IPElement->Type == detFormula) { ((TPDocFormula *)iep->IPElement)->Decimal = Decimal; } break; case detChart: cep = (TPDocChart *)sep; ccnt = cep->Cell->Count; for (k=0; kCell->Items[k]; if (csep->Type == detNumber) { ((TPDocNumber *)csep)->Decimal = Decimal; } else if (csep->Type == detFormula) { ((TPDocFormula *)csep)->Decimal = Decimal; } } break; } } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::EditNumberExp1Execute(TObject *Sender) { TNumExpForm *Form = new TNumExpForm(this); Form->cbDecimal->ItemIndex = 0; Form->cbSheet->ItemIndex = 0; if (Form->ShowModal() == mrOk) { if (Form->cbDecimal->ItemIndex) Decimal = false; else Decimal = true; if (Form->cbSheet->ItemIndex) SetNumExpression(true); else SetNumExpression(false); ReportDoc->Repaint(); } if (Form) delete Form; } //--------------------------------------------------------------------------- void __fastcall TMainForm::PutCommonData() { int cnt, i; cnt = SheafManagerForm->Sheaf->GetCount(); for (i=0; iSheaf->SetCommonData(i); } //---------------------------------------------------made by k3dog(20001027)preview formÀÌ ¶ç¿öÁ® ÀÖÀ¸¸é void __fastcall TMainForm::ReportRePaint() //ÀÜ»óÀÌ ³²¾Æ¼­ (<-- ÀÌÀ¯´Â ¾Ë ¼ö ¾ø´Ù.) { //TMainForm::TabControl1Change ¸¦ µû¼­ ¸¸µé¾ú´Ù. TPOpenSheet *os; //TViewForm::ShowBitmap()¿¡¼­ È£ÃâÇÑ´Ù. int index; // os = (TPOpenSheet *)OpenSheet->Items[TabControl1->TabIndex]; index = FindIndex(os->Sheet); SheafManagerForm->Sheaf->SetCommonData(index); if (ReportDoc->Sheet) ReportDoc->Sheet->DeleteBitmap(); if (!(os->Sheet->MakeBitmap(ReportDoc->ZoomIn, ReportDoc->ZoomOut))) goto fail; ReportDoc->Sheet = os->Sheet; TabControl1Resize(NULL); return; fail: if (ReportDoc->Sheet) { ReportDoc->Sheet->DeleteBitmap(); ReportDoc->Sheet = NULL; } ShowMessage("MakeBitmap fail!"); } //---------------------------------------------------------------------------s void __fastcall TMainForm::tbArrowMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { EType = E_NONE; UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::tbLineClick(TObject *Sender) { EType = E_NONE; UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose) { if (Modify){ AnsiString msg; msg = ReportFileName; int Btn = MessageDlg("Save Change to " + msg, mtWarning, TMsgDlgButtons()<Sheet == NULL) DesignCreate(); TabControl1->SendToBack(); ScrollBox1->BringToFront(); ToolChange->Caption = "To ReportTool"; if(ToolForm) ToolForm->Visible = true; else ToolForm = new TToolForm(this); if(DesignDoc->Sheet){ StatusBar1->Panels->Items[1]->Text = CurrentSelect; if(DesignDoc->Sheet->Title == "") StatusBar1->Panels->Items[2]->Text = "No Title"; else StatusBar1->Panels->Items[2]->Text = DesignDoc->Sheet->Title; StatusBar1->Panels->Items[3]->Text = DesignFileName; }else { StatusBar1->Panels->Items[1]->Text = ""; StatusBar1->Panels->Items[2]->Text = ""; StatusBar1->Panels->Items[3]->Text = ""; } } else { //DesignTool ¿¡¼­ ReportTool ·Î IsReport = true; ScrollBox1->SendToBack(); TabControl1->BringToFront(); ToolChange->Caption = "To DesignTool"; if(ToolForm) ToolForm->Visible = false; CurrentSelect = StatusBar1->Panels->Items[1]->Text; if(ReportDoc->Sheet){ StatusBar1->Panels->Items[1]->Text = ""; if(ReportDoc->Sheet->Title == "") StatusBar1->Panels->Items[2]->Text = "No Title"; else StatusBar1->Panels->Items[2]->Text = ReportDoc->Sheet->Title; StatusBar1->Panels->Items[3]->Text = ReportFileName; }else { StatusBar1->Panels->Items[1]->Text = ""; StatusBar1->Panels->Items[2]->Text = ""; StatusBar1->Panels->Items[3]->Text = ""; } } UpdateMenu(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::DesignCreate() { DSheet = new TPDocSheet; DesignDoc->Sheet = DSheet; DesignFileName = "Noname.fst"; item = detNone; IsDraw = false; Color = clBlack; inpstyle = true; ip_pos = DesignDoc->GridSpace; row = 1; col = 1; margin = 0; align = daCenter2; ltype = dltHorizental; lstyle = dlsOne; inpstyle = disHorizental; inpmethod = dimFix; CType = detNumber; bNewFont = false; bShift = false; numpos = 0; bhide = false; bSelect = false; bsub = false; bname = false; beditformula = false; MFont = new TFont; StatusBar1->Panels->Items[2]->Text = DesignDoc->Sheet->Title; //lbMainFont->Caption = DesignDoc->Sheet->GetFont()->Name; // FrameShape->Brush->Color = clBlack; //lbZoom->Caption = " 1 / 1 "; tbTImage->Visible = true; ChangeSize(); return; } //--------------------------------------------------------------------------- void __fastcall TMainForm::BaseMode() { if (!bShift) { MenuChange(14); tbSelect->Down = true; flstyle = dlsNone; cbFStyle->ItemIndex = 0; fColor = clBlack; //FrameShape->Brush->Color = clBlack; } IsDraw = false; bname = false; } //--------------------------------------------------------------------------- void __fastcall TMainForm::MenuChange(int Menu) { TPanel *pn; AnsiString str; switch (Menu) { case 0: //Line item = detLine; pn = ToolForm->pLine; str = " Line "; pn->Visible = true; pn->BringToFront(); ToolForm->rgLType->ItemIndex = ltype; ToolForm->rgLStyle->ItemIndex = lstyle; break; case 1: //Box item = detBox; pn = ToolForm->pShape; str = " Box "; pn->Visible = true; pn->BringToFront(); ToolForm->rgSLStyle->ItemIndex = lstyle; ToolForm->rgSLStyle->Visible = true; ToolForm->SNameEdit->Visible = false; ToolForm->rxMargin->Visible = false; break; case 2: //Colorchip item = detColorChip; pn = ToolForm->pShape; str = " Colorchip "; pn->Visible = true; pn->BringToFront(); ToolForm->rxMargin->Value = margin; ToolForm->rgSLStyle->Visible = false; ToolForm->rxMargin->Visible = true; ToolForm->SNameEdit->Visible = true; ToolForm->SNameEdit->Clear(); break; case 3: //Signature item = detSignature; pn = ToolForm->pSelect; str = " Signature "; pn->Visible = true; pn->BringToFront(); break; case 4: //Number item = detNumber; pn = ToolForm->pNumber; str = " Number "; pn->Visible = true; pn->BringToFront(); ToolForm->rxPoint->Value = numpos; ToolForm->rgNumAlign->ItemIndex = align; if (bhide) ToolForm->rgHide->ItemIndex = 1; else ToolForm->rgHide->ItemIndex = 0; ToolForm->FNNameEdit->Clear(); ToolForm->FFormulaEdit->Visible = false; break; case 5: //Formula item = detFormula; pn = ToolForm->pNumber; str = " Formula "; pn->Visible = true; pn->BringToFront(); ToolForm->rxPoint->Value = numpos; ToolForm->rgNumAlign->ItemIndex = align; if (bhide) ToolForm->rgHide->ItemIndex = 1; else ToolForm->rgHide->ItemIndex = 0; ToolForm->FNNameEdit->Clear(); ToolForm->FFormulaEdit->Visible = true; break; case 6: //Date item = detDate; pn = ToolForm->pText; str = " Date "; pn->Visible = true; pn->BringToFront(); ToolForm->rgAlignment->ItemIndex = align; ToolForm->LNameEdit->Visible = true; ToolForm->LNameEdit->Clear(); break; case 7: //Label item = detLabel; pn = ToolForm->pText; str = " Label "; pn->Visible = true; pn->BringToFront(); ToolForm->rgAlignment->ItemIndex = align; ToolForm->LNameEdit->Visible = false; break; case 8: //Edit item = detEdit; pn = ToolForm->pText; str = " Edit "; pn->Visible = true; pn->BringToFront(); ToolForm->rgAlignment->ItemIndex = align; ToolForm->LNameEdit->Visible = true; ToolForm->LNameEdit->Clear(); break; case 9: //Memo item = detMemo; pn = ToolForm->pImage; str = " Memo "; pn->Visible = true; pn->BringToFront(); if (align > 2) align = 0; ToolForm->rgImgAlign->ItemIndex = align; ToolForm->TitleEdit->Text = ""; break; case 10: //Image item = detImage; pn = ToolForm->pImage; str = " Image "; pn->Visible = true; pn->BringToFront(); if (align > 2) align = 0; ToolForm->rgImgAlign->ItemIndex = align; ToolForm->TitleEdit->Text = ""; break; case 11: //Input item = detInput; pn = ToolForm->pInput; str = " Input "; pn->Visible = true; pn->BringToFront(); ToolForm->rgInputAlign->ItemIndex = align; ToolForm->rgInputStyle->ItemIndex = inpstyle; break; case 12: //Chart item = detChart; pn = ToolForm->pChart; str = " Chart "; pn->Visible = true; pn->BringToFront(); ToolForm->rxRow->Value = 1; // row; ToolForm->rxCol->Value = 1; //col; ToolForm->cbSetFormula->Visible = true; ToolForm->cbSetFormula->Checked = false; break; case 13: // for Text file of Kido item = detTextImage; pn = ToolForm->pSelect; str = " TextImage "; pn->Visible = true; pn->BringToFront(); break; case 14: //Select item = detNone; pn = ToolForm->pSelect; str = " Select "; pn->Visible = true; pn->BringToFront(); break; } IsDraw = false; pn->Visible = true; pn->BringToFront(); StatusBar1->Panels->Items[1]->Text = str; bNewFont = false; bSelect = false; bsub = false; bname = false; //================================================= flstyle = dlsNone; cbFStyle->ItemIndex = 0; fColor = clBlack; beditformula = false; //FrameShape->Brush->Color = clBlack; //================================================= } //--------------------------------------------------------------------------- void __fastcall TMainForm::AddData() { RECT r; AnsiString name = ""; if (sp.x < ep.x) { r.left = sp.x; r.right = ep.x; } else { r.left = ep.x; r.right = sp.x; } if (sp.y < ep.y) { r.top = sp.y; r.bottom = ep.y; } else { r.top = ep.y; r.bottom = sp.y; } switch (item) { case detLine: DesignDoc->Sheet->AddLine(r, ltype, Color, lstyle); break; case detBox: DesignDoc->Sheet->AddBox(r, Color, lstyle); break; case detColorChip: if (bname) name = ToolForm->SNameEdit->Text; DesignDoc->Sheet->AddColorChip(r, margin, name, clWhite); break; case detSignature: DesignDoc->Sheet->AddSignature(r); // don't need frame?? break; case detNumber: if (bname) name = ToolForm->FNNameEdit->Text; DesignDoc->Sheet->AddNumber(r, align, numpos, bhide, name); if (bNewFont) ((TPDocText *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->SetFont(MFont, MFont->Color); break; case detFormula: if (bname) name = ToolForm->FNNameEdit->Text; DesignDoc->Sheet->AddFormula(r, align, numpos, bhide, name, ToolForm->FFormulaEdit->Text); if (bNewFont) ((TPDocText *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->SetFont(MFont, MFont->Color); break; case detDate: if (bname) name = ToolForm->LNameEdit->Text; DesignDoc->Sheet->AddDate(r, align, name); if (bNewFont) ((TPDocText *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->SetFont(MFont, MFont->Color); break; case detLabel: DesignDoc->Sheet->AddLabel(r, align, NameEdit->Text); if (bNewFont) ((TPDocText *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->SetFont(MFont, MFont->Color); break; case detEdit: if (bname) name = ToolForm->LNameEdit->Text; DesignDoc->Sheet->AddEdit(r, align, name); // Text is added in Report Tool if (bNewFont) ((TPDocText *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->SetFont(MFont, MFont->Color); break; case detMemo: DesignDoc->Sheet->AddMemo(r, align, ToolForm->TitleEdit->Text); if (bNewFont) ((TPDocText *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->SetFont(MFont, MFont->Color); break; case detImage: DesignDoc->Sheet->AddImage(r, align, ToolForm->TitleEdit->Text); if (bNewFont) ((TPDocText *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->SetFont(MFont, MFont->Color); break; case detInput: if (inpstyle == disHorizental) ip_pos = (r.right - r.left)/2; else ip_pos = (r.bottom - r.top)/2; DesignDoc->Sheet->AddInput(r, align, Color, inpstyle, NameEdit->Text, ip_pos, inpmethod); if (bNewFont) ((TPDocText *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->SetFont(MFont, MFont->Color); break; case detChart: DesignDoc->Sheet->AddChart(r, taCenter, col, row, Color, beditformula, CType); if (bNewFont) ((TPDocText *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->SetFont(MFont, MFont->Color); break; case detTextImage: DesignDoc->Sheet->AddTextImage(r); break; } ((TPDocElement *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->FrameStyle = flstyle; ((TPDocElement *)DesignDoc->Sheet->Element->Items[DesignDoc->Sheet->Element->Count-1])->FrameColor = fColor; DesignDoc->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::ChangeMenuPanel(TPDocElementType Item) { TPanel *pn; AnsiString str =""; bool enable = false; TPDocElement *sep; sep = DesignDoc->GetSelectElement(bsub); switch(Item) { case detLine: //Line pn = ToolForm->pLine; str = " Line "; pn->Visible = true; pn->BringToFront(); Color = ((TPDocLine *)sep)->Color; ltype = ((TPDocLine *)sep)->Type; lstyle = ((TPDocLine *)sep)->Style; ToolForm->colShape->Brush->Color = Color; ToolForm->rgLType->ItemIndex = ltype; ToolForm->rgLStyle->ItemIndex = lstyle; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detBox: //Box pn = ToolForm->pShape; str = " Box "; pn->Visible = true; pn->BringToFront(); Color = ((TPDocBox *)sep)->Color; lstyle = ((TPDocBox *)sep)->Style; ToolForm->colShape->Brush->Color = Color; ToolForm->rgSLStyle->ItemIndex = lstyle; ToolForm->rgSLStyle->Visible = true; ToolForm->SNameEdit->Visible = false; ToolForm->rxMargin->Visible = false; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detColorChip: //Colorchip pn = ToolForm->pShape; str = " ColorChip "; pn->Visible = true; pn->BringToFront(); margin = ((TPDocColorChip *)sep)->Margin; ToolForm->rxMargin->Value = margin; ToolForm->SNameEdit->Text = ((TPDocColorChip *)sep)->Name; ToolForm->rgSLStyle->Visible = false; ToolForm->SNameEdit->Visible = true; ToolForm->rxMargin->Visible = true; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detSignature: //Signature pn = ToolForm->pSelect; str = " Signature "; pn->Visible = true; pn->BringToFront(); NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detNumber: //Number pn = ToolForm->pNumber; str = " Number "; pn->Visible = true; pn->BringToFront(); numpos = ((TPDocNumber *)sep)->Precision; align = ((TPDocText *)sep)->Align; bhide = ((TPDocNumber *)sep)->Hide; ToolForm->rxPoint->Value = numpos; ToolForm->rgNumAlign->ItemIndex = align; if (bhide) ToolForm->rgHide->ItemIndex = 1; else ToolForm->rgHide->ItemIndex = 0; ToolForm->lbFont->Caption = ((TPDocText *)sep)->GetFont()->Name; ToolForm->FNNameEdit->Text = ((TPDocNumber *)sep)->Name; ToolForm->FFormulaEdit->Visible = false; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detFormula: //Formula pn = ToolForm->pNumber; str = " Formula "; pn->Visible = true; pn->BringToFront(); numpos = ((TPDocFormula *)sep)->Precision; align = ((TPDocText *)sep)->Align; bhide = ((TPDocFormula *)sep)->Hide; if (bhide) ToolForm->rgHide->ItemIndex = 1; else ToolForm->rgHide->ItemIndex = 0; ToolForm->rgNumAlign->ItemIndex = align; ToolForm->rxPoint->Value = numpos; ToolForm->lbFont->Caption = ((TPDocText *)sep)->GetFont()->Name; ToolForm->FNNameEdit->Text = ((TPDocFormula *)sep)->Name; ToolForm->FFormulaEdit->Text = ((TPDocFormula *)sep)->Formula; ToolForm->FFormulaEdit->Visible = true; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detDate: //Date pn = ToolForm->pText; str = " Date "; pn->Visible = true; pn->BringToFront(); align = ((TPDocDate *)sep)->Align; ToolForm->rgAlignment->ItemIndex = align; ToolForm->LNameEdit->Visible = true; ToolForm->LNameEdit->Text = ((TPDocDate *)sep)->Name; ToolForm->lbFont->Caption = ((TPDocText *)sep)->GetFont()->Name; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detLabel: //Label enable = true; pn = ToolForm->pText; str = " Label "; pn->Visible = true; pn->BringToFront(); align = ((TPDocText *)sep)->Align; ToolForm->rgAlignment->ItemIndex = align; ToolForm->lbFont->Caption = ((TPDocText *)sep)->GetFont()->Name; NameEdit->Enabled = true; NameEdit->Text = ((TPDocLabel *)sep)->Text; NameEdit->SetFocus(); ToolForm->LNameEdit->Visible = false; break; case detEdit: //Edit enable = true; pn = ToolForm->pText; str = " Edit "; pn->Visible = true; pn->BringToFront(); align = ((TPDocDate *)sep)->Align; ToolForm->rgAlignment->ItemIndex = align; ToolForm->LNameEdit->Visible = true; ToolForm->LNameEdit->Text = ((TPDocEdit *)sep)->Name; ToolForm->lbFont->Caption = ((TPDocText *)sep)->GetFont()->Name; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detMemo: //Memo pn = ToolForm->pImage; str = " Memo "; pn->Visible = true; pn->BringToFront(); align = ((TPDocText *)sep)->Align; ToolForm->rgImgAlign->ItemIndex = align; ToolForm->TitleEdit->Text = ((TPDocMemo *)sep)->Title; ToolForm->lbFont->Caption = ((TPDocText *)sep)->GetFont()->Name; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detImage: //Image pn = ToolForm->pImage; str = " Image "; pn->Visible = true; pn->BringToFront(); align = ((TPDocText *)sep)->Align; ToolForm->rgImgAlign->ItemIndex = align; ToolForm->TitleEdit->Text = ((TPDocImage *)sep)->ImgTitle; ToolForm->lbFont->Caption = ((TPDocText *)sep)->GetFont()->Name; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; case detInput: //Input enable = true; pn = ToolForm->pInput; str = " Input Text "; pn->Visible = true; pn->BringToFront(); Color = ((TPDocInput *)sep)->Color; align = ((TPDocText *)sep)->Align; inpstyle = ((TPDocInput *)sep)->ipStyle; inpmethod = ((TPDocInput *)sep)->Method; ToolForm->colShape->Brush->Color = Color; ToolForm->rgInputAlign->ItemIndex = align; ToolForm->rgInputStyle->ItemIndex = inpstyle; ToolForm->rgInputMethod->ItemIndex = inpmethod; ToolForm->lbFont->Caption = ((TPDocText *)sep)->GetFont()->Name; NameEdit->Enabled = true; NameEdit->Text = ((TPDocInput *)sep)->Text; NameEdit->SetFocus(); break; case detChart: //Chart enable = true; pn = ToolForm->pChart; str = " Chart "; pn->Visible = true; pn->BringToFront(); Color = ((TPDocChart *)sep)->Color; ToolForm->cbSetFormula->Visible = true; ToolForm->cbSetFormula->Checked = ((TPDocChart *)sep)->EditFormula; ToolForm->colShape->Brush->Color = Color; ToolForm->lbFont->Caption = ((TPDocText *)sep)->GetFont()->Name; NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; default: str = " None"; pn = ToolForm->pSelect; pn->Visible = true; pn->BringToFront(); NameEdit->Text = ""; //qe Label or Input À϶§¸¸ enabled NameEdit->Enabled = false; break; } if (bSelect) { if (sep->FrameStyle == dlsNone) { cbFStyle->ItemIndex = 0; //FrameShape->Brush->Color = clBlack; } else { cbFStyle->ItemIndex = sep->FrameStyle; //FrameShape->Brush->Color = sep->FrameColor; } } else { cbFStyle->ItemIndex = 0; //FrameShape->Brush->Color = clBlack; } StatusBar1->Panels->Items[1]->Text = str; } //--------------------------------------------------------------------------- void __fastcall TMainForm::ChangeSize() { int zi, zo; if(DesignDoc == NULL) return; if(DesignDoc->Sheet == NULL) return; zi = DesignDoc->ZoomIn; zo = DesignDoc->ZoomOut; DesignDoc->Width = DesignDoc->Sheet->Range.right * zi / zo; DesignDoc->Height = DesignDoc->Sheet->Range.bottom * zi / zo; } //--------------------------------------------------------------------------- void __fastcall TMainForm::SetIndex() { int x, y, W, H, gab, k, cnt, ccnt, j, index = 0; TPDocElement *sep, *iep, *cep; TPDocChart *cp; W = DesignDoc->Sheet->Range.right; H = DesignDoc->Sheet->Range.bottom; gab = DesignDoc->GridSpace; cnt = DesignDoc->Sheet->Element->Count; for (k=0; kSheet->Element->Items[k]; switch(sep->Type) { case detEdit: ((TPDocEdit *)sep)->Index = -1; ((TPDocEdit *)sep)->bIndex = false; break; case detDate: ((TPDocDate *)sep)->Index = -1; ((TPDocDate *)sep)->bIndex = false; break; case detMemo: ((TPDocMemo *)sep)->Index = -1; ((TPDocMemo *)sep)->bIndex = false; break; case detNumber: ((TPDocNumber *)sep)->Index = -1; ((TPDocNumber *)sep)->bIndex = false; break; case detFormula: ((TPDocFormula *)sep)->Index = -1; ((TPDocFormula *)sep)->bIndex = false; break; case detInput: ((TPDocInput *)sep)->bIndex = false; iep = ((TPDocInput *)sep)->IPElement; if (iep->Type == detEdit) { ((TPDocEdit *)iep)->Index = -1; ((TPDocEdit *)iep)->bIndex = false; } else if (iep->Type == detDate) { ((TPDocDate *)iep)->Index = -1; ((TPDocDate *)iep)->bIndex = false; } else if (iep->Type == detNumber) { ((TPDocNumber *)iep)->Index = -1; ((TPDocNumber *)iep)->bIndex = false; } else if (iep->Type == detFormula) { ((TPDocFormula *)iep)->Index = -1; ((TPDocFormula *)iep)->bIndex = false; } break; case detChart: ((TPDocChart *)sep)->bIndex = false; cp = (TPDocChart *)sep; ccnt = cp->Cell->Count; for (j=0; jCell->Items[j]; switch (cep->Type) { case detEdit: ((TPDocEdit *)cep)->Index = -1; ((TPDocEdit *)cep)->bIndex = false; break; case detDate: ((TPDocDate *)cep)->Index = -1; ((TPDocDate *)cep)->bIndex = false; break; case detMemo: ((TPDocMemo *)cep)->Index = -1; ((TPDocMemo *)cep)->bIndex = false; break; case detNumber: ((TPDocNumber *)cep)->Index = -1; ((TPDocNumber *)cep)->bIndex = false; break; case detFormula: ((TPDocFormula *)cep)->Index = -1; ((TPDocFormula *)cep)->bIndex = false; break; } } break; } } DesignDoc->Sheet->IndexCount = -1; for (y=gab/2; y gab/2 for (x=gab/2; x gab/2 if (DesignDoc->Select(Point(x, y), false)) { sep = DesignDoc->GetSelectElement(); if (sep->Type == detEdit) { if (!((TPDocEdit *)sep)->bIndex) { ((TPDocEdit *)sep)->Index = index; ((TPDocEdit *)sep)->bIndex = true; index++; x = ((TPDocEdit *)sep)->Range.right + gab; } } else if (sep->Type == detDate) { if (!((TPDocDate *)sep)->bIndex) { ((TPDocDate *)sep)->Index = index; ((TPDocDate *)sep)->bIndex = true; index++; x = ((TPDocDate *)sep)->Range.right + gab; } } else if (sep->Type == detMemo) { if (!((TPDocMemo *)sep)->bIndex) { ((TPDocMemo *)sep)->Index = index; ((TPDocMemo *)sep)->bIndex = true; index++; x = ((TPDocMemo *)sep)->Range.right + gab; } } else if (sep->Type == detNumber) { if (!((TPDocNumber *)sep)->bIndex) { ((TPDocNumber *)sep)->Index = index; ((TPDocNumber *)sep)->bIndex = true; index++; x = ((TPDocNumber *)sep)->Range.right + gab; } } else if (sep->Type == detFormula) { if (!((TPDocFormula *)sep)->bIndex) { ((TPDocFormula *)sep)->Index = index; ((TPDocFormula *)sep)->bIndex = true; index++; x = ((TPDocFormula *)sep)->Range.right + gab; } } else if (sep->Type == detInput) { iep = ((TPDocInput *)sep)->IPElement; if (!((TPDocInput *)sep)->bIndex) { if ((iep->Type == detEdit) && (!((TPDocEdit *)iep)->bIndex) && (((TPDocInput *)sep)->Method == dimEdit)) { ((TPDocEdit *)iep)->Index = index; ((TPDocEdit *)iep)->bIndex = true; index++; ((TPDocInput *)sep)->bIndex = true; x = ((TPDocInput *)sep)->Range.right + gab; } else if((iep->Type == detDate) && (!((TPDocDate *)iep)->bIndex)) { ((TPDocDate *)iep)->Index = index; ((TPDocDate *)iep)->bIndex = true; index++; ((TPDocInput *)sep)->bIndex = true; x = ((TPDocInput *)sep)->Range.right + gab; } else if((iep->Type == detNumber) && (!((TPDocNumber *)iep)->bIndex)) { ((TPDocNumber *)iep)->Index = index; ((TPDocNumber *)iep)->bIndex = true; index++; ((TPDocInput *)sep)->bIndex = true; x = ((TPDocInput *)sep)->Range.right + gab; } else if((iep->Type == detFormula) && (!((TPDocFormula *)iep)->bIndex)) { ((TPDocFormula *)iep)->Index = index; ((TPDocFormula *)iep)->bIndex = true; index++; ((TPDocInput *)sep)->bIndex = true; x = ((TPDocInput *)sep)->Range.right + gab; } } } else if (sep->Type == detChart) { cp = (TPDocChart *)sep; if (!cp->bIndex) { cnt = cp->Cell->Count; for (k=0; kCell->Items[k]; if (cep->Type == detEdit) { if (!((TPDocEdit *)cep)->bIndex) { ((TPDocEdit *)cep)->Index = index; ((TPDocEdit *)cep)->bIndex = true; index++; } } else if (cep->Type == detDate) { if (!((TPDocDate *)cep)->bIndex) { ((TPDocDate *)cep)->Index = index; ((TPDocDate *)cep)->bIndex = true; index++; } } else if (cep->Type == detMemo) { if (!((TPDocMemo *)cep)->bIndex) { ((TPDocMemo *)cep)->Index = index; ((TPDocMemo *)cep)->bIndex = true; index++; } } else if (cep->Type == detNumber) { if (!((TPDocNumber *)cep)->bIndex) { ((TPDocNumber *)cep)->Index = index; ((TPDocNumber *)cep)->bIndex = true; index++; } } else if (cep->Type == detFormula) { if (!((TPDocFormula *)cep)->bIndex) { ((TPDocFormula *)cep)->Index = index; ((TPDocFormula *)cep)->bIndex = true; index++; } } } ((TPDocChart *)sep)->bIndex = true; x = ((TPDocChart *)sep)->Range.right + gab; } } } } } if (index > 0) DesignDoc->Sheet->IndexCount = index; } //--------------------------------------------------------------------------- void __fastcall TMainForm::DesignDocMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { #ifdef LOCK_IFC if (!ProtectCard->CheckPassword()) { ShowMessage("Interface card doesn't exist."); Application->Terminate(); } #endif #ifdef LOCK_HASP ProtectCard->Read(); ProtectCard->Check(); #endif if(IsReport) return; TPDocElement *sep; AnsiString str = ""; sp = Point(X, Y); bsub = false; if (Button == mbLeft) { DModify = true; if (item == detNone) { //Select Mode if (DesignDoc->Select(sp)) { sep = DesignDoc->GetSelectElement(); bSelect = true; ChangeMenuPanel(sep->Type); } else { bSelect = false; ChangeMenuPanel(detNone); } } else { if (!IsDraw) { IsDraw = true; tp = sp; } } } else if (Button == mbRight) { pupChart->AutoPopup = false; pupInput->AutoPopup = false; pupOthers->AutoPopup = false; if (bSelect) { sep = DesignDoc->GetSelectElement(bsub); if (sep->Type == detChart) { if (((TPDocChart *)sep)->isExist(sp)) { DesignDoc->PopupMenu = pupChart; pupChart->AutoPopup = true; } } else if (sep->Type == detInput) { if (((TPDocInput *)sep)->isExist(sp)) { DesignDoc->PopupMenu = pupInput; pupInput->AutoPopup = true; } } else { if (((TPDocInput *)sep)->isExist(sp)) { DesignDoc->PopupMenu = pupOthers; pupOthers->AutoPopup = true; } } } } #ifdef LOCK_HASP if (ProtectCard->isHacking) Application->Terminate(); #endif } //--------------------------------------------------------------------------- void __fastcall TMainForm::DesignDocMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (IsDraw) { ep = Point(X, Y); DrawRect(); tp = ep; } StatusBar1->Panels->Items[0]->Text = Format("(%d, %d)", OPENARRAY(TVarRec, (X, Y))); } //--------------------------------------------------------------------------- void __fastcall TMainForm::DesignDocMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (IsDraw) { if (item == detLine) { switch (ltype) { case dltHorizental: ep = Point(X, sp.y); break; case dltVertical: ep = Point(sp.x, Y); break; case dltOblique: ep = Point(X, Y); break; } } else { ep = Point(X, Y); } AddData(); BaseMode();// where location? } // BaseMode(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::tbMenuDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TToolButton *sp = (TToolButton *)Sender; if (Shift.Contains(ssShift)) bShift = true; else bShift = false; MenuChange(sp->Tag); } //--------------------------------------------------------------------------- void __fastcall TMainForm::cbFStyleChange(TObject *Sender) { TPDocElement *sep; if (item != detNone) { flstyle = cbFStyle->ItemIndex; DesignDoc->Repaint(); } else if (item == detNone && bSelect) { sep = DesignDoc->GetSelectElement(bsub); sep->FrameStyle = cbFStyle->ItemIndex; DesignDoc->Repaint(); } else { cbFStyle->ItemIndex = 0; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::NameEditChange(TObject *Sender) { TPDocElement *sep; if (bSelect) { sep = DesignDoc->GetSelectElement(bsub); if (sep->Type == detLabel) { ((TPDocLabel *)sep)->Text = NameEdit->Text; } else if (sep->Type == detInput) { ((TPDocInput *)sep)->Text = NameEdit->Text; } DesignDoc->Repaint(); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::piMenuItemClick(TObject *Sender) { int index; TMenuItem *pmenu = (TMenuItem *)Sender; TPDocElementType cmt = detNone; TPDocElement *sep; if (pmenu->Tag) { switch (pmenu->Tag) { case 1: cmt = detColorChip; break; case 2: cmt = detNumber; break; case 3: cmt = detFormula; break; case 4: cmt = detLabel; break; case 5: cmt = detEdit; break; case 6: cmt = detImage; break; case 7: //added by qe DesignDoc->RemoveSelect(); bSelect = false; break; } if (cmt != detNone) { sep = DesignDoc->GetSelectElement(bsub); ((TPDocInput *)sep)->SetElement(sep, cmt); DesignDoc->Repaint(); } } else { bsub = true; sep = DesignDoc->GetSelectElement(bsub); ChangeMenuPanel(sep->Type); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::pcMenuItemClick(TObject *Sender) { int index; TMenuItem *pmenu = (TMenuItem *)Sender; TPDocElementType cmt = detNone; TPDocElement *sep; if (pmenu->Tag) { switch (pmenu->Tag) { case 1: cmt = detColorChip; break; case 2: cmt = detNumber; break; case 3: cmt = detFormula; break; case 4: cmt = detLabel; break; case 5: cmt = detEdit; break; case 6: cmt = detImage; break; case 7: //added by qe DesignDoc->RemoveSelect(); bSelect = false; break; } if (cmt != detNone) { sep = DesignDoc->GetSelectElement(bsub); ((TPDocChart *)sep)->SetElement(sep, cmt); DesignDoc->Repaint(); } } else { bsub = true; sep = DesignDoc->GetSelectElement(bsub); ChangeMenuPanel(sep->Type); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::DeleteItemClick(TObject *Sender) { DesignDoc->RemoveSelect(); bSelect = false; } //--------------------------------------------------------------------------- void __fastcall TMainForm::ResetDesign() { if(DesignDoc->Sheet) DesignDoc->Sheet = NULL; if(DSheet ) delete DSheet; DSheet = new TPDocSheet; DesignDoc->Sheet = DSheet; item = detNone; IsDraw = false; Color = clBlack; ip_pos = DesignDoc->GridSpace; row = 1; col = 1; margin = 0; align = daCenter2; ltype = dltHorizental; lstyle = dlsOne; inpstyle = disHorizental; inpmethod = dimFix; //CType = detNumber; bNewFont = false; bShift = false; numpos = 0; bhide = false; bSelect = false; bsub = false; bname = false; beditformula = false; NameEdit->Text = ""; cbFStyle->ItemIndex = 0; } //----------------------------------------------------------------------------