//--------------------------------------------------------------------------- #include #pragma hdrstop #include "MainMenu.h" #include "Fullview.h" #include "Main.h" #include "MainImage.h" #include "Palette.h" #include "SimpleWindow_F.h" #include "Texture_F.h" #include "TextureArrange_F.h" #include "Weaving_F.h" #include "YarnTable_F.h" #include "YarnArrange_F.h" #include "YarnAccount_F.h" #include "YarnDesign_F.h" #include "OneRepeat_F.h" #include "ColorChange_F.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_YARN StringTable[0] #define IDS_TEXTURE StringTable[1] #define IDS_WEAVING StringTable[2] #define IDS_NEW StringTable[3] #define IDS_WINDOW StringTable[4] #define IDS_FILE StringTable[5] #define IDS_PRINT StringTable[6] #define IDS_FCAPTION StringTable[7] #define IDS_COLOR StringTable[8] TMainMenuForm *MainMenuForm; //--------------------------------------------------------------------------- __fastcall TMainMenuForm::TMainMenuForm(TComponent* Owner) : TForm(Owner) { //=================================================== StringTable.Create(DirectoryItem, Language, "MainMenu"); SetSmallFont(Font); Caption = IDS_FCAPTION; sbYarn->Hint = IDS_YARN; sbTexture->Hint = IDS_TEXTURE; sbWeaving->Hint = IDS_WEAVING; sbColor->Hint = IDS_COLOR; sbNew->Hint = IDS_NEW; sbWindow->Hint = IDS_WINDOW; sbFile->Hint = IDS_FILE; sbPrint->Hint = IDS_PRINT; sbColorFile->Caption = IDS_FILE; sbColorPrint->Caption = IDS_PRINT; //=================================================== } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::FormClose(TObject *Sender, TCloseAction &Action) { ExitForm(); Visible = false; if (FOnUpdateMenu) FOnUpdateMenu(Sender); } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::FormCreate(TObject *Sender) { ClientWidth = 248; ClientHeight = 37; PosY = Height; FWidth = ClientWidth; FHeight = ClientHeight; } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbYarnClick(TObject *Sender) { bool sw; if (Item==WI_YARN) sw = false; else sw = true; MainForm->ExitMenuItem(); ExitForm(); if (sw) { Item = WI_YARN; ViewLight(); YarnTableForm = new TYarnTableForm(this); YarnTableForm->Parent = MainForm; YarnTableForm->Visible = true; YarnTableForm->InitForm(true); YarnAccountForm = new TYarnAccountForm(this); YarnAccountForm->Parent = MainForm; YarnAccountForm->Visible = false; YarnArrangeForm = new TYarnArrangeForm(this); YarnArrangeForm->Parent = MainForm; YarnArrangeForm->Visible = true; YarnArrangeForm->sbWORWClick(this); //½Ç¹è¿­ÆûÀ» ¶Ù¿ì¸é¼­ ÀÚµ¿À¸·Î °æ»ç°¡ Ŭ¸¯µÈ È¿°ú¸¦ ÁØ´Ù } } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbTextureClick(TObject *Sender) { bool sw; if (Item==WI_TEXTURE) sw = false; else sw = true; MainForm->ExitMenuItem(); ExitForm(); if (sw) { Item = WI_TEXTURE; ViewLight(); TextureForm = new TTextureForm(this); TextureForm->InitForm(); TextureForm->Parent = MainForm; TextureForm->Left = 2; TextureForm->Top = 30; TextureForm->Width = 358; TextureForm->Height = 910; TextureForm->Visible = true; TextureArrangeForm = new TTextureArrangeForm(this); TextureArrangeForm->Parent = MainForm; TextureArrangeForm->Visible = true; TextureArrangeForm->Left = 365; TextureArrangeForm->Top = 30; TextureArrangeForm->Width = 654; TextureArrangeForm->Height = 910; } } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbWeavingClick(TObject *Sender) { bool sw; if (Item==WI_WEAVING) sw = false; else sw = true; MainForm->ExitMenuItem(); ExitForm(); if (sw) { Item = WI_WEAVING; ViewLight(); WeavingForm = new TWeavingForm(this); WeavingForm->Parent = this; WeavingForm->BorderStyle = bsNone; WeavingForm->Left = 0; WeavingForm->Top = ClientHeight+20; WeavingForm->Visible = true; WeavingForm->WeaveCondition = MainImageForm->Plan->WeaveCondition; WeavingForm->InitForm(); } } //------------------------------------------f--------------------------------- void __fastcall TMainMenuForm::sbColorClick(TObject *Sender) { bool sw; if (Item==WI_COLOR) sw = false; else sw = true; MainForm->ExitMenuItem(); ExitForm(); if (sw) { Item = WI_COLOR; ViewLight(); ClientHeight = FHeight+58; ColorChangeForm = new TColorChangeForm(this); ColorChangeForm->Parent = MainForm; if (ColorChangeForm->InitForm() == true) sbColorPrint->Enabled = true; else sbColorPrint->Enabled = false; ColorChangeForm->Left = 5; ColorChangeForm->Top = 5; ColorChangeForm->Visible = true; } } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbNewClick(TObject *Sender) { MainForm->ExitMenuItem(); ExitForm(); int button = Application->MessageBox("Do you want to delete all data?", "Message Box", MB_OKCANCEL); if (button==IDOK) { if (MainImageForm->Plan) delete MainImageForm->Plan; int w = MainImageForm->iMainImage->Bitmap->Width; int h = MainImageForm->iMainImage->Bitmap->Height; COLORREF c = PaletteForm->DIB256Palette->GetBGCOLORREF(MainImageForm->iMainImage->Bitmap->BitsPerPixel); MainImageForm->iMainImage->Bitmap->FillRect(Rect(0, 0, w, h), c); MainImageForm->iMainImage->Repaint(); MainImageForm->ImageWarp->Bitmap->FillRect(Rect(0, 0, w, MainImageForm->ImageWarp->Bitmap->Height), c); MainImageForm->ImageWarp->Repaint(); MainImageForm->ImageWeft->Bitmap->FillRect(Rect(0, 0, MainImageForm->ImageWeft->Bitmap->Width, h), c); MainImageForm->ImageWeft->Repaint(); MainImageForm->WorkArea->PushUndo(); MainImageForm->WorkArea->ResetRegion(MainImageForm->iMainImage); if ((MainImageForm->Plan = new TPlan) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } MainImageForm->Plan->Init(w, h); FullViewForm->InitForm(MainImageForm->iMainImage); } } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbWindowClick(TObject *Sender) { bool sw; if (Item==WI_WINDOW) sw = false; else sw = true; MainForm->ExitMenuItem(); ExitForm(); if (sw) { Item = WI_WINDOW; ViewLight(); SimpleWindowForm = new TSimpleWindowForm(this); SimpleWindowForm->Parent = this; SimpleWindowForm->BorderStyle = bsNone; SimpleWindowForm->Left = 0; SimpleWindowForm->Top = ClientHeight+20; SimpleWindowForm->Visible = true; SimpleWindowForm->InitForm(); } } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbFileClick(TObject *Sender) { MainForm->ExitMenuItem(); ExitForm(); MainForm->FFileManagerItemClick(Sender); } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbPrintClick(TObject *Sender) { MainForm->ExitMenuItem(); ExitForm(); MainForm->FPrintingItemClick(Sender); } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbExitClick(TObject *Sender) { ExitForm(); } //--------------------------------------------------------------------------- // Private Methos //--------------------------------------------------------------------------- void TMainMenuForm::TPMExitFunction(TMessage &msg) { if (Item==WI_WEAVING) { if (msg.WParam==mrOk) { MainImageForm->Plan->WeaveCondition = WeavingForm->WeaveCondition; MainImageForm->Weaving(); } else if(msg.WParam==mrYes) { if(OneRepeatForm) {delete OneRepeatForm; OneRepeatForm = NULL;} OneRepeatForm = new TOneRepeatForm(this); OneRepeatForm->Parent = MainForm; OneRepeatForm->Weaving(); } } ExitForm(); } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::ViewLight() { switch (Item) { case WI_YARN: shYarn->Brush->Color = clRed; shYarn->Pen->Color = clRed; break; case WI_TEXTURE: shTexture->Brush->Color = clRed; shTexture->Pen->Color = clRed; break; case WI_WEAVING: shWeaving->Brush->Color = clRed; shWeaving->Pen->Color = clRed; break; case WI_WINDOW: shWindow->Brush->Color = clRed; shWindow->Pen->Color = clRed; break; case WI_COLOR: shColor->Brush->Color = clRed; shColor->Pen->Color = clRed; break; } } //--------------------------------------------------------------------------- // Public Methods //-------------------------------------------------------------------------- void __fastcall TMainMenuForm::UnitChange() { if (YarnArrangeForm) YarnArrangeForm->UnitChange(); if (YarnAccountForm) YarnAccountForm->UnitChange(); if (YarnDesignForm) YarnDesignForm->UnitChange(); } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::ExitForm() { if (Item!=WI_NONE) { Show(); switch (Item) { case WI_YARN: if (YarnArrangeForm) { delete YarnArrangeForm; YarnArrangeForm = NULL; } if (YarnAccountForm) { delete YarnAccountForm; YarnAccountForm = NULL; } if (YarnTableForm) { delete YarnTableForm; YarnTableForm = NULL; } sbYarn->Down = false; break; case WI_TEXTURE: if (TextureArrangeForm) { delete TextureArrangeForm; TextureArrangeForm = NULL; } if (TextureForm) { delete TextureForm; TextureForm = NULL; } sbTexture->Down = false; break; case WI_WEAVING: if (WeavingForm) { WeavingForm->ExitSuck(); delete WeavingForm; WeavingForm = NULL; } sbWeaving->Down = false; break; case WI_WINDOW: SimpleWindowForm->ExitForm(); delete SimpleWindowForm; SimpleWindowForm = NULL; sbWindow->Down = false; break; case WI_COLOR: if (ColorChangeForm) { ColorChangeForm->ExitForm(); delete ColorChangeForm; ColorChangeForm = NULL;} sbColor->Down = false; MainImageForm->Modify = true; break; } shYarn->Brush->Color = clBlack; shYarn->Pen->Color = clBlack; shTexture->Brush->Color = clBlack; shTexture->Pen->Color = clBlack; shWeaving->Brush->Color = clBlack; shWeaving->Pen->Color = clBlack; shWindow->Brush->Color = clBlack; shWindow->Pen->Color = clBlack; shColor->Brush->Color = clBlack; shColor->Pen->Color = clBlack; ClientWidth = FWidth; ClientHeight = FHeight; Item = WI_NONE; } if (MainImageForm) { FullViewForm->InitForm(MainImageForm->iMainImage); } } //--------------------------------------------------------------------------- bool __fastcall TMainMenuForm::iMainImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TMainImageForm *mif = (TMainImageForm *)Sender; if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { WORD yarn = mif->Plan->GetYarn(X, mif->iMainImage->Bitmap->Height-1-Y, mif->sbFrontBack->Down); if (yarn>0 && mif->Plan->Yarn->Choice[(yarn>>11)&7].Data) { PaletteForm->DIB256Palette->ChoiceIndex = mif->Plan->Yarn->Choice[(yarn>>11)&7].Color[(yarn>>8)&7][(yarn>>3)&0x1F]->Index; } else { PaletteForm->DIB256Palette->ChoiceIndex = 1; } } switch (Item) { case WI_NONE: return true; case WI_WINDOW: SimpleWindowForm->iMainImageMouseDown(Button, Shift, X, Y); break; } return false; } //--------------------------------------------------------------------------- bool __fastcall TMainMenuForm::iMainImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { TMainImageForm *mif = (TMainImageForm *)Sender; switch (Item) { case WI_NONE: return true; case WI_WINDOW: mif->iMainImage->Cursor = crCross; SimpleWindowForm->iMainImageMouseMove(Shift, X, Y); break; } return false; } //--------------------------------------------------------------------------- bool __fastcall TMainMenuForm::iMainImageMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { switch (Item) { case WI_NONE: return true; } return false; } //--------------------------------------------------------------------------- bool __fastcall TMainMenuForm::iMainImagePaint(TObject *Sender) { switch (Item) { case WI_NONE: return true; case WI_WINDOW: SimpleWindowForm->iMainImagePaint(); break; } return false; } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbYarnMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { AnsiString screencam, cam, camdir; TRegistry *Registry; SHELLEXECUTEINFO screeninfo; if (Button == mbRight && Shift.Contains(ssShift)) { Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexPro\\8.01\\Directory",TRUE); screencam = Registry->ReadString("screencam"); delete Registry; memset(&screeninfo,0,sizeof(screeninfo)); screeninfo.cbSize = sizeof(screeninfo); screeninfo.lpVerb = "open"; screeninfo.lpDirectory = screencam.c_str(); screeninfo.lpFile = "scplayer.exe"; switch(dynamic_cast(Sender)->Tag) { case 0 : cam = screencam + "\\weave\\sbyarn.scm"; break; case 1 : cam = screencam + "\\weave\\sbtexture.scm"; break; case 2 : cam = screencam + "\\weave\\weaving.scm"; break; case 3 : cam = screencam + "\\weave\\weaving_window_file(weave).scm"; break; case 4 : cam = screencam + "\\weave\\weaving_window_file(weave).scm"; break; case 5 : cam = screencam + "\\weave\\weaving_window_file(weave).scm"; break; case 6 : cam = screencam + "\\weave\\printer(weave).scm"; break; } camdir = "\"" + cam + "\""; screeninfo.lpParameters = camdir.c_str(); screeninfo.fMask = SEE_MASK_NOCLOSEPROCESS; screeninfo.nShow = SW_SHOWDEFAULT; if(!ShellExecuteEx(&screeninfo)) { ShowMessage("can't play screencam movie."); return; } } } //--------------------------------------------------------------------------- ///////////////////////////////////////////////////ColorChange ÆûÀ» À§ÇÑ Menu void __fastcall TMainMenuForm::sbColorFileClick(TObject *Sender) { MainForm->FMColorItem(); } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::InitForColorChangeForm() { Item = WI_COLOR; ViewLight(); ClientHeight = FHeight+58; ColorChangeForm->InitFormFile(); ColorChangeForm->Left = 5; ColorChangeForm->Top = 5; ColorChangeForm->Visible = true; sbColorPrint->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::sbColorPrintClick(TObject *Sender) { ColorChangeForm->Printing(); } //--------------------------------------------------------------------------- void __fastcall TMainMenuForm::iMainImageKeyDown(TObject *Sender, char &Key) { // switch (Key) { // By GreenFish ´ÜÃàŰ Á¤¸® // case 1:// case 97: // Ctrl+A ÀÛ¾÷±¸¿ª Àüü // SimpleWindowForm->sbFullClick(this); break; // case 4: // case 100: // Ctrl+D ÀÛ¾÷±¸¿ª ÇØÁ¦ // if (Item==T_NONE || Item==T_WIN) // SimpleWindowForm->sbOffClick(this); break; // } } //---------------------------------------------------------------------------