//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Design.h" #include "Main_F.h" #include "GuideBar.h" #include "DesignViewForm.h" #include "YarnCompositionData.h" #include "treatment.h" #include "FloatingWin.h" #include "Editor.h" #include "capture.h" #include "jpeg.hpp" #ifdef LOCK_TEX #include "Seedx.h" #endif //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPRuler2D" #pragma link "RzButton" #pragma link "RzCmboBx" #pragma link "RzEdit" #pragma link "RzPanel" #pragma link "RzRadChk" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_DESIGN StringTable[0] #define IDS_POSITION StringTable[1] #define IDS_VIEW_MENU StringTable[2] #define IDS_INPUT_MENU StringTable[3] #define IDS_OVERLAP StringTable[4] #define IDS_REPEAT StringTable[5] #define IDS_BLACK StringTable[6] #define IDS_GRAY StringTable[7] #define IDS_WHITE StringTable[8] #define IDS_SHOW_DESIGN_VIEWER StringTable[9] #define IDS_VIEW_TEXT StringTable[10] #define IDS_INVERT StringTable[11] #define IDS_PM_REPEAT StringTable[12] #define IDS_SHIFT StringTable[13] #define IDS_ZOOM StringTable[14] #define IDS_UNDO StringTable[15] #define IDS_REDO StringTable[16] #define IDS_START StringTable[17] #define IDS_COPY StringTable[18] #define IDS_SAVE StringTable[19] //--------------------------------------------------------------------------- TDesignForm *DesignForm; //--------------------------------------------------------------------------- __fastcall TDesignForm::TDesignForm(TComponent* Owner) : TForm(Owner) { stop_draw=false; Chart->Parent->DoubleBuffered = true; ChartBox->ParentColor = false; ChartBox->DoubleBuffered = true; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbOverlapLayerClick(TObject *Sender) { Main->UpdateBtn(); UpdateCheckBox(); if(!DesignForm->stop_draw)DrawChart(false); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::edYKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); if(Key==VK_RETURN){ int num; if (!::TryStrToInt(edY->Text, num)) return;// by maxleo21c (06.11.04) if(num<1)edY->Text="1"; if(StrToInt(edY->Text)>Main->maindata.course)edY->Text=Main->maindata.course; edXIn->SetFocus(); ChartVScrollBar->Position=ChartVScrollBar->Max-num*ChartVScrollBar->Max/Main->maindata.course; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::edXInKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); if(Key==VK_RETURN){ int num; if (!::TryStrToInt(edXIn->Text, num)) return;// by maxleo21c (06.11.04) if(num<0)edXIn->Text="0"; edXVia->SetFocus(); ChartVScrollBar->Position=ChartVScrollBar->Max-num*ChartVScrollBar->Max/Main->maindata.course; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::edXViaKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); if(Key==VK_RETURN){ Main->Undo->do_(Main->texlayer); int i_edXVia, y, i_edXIn; if (!::TryStrToInt(edXVia->Text, i_edXVia)) return;// by maxleo21c (06.11.04) if(i_edXVia<0)edXVia->Text="0"; if (!::TryStrToInt(edY->Text, y)) return; if (!::TryStrToInt(edXIn->Text, i_edXIn)) return; Tex *tex = ((Tex *)(Main->texlayer->TexList->Items[Main->LayerNum])); KO *ko=(KO *)tex->Curve->Items[(y-1+tex->Curve->Count)%tex->Curve->Count]; ko->in=i_edXIn; ko->via=i_edXVia; int minx,maxx; if(ko->inout&&ko->outvia) ko->out = ko->via-1; else if(ko->in>ko->out&&ko->out>ko->via) ko->out = ko->via+1; minx = min(ko->in,ko->via); maxx = max(ko->in,ko->via); if(ko->out>maxx) ko->out = maxx; else if(ko->outout = minx; tex->Correction(); Main->texlayer->setFocus(min(ko->in,ko->via)+tex->leftShift,y-1); DrawChart(false); y++; if(y==Main->maindata.course+1)y=1; edY->Text=IntToStr(y); edXIn->SetFocus(); ChartVScrollBar->Position=ChartVScrollBar->Max-StrToInt(edY->Text)*ChartVScrollBar->Max/Main->maindata.course; if(EditorForm&&EditorForm->Visible)EditorForm->Init(); } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbChartBGColorChange(TObject *Sender) { switch(cbChartBGColor->ItemIndex){ case 0: chartTemp->LoadFromFile(BaseDir + "\\cell.bmp"); break; case 1: chartTemp->LoadFromFile(BaseDir + "\\cellg.bmp"); break; case 2: chartTemp->LoadFromFile(BaseDir + "\\cellw.bmp"); break; default: return; } DrawChart(true); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::sbEnlargeClick(TObject *Sender) { BEGIN_TEX; DesignView_F->Visible=!DesignView_F->Visible; DesignView_F->pmcx1->OnClick = DesignViewZoomClick; DesignView_F->pmcx1over2->OnClick = DesignViewZoomClick; DesignView_F->pmcx1over4->OnClick = DesignViewZoomClick; DesignView_F->pmcx1over4->Checked=false; DesignView_F->pmcx1over2->Checked=false; DesignView_F->pmcx1->Checked=false; switch(Zoom){ case 1: { DesignView_F->pmcx1over4->Checked=true; break; } case 2: { DesignView_F->pmcx1over2->Checked=true; break; } case 4: { DesignView_F->pmcx1->Checked=true; break; } default: break; } if(DesignView_F->Visible){ DesignView_F->Show(Main->texlayer, chartTempL, DistX, DistY); } END_TEX; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::DesignViewZoomClick(TObject *Sender) { int ori_Zoom = Zoom; Zoom=((TMenuItem *)Sender)->Tag; DesignView_F->pmcx1over4->Checked=false; DesignView_F->pmcx1over2->Checked=false; DesignView_F->pmcx1->Checked=false; switch(Zoom){ case 1: { DesignView_F->pmcx1over4->Checked=true; break; } case 2: { DesignView_F->pmcx1over2->Checked=true; break; } case 4: { DesignView_F->pmcx1->Checked=true; break; } default: break; } UpdateMenu(); SetDist(); DrawChart(true); DesignView_F->Visible=false; sbEnlargeClick(Sender); Zoom = ori_Zoom; UpdateMenu(); SetDist(); DrawChart(true); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartHScrollBarChange(TObject *Sender) { DrawChart(false,true);//when EL //ShowChart(); ChartRuler->StartX=(ChartHScrollBar->Max-ChartHScrollBar->Position); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartVScrollBarChange(TObject *Sender) { DrawChart(false,true);//when EL //ShowChart(); ChartRuler->StartY=this->DistY/2 + (ChartVScrollBar->Max-ChartVScrollBar->Position); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartRulerMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int yoff=ChartVScrollBar->Position; int xoff=ChartHScrollBar->Position; Tex *tex = ((Tex *)Main->texlayer->TexList->Items[Main->LayerNum]); RECT r = Rect(0,0,chartTempL->Width, chartTempL_Height_ideal); POINT p1 = Chart->ScreenToClient(ChartRuler->ClientToScreen(Point(X,Y))); POINT p2 = Main->texlayer->FindCell2(r, p1.x+xoff, p1.y+yoff, DistX, DistY); if(p2.y != 0) return;//ÀåÁø¸¸: µðÀÚÀΠâ ȸ»öºÎºÐ ´­·¯µµ ½Ç Àüü°¡ ¿·À¸·Î À̵¿ ¾ÈµÇ°Ô tex->leftShift = p2.x; GuideBar_F->UpdateGuideBar(); UpdateEdit(); DrawChart(false); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartClick(TObject *Sender) { ChartHScrollBar->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { //EditorForm->cbELmode->Checked = false;//gabriel: µðÀÚÀÎ ¹Ù²Ù¸é ELmodeÀÚµ¿ÇØÁ¦ //EditorForm->cbELmodeClick(NULL); int yoff=ChartVScrollBar->Position; int xoff=ChartHScrollBar->Position; if(Shift.Contains(ssAlt)||Shift.Contains(ssCtrl)) { Main->texlayer->Complex = true; } else { Main->texlayer->Complex = false; } if(Shift.Contains(ssLeft)&&!Shift.Contains(ssShift)){ Main->Undo->do_(Main->texlayer); } if(Shift.Contains(ssLeft)){ if(!IsCurrentLayerRepeat()){ if( false == Main->texlayer->LayerMouseDown(Shift, Rect(0,0,chartTempL->Width, chartTempL_Height_ideal), X+xoff , Y+yoff, DistX, DistY, Main->LayerNum)){ Tex *tex = ((Tex *)Main->texlayer->TexList->Items[Main->LayerNum]); POINT p = Main->texlayer->FindCell( Rect(0,0,chartTempL->Width, chartTempL_Height_ideal), X+xoff, Y+yoff, DistX, DistY); KO *ko = (KO *)tex->Curve->Items[p.y%tex->Curve->Count]; edXIn->Text = IntToStr(ko->in); edXVia->Text = IntToStr(ko->via); edY->Text = IntToStr((p.y+1)%tex->Curve->Count); DrawChart(false); if(EditorForm&&EditorForm->Visible)EditorForm->Init(); } } else if(!Shift.Contains(ssShift)){ //Åë°æ ¹è¿­ º¯°æ ÄÚµå Tex *tex = ((Tex *)Main->texlayer->TexList->Items[Main->LayerNum]); WaleState *ws = NULL; if(tex->Wales->Count==0) return; int ion,iotc=0; for(int i=0;iWales->Count;i++){ iotc+=((WaleState *)tex->Wales->Items[i])->cnt; } if(iotc<=1||tex->Wales->Count==0) { return; } POINT p = Main->texlayer->FindCell( Rect(0,0,chartTempL->Width, chartTempL_Height_ideal), X+xoff, Y+yoff, DistX, DistY); KO *ko = (KO *)tex->Curve->Items[p.y%tex->Curve->Count]; int x = p.x - tex->leftShift-min(ko->in,ko->via); ion=0; int k; for(int k=0;kWales->Count;k++){ ws=(WaleState *)tex->Wales->Items[k]; int l=x; while(l<0){l+=iotc;} l%=iotc; if( ion<=l && l cnt) ){ if(ws->cnt==1){ ws->in=!ws->in; } else if(ws->cnt>1){ if(ion==l){ WaleState *ws1 = new WaleState; *ws1 = *ws; ws1->cnt=1; ws1->in=!ws->in; tex->Wales->Insert(k,ws1); ws->cnt--; } else if(l==ion+(ws->cnt)-1){ WaleState *ws1 = new WaleState; *ws1 = *ws; ws1->cnt=1; ws1->in=!ws->in; tex->Wales->Insert(k+1,ws1); ws->cnt--; } else { WaleState *ws1 = new WaleState; WaleState *ws2 = new WaleState; int c1=l-ion; int c2=ion+(ws->cnt)-1-l; *ws1 = *ws; *ws2 = *ws; ws->cnt=c1; ws1->cnt=1; ws2->cnt=c2; ws1->in=!ws->in; tex->Wales->Insert(k+1,ws1); tex->Wales->Insert(k+2,ws2); } } arrange_wales(tex); break; } ion+=(ws->cnt); } DrawChart(false); } } //if(CaptureForm->Visible) CaptureForm->UpdatePath(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { int yoff=ChartVScrollBar->Position; int xoff=ChartHScrollBar->Position; static bool isMoving=false; if(isMoving)return; isMoving=true; //TCursor cur; //cur=Screen->Cursor; //Screen->Cursor=crHourGlass; RECT r = Rect(0,0,chartTempL->Width, chartTempL_Height_ideal); if( false == Main->texlayer->LayerMouseMove(Shift, r, X+xoff , Y+yoff, DistX, DistY, Main->LayerNum) ){ DrawChart(false,false); } double CursorX = FindCursorPositionX(r, X+xoff, Y+yoff, DistX, DistY); double CursorY = FindCursorPositionY(r, X+xoff, Y+yoff, DistX, DistY); if(Shift.Contains(ssAlt)||Shift.Contains(ssCtrl)) { ChartStatusBar->Panels->Items[0]->Text="X "+IDS_POSITION+" \"" + IntToStr((int)CursorX)+"\""; Main->texlayer->Complex = true; } else { ChartStatusBar->Panels->Items[0]->Text="X "+IDS_POSITION+" \"" + IntToStr((int)CursorX)+" "+IntToStr((int)CursorX+1)+"\""; Main->texlayer->Complex = false; } ChartStatusBar->Panels->Items[0]->Text += " Y "+IDS_POSITION+" \"" + IntToStr((int)CursorY) + "\""; //Screen->Cursor=cur; isMoving=false; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int yoff=ChartVScrollBar->Position; int xoff=ChartHScrollBar->Position; if(Shift.Contains(ssAlt)||Shift.Contains(ssCtrl)) { Main->texlayer->Complex = true; } else { Main->texlayer->Complex = false; } if(Shift.Contains(ssShift)){ Main->texlayer->LayerMouseUp(Shift, Rect(0,0,chartTempL->Width, chartTempL_Height_ideal), X+xoff , Y+yoff, DistX, DistY, Main->LayerNum); POINT p = Chart->ClientToScreen(Point(X,Y)); ChartPopupMenu->Popup(p.x, p.y); } } //--------------------------------------------------------------------------- bool __fastcall TDesignForm::InitChart(bool reDrawChartBase){ if(!Main->texlayer)return false; if(!Main->texlayer->TexList)return false; if(Main->texlayer->TexList->Count==0)return false; static bool first=true; if(first||chartTempL->Width!=this->DistX*Main->maindata.tex_max_width2||chartTempL_Height_ideal!=Main->maindata.course*this->DistY){ first=false; try { chartTempL_Height_ideal = Main->maindata.course*this->DistY;//gabriel: ÇѰ踦 ³ÑÀ» °æ¿ì chartTempL->Height ¿Í ´Þ¶óÁü //chartTempL's Height Á¦ÇÑ, ÃÖ´ë = 50 ÄÚ½º (1¹è zoom) int HeightLimit = (chartTempL_Height_ideal<50*20)? chartTempL_Height_ideal: 50*20; chartTempL->Create(this->DistX*Main->maindata.tex_max_width2, HeightLimit, 24); } catch(...){ Zoom=2; UpdateMenu(); SetDist(); ShowMessage(IDS_MESSAGE_TOO_LARGE_BITMAP_ZOOM); return false; } } RECT r=Rect(0,0,chartTempL->Width,chartTempL->Height); int i,j; int w = (r.right-r.left)/this->DistX; int h = (r.bottom-r.top)/this->DistY; static DistX=0, DistY=0, Course=0; if(reDrawChartBase||DistX!=this->DistX||DistY!=this->DistY||Course!=Main->maindata.course){ int RULER_THICKNESS=ChartRuler->Thick; OnChangeSize(); if(ChartRuler->Height-RULER_THICKNESS > chartTempL->Height){ ChartRulerPanel->Top=ChartRuler->Top+ChartRuler->Height-chartTempL->Height-RULER_THICKNESS; ChartRulerPanel->Height=ChartRuler->Height+ChartRuler->Top-ChartRulerPanel->Top-RULER_THICKNESS; } else { ChartRulerPanel->Top=ChartRuler->Top; ChartRulerPanel->Height=ChartRuler->Height-RULER_THICKNESS; } if(ChartRuler->Width-RULER_THICKNESS > chartTempL->Width){ ChartRulerPanel->Left=ChartRuler->Left+ChartRuler->Width-chartTempL->Width-RULER_THICKNESS; ChartRulerPanel->Width=ChartRuler->Width+ChartRuler->Left-ChartRulerPanel->Left-RULER_THICKNESS; } else { ChartRulerPanel->Left=ChartRuler->Left; ChartRulerPanel->Width=ChartRuler->Width-RULER_THICKNESS; } ChartRuler->StartY=this->DistY/2; ChartRuler->DPI=this->DistX; Chart->Top=0; Chart->Left=0; Chart->Height=ChartRulerPanel->Height; Chart->Width=ChartRulerPanel->Width; Chart->Picture->Bitmap->Height=ChartRulerPanel->Height; Chart->Picture->Bitmap->Width=ChartRulerPanel->Width; ChartVScrollBar->Max= (chartTempL_Height_ideal - Chart->Height > 0) ? (chartTempL_Height_ideal - Chart->Height) : 0; ChartHScrollBar->Max= (chartTempL->Width - Chart->Width > 0) ? (chartTempL->Width - Chart->Width) : 0; ChartVScrollBar->Position=ChartVScrollBar->Max; ChartHScrollBar->Position=ChartHScrollBar->Max; //µðÀÚÀÎ ¹ÙÅÁÈ­¸é¿¡ Æ÷ÀÌÆ® À̹ÌÁö¸¦ copyÇÏ´Â ºÎºÐ---------------------- HDC dc=chartTempL->CreateDC(); SetStretchBltMode(dc,COLORONCOLOR); for(i=0;iDistX, r.bottom-(j+1)*this->DistY, this->DistX, this->DistY, chartTemp->Canvas->Handle, 0, 0, 20, 20, SRCCOPY); } } chartTempL->DeleteDC(dc); //---------------------------------------------------------------------- } else { /* 2006.03.30 HDC dc=chartTempL->CreateDC(); HDC dc2=chartTempL2->CreateDC(); BitBlt(dc2, 0, 0, chartTempL->Width, chartTempL->Height, dc, 0, 0, SRCCOPY); chartTempL->DeleteDC(dc); chartTempL2->DeleteDC(dc2); */ } DistX=this->DistX; DistY=this->DistY; Course=Main->maindata.course; return true; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::DrawChart(bool reDrawChartBase, bool reDrawChartCurve){ if(!InitChart(reDrawChartBase)) return; if(!Main->texlayer)return; smallchartHeight = (Chart->Height < chartTempL->Height)? Chart->Height:chartTempL->Height;//used in TexLayer smallchart->Create(chartTempL->Width, smallchartHeight, 24); int yoff2=ChartVScrollBar->Max-ChartVScrollBar->Position; int xoff2=ChartHScrollBar->Max-ChartHScrollBar->Position; int trim_y = -yoff2%DistY; if (trim_y<0) trim_y += DistY; int r_top = chartTempL_Height_ideal - smallchart->Height - yoff2; if(r_top<0) r_top=0; RECT r = Rect(0, r_top, chartTempL->Width, chartTempL_Height_ideal); HDC dc=smallchart->CreateDC(); HDC dc3=chartTempL->CreateDC(); if (Chart->Height == chartTempL->Height) { BitBlt(dc,//¹Ø¹ÙÅÁÀ» ±×·ÁÁÜ 0, 0, smallchart->Width, smallchart->Height, dc3, 0,0, SRCCOPY); }else { BitBlt(dc,//¹Ø¹ÙÅÁÀ» ±×·ÁÁÜ 0, 0, smallchart->Width, smallchart->Height, dc3, 0, trim_y+chartTempL->Height - smallchart->Height - DistY, SRCCOPY); } Main->texlayer->Draw(dc, r, DistX, DistY, reDrawChartBase|reDrawChartCurve); int dx=0,dy=0,sx=0,sy=0; if(smallchart->Width>Chart->Width) { sx = smallchart->Width-Chart->Width-xoff2; dx = 0; } else { sx = 0; dx = Chart->Width-smallchart->Width; } if(smallchart->Height>Chart->Height) { sy = smallchart->Height-Chart->Height-yoff2; dy = 0; } else { sy = 0; dy = Chart->Height-smallchart->Height; } // ¹ÙÅÁÈ­¸é¿¡ Ãâ·Â BitBlt(Chart->Canvas->Handle, dx, dy, Chart->Width, Chart->Height, dc, sx, 0, SRCCOPY); Chart->Repaint(); smallchart->DeleteDC(dc); chartTempL->DeleteDC(dc3); if(GuideBar_F&&GuideBar_F->Visible) GuideBar_F->Repaint(); if(YarnCompositionData_F&&YarnCompositionData_F->Visible) YarnCompositionData_F->Repaint(); Main->UpdateBtn(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::UpdateMenu(){ //¸Þ´º¿Í ÆË¾÷¸Å´º¸¦ ¾÷µ¥ÀÌÆ®ÇÑ´Ù pmcx1over4->Checked=false; pmcx1over2->Checked=false; pmcx1->Checked=false; switch(Zoom){ case 1: { pmcx1over4->Checked=true; break; } case 2: { pmcx1over2->Checked=true; break; } case 4: { pmcx1->Checked=true; break; } default: break; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::SetDist(){ DistX=5*Zoom; DistY=5*Zoom; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcx1over4Click(TObject *Sender) { TCursor cursor; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; Zoom=1; UpdateMenu(); SetDist(); DrawChart(true); Screen->Cursor = cursor; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcx1over2Click(TObject *Sender) { TCursor cursor; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; Zoom=2; UpdateMenu(); SetDist(); DrawChart(true); Screen->Cursor = cursor; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcx1Click(TObject *Sender) { TCursor cursor; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; Zoom=4; UpdateMenu(); SetDist(); DrawChart(true); Screen->Cursor = cursor; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcUndoClick(TObject *Sender) { BEGIN_TEX; Main->Undo->undo(Main->texlayer); DrawChart(false); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcRedoClick(TObject *Sender) { BEGIN_TEX; Main->Undo->redo(Main->texlayer); DrawChart(false); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartPopupMenuPopup(TObject *Sender) { if(Main->Undo->canundo()){ pmcUndo->Enabled = true; } else { pmcUndo->Enabled = false; } if(Main->Undo->canredo()){ pmcRedo->Enabled = true; } else { pmcRedo->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcInvertClick(TObject *Sender) { BEGIN_TEX; Main->Undo->do_(Main->texlayer); Main->texlayer->invertRegion(Main->LayerNum); DrawChart(false); if(EditorForm&&EditorForm->Visible)EditorForm->Init(); //by siuaa END_TEX; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcRepeatClick(TObject *Sender)//ÀåÁø¸¸:¸®ÇÍ È½¼ö ÀԷ°¡´É { BEGIN_TEX; // Main->Undo->do_(Main->texlayer); // Main->texlayer->repeatUpperRegion(Main->LayerNum); // DrawChart(false); TCursor cursor = Screen->Cursor; Screen->Cursor = crIBeam; FloatingWindow->Left=Mouse->CursorPos.x; FloatingWindow->Top=Mouse->CursorPos.y-FloatingWindow->Height; FloatingWindow->Caption=0; if(FloatingWindow->ShowModal()==mrOk){ Main->Undo->do_(Main->texlayer); Main->texlayer->repeatUpperRegion(Main->LayerNum, StrToInt(FloatingWindow->edit->Text)); DrawChart(false); if(EditorForm&&EditorForm->Visible)EditorForm->Init(); //by siuaa } Screen->Cursor = cursor; END_TEX; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcShiftClick(TObject *Sender) { BEGIN_TEX; TCursor cursor = Screen->Cursor; Screen->Cursor = crIBeam; FloatingWindow->Left=Mouse->CursorPos.x; FloatingWindow->Top=Mouse->CursorPos.y-FloatingWindow->Height; if(FloatingWindow->ShowModal()==mrOk){ Main->Undo->do_(Main->texlayer); Main->texlayer->leftShiftRegion(StrToInt(FloatingWindow->edit->Text), Main->LayerNum); DrawChart(false); if(EditorForm&&EditorForm->Visible)EditorForm->Init(); //by siuaa } Screen->Cursor = cursor; END_TEX; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::FormCreate(TObject *Sender) { StringTable.Create(BaseDir, Language, "Design"); Caption=IDS_DESIGN; //gbView->Caption=IDS_VIEW_MENU; //gbInput->Caption=IDS_INPUT_MENU; //gbOverlap->Caption=IDS_OVERLAP; //gbOverlap1->Caption=IDS_OVERLAP; //gbRepeat->Caption=IDS_REPEAT; //gbRepeat1->Caption=IDS_REPEAT; lbInput->Caption=IDS_INPUT_MENU; lbOverlap->Caption=IDS_OVERLAP; lbOverlap1->Caption=IDS_OVERLAP; lbRepeat->Caption=IDS_REPEAT; lbRepeat1->Caption=IDS_REPEAT; cbChartBGColor->Text=IDS_BLACK; cbChartBGColor->Items->Clear(); cbChartBGColor->Items->Add(IDS_BLACK); cbChartBGColor->Items->Add(IDS_GRAY); cbChartBGColor->Items->Add(IDS_WHITE); sbEnlarge->Caption=IDS_SHOW_DESIGN_VIEWER; sbViewtext->Caption=IDS_VIEW_TEXT; pmcInvert->Caption=IDS_INVERT; pmcRepeat->Caption=IDS_PM_REPEAT; pmcShift->Caption=IDS_SHIFT; pmcZoom->Caption=IDS_ZOOM; pmcUndo->Caption=IDS_UNDO; pmcRedo->Caption=IDS_REDO; pmcToClipBoard->Caption=IDS_COPY; pmcSave->Caption=IDS_SAVE; lbStart->Caption=IDS_START; SetFont(); chartTemp = new Graphics::TBitmap; chartTempL = new TTexpiaBitmap; smallchart = new TTexpiaBitmap; chartTemp->LoadFromFile(BaseDir + "\\cell.bmp"); Zoom = 4; SetDist(); Main->UpdateBtn(); UpdateCheckBox(); DrawChart(true); SavePictureDialog->InitialDir=BaseDir+"\\bmp"; SavePictureDialog->DefaultExt = "bmp"; SavePictureDialog->FileName = "Noname1"; SavePictureDialog->Filter="Bitmaps (*.bmp)|*.bmp|JPEG Image File (*.jpg)|*.jpg"; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::FormDestroy(TObject *Sender) { if(chartTemp){ delete chartTemp; chartTemp = NULL; } if(chartTempL){ delete chartTempL; chartTempL = NULL; } if(smallchart){ delete smallchart; smallchart = NULL; } DesignForm=NULL; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::UpdateCheckBox(void) //MAX_LAYER_COUNT { int barCount = Main->maindata.bar; if (Main->LayerMode) { Main->texlayer->SetVisibleLayer(barCount - 1, cbBar1->Checked); Main->texlayer->SetVisibleLayer(barCount - 2, cbBar2->Checked); Main->texlayer->SetVisibleLayer(barCount - 3, cbBar3->Checked); Main->texlayer->SetVisibleLayer(barCount - 4, cbBar4->Checked); Main->texlayer->SetVisibleLayer(barCount - 5, cbBar5->Checked); Main->texlayer->SetVisibleLayer(barCount - 6, cbBar6->Checked); Main->texlayer->SetVisibleLayer(barCount - 7, cbBar7->Checked); Main->texlayer->SetRepeatLayer(barCount - 1, cbRepeatBar1->Checked); Main->texlayer->SetRepeatLayer(barCount - 2, cbRepeatBar2->Checked); Main->texlayer->SetRepeatLayer(barCount - 3, cbRepeatBar3->Checked); Main->texlayer->SetRepeatLayer(barCount - 4, cbRepeatBar4->Checked); Main->texlayer->SetRepeatLayer(barCount - 5, cbRepeatBar5->Checked); Main->texlayer->SetRepeatLayer(barCount - 6, cbRepeatBar6->Checked); Main->texlayer->SetRepeatLayer(barCount - 7, cbRepeatBar7->Checked); switch(barCount){ case 1: cbBar1->Enabled=true; cbBar2->Enabled=false; cbBar3->Enabled=false; cbBar4->Enabled=false; cbBar5->Enabled=false; cbBar6->Enabled=false; cbBar7->Enabled=false; cbBar2->Checked=false; cbBar3->Checked=false; cbBar4->Checked=false; cbBar5->Checked=false; cbBar6->Checked=false; cbBar7->Checked=false; cbRepeatBar1->Enabled=cbBar1->Checked; cbRepeatBar2->Enabled=false; cbRepeatBar3->Enabled=false; cbRepeatBar4->Enabled=false; cbRepeatBar5->Enabled=false; cbRepeatBar6->Enabled=false; cbRepeatBar7->Enabled=false; cbRepeatBar2->Checked=false; cbRepeatBar3->Checked=false; cbRepeatBar4->Checked=false; cbRepeatBar5->Checked=false; cbRepeatBar6->Checked=false; cbRepeatBar7->Checked=false; break; case 2: cbBar1->Enabled=true; cbBar2->Enabled=true; cbBar3->Enabled=false; cbBar4->Enabled=false; cbBar5->Enabled=false; cbBar6->Enabled=false; cbBar7->Enabled=false; cbBar3->Checked=false; cbBar4->Checked=false; cbBar5->Checked=false; cbBar6->Checked=false; cbBar7->Checked=false; cbRepeatBar1->Enabled=cbBar1->Checked; cbRepeatBar2->Enabled=cbBar2->Checked; cbRepeatBar3->Enabled=false; cbRepeatBar4->Enabled=false; cbRepeatBar5->Enabled=false; cbRepeatBar6->Enabled=false; cbRepeatBar7->Enabled=false; cbRepeatBar3->Checked=false; cbRepeatBar4->Checked=false; cbRepeatBar5->Checked=false; cbRepeatBar6->Checked=false; cbRepeatBar7->Checked=false; break; case 3: cbBar1->Enabled=true; cbBar2->Enabled=true; cbBar3->Enabled=true; cbBar4->Enabled=false; cbBar5->Enabled=false; cbBar6->Enabled=false; cbBar7->Enabled=false; cbBar4->Checked=false; cbBar5->Checked=false; cbBar6->Checked=false; cbBar7->Checked=false; cbRepeatBar1->Enabled=cbBar1->Checked; cbRepeatBar2->Enabled=cbBar2->Checked; cbRepeatBar3->Enabled=cbBar3->Checked; cbRepeatBar4->Enabled=false; cbRepeatBar5->Enabled=false; cbRepeatBar6->Enabled=false; cbRepeatBar7->Enabled=false; cbRepeatBar4->Checked=false; cbRepeatBar5->Checked=false; cbRepeatBar6->Checked=false; cbRepeatBar7->Checked=false; break; case 4: cbBar1->Enabled=true; cbBar2->Enabled=true; cbBar3->Enabled=true; cbBar4->Enabled=true; cbBar5->Enabled=false; cbBar6->Enabled=false; cbBar7->Enabled=false; cbBar5->Checked=false; cbBar6->Checked=false; cbBar7->Checked=false; cbRepeatBar1->Enabled=cbBar1->Checked; cbRepeatBar2->Enabled=cbBar2->Checked; cbRepeatBar3->Enabled=cbBar3->Checked; cbRepeatBar4->Enabled=cbBar4->Checked; cbRepeatBar5->Enabled=false; cbRepeatBar6->Enabled=false; cbRepeatBar7->Enabled=false; cbRepeatBar5->Checked=false; cbRepeatBar6->Checked=false; cbRepeatBar7->Checked=false; break; case 5: cbBar1->Enabled=true; cbBar2->Enabled=true; cbBar3->Enabled=true; cbBar4->Enabled=true; cbBar5->Enabled=true; cbBar6->Enabled=false; cbBar7->Enabled=false; cbBar6->Checked=false; cbBar7->Checked=false; cbRepeatBar1->Enabled=cbBar1->Checked; cbRepeatBar2->Enabled=cbBar2->Checked; cbRepeatBar3->Enabled=cbBar3->Checked; cbRepeatBar4->Enabled=cbBar4->Checked; cbRepeatBar5->Enabled=cbBar5->Checked; cbRepeatBar6->Enabled=false; cbRepeatBar7->Enabled=false; cbRepeatBar6->Checked=false; cbRepeatBar7->Checked=false; break; case 6: cbBar1->Enabled=true; cbBar2->Enabled=true; cbBar3->Enabled=true; cbBar4->Enabled=true; cbBar5->Enabled=true; cbBar6->Enabled=true; cbBar7->Enabled=false; cbBar7->Checked=false; cbRepeatBar1->Enabled=cbBar1->Checked; cbRepeatBar2->Enabled=cbBar2->Checked; cbRepeatBar3->Enabled=cbBar3->Checked; cbRepeatBar4->Enabled=cbBar4->Checked; cbRepeatBar5->Enabled=cbBar5->Checked; cbRepeatBar6->Enabled=cbBar6->Checked; cbRepeatBar7->Enabled=false; cbRepeatBar7->Checked=false; break; case 7: cbBar1->Enabled=true; cbBar2->Enabled=true; cbBar3->Enabled=true; cbBar4->Enabled=true; cbBar5->Enabled=true; cbBar6->Enabled=true; cbBar7->Enabled=true; cbRepeatBar1->Enabled=cbBar1->Checked; cbRepeatBar2->Enabled=cbBar2->Checked; cbRepeatBar3->Enabled=cbBar3->Checked; cbRepeatBar4->Enabled=cbBar4->Checked; cbRepeatBar5->Enabled=cbBar5->Checked; cbRepeatBar6->Enabled=cbBar6->Checked; cbRepeatBar7->Enabled=cbBar7->Checked; } } else { Main->texlayer->SetVisibleLayer(0, cbLayer1->Checked); Main->texlayer->SetVisibleLayer(1, cbLayer2->Checked); Main->texlayer->SetVisibleLayer(2, cbLayer3->Checked); Main->texlayer->SetVisibleLayer(3, cbLayer4->Checked); Main->texlayer->SetVisibleLayer(4, cbLayer5->Checked); Main->texlayer->SetVisibleLayer(5, cbLayer6->Checked); Main->texlayer->SetVisibleLayer(6, cbLayer7->Checked); Main->texlayer->SetRepeatLayer(0, cbRepeatLayer1->Checked); Main->texlayer->SetRepeatLayer(1, cbRepeatLayer2->Checked); Main->texlayer->SetRepeatLayer(2, cbRepeatLayer3->Checked); Main->texlayer->SetRepeatLayer(3, cbRepeatLayer4->Checked); Main->texlayer->SetRepeatLayer(4, cbRepeatLayer5->Checked); Main->texlayer->SetRepeatLayer(5, cbRepeatLayer6->Checked); Main->texlayer->SetRepeatLayer(6, cbRepeatLayer7->Checked); //Main->texlayer->SetVisibleLayer(Main->LayerNum, true); switch(barCount){ case 1: cbLayer1->Enabled=true; cbLayer2->Enabled=false; cbLayer3->Enabled=false; cbLayer4->Enabled=false; cbLayer5->Enabled=false; cbLayer6->Enabled=false; cbLayer7->Enabled=false; cbLayer2->Checked=false; cbLayer3->Checked=false; cbLayer4->Checked=false; cbLayer5->Checked=false; cbLayer6->Checked=false; cbLayer7->Checked=false; cbRepeatLayer1->Enabled=cbLayer1->Checked; cbRepeatLayer2->Enabled=false; cbRepeatLayer3->Enabled=false; cbRepeatLayer4->Enabled=false; cbRepeatLayer5->Enabled=false; cbRepeatLayer6->Enabled=false; cbRepeatLayer7->Enabled=false; cbRepeatLayer2->Checked=false; cbRepeatLayer3->Checked=false; cbRepeatLayer4->Checked=false; cbRepeatLayer5->Checked=false; cbRepeatLayer6->Checked=false; cbRepeatLayer7->Checked=false; break; case 2: cbLayer1->Enabled=true; cbLayer2->Enabled=true; cbLayer3->Enabled=false; cbLayer4->Enabled=false; cbLayer5->Enabled=false; cbLayer6->Enabled=false; cbLayer7->Enabled=false; cbLayer3->Checked=false; cbLayer4->Checked=false; cbLayer5->Checked=false; cbLayer6->Checked=false; cbLayer7->Checked=false; cbRepeatLayer1->Enabled=cbLayer1->Checked; cbRepeatLayer2->Enabled=cbLayer2->Checked; cbRepeatLayer3->Enabled=false; cbRepeatLayer4->Enabled=false; cbRepeatLayer5->Enabled=false; cbRepeatLayer6->Enabled=false; cbRepeatLayer7->Enabled=false; cbRepeatLayer3->Checked=false; cbRepeatLayer4->Checked=false; cbRepeatLayer5->Checked=false; cbRepeatLayer6->Checked=false; cbRepeatLayer7->Checked=false; break; case 3: cbLayer1->Enabled=true; cbLayer2->Enabled=true; cbLayer3->Enabled=true; cbLayer4->Enabled=false; cbLayer5->Enabled=false; cbLayer6->Enabled=false; cbLayer7->Enabled=false; cbLayer4->Checked=false; cbLayer5->Checked=false; cbLayer6->Checked=false; cbLayer7->Checked=false; cbRepeatLayer1->Enabled=cbLayer1->Checked; cbRepeatLayer2->Enabled=cbLayer2->Checked; cbRepeatLayer3->Enabled=cbLayer3->Checked; cbRepeatLayer4->Enabled=false; cbRepeatLayer5->Enabled=false; cbRepeatLayer6->Enabled=false; cbRepeatLayer7->Enabled=false; cbRepeatLayer4->Checked=false; cbRepeatLayer5->Checked=false; cbRepeatLayer6->Checked=false; cbRepeatLayer7->Checked=false; break; case 4: cbLayer1->Enabled=true; cbLayer2->Enabled=true; cbLayer3->Enabled=true; cbLayer4->Enabled=true; cbLayer5->Enabled=false; cbLayer6->Enabled=false; cbLayer7->Enabled=false; cbLayer5->Checked=false; cbLayer6->Checked=false; cbLayer7->Checked=false; cbRepeatLayer1->Enabled=cbLayer1->Checked; cbRepeatLayer2->Enabled=cbLayer2->Checked; cbRepeatLayer3->Enabled=cbLayer3->Checked; cbRepeatLayer4->Enabled=cbLayer4->Checked; cbRepeatLayer5->Enabled=false; cbRepeatLayer6->Enabled=false; cbRepeatLayer7->Enabled=false; cbRepeatLayer5->Checked=false; cbRepeatLayer6->Checked=false; cbRepeatLayer7->Checked=false; break; case 5: cbLayer1->Enabled=true; cbLayer2->Enabled=true; cbLayer3->Enabled=true; cbLayer4->Enabled=true; cbLayer5->Enabled=true; cbLayer6->Enabled=false; cbLayer7->Enabled=false; cbLayer6->Checked=false; cbLayer7->Checked=false; cbRepeatLayer1->Enabled=cbLayer1->Checked; cbRepeatLayer2->Enabled=cbLayer2->Checked; cbRepeatLayer3->Enabled=cbLayer3->Checked; cbRepeatLayer4->Enabled=cbLayer4->Checked; cbRepeatLayer5->Enabled=cbLayer5->Checked; cbRepeatLayer6->Enabled=false; cbRepeatLayer7->Enabled=false; cbRepeatLayer6->Checked=false; cbRepeatLayer7->Checked=false; break; case 6: cbLayer1->Enabled=true; cbLayer2->Enabled=true; cbLayer3->Enabled=true; cbLayer4->Enabled=true; cbLayer5->Enabled=true; cbLayer6->Enabled=true; cbLayer7->Enabled=false; cbLayer7->Checked=false; cbRepeatLayer1->Enabled=cbLayer1->Checked; cbRepeatLayer2->Enabled=cbLayer2->Checked; cbRepeatLayer3->Enabled=cbLayer3->Checked; cbRepeatLayer4->Enabled=cbLayer4->Checked; cbRepeatLayer5->Enabled=cbLayer5->Checked; cbRepeatLayer6->Enabled=cbLayer6->Checked; cbRepeatLayer7->Enabled=false; cbRepeatLayer7->Checked=false; break; case 7: cbLayer1->Enabled=true; cbLayer2->Enabled=true; cbLayer3->Enabled=true; cbLayer4->Enabled=true; cbLayer5->Enabled=true; cbLayer6->Enabled=true; cbLayer7->Enabled=true; cbRepeatLayer1->Enabled=cbLayer1->Checked; cbRepeatLayer2->Enabled=cbLayer2->Checked; cbRepeatLayer3->Enabled=cbLayer3->Checked; cbRepeatLayer4->Enabled=cbLayer4->Checked; cbRepeatLayer5->Enabled=cbLayer5->Checked; cbRepeatLayer6->Enabled=cbLayer6->Checked; cbRepeatLayer7->Enabled=cbLayer7->Checked; break; } } } //--------------------------------------------------------------------------- double __fastcall TDesignForm::FindCursorPositionX(RECT r, int X, int Y, int DistX, int DistY){ if(Main->texlayer->Complex){ return (int)(r.right-X + 0.5*DistX)/DistX; } else { return (r.right-X)/DistX; } } //--------------------------------------------------------------------------- double __fastcall TDesignForm::FindCursorPositionY(RECT r, int X, int Y, int DistX, int DistY){ return (r.bottom-Y)/DistY + 1; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::OnChangeSize(){ StructurePanel->Left=2; StructurePanel->Top=2; StructurePanel->Height=220; //º¯°æÇϱâ Àü height = 176 StructurePanel->Width=ClientWidth-4; ChartBox->Left=2; ChartBox->Top=StructurePanel->Height+4;; ChartBox->Width=ClientWidth-4; ChartBox->Height=ClientHeight-StructurePanel->Height-ChartStatusBar->Height-6; //StructurePanel ³»ºÎ ModePanel1->Width = StructurePanel->Width - InputPanel->Width - ModePanel1->Left; ModePanel2->Width = ModePanel1->Width; int gap = 10; int half = ModePanel1->Width/2 - gap; gbOverlap->Width = half; gbRepeat->Width = half; gbRepeat->Left = gbOverlap->Left + gbOverlap->Width + gap; lbRepeat->Left = gbRepeat->Left; if (Main->LayerMode) {//new ModePanel1->Visible = false; ModePanel2->Left = ModePanel1->Left; ModePanel2->Top = ModePanel1->Top; gbOverlap1->Width = half; gbRepeat1->Width = half; gbRepeat1->Left = gbOverlap->Left + gbOverlap->Width + gap; lbRepeat1->Left = gbRepeat1->Left; ModePanel2->BringToFront(); ModePanel2->Visible = true; } else { //old ModePanel2->Visible = false; ModePanel1->BringToFront(); ModePanel1->Visible = true; } //gbOverlap->Width=102+(StructurePanel->Width-393)/2; //gbRepeat->Left=115+(StructurePanel->Width-393)/2; //gbRepeat->Width=102+(StructurePanel->Width-393)/2; //InputPanel->Left=212+(StructurePanel->Width-393); InputPanel->Left = ModePanel1->Width; //ChartBox ³»ºÎ ChartVScrollBar->Width=16; ChartHScrollBar->Height=16; RBPanel->Top=2; RBPanel->Left=2; ChartHScrollBar->Width=ChartBox->ClientWidth-RBPanel->Width-4; ChartVScrollBar->Height=ChartBox->ClientHeight-RBPanel->Height-4; ChartHScrollBar->Left=RBPanel->Width; ChartVScrollBar->Left=RBPanel->Left; ChartVScrollBar->Top=RBPanel->Height; ChartHScrollBar->Top=RBPanel->Top; ChartRuler->Height=ChartVScrollBar->Height; ChartRuler->Width=ChartHScrollBar->Width; ChartRuler->Top=RBPanel->Height; ChartRuler->Left=RBPanel->Width; ChartStatusBar->Top=ClientHeight-ChartStatusBar->Height; ChartStatusBar->Left=2; ChartStatusBar->Width=ClientWidth-4; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::FormResize(TObject *Sender) { OnChangeSize(); DrawChart(true); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::arrange_wales(Tex *tex){ // ÀÌÇÔ¼ö¿¡ µé¾î ¿Ã¶§¿¡´Â Çѹø¿¡ ÇѰ¡Áö¸¸ º¯ÇÑ´Ù°í °¡Á¤//Á¤·ÄÀÇ ´ë»óÀº ¿ÀÁ÷Çϳª//¶Ç´Â ÀÏÂ÷¿øÀû ºñÁ¤·Ä »óÅ WaleState *ws=NULL; WaleState *ws1=NULL; for(int k=0;kWales->Count-1;k++){ if(tex->Wales->Count<2) return; //Áß°£¿¡ ÀÛ¾ÆÁø´Ù// ws=(WaleState *)tex->Wales->Items[k]; ws1=(WaleState *)tex->Wales->Items[k+1]; if(ws->IsSameType(*ws1)&&ws->in==ws1->in){ ws1->cnt+=ws->cnt; ws->cnt=0; } if(ws->cnt==0){ delete ws; tex->Wales->Remove(ws); k--; } } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::sbViewtextClick(TObject *Sender) { BEGIN_TEX; EditorForm->Init(); EditorForm->Show(); END_TEX; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::SetFont(){ SetSmallFont(Font); SetSmallFont(ChartStatusBar->Font); //SetSmallFont(StructurePanel->Font); //SetSmallFont(gbView->Font); SetSmallFont(gbInput->Font); SetSmallFont(gbOverlap->Font); SetSmallFont(gbRepeat->Font); SetSmallFont(cbLayer7->Font); SetSmallFont(cbLayer6->Font); SetSmallFont(cbLayer5->Font); SetSmallFont(cbLayer4->Font); SetSmallFont(cbLayer3->Font); SetSmallFont(cbLayer2->Font); SetSmallFont(cbLayer1->Font); SetSmallFont(cbRepeatLayer7->Font); SetSmallFont(cbRepeatLayer6->Font); SetSmallFont(cbRepeatLayer5->Font); SetSmallFont(cbRepeatLayer4->Font); SetSmallFont(cbRepeatLayer3->Font); SetSmallFont(cbRepeatLayer2->Font); SetSmallFont(cbRepeatLayer1->Font); SetSmallFont(gbOverlap1->Font); SetSmallFont(gbRepeat1->Font); SetSmallFont(cbBar6->Font); SetSmallFont(cbBar5->Font); SetSmallFont(cbBar4->Font); SetSmallFont(cbBar3->Font); SetSmallFont(cbBar2->Font); SetSmallFont(cbBar1->Font); SetSmallFont(cbRepeatBar6->Font); SetSmallFont(cbRepeatBar5->Font); SetSmallFont(cbRepeatBar4->Font); SetSmallFont(cbRepeatBar3->Font); SetSmallFont(cbRepeatBar2->Font); SetSmallFont(cbRepeatBar1->Font); SetSmallFont(cbChartBGColor->Font); SetSmallFont(sbEnlarge->Font); SetSmallFont(sbViewtext->Font); SetSmallFont(lbY->Font); SetSmallFont(lbX1->Font); SetSmallFont(lbX2->Font); //SetSmallFont(edY->Font); //SetSmallFont(edXIn->Font); //SetSmallFont(edXVia->Font); SetSmallFont(lbStart->Font); //SetSmallFont(edShift->Font); SetSmallFont(cbChartBGColor->Font); SetSmallFont(sbEnlarge->Font); SetSmallFont(sbViewtext->Font); SetSmallFont(lbOverlap->Font); SetSmallFont(lbRepeat->Font); SetSmallFont(lbInput->Font); SetSmallFont(lbOverlap1->Font); SetSmallFont(lbRepeat1->Font); SetSmallFont(Label1->Font); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ShowChart(){ } //--------------------------------------------------------------------------- void __fastcall TDesignForm::edShiftKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); Tex *tex = (Tex *)Main->texlayer->TexList->Items[Main->LayerNum]; if(Key==VK_RETURN){ if(edShift->Text=="")return; int i_edShift; if (!::TryStrToInt(edShift->Text, i_edShift)) return; //by maxleo21c (06.11.04) if(i_edShift<0) edShift->Text = "0"; tex->leftShift=i_edShift; GuideBar_F->UpdateGuideBar(); DrawChart(false); GuideBar_F->edShift->Text=edShift->Text; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::UpdateEdit(){ Tex *tex = (Tex *)Main->texlayer->TexList->Items[Main->LayerNum]; edShift->Text = IntToStr(tex->leftShift); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcToClipBoardClick(TObject *Sender) { BEGIN_TEX; BITMAPHANDLE bh; HDC dcSrc = NULL, dcDst = NULL; memset(&bh, 0, sizeof(BITMAPHANDLE)); L_CreateBitmap(&bh, sizeof(BITMAPHANDLE), TYPE_CONV, Chart->Width, Chart->Height, 24, ORDER_BGR, NULL, TOP_LEFT, NULL, NULL); dcDst = L_CreateLeadDC(&bh); dcSrc = Chart->Canvas->Handle; BitBlt(dcDst, 0, 0, Chart->Width, Chart->Height, dcSrc, 0, 0, SRCCOPY); L_DeleteLeadDC(dcDst); dcDst = NULL; L_CopyToClipboard(Handle, &bh, COPY2CB_EMPTY | COPY2CB_DIB); L_FreeBitmap(&bh); END_TEX; } //--------------------------------------------------------------------------- bool __fastcall TDesignForm::ReadFromFile(HANDLE hFile) { DWORD dwRead; int index=0; try{ int ver; ReadFile(hFile, &ver, sizeof(int), &dwRead, NULL); if(ver>=1){ ReadFile(hFile, &index, sizeof(int), &dwRead, NULL); cbChartBGColor->ItemIndex=index; cbChartBGColorChange(NULL); } //gabriel: el mode data read EditorForm->initMode3(); if(ver==1) { //EditorForm->initMode3(); } else if(ver>=2) { ReadFile(hFile, &ELmode, sizeof(ELmode), &dwRead, NULL); //EditorForm->cbELmode->Checked = ELmode; //if (ELmode) {¹«Á¶°Ç ·Îµå ÇÔ EditorForm->LoadELdata(hFile, ver); //} else // EditorForm->initMode3(); } if (ver<3) {//³·Àº ¹öÁ¯¿¡¼­´Â checkbox¸¦ ÃʱâÈ­(¸ðµÎ off) //EditorForm->initMode3(); } else if (ver>=3) { int maxLayerCnt; if(ver < 6) maxLayerCnt = 5; else maxLayerCnt = MAX_LAYER_COUNT; bool *cbEL = new bool[maxLayerCnt]; for (int i=0;icbEL1->Checked = cbEL[0]; EditorForm->cbEL2->Checked = cbEL[1]; EditorForm->cbEL3->Checked = cbEL[2]; EditorForm->cbEL4->Checked = cbEL[3]; EditorForm->cbEL5->Checked = cbEL[4]; EditorForm->cbEL6->Checked = cbEL[5]; if(ver < 7) EditorForm->cbEL6->Checked = false; else EditorForm->cbEL6->Checked = cbEL[6]; delete[] cbEL; } if (ver>=4) { // ver 4: by maxleo21c (06.12.01) int maxLayerCnt; if(ver < 6) maxLayerCnt = 5; else maxLayerCnt = MAX_LAYER_COUNT; bool *bCheck = new bool[maxLayerCnt]; for (int i=0;iChecked = bCheck[0]; cbLayer2->Checked = bCheck[1]; cbLayer3->Checked = bCheck[2]; cbLayer4->Checked = bCheck[3]; cbLayer5->Checked = bCheck[4]; cbLayer6->Checked = bCheck[5]; if(ver < 7) cbLayer7->Checked = false; else cbLayer7->Checked = bCheck[6]; for (int i=0;iChecked = bCheck[0]; cbRepeatLayer2->Checked = bCheck[1]; cbRepeatLayer3->Checked = bCheck[2]; cbRepeatLayer4->Checked = bCheck[3]; cbRepeatLayer5->Checked = bCheck[4]; cbRepeatLayer6->Checked = bCheck[5]; if(ver < 7) cbRepeatLayer7->Checked = false; else cbRepeatLayer7->Checked = bCheck[6]; delete[] bCheck; } if (ver>=5) { //Zoom (Zoom °ª), Zoom=2; UpdateMenu(); SetDist(); DrawChart(true); ReadFile(hFile, &Zoom, sizeof(int), &dwRead, NULL); UpdateMenu(); SetDist(); DrawChart(true); } } catch(...){ ShowMessage(IDS_MESSAGE_LOAD_FAIL); return false; } return true; } //--------------------------------------------------------------------------- ///todo: ¼¼À̺êÇÔ¼ö, Zoom °ªÀÇ ¼¼À̺ê,·Îµå bool __fastcall TDesignForm::SaveToFile(HANDLE hFile){ DWORD dwWrite; int index=cbChartBGColor->ItemIndex; if(index>=cbChartBGColor->Items->Count||index<0)index=0; try{ // ver 5: by diekun (06.12.11) int ver=7;//1---> 2: EL mode data -->3: cbEL //ver 4:save check box data // ver 5: Zoom value save // ver 6: 6 bar // ver 7: 7 bar WriteFile(hFile, &ver, sizeof(int), &dwWrite, NULL); WriteFile(hFile, &index, sizeof(int), &dwWrite, NULL); //gabriel: el mode data save (ver=2) WriteFile(hFile, &ELmode, sizeof(ELmode), &dwWrite, NULL); //if(ELmode==true) {¹«Á¶°Ç ÀúÀåÇÏ°Ô ÇÔ EditorForm->SaveELdata(hFile); //} bool cbEL[MAX_LAYER_COUNT]; cbEL[0] = EditorForm->cbEL1->Checked; cbEL[1] = EditorForm->cbEL2->Checked; cbEL[2] = EditorForm->cbEL3->Checked; cbEL[3] = EditorForm->cbEL4->Checked; cbEL[4] = EditorForm->cbEL5->Checked; cbEL[5] = EditorForm->cbEL6->Checked; cbEL[6] = EditorForm->cbEL7->Checked; WriteFile(hFile, &(cbEL[0]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[1]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[2]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[3]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[4]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[5]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[6]), sizeof(bool), &dwWrite, NULL); //ver 4¿¡ Ãß°¡µÇ´Â ³»¿ë. bool cbEL[MAX_LAYER_COUNT]; ÀÌ ÀÌ¹Ì ¼±¾ðµÇ¾î À־ ±âÁ¸ º¯¼ö¸¦ ÀÌ¿ëÇß´Ù. cbEL[0] = cbLayer1->Checked; cbEL[1] = cbLayer2->Checked; cbEL[2] = cbLayer3->Checked; cbEL[3] = cbLayer4->Checked; cbEL[4] = cbLayer5->Checked; cbEL[5] = cbLayer6->Checked; cbEL[6] = cbLayer7->Checked; WriteFile(hFile, &(cbEL[0]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[1]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[2]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[3]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[4]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[5]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[6]), sizeof(bool), &dwWrite, NULL); cbEL[0] = cbRepeatLayer1->Checked; cbEL[1] = cbRepeatLayer2->Checked; cbEL[2] = cbRepeatLayer3->Checked; cbEL[3] = cbRepeatLayer4->Checked; cbEL[4] = cbRepeatLayer5->Checked; cbEL[5] = cbRepeatLayer6->Checked; cbEL[6] = cbRepeatLayer7->Checked; WriteFile(hFile, &(cbEL[0]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[1]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[2]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[3]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[4]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[5]), sizeof(bool), &dwWrite, NULL); WriteFile(hFile, &(cbEL[6]), sizeof(bool), &dwWrite, NULL); //Zoom (Zoom °ª), Zoom=2; UpdateMenu(); SetDist(); DrawChart(true); WriteFile(hFile, &Zoom, sizeof(int), &dwWrite, NULL); }catch(...){ ShowMessage(IDS_MESSAGE_SAVE_FAIL); return false; } return true; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcSaveClick(TObject *Sender) { BEGIN_TEX; if (SavePictureDialog->Execute()) { if(SavePictureDialog->FilterIndex==1){ Chart->Picture->Bitmap->SaveToFile(SavePictureDialog->FileName); } else if(SavePictureDialog->FilterIndex==2){ TJPEGImage *jp = new TJPEGImage(); try { jp->Assign(Chart->Picture->Bitmap); jp->SaveToFile(SavePictureDialog->FileName); } __finally { delete jp; } } } END_TEX; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::FormShow(TObject *Sender) { static bool first=true; if(first){ InitForm(); } first=false; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::InitForm() { Top=0; Height=Main->ClientHeight-4; Left=(Main->ClientWidth-209-2)/2; Width=(Main->ClientWidth-209-2)/2; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::HotKeyPress(char &Key) { switch(Key) { case '\x03'://ctrl+c { pmcToClipBoardClick(NULL); break; } case '\x19'://ctrl+y { Main->Undo->redo(Main->texlayer); DrawChart(false); break; } case '\x1A'://ctrl+z { Main->Undo->undo(Main->texlayer); DrawChart(false); break; } /* case '\x0E'://ctrl+n { Main->mNewClick(NULL); break; } case '\x0F'://ctrl+o { Main->mOpenSaveClick(NULL); break; } */ } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::RepeatCheckBoxKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbOverlapLayerKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbChartBGColorKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartHScrollBarKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartVScrollBarKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- bool __fastcall TDesignForm::IsCurrentLayerRepeat() { if (Main->LayerMode) { //by david //LayerNum = maindata.bar-1; int barCount = Main->maindata.bar; int LayerNum = Main->LayerNum; if (LayerNum == barCount - 1) return cbRepeatBar1->Checked; else if (LayerNum == barCount - 2) return cbRepeatBar2->Checked; else if (LayerNum == barCount - 3) return cbRepeatBar3->Checked; else if (LayerNum == barCount - 4) return cbRepeatBar4->Checked; else if (LayerNum == barCount - 5) return cbRepeatBar5->Checked; else if (LayerNum == barCount - 6) return cbRepeatBar6->Checked; else if (LayerNum == barCount - 7) return cbRepeatBar7->Checked; } else { switch(Main->LayerNum) { case 0: return cbRepeatLayer1->Checked; case 1: return cbRepeatLayer2->Checked; case 2: return cbRepeatLayer3->Checked; case 3: return cbRepeatLayer4->Checked; case 4: return cbRepeatLayer5->Checked; case 5: return cbRepeatLayer6->Checked; case 6: return cbRepeatLayer7->Checked; } } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbRepeatLayerKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbRepeatLayerClick(TObject *Sender) { Main->UpdateBtn(); UpdateCheckBox(); DrawChart(false); } //--------------------------------------------------------------------------- //by siuaa 080328 //print°ü·Ã ¼öÁ¤ //print ÇÒ¶§ »õ·Î¿î BitmapÀ» ¸¸µë. //À̰ÍÀ» copyÇÏ¿© printÀÇ quick report¿¡ µé¾î°¥ image¸¦ ¸¸µç´Ù. void __fastcall TDesignForm::SetupForPrint() { int rulerThick = DistY * 3 / 2; ChartForPrint = new TTexpiaBitmap; if(Zoom >= 2) ChartForPrint->Create(chartTempL->Width + rulerThick, chartTempL->Height + rulerThick, 24); else ChartForPrint->Create(chartTempL->Width, chartTempL->Height, 24); RECT r = Rect(0, 0, chartTempL->Width, chartTempL->Height); HDC srcDC = chartTempL->CreateDC(); HDC dstDC = ChartForPrint->CreateDC(); BitBlt(dstDC, 0, 0, chartTempL->Width, chartTempL->Height, srcDC, 0, 0, SRCCOPY); Main->texlayer->Draw(dstDC, r, DistX, DistY, true, false); if(Zoom >= 2) { HPEN newPen, oldPen; newPen = CreatePen(PS_SOLID, 1, 0xFFFFFF); oldPen = SelectObject(dstDC, newPen); Rectangle(dstDC, ChartForPrint->Width - rulerThick, 0, ChartForPrint->Width, ChartForPrint->Height); Rectangle(dstDC, 0, ChartForPrint->Height - rulerThick, ChartForPrint->Width, ChartForPrint->Height); SelectObject(dstDC, oldPen); DeleteObject(newPen); MoveToEx(dstDC, 0, 0, NULL); LineTo(dstDC, 0, ChartForPrint->Height); MoveToEx(dstDC, 0, 0, NULL); LineTo(dstDC, ChartForPrint->Width, 0); MoveToEx(dstDC, ChartForPrint->Width - 1, 0, NULL); LineTo(dstDC, ChartForPrint->Width - 1, ChartForPrint->Height); MoveToEx(dstDC, 0, ChartForPrint->Height - 1, NULL); LineTo(dstDC, ChartForPrint->Width, ChartForPrint->Height - 1); } chartTempL->DeleteDC(srcDC); ChartForPrint->DeleteDC(dstDC); } //--------------------------------------------------------------------------- //by siuaa 080328 //quick reportÀÇ image¿¡ copyÇÑ ÈÄ memory free void __fastcall TDesignForm::EndSetupForPrint() { if(ChartForPrint) { delete ChartForPrint; ChartForPrint = NULL; } DrawChart(true); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbBarClick(TObject *Sender) { Main->UpdateBtn(); UpdateCheckBox(); if(!DesignForm->stop_draw)DrawChart(false); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbBarKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbRepeatBarClick(TObject *Sender) { Main->UpdateBtn(); UpdateCheckBox(); DrawChart(false); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbRepeatBarKeyPress(TObject *Sender, char &Key) { HotKeyPress(Key); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcx2Click(TObject *Sender) { //# sjpark TCursor cursor; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; Zoom=8; UpdateMenu(); SetDist(); DrawChart(true); Screen->Cursor = cursor; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcx4Click(TObject *Sender) { //# sjpark TCursor cursor; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; Zoom=16; UpdateMenu(); SetDist(); DrawChart(true); Screen->Cursor = cursor; } //---------------------------------------------------------------------------