//--------------------------------------------------------------------------- #include #pragma hdrstop #include "InputMode3Data_F.h" #include "Editor.h" #include "Main_F.h" #include "common.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzEdit" #pragma link "RzButton" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_Caption StringTable[0] #define IDS_DataLabel StringTable[1] #define IDS_RepeatLabel StringTable[2] #define IDS_RzEditBtn StringTable[3] #define IDS_RzClearBtn StringTable[4] #define IDS_UndoBtn StringTable[5] #define IDS_RedoBtn StringTable[6] //--------------------------------------------------------------------------- TInputMode3DataForm *InputMode3DataForm; //--------------------------------------------------------------------------- __fastcall TInputMode3DataForm::TInputMode3DataForm(TComponent* Owner) : TForm(Owner) { StringTable.Create(BaseDir, Language, "InputMode3Data"); Caption = IDS_Caption; DataLabel->Caption = IDS_DataLabel; RepeatLabel->Caption = IDS_RepeatLabel; RzEditBtn->Caption = IDS_RzEditBtn; RzClearBtn->Caption = IDS_RzClearBtn; UndoBtn->Caption = IDS_UndoBtn; RedoBtn->Caption = IDS_RedoBtn; SetSmallFont(DataLabel->Font); SetSmallFont(RepeatLabel->Font); SetSmallFont(RzEditData->Font); SetSmallFont(RzEditRepeat->Font); SetSmallFont(RzEditBtn->Font); SetSmallFont(RzClearBtn->Font); SetSmallFont(UndoBtn->Font); SetSmallFont(RedoBtn->Font); } //--------------------------------------------------------------------------- void __fastcall TInputMode3DataForm::RzEditDataClick(TObject *Sender) { RzEditData->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TInputMode3DataForm::RzEditRepeatClick(TObject *Sender) { RzEditRepeat->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TInputMode3DataForm::RzClearBtnClick(TObject *Sender) { RzEditData->Text = ""; RzEditRepeat->Text = "1"; RzEditData->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TInputMode3DataForm::RzEditBtnClick(TObject *Sender) { TMemo *memo = NULL; AnsiString text; if (!CheckData()) return; memo = GetMemo(); if (memo == NULL) return; text = memo->Text; int memoLength = memo->Text.Length(); AnsiString addMemo; if (memoLength) addMemo += " + ("; else addMemo += "("; addMemo += RzEditData->Text; addMemo += ") * "; addMemo += RzEditRepeat->Text; text += addMemo; UndoString = memo->Text; memo->Text = text; RzClearBtn->SetFocus(); } //--------------------------------------------------------------------------- TMemo* __fastcall TInputMode3DataForm::GetMemo() { TRzTabSheet *sheet = EditorForm->pcLayer->ActivePage; TMemo *memo = NULL; if (sheet == NULL) return NULL; switch(sheet->PageIndex) { case 0: memo = EditorForm->ELMemo1; break; case 1: memo = EditorForm->ELMemo2; break; case 2: memo = EditorForm->ELMemo3; break; case 3: memo = EditorForm->ELMemo4; break; case 4: memo = EditorForm->ELMemo5; break; case 5: memo = EditorForm->ELMemo6; break; case 6: memo = EditorForm->ELMemo7; break; } return memo; } //--------------------------------------------------------------------------- void __fastcall TInputMode3DataForm::UndoBtnClick(TObject *Sender) { TMemo *memo = NULL; memo = GetMemo(); if (memo == NULL) return; if (memo->Text == UndoString) return; RedoString = memo->Text; memo->Text = UndoString; } //--------------------------------------------------------------------------- void __fastcall TInputMode3DataForm::RedoBtnClick(TObject *Sender) { TMemo *memo = NULL; memo = GetMemo(); if (memo == NULL) return; if (memo->Text == RedoString) return; UndoString = memo->Text; memo->Text = RedoString; } //--------------------------------------------------------------------------- bool __fastcall TInputMode3DataForm::CheckData() { AnsiString text = RzEditData->Text; int length = text.Length(), t_length; AnsiString temp; char t_char; bool b_exist = false; for (int i = 0; i < length; i++) { t_char = text.c_str()[i]; if (t_char != 44 && t_char != VK_SPACE && (t_char < 48 || t_char > 57)) return false; if (i == 0 && t_char == 44) return false; if (t_char == 44) {// ',' if (i-1 >= 0 && text.c_str()[i-1] == VK_SPACE) return false; //spµÚ¿¡ ,°¡ ÀÖÀ¸¸é ¸®ÅÏ temp += t_char; } else if (t_char == VK_SPACE) { if (i-1 >= 0 && text.c_str()[i-1] == 44) return false; //sp¾Õ¿¡ ,°¡ ÀÖÀ¸¸é ¸®ÅÏ b_exist = false; t_length = temp.Length(); if (t_length == 1) return false; //sp¾Õ¿¡ ¼ýÀÚ°¡ ÇÑÀÚ¸®¸é ¸®ÅÏ for (int j = 0; j < t_length; j++) { t_char = temp.c_str()[j]; if (t_char == 44) { if (b_exist) return false; //,°¡ µÎ¹ø ÀÌ»ó ³ª¿À¸é ¸®ÅÏ b_exist = true; } } if (!b_exist && t_length > 2) return false;//,°¡ ¾ø´Âµ¥ ±æÀ̰¡ 3ÀÌ»óÀÌ¸é ¸®ÅÏ temp = ""; } else { temp += t_char; } } } //--------------------------------------------------------------------------- void __fastcall TInputMode3DataForm::FormClose(TObject *Sender, TCloseAction &Action) { //EditorForm->cbELmode->Checked = false; }