📄 envopt.cpp
字号:
/**************************************************************************
Project: WinAVRIDE Class: Environment Options
Copyright (C) 2005 Philipp Schober
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
History
19.Feb 2005 - First Release (V1.0)
****************************************************************************/
#include <vcl.h>
#pragma hdrstop
#include "EnvOpt.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CGRID"
#pragma link "SynEdit"
#pragma link "SynEditHighlighter"
#pragma link "ColorField"
#pragma resource "*.dfm"
TEnvOptions *EnvOptions;
//---------------------------------------------------------------------------
__fastcall TEnvOptions::TEnvOptions(TComponent* Owner)
: TForm(Owner)
{
AttrReset = false;
SynAVRCSyn1 = new TSynAVRCSyn (this);
SynEdit1->Highlighter = SynAVRCSyn1;
}
//---------------------------------------------------------------------------
int __fastcall TEnvOptions::ShowModal (void)
{
int ret;
Position = poScreenCenter;
SynAVRCSyn1->Assign (Highlighter);
Memo1->Font->Assign (memoset->Font);
Memo1->Color = memoset->Color;
TreeView1->Font->Assign (treeset->Font);
TreeView1->Color = treeset->Color;
ListBox1->ItemIndex = 0;
ListBox1Click (this);
PaPropBox->Checked = ParamProp;
LineBox->Checked = LineNumbers;
ret = TForm::ShowModal ();
ParamProp = PaPropBox->Checked;
LineNumbers = LineBox->Checked;
return ret;
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::CancelClick(TObject *Sender)
{
ModalResult = mrCancel;
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::OkButtonClick(TObject *Sender)
{
Highlighter->Assign (SynAVRCSyn1);
memoset->Font->Assign (Memo1->Font);
memoset->Color = Memo1->Color;
treeset->Font->Assign (TreeView1->Font);
treeset->Color = TreeView1->Color;
SpLineSrc->ELineFG = SpLine.ELineFG;
SpLineSrc->ELineBG = SpLine.ELineBG;
SpLineSrc->MLineFG = SpLine.MLineFG;
SpLineSrc->MLineBG = SpLine.MLineBG;
ModalResult = mrOk;
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::StandardClick(TObject *Sender)
{
// Asm Attributes
SynAVRCSyn1->AsmAttri->Foreground = clSilver;
SynAVRCSyn1->AsmAttri->Background = clNone;
SynAVRCSyn1->AsmAttri->Style = TFontStyles ();
// Char Attributes
SynAVRCSyn1->CharAttri->Foreground = clOlive;
SynAVRCSyn1->CharAttri->Background = clNone;
SynAVRCSyn1->CharAttri->Style = TFontStyles ();
// Comment Attributes
SynAVRCSyn1->CommentAttri->Foreground = clGreen;
SynAVRCSyn1->CommentAttri->Background = clNone;
SynAVRCSyn1->CommentAttri->Style = TFontStyles ();
// Directive Attributes
SynAVRCSyn1->DirecAttri->Foreground = clMaroon;
SynAVRCSyn1->DirecAttri->Background = clNone;
SynAVRCSyn1->DirecAttri->Style = TFontStyles ();
// Float Attributes
SynAVRCSyn1->FloatAttri->Foreground = clRed;
SynAVRCSyn1->FloatAttri->Background = clNone;
SynAVRCSyn1->FloatAttri->Style = TFontStyles ();
// Hex Attributes
SynAVRCSyn1->HexAttri->Foreground = clRed;
SynAVRCSyn1->HexAttri->Background = clNone;
SynAVRCSyn1->HexAttri->Style = TFontStyles ();
// Identifier Attributes
SynAVRCSyn1->IdentifierAttri->Foreground = clBlack;
SynAVRCSyn1->IdentifierAttri->Background = clNone;
SynAVRCSyn1->IdentifierAttri->Style = TFontStyles ();
// Invalid Attributes
SynAVRCSyn1->InvalidAttri->Foreground = clBlack;
SynAVRCSyn1->InvalidAttri->Background = clRed;
SynAVRCSyn1->InvalidAttri->Style = TFontStyles () << fsBold;
// Keyword Attributes
SynAVRCSyn1->KeyAttri->Foreground = clBlue;
SynAVRCSyn1->KeyAttri->Background = clNone;
SynAVRCSyn1->KeyAttri->Style = TFontStyles () << fsBold;
// Number Attributes
SynAVRCSyn1->NumberAttri->Foreground = clRed;
SynAVRCSyn1->NumberAttri->Background = clNone;
SynAVRCSyn1->NumberAttri->Style = TFontStyles ();
// Octal Attributes
SynAVRCSyn1->OctalAttri->Foreground = clRed;
SynAVRCSyn1->OctalAttri->Background = clNone;
SynAVRCSyn1->OctalAttri->Style = TFontStyles () << fsBold;
// Space Attributes
SynAVRCSyn1->SpaceAttri->Foreground = clNone;
SynAVRCSyn1->SpaceAttri->Background = clWhite;
SynAVRCSyn1->SpaceAttri->Style = TFontStyles ();
// String Attributes
SynAVRCSyn1->StringAttri->Foreground = clOlive;
SynAVRCSyn1->StringAttri->Background = clNone;
SynAVRCSyn1->StringAttri->Style = TFontStyles () << fsBold;
// Symbol Attributes
SynAVRCSyn1->SymbolAttri->Foreground = clBlack;
SynAVRCSyn1->SymbolAttri->Background = clNone;
SynAVRCSyn1->SymbolAttri->Style = TFontStyles () << fsBold;
// Special Colors
SpLine.ELineFG = clWhite;
SpLine.ELineBG = clRed;
SpLine.MLineFG = clSilver;
SpLine.MLineBG = clNavy;
ListBox1Click (Sender);
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::ListBox1Click(TObject *Sender)
{
AttrReset = true;
SpLineSel = 0;
switch (ListBox1->ItemIndex)
{
case 0: ActualAttr = SynAVRCSyn1->AsmAttri;
break;
case 1: ActualAttr = SynAVRCSyn1->CharAttri;
break;
case 2: ActualAttr = SynAVRCSyn1->CommentAttri;
break;
case 3: ActualAttr = SynAVRCSyn1->NumberAttri;
break;
case 4: ActualAttr = SynAVRCSyn1->DirecAttri;
break;
case 5: ActualAttr = SynAVRCSyn1->FloatAttri;
break;
case 6: ActualAttr = SynAVRCSyn1->HexAttri;
break;
case 7: ActualAttr = SynAVRCSyn1->IdentifierAttri;
break;
case 8: ActualAttr = SynAVRCSyn1->InvalidAttri;
break;
case 9: ActualAttr = SynAVRCSyn1->KeyAttri;
break;
case 10: ActualAttr = SynAVRCSyn1->OctalAttri;
break;
case 11: ActualAttr = SynAVRCSyn1->SpaceAttri;
break;
case 12: ActualAttr = SynAVRCSyn1->StringAttri;
break;
case 13: ActualAttr = SynAVRCSyn1->SymbolAttri;
break;
case 14: SpLineSel = 1;
break;
case 15: SpLineSel = 2;
break;
default: return;
}
if (ActualAttr->Style.Contains (fsBold)) BoldAttr->State = cbChecked;
else BoldAttr->State = cbUnchecked;
if (ActualAttr->Style.Contains (fsItalic)) ItalAttr->State = cbChecked;
else ItalAttr->State = cbUnchecked;
if (ActualAttr->Style.Contains (fsUnderline)) UndAttr->State = cbChecked;
else UndAttr->State = cbUnchecked;
if (ActualAttr->Style.Contains (fsStrikeOut)) StrAttr->State = cbChecked;
else StrAttr->State = cbUnchecked;
switch (SpLineSel)
{
case 0: ColorField1->Foreground = ActualAttr->Foreground;
ColorField1->Background = ActualAttr->Background;
break;
case 1: ColorField1->Foreground = SpLine.ELineFG;
ColorField1->Background = SpLine.ELineBG;
break;
case 2: ColorField1->Foreground = SpLine.MLineFG;
ColorField1->Background = SpLine.MLineBG;
break;
}
if (SpLineSel != 0)
{
BoldAttr->Enabled = false;
ItalAttr->Enabled = false;
UndAttr->Enabled = false;
StrAttr->Enabled = false;
}
else
{
BoldAttr->Enabled = true;
ItalAttr->Enabled = true;
UndAttr->Enabled = true;
StrAttr->Enabled = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::FontAttrChanged(TObject *Sender)
{
TFontStyles style;
if (AttrReset == true)
{
return;
}
if (BoldAttr->Checked == true) style << fsBold;
if (ItalAttr->Checked == true) style << fsItalic;
if (UndAttr->Checked == true) style << fsUnderline;
if (StrAttr->Checked == true) style << fsStrikeOut;
ActualAttr->Style = style;
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::FontAttrMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
AttrReset = false;
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::ColorField1Change(TObject *Sender)
{
switch (SpLineSel)
{
case 0: ActualAttr->Foreground = ColorField1->Foreground;
ActualAttr->Background = ColorField1->Background;
break;
case 1: SpLine.ELineFG = ColorField1->Foreground;
SpLine.ELineBG = ColorField1->Background;
SynEdit1->InvalidateLine (SynEdit1->Lines->Count);
break;
case 2: SpLine.MLineFG = ColorField1->Foreground;
SpLine.MLineBG = ColorField1->Background;
SynEdit1->InvalidateLine (SynEdit1->Lines->Count - 1);
break;
}
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::AssignSettings (TSynAVRCSyn *hlgt, TTreeView *tv,
TMemo *mem, SpecialLines *spl)
{
Highlighter = hlgt;
treeset = tv;
memoset = mem;
SpLineSrc = spl;
SpLine.ELineFG = SpLineSrc->ELineFG;
SpLine.ELineBG = SpLineSrc->ELineBG;
SpLine.MLineFG = SpLineSrc->MLineFG;
SpLine.MLineBG = SpLineSrc->MLineBG;
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::PageControl1Change(TObject *Sender)
{
TreeView1->FullExpand ();
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::Button1Click(TObject *Sender)
{
FontDialog1->Font->Assign (TreeView1->Font);
if (FontDialog1->Execute ())
{
TreeView1->Font->Assign (FontDialog1->Font);
}
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::Button2Click(TObject *Sender)
{
if (ColorDialog1->Execute ())
{
TreeView1->Color = ColorDialog1->Color;
}
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::Button3Click(TObject *Sender)
{
FontDialog1->Font->Assign (Memo1->Font);
if (FontDialog1->Execute ())
{
Memo1->Font->Assign (FontDialog1->Font);
}
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::Button4Click(TObject *Sender)
{
if (ColorDialog1->Execute ())
{
Memo1->Color = ColorDialog1->Color;
}
}
//---------------------------------------------------------------------------
void __fastcall TEnvOptions::Standard2Click(TObject *Sender)
{
Memo1->Color = clWindow;
Memo1->Font->Color = clBlack;
Memo1->Font->Name = "MS Sans Serif";
Memo1->Font->Style = TFontStyles ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -