Разработка текстового редактораРефераты >> Программирование и компьютеры >> Разработка текстового редактора
else
{
RichEdit1->SelText = ReplaceDialog1->ReplaceText;
FindDialog1Find(Sender);
}
if (ReplaceDialog1->Options.Contains(frReplaceAll))
while (RichEdit1->SelLength !=0)
ReplaceDialog1Replace(Sender);
}
void fastcall TForm1::ReplaceClick(TObject *Sender)
{
ReplaceDialog1->Execute();
}
void fastcall TForm1::N5Click(TObject *Sender)
{
FontDialog1->Options << fdApplyButton;
FontDialog1->Execute();
}
void fastcall TForm1::FontDialog1Apply(TObject *Sender, HWND Wnd)
{
if (ActiveControl->ClassNameIs("TEdit"))
((TEdit *)ActiveControl)->Font->Assign(FontDialog1->Font);
else if (ActiveControl->ClassNameIs("TRichEdit"))
((TRichEdit *)ActiveControl)->SelAttributes->Assign(FontDialog1->Font);
else
MessageBeep(0);
}
void fastcall TForm1::prClick(TObject *Sender)
{
ToolButton8->Visible=false;
}
void fastcall TForm1::rp1Click(TObject *Sender)
{
ToolButton8->Visible=true;
}
void fastcall TForm1::CenterAlignClick(TObject *Sender)
{
RichEdit1->Paragraph->Alignment = taCenter;
}
void fastcall TForm1::LeftAlignClick(TObject *Sender)
{
RichEdit1->Paragraph->Alignment = taLeftJustify;
}
void fastcall TForm1::RightAlignClick(TObject *Sender)
{
RichEdit1->Paragraph->Alignment = taRightJustify;
}
void fastcall TForm1::SetupRuler(void)
{ int iCtr = 1;
char sTmp[201];
while (iCtr < 200) {
sTmp[iCtr] = 9;
iCtr++;
sTmp[iCtr] = '|';
iCtr++;
}
Ruler->Caption = (AnsiString)sTmp;
}
void fastcall TForm1::FormCreate(TObject *Sender)
{
OpenDialog->InitialDir = ExtractFilePath(ParamStr(0));
SaveDialog->InitialDir = OpenDialog->InitialDir;
SetupRuler();
for (int i = 0; i < Screen->Fonts->Count; i++)
ComboBox1->Items->Add(Screen->Fonts->Strings[i]);
RichEdit1->SelStart = 0;
}
void fastcall TForm1::ToolButton14Click(TObject *Sender)
{
if(RichEdit1->Paragraph->Numbering == TNumberingStyle(nsBullet))
RichEdit1->Paragraph->Numbering = TNumberingStyle(nsNone);
else
RichEdit1->Paragraph->Numbering = TNumberingStyle(nsBullet);
}
void fastcall TForm1::ComboBox1Change(TObject *Sender)
{
TCharsetObject* ChasrsetObject;
if ( !FUpdating ){
ChasrsetObject = (TCharsetObject*)ComboBox1->Items->Objects[ComboBox1->ItemIndex];
CurrText()->Name = ComboBox1->Items->Strings[ComboBox1->ItemIndex];
}
}
void fastcall TForm1::ToolButton15Click(TObject *Sender)
{
if (CurrText()->Style == CurrText()->Style >> fsBold)
CurrText()->Style = CurrText()->Style << fsBold;
else
CurrText()->Style = CurrText()->Style >> fsBold;
}
void fastcall TForm1::ToolButton17Click(TObject *Sender)
{
if (CurrText()->Style ==CurrText()->Style >> fsItalic)
CurrText()->Style = CurrText()->Style << fsItalic;
else
CurrText()->Style = CurrText()->Style >> fsItalic;
}
void fastcall TForm1::Edit2Change(TObject *Sender)
{
int fontsize = atoi(Edit2->Text.c_str());
if ((!FUpdating) && (fontsize))
{
CurrText()->Size = atoi(Edit2->Text.c_str());
}
}
void fastcall TForm1::ToolButton3Click(TObject *Sender)
{
if (CurrText()->Style ==CurrText()->Style >> fsUnderline)
CurrText()->Style = CurrText()->Style << fsUnderline;
else
CurrText()->Style = CurrText()->Style >> fsUnderline;
}
void fastcall TForm1::FirstIndMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
TLabel * oTmpLabel = (TLabel *)Sender;
FDragOfs = oTmpLabel->Width / 2;
oTmpLabel->Left = oTmpLabel->Left+X-FDragOfs;
FDragging = True;
}
void fastcall TForm1::FirstIndMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
FDragging = False;
RichEdit1->Paragraph->FirstIndent = int((FirstInd->Left+FDragOfs-GutterWid) / RulerAdj);
LeftIndMouseUp(Sender, Button, Shift, X, Y);
}
void fastcall TForm1::LeftIndMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
FDragging = False;
RichEdit1->Paragraph->LeftIndent = int((LeftInd->Left+FDragOfs-GutterWid)/
RulerAdj)-RichEdit1->Paragraph->FirstIndent;
RichEdit1SelectionChange(Sender);
}
void fastcall TForm1::FirstIndMouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
if (FDragging) {
TLabel * oTmpLabel = (TLabel *)Sender;
oTmpLabel->Left = oTmpLabel->Left+X-FDragOfs;
}
}
void fastcall TForm1::RightIndMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
FDragging = False;
RichEdit1->Paragraph->RightIndent =
int((Ruler->ClientWidth-RightInd->Left+FDragOfs-2) /
RulerAdj)-2*GutterWid;
RichEdit1SelectionChange(Sender);
}
void fastcall TForm1::RulerResize(TObject *Sender)
{
RulerLine->Width = (int)Ruler->ClientWidth - (RulerLine->Left*2);
}
void fastcall TForm1::FormPaint(TObject *Sender)
{
TRect Rct = Rect(GutterWid, 0, RichEdit1->ClientWidth-GutterWid,
ClientHeight);
SendMessage(RichEdit1->Handle, EM_SETRECT, 0, long(&Rct));;
}
void fastcall TForm1::FormResize(TObject *Sender)
{
RichEdit1SelectionChange(Sender);
}
void fastcall TForm1::FormActivate(TObject *Sender)
{
FileNew1Execute(Sender);
RichEdit1->SetFocus();
}
void fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
{
try{
CheckFileSave();
}
catch ( .) {
CanClose = False;
}
}
void fastcall TForm1::NRulerClick(TObject *Sender)
{
if (Ruler->Visible==false)
{
Ruler->Visible=true;
NRuler->Checked=true;}
else {Ruler->Visible=false; NRuler->Checked=false;
}
}
void fastcall TForm1::NPanelClick(TObject *Sender)
{
if (Panel1->Visible==false)
{
Panel1->Visible=true;
NPanel->Checked=true;
}
else {Panel1->Visible=false;
NPanel->Checked=false;
}
}
void fastcall TForm1::NBarClick(TObject *Sender)
{
if (StatusBar->Visible==false)
{StatusBar->Visible=true;
NBar->Checked=true;}
else { StatusBar->Visible=false;
NBar->Checked=false;
}
}