📄 unit1.cpp
字号:
TRVSaveFormat SaveFormat, AnsiString &Target, AnsiString &Extras)
{
Target = (char*)(RVData->GetItemTag(ItemNo));
}
//---------------------------------------------------------------------------
// URL detection on typing
void __fastcall TForm3::RichViewEdit1KeyPress(TObject *Sender, char &Key)
{
/*
// uncomment if you use Addict3
if (Key=='\'' || Key==13 || Key==9 || RichViewEdit1->Delimiters.Pos(Key))
RVA_Addict3AutoCorrect(RichViewEdit1);
*/
if (Key==13 || Key==9 || Key==' ' || Key==',' || Key==';')
{
rvActionsResource->rvActionInsertHyperlink1->DetectURL(RichViewEdit1);
rvActionsResource->rvActionInsertHyperlink1->TerminateHyperlink(RichViewEdit1);
}
}
//---------------------------------------------------------------------------
/* Insert table popup */
//---------------------------------------------------------------------------
/* We use a trick: insert-table button has style tbsDropDown and assigned
DropDownMenu (pmFakeDropDown). This menu is empty, but shows table size
popup instead of itself */
void __fastcall TForm3::pmFakeDropDownPopup(TObject *Sender)
{
rvActionsResource->rvActionInsertTable1->ShowTableSizeDialog(RichViewEdit1,
ToolButton12);
}
//---------------------------------------------------------------------------
/* Working with combo-boxes */
//---------------------------------------------------------------------------
// Current font is changed. Updating the combo-boxes.
void __fastcall TForm3::RichViewEdit1CurTextStyleChanged(TObject *Sender)
{
UpdatingCombos = true;
TFontInfo* CurStyle = RVStyle1->TextStyles->Items[RichViewEdit1->CurTextStyleNo];
cmbFont->Text = CurStyle->FontName;
cmbFont->OnClick(Sender);
cmbFontSize->FontName = CurStyle->FontName;
cmbFontSize->Text = IntToStr(CurStyle->Size);
UpdatingCombos = false;
}
//---------------------------------------------------------------------------
// Applying the font name
void __fastcall TForm3::cmbFontClick(TObject *Sender)
{
AnsiString FontName;
if (cmbFont->ItemIndex<0)
FontName = cmbFont->Text;
else
FontName = cmbFont->Items->Strings[cmbFont->ItemIndex];
if (UpdatingCombos)
return;
UpdatingCombos = true;
cmbFontSize->FontName = FontName;
UpdatingCombos = False;
if (cmbFont->ItemIndex<0)
cmbFont->ItemIndex = cmbFont->Items->IndexOf(FontName);
if (cmbFont->ItemIndex<0)
Beep();
else
{
rvActionsResource->rvActionFontEx1->UserInterface = false;
rvActionsResource->rvActionFontEx1->ValidProperties = (TRVFontInfoMainProperties() << rvfimFontName);
rvActionsResource->rvActionFontEx1->Font->Name = FontName;
rvActionsResource->rvActionFontEx1->Execute();
rvActionsResource->rvActionFontEx1->UserInterface = true;
}
RichViewEdit1->SetFocus();
}
//---------------------------------------------------------------------------
// Changing the font size
void __fastcall TForm3::cmbFontSizeClick(TObject *Sender)
{
if (UpdatingCombos)
return;
try
{
int FontSize = StrToInt(cmbFontSize->Text);
rvActionsResource->rvActionFontEx1->UserInterface = false;
rvActionsResource->rvActionFontEx1->ValidProperties = (TRVFontInfoMainProperties() << rvfimSize);
rvActionsResource->rvActionFontEx1->Font->Size = FontSize;
rvActionsResource->rvActionFontEx1->Execute();
rvActionsResource->rvActionFontEx1->UserInterface = true;
}
catch(...)
{
Beep();
}
RichViewEdit1->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TForm3::cmbtKeyPress(TObject *Sender, char &Key)
{
if (Key==13)
{
Key = 0;
((TComboBox*)Sender)->OnClick(Sender);
}
}
//---------------------------------------------------------------------------
/* Ruler */
//---------------------------------------------------------------------------
void __fastcall TForm3::RVAControlPanel1MarginsChanged(TrvAction *Sender,
TCustomRichViewEdit *Edit)
{
RVRuler1->UpdateRulerMargins();
}
//---------------------------------------------------------------------------
/* Localization */
//---------------------------------------------------------------------------
void TForm3::Localize()
{
// Fonts
Font->Charset = RVA_GetCharset();
StatusBar1->Font->Charset = RVA_GetCharset();
#if __BORLANDC__>0x0550
Screen->HintFont->Charset = RVA_GetCharset();
Screen->MenuFont->Charset = RVA_GetCharset();
#endif
// Localizing all actions on rvActionsResource
RVA_LocalizeForm(rvActionsResource);
// Localizing all actions on this form
RVA_LocalizeForm(this);
// Localizing ruler
RVALocalizeRuler(RVRuler1);
// Localizing menus (not all menus in this demo are translated)
mitFile->Caption = RVA_GetS(rvam_menu_File);
mitEdit->Caption = RVA_GetS(rvam_menu_Edit);
mitFont->Caption = RVA_GetS(rvam_menu_Font);
mitPara->Caption = RVA_GetS(rvam_menu_Para);
mitFormat->Caption = RVA_GetS(rvam_menu_Format);
mitInsert->Caption = RVA_GetS(rvam_menu_Insert);
mitTable->Caption = RVA_GetS(rvam_menu_Table);
mitExit->Caption = RVA_GetS(rvam_menu_Exit);
mitFontSize->Caption = RVA_GetS(rvam_menu_FontSize);
mitFontStyle->Caption = RVA_GetS(rvam_menu_FontStyle);
mitTableSelect->Caption = RVA_GetS(rvam_menu_TableSelect);
mitTableCellBorders->Caption = RVA_GetS(rvam_menu_TableCellBorders);
mitTableAlignCellContents->Caption = RVA_GetS(rvam_menu_TableCellAlign);
// In your application, you can use either TrvActionFonts or TrvActionFontEx
rvActionsResource->rvActionFonts1->Caption = rvActionsResource->rvActionFonts1->Caption+" (Standard)";
rvActionsResource->rvActionFontEx1->Caption = rvActionsResource->rvActionFontEx1->Caption+" (Advanced)";
/*
// uncomment if you use Addict3. It's assumed that RVAddictSpell31
// and RVThesaurus31 are on this form.
RVAddictSpell31->UILanguage = GetAddictSpellLanguage(RVA_GetLanguageName());
RVThesaurus31->UILanguage = GetAddictThesLanguage(RVA_GetLanguageName());
*/
}
//---------------------------------------------------------------------------
/* Misc. */
//---------------------------------------------------------------------------
void __fastcall TForm3::RVAControlPanel1Download(TrvAction *Sender,
const AnsiString Source)
{
if (Source=="")
Application->Hint = "";
else
Application->Hint = "Downloading "+Source+"...";
}
//---------------------------------------------------------------------------
/* Live spelling with Addict 3 */
//---------------------------------------------------------------------------
/*
// Add these events if you use Addict3
// (Assuming that you have RVAddictSpell31: TRVAddictSpell3 on the form)
// RichViewEdit1->OnSpellingCheck event
void __fastcall TForm3::RichViewEdit1SpellingCheck(TCustomRichView* Sender,
const AnsiString AWord, int StyleNo, bool& Misspelled)
{
Misspelled = ! (RVAddictSpell31->WordAcceptable(AWord));
}
// RVAddictSpell31->OnParserIgnoreWord: if Ignore All or Add buttons were pressed
// in spellchecker dialog, removing underlines from the ignored word
void __fastcall TForm3::RVAddictSpell31ParserIgnoreWord(TObject* Sender,
bool Before, int State)
{
if (!Before && (State==IgnoreState_IgnoreAll || State==IgnoreState_Add))
RichViewEdit1->LiveSpellingValidateWord(RVAddictSpell31->CurrentWord);
}
// Besides, if you want spelling check starting when loading document, call
// RichViewEdit1.StartLiveSpelling in rvActionFileOpen.OnOpenFile event
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -