📄 tmtimelinemainformu.cpp
字号:
if( pCD-> Execute() )
{
JvTimeLine1->LineColor = pCD->Color;
}
}
__finally
{
delete pCD;
}
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::btnFontClick(TObject *Sender)
{
TFontDialog* pFD;
pFD = new TFontDialog(NULL);
try
{
pFD->Font = JvTimeLine1->Font;
if( pFD->Execute() )
{
JvTimeLine1->Font = pFD->Font;
}
}
__finally
{
delete pFD;
}
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::btnTodayColorClick(TObject *Sender)
{
TColorDialog* pCD;
pCD = new TColorDialog(NULL);
try
{
pCD->Color = JvTimeLine1->TodayColor;
if( pCD->Execute() )
{
JvTimeLine1->TodayColor = pCD->Color;
}
}
__finally
{
delete pCD;
}
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::btnMonthFontClick(TObject *Sender)
{
TFontDialog* pFD;
pFD = new TFontDialog(NULL);
try
{
pFD->Font = JvTimeLine1->MonthFont;
if( pFD->Execute() )
{
JvTimeLine1->MonthFont = pFD->Font;
}
}
__finally
{
delete pFD;
}
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::btnPenColorClick(TObject *Sender)
{
TColorDialog* pCD;
pCD = new TColorDialog(NULL);
try
{
pCD->Color = JvTimeLine1->Selection->Pen->Color;
if( pCD->Execute() )
{
JvTimeLine1->Selection->Pen->Color = pCD->Color;
}
}
__finally
{
delete pCD;
}
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::btnLoadClick(TObject *Sender)
{
TOpenDialog* pOD;
pOD = new TOpenDialog(NULL);
try
{
pOD->Filter = "Timeline files|*.tm|All files|*.*";
pOD->DefaultExt = "TM";
if( pOD->Execute() )
{
JvTimeLine1->OnReadObject = DoObjectLoad;
JvTimeLine1->LoadFromFile(pOD->FileName);
}
}
__finally
{
delete pOD;
}
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::DoObjectLoad(TObject* Sender, TStream* Stream, TObject *&AObject)
{
AnsiString S;
int Count;
// Get the length of the string:
Stream->Read(&Count,sizeof(Count));
S.SetLength(Count);
// need we read any more ?
if( Count > 0 )
{
Stream->Read(&S[1],Count);
AObject = new TStringList();
dynamic_cast<TStringList* >(AObject)->Text = S;
}
}
void __fastcall TTMTimeLineMainForm::DoObjectSave(TObject * Sender, TStream * Stream,const TObject * AObject)
{
AnsiString S;
int Count;
TStringList *pSL = (TStringList *)(AObject);
S = pSL->Text;
Count = S.Length();
// save length of string
Stream->Write(&Count,sizeof(Count));
// need we store anything ?
if( Count > 0 )
{
Stream->Write(&S[1],Count);
}
}
void __fastcall TTMTimeLineMainForm::btnSaveClick(TObject *Sender)
{
TSaveDialog* pSD;
pSD = new TSaveDialog(NULL);
try
{
pSD->Filter = "Timeline files|*.tm|All files|*.*";
pSD->DefaultExt = "TM";
if( pSD->Execute() )
{
JvTimeLine1->OnWriteObject = DoObjectSave;
JvTimeLine1->SaveToFile(pSD->FileName);
}
}
__finally
{
delete pSD;
}
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::btnAddClick(TObject *Sender)
{
JvTimeLine1->ImageIndex[dtpImageDate->DateTime] = udImageNo->Position;
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::dtpFirstDateChange(TObject *Sender)
{
JvTimeLine1->Date = dtpFirstDate->Date;
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::dtpSelDateChange(TObject *Sender)
{
JvTimeLine1->SelDate = dtpSelDate->Date;
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::lbObjFontStyleClickCheck(
TObject *Sender)
{
TFontStyles F;
F = TFontStyles() >> fsBold >> fsItalic >> fsUnderline >> fsStrikeOut;
if( lbObjFontStyle->Checked[0])
{
F = F + TFontStyles() << fsBold;
}
if( lbObjFontStyle->Checked[1] )
{
F = F + TFontStyles() << fsItalic ;
}
if( lbObjFontStyle->Checked[2] )
{
F = F + TFontStyles() << fsUnderline;
}
if( lbObjFontStyle->Checked[3] )
{
F = F + TFontStyles() << fsStrikeOut;
}
JvTimeLine1->ObjectsFontStyle = F;
}
//---------------------------------------------------------------------------
// just update the controls when an item in the listview is clicked
void __fastcall TTMTimeLineMainForm::lvImagesSelectItem(TObject *Sender,
TListItem *Item, bool Selected)
{
if( /*Assigned(Item)*/(Item!=NULL) && Selected )
{
udImageNo->Position = Item->ImageIndex;
}
}
//---------------------------------------------------------------------------
// Free any stringlists still around in the Objects array by calling the ClearObjects method
// Do NOT call this method unless the Objects array actually contains
// TObjects (or descendants): calling this method if you store ordinal values
// (like integers), will cause an AV
// You can freely mix object types in the array: the will be freed correctly anyway
void __fastcall TTMTimeLineMainForm::FormCloseQuery(TObject *Sender,
bool &CanClose)
{
JvTimeLine1->ClearObjects();
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::FormMouseWheelDown(TObject *Sender,
TShiftState Shift, TPoint &MousePos, bool &Handled)
{
if( !JvTimeLine1->Focused()
&&
( ControlAtPos(ScreenToClient(MousePos),false,true) == JvTimeLine1 /*TJvTMTimeline*/ )
)
{
Handled = true;
if( Shift.Contains(ssCtrl) )
{
JvTimeLine1->ScrollDate(this,-udScrollSmall->Position);
}
else
{
JvTimeLine1->ScrollDate(this,-udScrollLarge->Position);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::FormMouseWheelUp(TObject *Sender,
TShiftState Shift, TPoint &MousePos, bool &Handled)
{
if( !JvTimeLine1->Focused()
&&
( ControlAtPos(ScreenToClient(MousePos),false,true) == JvTimeLine1 /*TJvTMTimeline*/ )
)
{
Handled = true;
if( Shift.Contains(ssCtrl) )
{
JvTimeLine1->ScrollDate(this,udScrollSmall->Position);
}
else
{
JvTimeLine1->ScrollDate(this,udScrollLarge->Position);
}
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -