📄 ide.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <IniFiles.hpp>
#include "IDE.h"
#include "Logo.h"
#include "DockForm.h"
#include "FileBrowser.h"
#include "ProjectWindow.h"
#include "OutputWindow.h"
#include "WatchWindow.h"
#include "SourceEditor.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "SynMemo"
#pragma link "SynHighlighterHtml"
#pragma link "SynHighlighterIni"
#pragma resource "*.dfm"
TIdeForm *IdeForm;
//---------------------------------------------------------------------------
__fastcall TIdeForm::TIdeForm(TComponent* Owner)
: TForm(Owner)
{
LeftDockPanelWidthHistory = 170;
BottomDockPanelHeightHistory = 100;
RightDockPanelWidthHistory = 170;
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::FormCreate(TObject *Sender)
{
EditorList = new TList;
LeftDockPanel->Width = 0;
LeftDockPanel->Align = alLeft;
LeftDockPanel->DockSite = true;
LeftDockPanel->DragKind = dkDrag;
LeftDockPanel->DragMode = dmManual;
LeftDockPanel->UseDockManager = true;
LeftSplitter->Align = alLeft;
LeftSplitter->Width = 4;
BottomDockPanel->Height = 0;
BottomDockPanel->Align = alBottom;
BottomDockPanel->DockSite = true;
BottomDockPanel->DragKind = dkDrag;
BottomDockPanel->DragMode = dmManual;
BottomDockPanel->UseDockManager = true;
BottomSplitter->Align = alBottom;
BottomSplitter->Height = 4;
RightDockPanel->Width = 0;
RightDockPanel->Align = alRight;
RightDockPanel->DockSite = true;
RightDockPanel->DragKind = dkDrag;
RightDockPanel->DragMode = dmManual;
RightDockPanel->UseDockManager = true;
RightSplitter->Align = alRight;
RightSplitter->Width = 4;
DragAcceptFiles(this->Handle,true);
UpdataComboBoxOpenedFile();
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::LeftDockPanelDockDrop(TObject *Sender,
TDragDockObject *Source, int X, int Y)
{
TPanel* SenderPanel = dynamic_cast<TPanel*>(Sender);
if(SenderPanel == NULL)
throw EInvalidCast("");
if(SenderPanel->DockClientCount == 1)
ShowDockPanel(SenderPanel, true, NULL);
SenderPanel->DockManager->ResetBounds(true);
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::LeftDockPanelDockOver(TObject *Sender,
TDragDockObject *Source, int X, int Y, TDragState State,
bool &Accept)
{
Accept = (dynamic_cast<TDockableForm*>(Source->Control) != NULL);
if(Accept)
{
Types::TPoint TopLeft = LeftDockPanel->ClientToScreen(Point(0, 0));
Types::TPoint BottomRight = LeftDockPanel->ClientToScreen(Point(LeftDockPanelWidthHistory, LeftDockPanel->Height));
Source->DockRect = Types::TRect(TopLeft, BottomRight);
}
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::LeftDockPanelGetSiteInfo(TObject *Sender,
TControl *DockClient, TRect &InfluenceRect, TPoint &MousePos,
bool &CanDock)
{
CanDock = (dynamic_cast<TDockableForm*>(DockClient) != NULL);
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::LeftDockPanelUnDock(TObject *Sender,
TControl *Client, TWinControl *NewTarget, bool &Allow)
{
TPanel* SenderPanel = dynamic_cast<TPanel*>(Sender);
if(SenderPanel == NULL)
throw EInvalidCast("");
if(SenderPanel->DockClientCount == 1)
ShowDockPanel(SenderPanel, false, NULL);
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::ShowDockPanel(TPanel* APanel, bool MakeVisible, TControl* Client)
{
if(!MakeVisible && (APanel->VisibleDockClientCount > 1))
return;
if(APanel == LeftDockPanel)
LeftSplitter->Visible = MakeVisible;
else if(APanel == BottomDockPanel)
BottomSplitter->Visible = MakeVisible;
else if(APanel == RightDockPanel)
RightSplitter->Visible = MakeVisible;
if(MakeVisible)
{
if(APanel == LeftDockPanel)
{
APanel->Width = LeftDockPanelWidthHistory;
LeftSplitter->Left = APanel->Width + LeftSplitter->Width;
}
else if(APanel == BottomDockPanel)
{
APanel->Height = BottomDockPanelHeightHistory;
BottomSplitter->Top = ClientHeight - APanel->Height - BottomSplitter->Width;
}
else if(APanel == RightDockPanel)
{
APanel->Width = RightDockPanelWidthHistory;
LeftSplitter->Left = ClientWidth - APanel->Width - LeftSplitter->Width;
}
}
else
{
if(APanel == LeftDockPanel)
APanel->Width = 0;
else if(APanel == BottomDockPanel)
APanel->Height = 0;
else if(APanel == RightDockPanel)
APanel->Width = 0;
}
if(MakeVisible && (Client != NULL))
Client->Show();
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::BottomDockPanelDockOver(TObject *Sender,
TDragDockObject *Source, int X, int Y, TDragState State,
bool &Accept)
{
Accept = (dynamic_cast<TDockableForm*>(Source->Control) != NULL);
if(Accept)
{
Types::TPoint TopLeft = BottomDockPanel->ClientToScreen(Point(0, -BottomDockPanelHeightHistory));
Types::TPoint BottomRight = BottomDockPanel->ClientToScreen(Point(BottomDockPanel->Width, BottomDockPanel->Height));
Source->DockRect = Types::TRect(TopLeft, BottomRight);
}
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::BottomDockPanelDockDrop(TObject *Sender,
TDragDockObject *Source, int X, int Y)
{
LeftDockPanelDockDrop(Sender,Source,X,Y);
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::BottomDockPanelGetSiteInfo(TObject *Sender,
TControl *DockClient, TRect &InfluenceRect, TPoint &MousePos,
bool &CanDock)
{
LeftDockPanelGetSiteInfo(Sender,DockClient,InfluenceRect,MousePos,CanDock);
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::BottomDockPanelUnDock(TObject *Sender,
TControl *Client, TWinControl *NewTarget, bool &Allow)
{
LeftDockPanelUnDock(Sender,Client,NewTarget,Allow);
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::RightDockPanelDockOver(TObject *Sender,
TDragDockObject *Source, int X, int Y, TDragState State,
bool &Accept)
{
Accept = (dynamic_cast<TDockableForm*>(Source->Control) != NULL);
if(Accept)
{
Types::TPoint TopLeft = RightDockPanel->ClientToScreen(Point(-RightDockPanelWidthHistory, 0));
Types::TPoint BottomRight = RightDockPanel->ClientToScreen(Point(0, RightDockPanel->Height));
Source->DockRect = Types::TRect(TopLeft, BottomRight);
}
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::RightDockPanelDockDrop(TObject *Sender,
TDragDockObject *Source, int X, int Y)
{
LeftDockPanelDockDrop(Sender,Source,X,Y);
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::RightDockPanelGetSiteInfo(TObject *Sender,
TControl *DockClient, TRect &InfluenceRect, TPoint &MousePos,
bool &CanDock)
{
LeftDockPanelGetSiteInfo(Sender,DockClient,InfluenceRect,MousePos,CanDock);
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::RightDockPanelUnDock(TObject *Sender,
TControl *Client, TWinControl *NewTarget, bool &Allow)
{
LeftDockPanelUnDock(Sender,Client,NewTarget,Allow);
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::ControlBarDockOver(TObject *Sender,
TDragDockObject *Source, int X, int Y, TDragState State,
bool &Accept)
{
Accept = (dynamic_cast<TToolBar*>(Source->Control) != NULL);
if(Accept)
{
Types::TPoint TopLeft = Types::TPoint(ControlBar->ClientRect.Left, ControlBar->ClientRect.Top);
TopLeft = ControlBar->ClientToScreen(TopLeft);
Types::TPoint BottomRight = Types::TPoint(ControlBar->ClientRect.Right, ControlBar->ClientRect.Bottom);
BottomRight = ControlBar->ClientToScreen(BottomRight);
Source->DockRect = Types::TRect(TopLeft, BottomRight);
}
}
//---------------------------------------------------------------------------
void __fastcall TIdeForm::FileBrowserWindowShow(bool IsShow)
{
if(IsShow)
{
if(FileBrowserForm == NULL)
throw EInvalidCast("");
if(dynamic_cast<TPageControl*>(FileBrowserForm->HostDockSite) != NULL)
static_cast<TTabDockHost*>(FileBrowserForm->HostDockSite->Owner)->Show();
else if( (dynamic_cast<TConJoinDockHost*>(FileBrowserForm->HostDockSite) != NULL) && !FileBrowserForm->HostDockSite->Visible)
{
FileBrowserForm->HostDockSite->Show();
(static_cast<TConJoinDockHost*>(FileBrowserForm->HostDockSite))->UpdateCaption(NULL);
FileBrowserForm->Show();
}
else
{
if((dynamic_cast<TPanel*>(FileBrowserForm->HostDockSite) != NULL)&& ((FileBrowserForm->HostDockSite->Height == 0) | (FileBrowserForm->HostDockSite->Width == 0)))
IdeForm->ShowDockPanel((static_cast<TPanel*>(FileBrowserForm->HostDockSite)), true, FileBrowserForm);
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -