⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tmtimelinemainformu.cpp

📁 jvcl driver development envionment
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************

                       JEDI-VCL Demo

 Copyright (C) 2002 Project JEDI

The Initial Developer of the Original Code is Peter Th鰎nqvist [peter3 att users dott sourceforge dott net]
Portions created by Peter Th鰎nqvist are Copyright (C) 2002 Peter Th鰎nqvist.
All Rights Reserved.

 Contributor(s):
   korecek: translation from Delphi to BCB

 You may retrieve the latest version of this file at the JEDI-JVCL
 home page, located at http://jvcl.sourceforge.net

 The contents of this file are used with permission, subject to
 the Mozilla Public License Version 1.1 (the "License"); you may
 not use this file except in compliance with the License. You may
 obtain a copy of the License at
 http://www.mozilla.org/MPL/MPL-1_1Final.html

 Software distributed under the License is distributed on an
 "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 implied. See the License for the specific language governing
 rights and limitations under the License.

******************************************************************/
// $Id: TMTimeLineMainFormU.cpp,v 1.2 2005/11/22 13:50:35 ahuser Exp $
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "TMTimeLineMainFormU.h"
#include "frmMemoEdit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#pragma link "JvTMTimeLine"
TTMTimeLineMainForm *TMTimeLineMainForm;
//---------------------------------------------------------------------------
__fastcall TTMTimeLineMainForm::TTMTimeLineMainForm(TComponent* Owner)
        : TForm(Owner)
{
  ForceCurrentDirectory = true;
  JvTimeLine1               = new TJvTMTimeline(this);
  JvTimeLine1->Parent       = this;
  JvTimeLine1->PopupMenu    = popTimeLine;
  JvTimeLine1->OnChange     = DoDateChange;
  JvTimeLine1->OnClick      = DoClick;
  JvTimeLine1->OnDblClick   = DoDblClick;
  JvTimeLine1->Images       = il16;
  JvTimeLine1->Align        = alClient;
  JvTimeLine1->Hint         = "Double-click a date to edit it's memo content.\n\rRight-click to display pop-up menu.";
  dtpSelDate->Date     = Date();
  dtpFirstDate->Date   = Date()-7;
  dtpImageDate->Date   = Date()+7;
  udDayWidth->Position = JvTimeLine1->DayWidth;
  chkReadOnly->Checked = JvTimeLine1->ReadOnly;
  JvTimeLine1->Date    = dtpFirstDate->Date;
  JvTimeLine1->SelDate = dtpSelDate->Date;
  lbObjFontStyle->Checked[2] = true;
  for(int i = 0;i<il16->Count;++i)
  {
    TListItem* pLI=lvImages->Items->Add();
    pLI->ImageIndex = i;
    pLI->Caption = IntToStr(i);
  }
  Splitter1->Top = JvTimeLine1->Height + 5;
}
//---------------------------------------------------------------------------
void __fastcall TTMTimeLineMainForm::udScrollSmallClick(TObject *Sender,
      TUDBtnType Button)
{
  JvTimeLine1->SmallChange = udScrollSmall->Position;        
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::DoDateChange(TObject* Sender)
{
  dtpFirstDate->Date = JvTimeLine1->Date;
  StatusBarResize(Sender);
}


void __fastcall TTMTimeLineMainForm::DoClick(TObject* Sender)
{
  dtpSelDate->Date   = JvTimeLine1->SelDate;
  dtpImageDate->Date = JvTimeLine1->SelDate;
}


void __fastcall TTMTimeLineMainForm::DoDblClick(TObject* Sender)
{
  mnuEditMemo->Click();
}

void __fastcall TTMTimeLineMainForm::StatusBarResize(TObject *Sender)
{
  StatusBar->Panels->Items[0]->Text = Format("Visible days: %d",OPENARRAY(TVarRec,(JvTimeLine1->VisibleDays)));
  StatusBar->Panels->Items[1]->Text = Format("Last visible date: %s",OPENARRAY(TVarRec,(DateToStr(JvTimeLine1->LastVisibleDate))));

}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::mnuEditMemoClick(TObject *Sender)
{
 TStringList *S;
 int i;
 TIcon *Ico;

// WARNING: if you store integers or other ordinal values in the Objects array
// you will get an AV if you call the ClearObjects method:
//  JvTimeLine1.Objects[JvTimeLine1.Date] := TObject(Random(100));

  S = dynamic_cast<TStringList* >( JvTimeLine1->Objects[JvTimeLine1->SelDate]);
  // here's a trick: extract the image from the imagelist and assign t to the icon property of the form:
  i = JvTimeLine1->ImageIndex[JvTimeLine1->SelDate];
  if( i > -1 )
  {
    Ico = new TIcon();
    il16->GetIcon(i,Ico);
  }
  else
  {
    Ico = NULL;
  }
  if( S == NULL )
  {
    S =  new TStringList();
  }
  // TIP: add a class function to dialogs that you show modally.
  // That way, you can keep all the creating and freeing stuff in the
  // dialog unit instead of in the calling unit.
  // This reduces the dialog call to a one-liner:
  TMemoEditFrm_Edit(S,JvTimeLine1->SelDate,Ico); // the Edit function automatically updates S if the user clicked OK in the dialog
  AnsiString sTmp = Trim(S->Text);
  if( sTmp.Length() == 0 )
  { // there is no text, so free the stringlist to conserve memory
    delete S;
    S = NULL;
  }
  JvTimeLine1->Objects[JvTimeLine1->SelDate] = S; // either way, store the value (nil or TStringlist)
  // if Objects[JvTimeLine1.Date] has a non-nil value, the day number is underlined for that date
  delete Ico;

}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::mnuInsertImageClick(TObject *Sender)
{
  JvTimeLine1->ImageIndex[JvTimeLine1->SelDate] = udImageNo->Position;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::mnuRemoveImageClick(TObject *Sender)
{
  JvTimeLine1->ImageIndex[JvTimeLine1->SelDate] = -1;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::mnuTodayClick(TObject *Sender)
{
  JvTimeLine1->Date = Date() - JvTimeLine1->VisibleDays / 2;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::mnuGotoDateClick(TObject *Sender)
{
  JvTimeLine1->Date = JvTimeLine1->SelDate - (JvTimeLine1->VisibleDays / 2);
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::udScrollLargeClick(TObject *Sender,
      TUDBtnType Button)
{
  JvTimeLine1->LargeChange = udScrollLarge->Position;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::udDayWidthClick(TObject *Sender,
      TUDBtnType Button)
{
  JvTimeLine1->DayWidth = udDayWidth->Position;
  udDayWidth->Position  = JvTimeLine1->DayWidth;
  StatusBarResize(Sender);
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::udPenWidthClick(TObject *Sender,
      TUDBtnType Button)
{
  JvTimeLine1->Selection->Pen->Width = udPenWidth->Position;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::udButtonWidthClick(TObject *Sender,
      TUDBtnType Button)
{
  JvTimeLine1->ButtonWidth = udButtonWidth->Position;
  StatusBarResize(Sender);
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::chkReadOnlyClick(TObject *Sender)
{
  JvTimeLine1->ReadOnly = chkReadOnly->Checked;
  StatusBarResize(Sender);
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::chkFlatClick(TObject *Sender)
{
  TBorderStyle cBStyle[2] = {bsSingle,bsNone};

  JvTimeLine1->BorderStyle = cBStyle[chkFlat->Checked];

}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::chkRClickClick(TObject *Sender)
{
  JvTimeLine1->RightClickSelect = chkRClick->Checked;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::chkEnabledClick(TObject *Sender)
{
  JvTimeLine1->Enabled = chkEnabled->Checked;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::chkShowTodayClick(TObject *Sender)
{
  JvTimeLine1->ShowToday = chkShowToday->Checked;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::chkShowTodayIconClick(TObject *Sender)
{
  JvTimeLine1->ShowTodayIcon = chkShowTodayIcon->Checked;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::chkShowWeeksClick(TObject *Sender)
{
  JvTimeLine1->ShowWeeks = chkShowWeeks->Checked;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::chkShowMonthsClick(TObject *Sender)
{
  JvTimeLine1->ShowMonths = chkShowMonths->Checked;
}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::btnColorClick(TObject *Sender)
{
  TColorDialog *pCD;
  pCD = new TColorDialog(NULL);


  try
  {
    pCD->Color = JvTimeLine1->Color;
    if( pCD-> Execute() )
    {
      JvTimeLine1->Color = pCD->Color;
    }
  }
  __finally
  {
    delete pCD;
  }

}
//---------------------------------------------------------------------------

void __fastcall TTMTimeLineMainForm::btnLineColorClick(TObject *Sender)
{
  TColorDialog *pCD;
  pCD = new TColorDialog(NULL);


  try
  {
    pCD->Color = JvTimeLine1->LineColor;;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -