Advertisement
Guest User

HM error

a guest
Feb 14th, 2014
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 35.81 KB | None | 0 0
  1. unit UWelcomePageFrame;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, ExtCtrls, jpeg, Buttons, ExtDlgs, Math, HMGdiPanel,
  8.   Vcl.OleCtrls, SHDocVw
  9.   , frmVideosUnit
  10.   ;
  11.  
  12. type
  13.   THMTileColorSet = Array[0..5] of TColor;
  14.  
  15. const
  16.   BLUE_COLORSET: THMTileColorSet = ($966438, $3A9638, $933896, $3A9638, $967B38, $96383A);
  17.   BLACK_COLORSET: THMTileColorSet = ($4B9417, $932117, $5F1793, $178993, $17935F, $4A9317);
  18.   SILVER_COLORSET: THMTileColorSet = ($386496, $38963A, $963893, $966938, $387B96, $3A3896);
  19.  
  20. {$DEFINE MEDIA_AS_FILES}
  21.  
  22. type
  23.   TRecentFilesOpenDocument = procedure(Sender: TObject; const AFileName: String) of object;
  24.   THMExecFrameCommandEvent = function(ACommand: String): Boolean of object;
  25.  
  26.   THMNewsItem = record
  27.     Title: String;
  28.     Description: String;
  29.     Link: String;
  30.     PubDate: String;
  31.   end;
  32.   THMNewsItemArray = Array of THMNewsItem;
  33.  
  34.   TWelcomePageFrame = class(TForm)
  35.     objStartTimer: TTimer;
  36.     imgBackground: TImage;
  37.     imgDefault: TImage;
  38.     GDIPaintPanel: THMGDIPaintPanel;
  39.     CheckBox1: TCheckBox;
  40.     procedure FormDestroy(Sender: TObject);
  41.     procedure FormShow(Sender: TObject);
  42.     procedure objStartTimerTimer(Sender: TObject);
  43.     procedure GDIPaintPanelMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  44.     procedure GDIPaintPanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  45.     procedure GDIPaintPanelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  46.     procedure GDIPaintPanelMouseLeave(Sender: TObject);
  47.     procedure FormCreate(Sender: TObject);
  48.     procedure FormResize(Sender: TObject);
  49.     procedure GDIPaintPanelBackgroundDraw(Sender: TObject; ADC: HDC; const AWidth, AHeight: Integer);
  50.     procedure btnStartClick(Sender: TObject);
  51.     procedure btnNewsClick(Sender: TObject);
  52.     procedure BtnWallpaperClick(Sender: TObject);
  53.   strict private
  54.     procedure BackFromVideos(sender: TObject);
  55.     procedure DoVideosClick(Sender: TObject);
  56.   private
  57.     FOnFrameCommand: THMExecFrameCommandEvent;
  58.     FNews: THMNewsItemArray;
  59.  
  60.     FSelectedItem: THMTileItem;
  61.     FPressedItem: THMTileItem;
  62.     FIsRecentPage: Boolean;
  63.     FWelcomeItem: THMTileItem;
  64.     FFacebookItem: THMTileItem;
  65.     FForumItem: THMTileItem;
  66.     FBackItem: THMTileItem;
  67.     FBackgroundColor: TColor;
  68.     FUpdatesItem: THMTileItem;
  69.     FRecentFileNames: TStringList;
  70.     FOnOpenRecentFile: TRecentFilesOpenDocument;
  71.     FNewProjectItem: THMTileItem;
  72.     FOpenProjectItem: THMTileItem;
  73.     FExamplesItem: THMTileItem;
  74.     FTutorialsItem: THMTileItem;
  75.     FNewsUpdateItem: THMTileItem;
  76.     FNewsFeedItem: THMTileItem;
  77.     FColorSet: THMTileColorSet;
  78.     FBkImage: TBitmap;
  79.     fVideosFrame: TFrmVideos;
  80.     FWallpaper: String;
  81.     procedure SetBackgroundColor(const Value: TColor);
  82.  
  83.     procedure DoBack2Click(Sender: TObject);
  84.     procedure DoNewsClick(Sender: TObject);
  85.     procedure DoOpenRecentClick(Sender: TObject);
  86.  
  87.     procedure DoWelcomeClick(Sender: TObject);
  88.     procedure DoNewProjectClick(Sender: TObject);
  89.     procedure DoOpenSamplesClick(Sender: TObject);
  90.  
  91.     procedure DoForumClick(Sender: TObject);
  92.     procedure DoFacebookClick(Sender: TObject);
  93.     procedure DoSupportClick(Sender: TObject);
  94.     procedure DoUpdateClick(Sender: TObject);
  95.  
  96.     procedure DoOpenNewsClick(Sender: TObject);
  97.     procedure DoOpenNewsItemClick(Sender: TObject);
  98.     procedure SetColorSet(const Value: THMTileColorSet);
  99.     procedure SetSelectedItem(const Value: THMTileItem);
  100.     procedure SetWallpaper(const Value: String);
  101.     procedure InternalCreateWhatsNewItem(const aScale, aIndex: Integer;
  102.       caption, desc: string);
  103.  
  104.   protected
  105.  
  106.     function _x(const AXIndex: Integer): Integer;
  107.     function _w(const AWCount: Integer): Integer;
  108.     function _y(const AYIndex: Integer): Integer;
  109.     function _h(const AHCount: Integer): Integer;
  110.  
  111.     function _x2(const AXIndex: Integer): Integer;
  112.     function _w2(const AWCount: Integer): Integer;
  113.     function _y2(const AYIndex: Integer): Integer;
  114.     function _h2(const AHCount: Integer): Integer;
  115.  
  116. {$IFDEF MEDIA_AS_FILES}
  117.     function _media(const AFileName: String): String;
  118. {$ELSE}
  119.     function _media(const AFileName: String): TStream;
  120. {$ENDIF}
  121.     function _recentFiles: String;
  122.  
  123.     procedure EvalImageSize;
  124.  
  125.     function  ExecFrameCommand(const ACommand: String): boolean;
  126.  
  127.     function CreateSingleRecentItem(const AFileName: String): THMTileItem;
  128.     function CreateSingleRecentItem2(const AFileName: String; const AIndex, AScale, AHeightMultiplier: Integer): THMTileItem;
  129.     function CreateBackTile: THMTileItem;
  130.  
  131.     procedure CreateMainItems(const AScale: Integer);
  132.     procedure CreateMainRecentItems(const AScale: Integer);
  133.     procedure CreateRecentItems;
  134.     procedure CreateNewsItems(const AScale: Integer);
  135.  
  136.     procedure ShowMainItems;
  137.  
  138.     procedure DoOpenRecentFile(const AFileName: String);
  139.  
  140.     procedure AnimateMainIcons;
  141.     procedure AnimateNewsIcons;
  142.     property SelectedItem: THMTileItem read FSelectedItem write SetSelectedItem;
  143.  
  144.   public
  145.     constructor Create(AOwner: TComponent); override;
  146.       destructor Destroy; override;
  147.  
  148.     function  DoCommandClick(ACommand: String): boolean;
  149.  
  150.     procedure DisplayUpdatePage;
  151.     procedure DisplayMainPage;
  152.  
  153.     procedure ClearIcons;
  154.     procedure RefreshDisplay;
  155.     property ColorSet: THMTileColorSet read FColorSet write SetColorSet;
  156.  
  157.     property OnFrameCommand: THMExecFrameCommandEvent read FOnFrameCommand write FOnFrameCommand;
  158.     property OnOpenRecentFile: TRecentFilesOpenDocument read FOnOpenRecentFile write FOnOpenRecentFile;
  159.     property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor;
  160.     property Wallpaper: String read FWallpaper write SetWallpaper;
  161.   end;
  162.  
  163.   function HMEllipsifyText(AsPath: Boolean; const Text: String; const Canvas: TCanvas; MaxWidth: Integer): String;
  164.  
  165.  
  166. var
  167.   WelcomePageFrame: TWelcomePageFrame;
  168.  
  169.  
  170. implementation
  171.  
  172. uses
  173.   ShellAPI;
  174.  
  175. {$R *.dfm}
  176.  
  177. var
  178.   AppFileDate: TDateTimeInfoRec;
  179.  
  180. const
  181.   TILE_HEIGHT = 120;
  182.   TILE_WIDTH = 120;
  183.   TILE_HGAP = 8;
  184.   TILE_VGAP = 8;
  185.  
  186.   V_OFFSET = 8; // 40;
  187.   H_OFFSET = 40;
  188.  
  189.   TILE_HEIGHT2 = 56;
  190. //  TILE_WIDTH2 = 78;
  191.   TILE_WIDTH2 = 88;
  192.   TILE_HGAP2 = 8;
  193.   TILE_VGAP2 = 8;
  194.  
  195.   V_OFFSET2 = 8; // 40;
  196.   H_OFFSET2 = 40;
  197.  
  198.   RECENT_TILESPAN = 4;
  199.   RECENT_TILESPERROW = 2;
  200.  
  201.   EXAMPLE_TILESPAN = 3;
  202.   EXAMPLE_TILESPERROW = 2;
  203.  
  204.   INFLATE_X = 4;
  205.   INFLATE_Y = 4;
  206.  
  207.   ExamplesFilesDir = 'Examples\';
  208.  
  209.  
  210. var
  211.   gStrNewsPage: AnsiString;
  212.  
  213. resourcestring
  214.   SUHMUpdateVersionUptodate = 'Your copy of the program is up-to-date!'#13#10'Thank you for checking!';
  215.   SUHMHtmlWelcomePage4NoConnect = 'Cannot retrieve news feed from the website.';
  216.  
  217.   SUHMTileGetStartedHeading = 'Get Started!';
  218.   SUHMTileGetStartedText    = 'A brief introduction to FCS Express';
  219.   SUHMTileNewsHeading = 'Updates';
  220.   SUHMTileNewsText = 'Check for updates and news';
  221.   SUHMTileRecentHeading = 'Recent Projects';
  222.   SUHMTileNewProjectHeading = 'New Layout';
  223.   SUHMTileNewProjectText = 'Create a new layout';
  224.  
  225.   SUHMTileOpenLayoutHeading = 'Open Layout';
  226.   SUHMTileOpenLayoutText = 'Open an existing layout';
  227.  
  228.   SUHMTileForumHeading = 'Forum';
  229.   SUHMTileFacebookHeading = '';
  230.   SUHMTileLinkedInHeading = 'LinkedIn';
  231.   SUHMTileFeedbackHeading = 'Feedback';
  232.   SUHMTileExamplesHeading = 'Examples';
  233.   SUHMTileExamplesText = 'Example layouts (for Research Use Only)';
  234.   SUHMTileHelpfileHeading = 'Help';
  235.   SUHMTileTutorialsHeading = 'Tutorials';
  236.   SUHMTileTutorialsText = 'Check out the tutorials on our website';
  237.  
  238.   SUHMTileVideosHeading = 'Videos';
  239.   SUHMTileVideosText = '';
  240.  
  241.   SUHMTileUpdateHeading = 'Update';
  242.   SUHMTileNewsfeedHeading = 'Help+Manual News';
  243.   SUHMTileBackToWelcomeHeading = 'Back';
  244.   SUHMTileBackToWelcomeText = '';
  245.   SUHMUpdateNotAvailable = 'Update information could not be retrieved. Please check your internet connection!';
  246.  
  247. function HMEllipsifyText(AsPath: Boolean; const Text: String; const Canvas: TCanvas; MaxWidth: Integer): String;
  248. var
  249.   TempPChar: PChar;
  250.   TempRect: TRect;
  251.   Params: UINT;
  252. begin
  253.   GetMem(TempPChar, (Length(Text) + 1) * SizeOf(TempPChar));
  254.   try
  255.     TempPChar := StrPCopy(TempPChar, Text);
  256.     TempRect := Rect(0, 0, MaxWidth, High(Integer));
  257.     if AsPath then Params := DT_PATH_ELLIPSIS
  258.               else Params := DT_END_ELLIPSIS;
  259.     Params := Params + DT_MODIFYSTRING + DT_CALCRECT;
  260.     DrawTextEx(Canvas.Handle, TempPChar, -1, TempRect, Params, nil);
  261.     Result := StrPas(TempPChar);
  262.   finally
  263.     FreeMem(TempPChar);
  264.   end;
  265. end;
  266.  
  267. function _min(const AValue1, AValue2: Extended): Extended;
  268. begin
  269.   if AValue1 < AValue2 then Result := AValue1 else Result := AValue2;
  270. end;
  271.  
  272. function _dpi(const AValue: Integer): Integer;
  273. begin
  274.   Result := MulDiv(AValue, Screen.PixelsPerInch, 96);
  275. end;
  276.  
  277. function _makeHeader(ATile: THMTileItem; const DoPrepare: Boolean; const aHeaderMarginLeft: Integer;
  278.                           const aHeaderMarginTop: Integer; const aForcePrepare: boolean;
  279.                           const aSetLeftMargins: boolean; const aSetBottomMargins: boolean):
  280.     THMTileItem;
  281. begin
  282.   ATile.HeaderVerticalAlign := taVerticalCenter;
  283.   ATile.HeaderMargins.Left := _dpi(aHeaderMarginLeft);
  284.   ATile.HeaderMargins.Top := _dpi(aHeaderMarginTop);
  285.   if aSetLeftMargins then
  286.     ATile.TextMargins.Left := _dpi(90);
  287.   if aSetBottomMargins and (ATile.Description <> '') then
  288.     ATile.HeaderMargins.Bottom := _dpi(40);
  289.  
  290.   if DoPrepare then
  291.     ATile.PrepareItem(aForcePrepare);
  292.   Result := ATile;
  293. end;
  294.  
  295. function _makeFullHeader(ATile: THMTileItem; const DoPrepare: Boolean = True):
  296.     THMTileItem;
  297. begin
  298.   result := _makeHeader(ATile, DoPrepare, 90, 6, False, True, True);
  299. end;
  300.  
  301. function _makeHalfHeader(ATile: THMTileItem; const DoPrepare: Boolean = True;
  302.     aHeaderOnBottom: Boolean = False): THMTileItem;
  303. var
  304.   headerTop: Integer;
  305. begin
  306.   if aHeaderOnBottom then
  307.     headerTop := 75
  308.   else
  309.     headerTop := 2;
  310.  
  311.   result := _makeHeader(ATile, DoPrepare, 7, headerTop, True, False, False);
  312. end;
  313.  
  314.  
  315. { TWelcomePageFrame }
  316.  
  317. procedure TWelcomePageFrame.AnimateMainIcons;
  318. begin
  319.   GDIPaintPanel.ClearItems;
  320.   CreateMainItems(100);
  321.  
  322.   objStartTimer.Enabled := True;
  323. end;
  324.  
  325. procedure TWelcomePageFrame.AnimateNewsIcons;
  326. begin
  327.   GDIPaintPanel.ClearItems;
  328.   CreateNewsItems(0);
  329.   objStartTimer.Enabled := True;
  330. end;
  331.  
  332.  
  333. function TWelcomePageFrame.DoCommandClick(ACommand: String): boolean;
  334. begin
  335.  
  336.   if ACommand = '!Update' then
  337.     ShellExecute(Application.MainForm.Handle, 'open', 'http://www.helpandmanual.com/downloads.html', nil, nil, SW_SHOWNORMAL)
  338.   else if ACommand = '!Facebook' then
  339.     ShellExecute(Application.MainForm.Handle, 'open', 'https://www.facebook.com/pages/FCS-Express-by-De-Novo-Software/174628995902591', nil, nil, SW_SHOWNORMAL)
  340.   else
  341.     showmessage('Command clicked: ' + ACommand);
  342.  
  343.   result := true;
  344. end;
  345.  
  346. procedure TWelcomePageFrame.btnNewsClick(Sender: TObject);
  347. begin
  348.   AnimateNewsIcons;
  349. end;
  350.  
  351. procedure TWelcomePageFrame.btnStartClick(Sender: TObject);
  352. begin
  353.   AnimateMainIcons;
  354. end;
  355.  
  356. procedure TWelcomePageFrame.BtnWallpaperClick(Sender: TObject);
  357. begin
  358.   with TOpenDialog.create(nil) do
  359.   try
  360.     if Execute then SetWallpaper(filename);
  361.   finally
  362.     free;
  363.   end;
  364. end;
  365.  
  366. procedure TWelcomePageFrame.ClearIcons;
  367. begin
  368.   FRecentFileNames.Clear;
  369.   GDIPaintPanel.ClearItems;
  370.   GDIPaintPanel.Redraw;
  371. end;
  372.  
  373. constructor TWelcomePageFrame.Create(AOwner: TComponent);
  374. begin
  375.   inherited;
  376.  
  377.   FBkImage := nil;
  378.  
  379.   FRecentFileNames := TStringList.Create;
  380.   FSelectedItem := nil;
  381.   FPressedItem := nil;
  382.   FIsRecentPage := False;
  383.  
  384.   FOnFrameCommand := nil;
  385.   FOnOpenRecentFile := nil;
  386.  
  387.   imgBackground.Picture.assign(imgDefault.Picture);
  388.  
  389.   FOnFrameCommand := DoCommandClick;
  390.  
  391.   CreateMainItems(0);
  392. end;
  393.  
  394. function TWelcomePageFrame.CreateBackTile: THMTileItem;
  395. begin
  396.   Result := THMTileItem.CreateEx(GDIPaintPanel, _x(2), _y(2), clYellow, clBlack, 'Show the home screen', '', '');
  397.   Result.BorderWidth := 0;
  398.   Result.PrepareItem;
  399. end;
  400.  
  401. procedure TWelcomePageFrame.CreateMainItems(const AScale: Integer);
  402. const LONG_LINE = 'I am the very model of a modern major text error. ';
  403. begin
  404.   Canvas.Font.Size := 10;
  405.  
  406.   FBackItem := nil;
  407.  
  408.   // first line
  409.   FWelcomeItem := _makeFullHeader(THMTileItem.CreateEx(GDIPaintPanel, _x(2), _y(0), _w(2), _h(1), AScale, AScale, FColorSet[0], clBlack, SUHMTileGetStartedHeading, SUHMTileGetStartedText, _media('welcome.png'), clWhite, taLeftJustify, 1, DoWelcomeClick));
  410.   FNewProjectItem := _makeFullHeader(THMTileItem.CreateEx(GDIPaintPanel, _x(0), _y(0), _w(2), _h(1), AScale, AScale, FColorSet[1], clBlack, SUHMTileNewProjectHeading, SUHMTileNewProjectText, _media('newproject.png'), clBlack, taLeftJustify, 1, DoNewProjectClick));
  411.   FTutorialsItem := _makeHalfHeader(THMTileItem.CreateEx(GDIPaintPanel, _x(4), _y(0), _w(2), _h(1), AScale, AScale, FColorSet[5], clRed, SUHMTileVideosHeading, SUHMTileVideosText, nil{ _media('support.png')}, clWhite, taLeftJustify, 1, DoVideosClick), True, False);
  412.  
  413.  
  414.   CreateMainRecentItems(AScale);
  415.  
  416.   // second line
  417. //  FExamplesItem := _makeHalfHeader(THMTileItem.CreateEx(GDIPaintPanel, _x(0), _y(1), _w(2), _h(2), AScale, AScale, FColorSet[2], clBlack, 'What''s New', '', nil, clRed, taLeftJustify, 1, DoOpenSamplesClick));
  418. //  FExamplesItem.HeaderVerticalAlign := taAlignTop;
  419.   FOpenProjectItem := _makeFullHeader(THMTileItem.CreateEx(GDIPaintPanel, _x(6), _y(0), _w(2), _h(1), AScale, AScale, FColorSet[1], clBlack, SUHMTileOpenLayoutHeading, SUHMTileOpenLayoutText, _media('newproject.png'), clBlack, taLeftJustify, 1, DoNewProjectClick));
  420.  
  421.   FTutorialsItem := _makeHalfHeader(THMTileItem.CreateEx(GDIPaintPanel, _x(2), _y(1), _w(2), _h(1), AScale, AScale, FColorSet[0], clBlack, SUHMTileHelpfileHeading, '', nil{ _media('support.png')}, clWhite, taLeftJustify, 1, DoSupportClick), True, False);
  422.   FTutorialsItem := _makeHalfHeader(THMTileItem.CreateEx(GDIPaintPanel, _x(4), _y(1), _w(2), _h(1), AScale, AScale, FColorSet[5], clBlack, SUHMTileTutorialsHeading, SUHMTileTutorialsText, nil{ _media('support.png')}, clWhite, taLeftJustify, 1, DoSupportClick), True, False);
  423.  
  424.   FForumItem := _makeHalfHeader(THMTileItem.CreateEx(GDIPaintPanel, _x(2), _y(2), _w(1), _h(1), AScale, AScale, FColorSet[3], clBlack, SUHMTileFeedbackHeading, '', nil, clWhite, taRightJustify, 1), True, True);
  425.   FForumItem := _makeHalfHeader(THMTileItem.CreateEx(GDIPaintPanel, _x(3), _y(2), _w(1), _h(1), AScale, AScale, FColorSet[5], clBlack, SUHMTileForumHeading, '', _media('forum.png'), clWhite, taRightJustify, 1, DoForumClick), True, True);
  426.   FFacebookItem := THMTileItem.CreateEx(GDIPaintPanel, _x(4), _y(2), _w(1), _h(1), AScale, AScale, FColorSet[4], clBlack, SUHMTileFacebookHeading, '', _media('facebook.png'), clWhite, taLeftJustify, 1, DoFacebookClick);
  427.   FFacebookItem := THMTileItem.CreateEx(GDIPaintPanel, _x(5), _y(2), _w(1), _h(1), AScale, AScale, FColorSet[2], clBlack, SUHMTileLinkedInHeading, '', nil, clWhite, taRightJustify, 1);
  428.  
  429.   InternalCreateWhatsNewItem(AScale, 1, 'Test', LONG_LINE + LONG_LINE + LONG_LINE + LONG_LINE + LONG_LINE + LONG_LINE);
  430. end;
  431.  
  432. procedure TWelcomePageFrame.CreateMainRecentItems(const AScale: Integer);
  433. var
  434.   tmpFiles: TStringList;
  435.   intIndex, intTotal, intHeightMultiplier: Integer;
  436. begin
  437.   SelectedItem := nil;
  438.   FPressedItem := nil;
  439.   FIsRecentPage := True;
  440.   intHeightMultiplier := 1;
  441.  
  442.   tmpFiles := TStringList.Create;
  443.   try
  444.     FRecentFileNames.Clear;
  445.     for intIndex := 1 to 4 do
  446.       tmpFiles.add(ExtractFilepath(application.ExeName)+ Format('MyFiles\File%d.txt', [intIndex]));
  447.     Canvas.Font.Size := 8;
  448.  
  449.     intTotal := Min(4, tmpFiles.Count);
  450.     for intIndex := 0 to intTotal-1 do
  451.       CreateSingleRecentItem2(tmpFiles[intIndex], intIndex, AScale, intHeightMultiplier);
  452.   finally
  453.     FreeAndNil(tmpFiles);
  454.   end;
  455. end;
  456.  
  457. procedure TWelcomePageFrame.CreateNewsItems(const AScale: Integer);
  458.  
  459.   function GetNews: THMNewsItemArray;
  460.   var
  461.     intIdx: integer;
  462.   begin
  463.     for intIdx := 0 to 5 do
  464.     begin
  465.       SetLength(Result, intIdx+1);
  466.       Result[intIdx].Title := Format('Title of news item %d', [intIdx+1]);
  467.       Result[intIdx].Description := Format('Description of news item %d', [intIdx+1]);
  468.       Result[intIdx].Link := 'http://www.helpandmanual.com/';
  469.       Result[intIdx].PubDate := DateTimeToStr(now);
  470.     end;
  471.   end;
  472.  
  473.  
  474. var
  475.   intIndex: Integer;
  476.   tmpItem: THMTileItem;
  477.   tmpText: String;
  478. begin
  479.   Screen.Cursor := crHourglass;
  480.   try
  481.     // first line
  482.     FNewsUpdateItem := THMTileItem.CreateEx(GDIPaintPanel, _x2(0), _y2(0), _w2(3), _h2(5), AScale, AScale, FColorSet[0], clBlack, SUHMTileUpdateHeading, SUHMUpdateVersionUptodate, _media('update.png'), clWhite, taLeftJustify, 3, DoUpdateClick);
  483.     FNewsUpdateItem.TextMargins.Left := 0;
  484.     FNewsUpdateItem.HeaderTextAlign := taCenter;
  485.     FNewsUpdateItem.PrepareItem;
  486.  
  487.     try
  488.       if Length(FNews) = 0 then
  489.         FNews := GetNews;
  490.  
  491.       Canvas.Font.Size := 8;
  492.       for intIndex := Low(FNews) to High(FNews) do
  493.       begin
  494.         if pos('+', FNews[intIndex].PubDate) > 0 then tmpText := copy(FNews[intIndex].PubDate, 1, pos('+', FNews[intIndex].PubDate)-11)
  495.                                                  else tmpText := FNews[intIndex].PubDate;
  496.         tmpText := '[' + tmpText + '] ' + FNews[intIndex].Description;
  497.   //      tmpText := '[' + FormatDateTime(FormatSettings.ShortDateFormat,  FNews[intIndex].PubDate) + '] ' + FNews[intIndex].Description;
  498.  
  499.   //ItemDate := copy(ItemDate, 1, pos('+', ItemDate)-10);
  500.  
  501.         tmpText := HMEllipsifyText(False, tmpText, Canvas, _w2(5)-2*_dpi(36));
  502.         tmpItem := THMTileItem.CreateEx(GDIPaintPanel, _x2(3), _y2(intIndex), _w2(5), _h2(1), AScale, AScale, FColorSet[2], clBlack, FNews[intIndex].Title, tmpText, _media('newsitem.png'), clBlack, taLeftJustify, 3, DoOpenNewsItemClick);
  503.         tmpItem.TitleFontSize := 13;
  504.         tmpItem.HeaderMargins.Left := _dpi(36);
  505.         tmpItem.TextMargins.Left := _dpi(36);
  506.         tmpItem.DescriptionFontSize := 8;
  507.         tmpItem.TextGap := 7;
  508.  
  509.         tmpItem.Tag := intIndex;
  510.         tmpItem.PrepareItem;
  511.       end;
  512.  
  513.     except
  514.       FNewsFeedItem := THMTileItem.CreateEx(GDIPaintPanel, _x2(3), _y2(0), _w2(5), _h2(6), AScale, AScale, clYellow, clBlack, SUHMTileNewsfeedHeading, SUHMHtmlWelcomePage4NoConnect, _media('news.png'), clBlack, taLeftJustify, 3, DoOpenNewsClick);
  515.       FNewsFeedItem.PrepareItem;
  516.     end;
  517.  
  518.  
  519.     FBackItem := THMTileItem.CreateEx(GDIPaintPanel, _x2(0), _y2(5), _w2(3), _h2(1), AScale, AScale, clGray, clBlack, SUHMTileBackToWelcomeHeading, SUHMTileBackToWelcomeText, _media('back.png'), clWhite, taRightJustify, 3, DoBack2Click);
  520.   finally
  521.     Screen.Cursor := crDefault;
  522.   end;
  523.  
  524. //
  525. //  // second line
  526. //  FNewProjectItem := THMTileItem.CreateEx(GDIPaintPanel, _x(0), _y(1), _w(2), _h(1), AScale, AScale, clYellow, clBlack, 'New project', 'Get help for Help & Manual', _media('buitl2.png'), clBlack, taLeftJustify);
  527. //  FHelpItem := THMTileItem.CreateEx(GDIPaintPanel, _x(2), _y(1), _w(1), _h(1), AScale, AScale, clYellow, clBlack, 'Help', 'Get help for Help & Manual', _media('buitl2.png'), clBlack, taLeftJustify);
  528. //  FForumItem := THMTileItem.CreateEx(GDIPaintPanel, _x(3), _y(1), _w(1), _h(1), AScale, AScale, clYellow, clBlack, 'Forum', 'Get help for Help & Manual', _media('buitl2.png'), clBlack, taLeftJustify);
  529. //
  530. //  FExamplesItem := THMTileItem.CreateEx(GDIPaintPanel, _x(0), _y(2), _w(2), _h(1), AScale, AScale, clYellow, clBlack, 'Examples', 'Get help for Help & Manual', _media('buitl2.png'), clBlack, taLeftJustify);
  531. //  FTutorialsItem := THMTileItem.CreateEx(GDIPaintPanel, _x(2), _y(2), _w(1), _h(1), AScale, AScale, clYellow, clBlack, 'Support', 'Get help for Help & Manual', _media('buitl2.png'), clBlack, taLeftJustify);
  532. //  FFacebookItem := THMTileItem.CreateEx(GDIPaintPanel, _x(3), _y(2), _w(1), _h(1), AScale, AScale, clYellow, clBlack, 'Facebook', 'Irgendso a Schaß mit facebook', _media('buitl3.png'), clBlack, taLeftJustify);
  533. end;
  534.  
  535. procedure TWelcomePageFrame.CreateRecentItems;
  536. var
  537.   tmpFiles: TStringList;
  538.   intIndex: Integer;
  539. begin
  540.   SelectedItem := nil;
  541.   FPressedItem := nil;
  542.   FIsRecentPage := True;
  543.  
  544.   tmpFiles := TStringList.Create;
  545.   try
  546.     FRecentFileNames.Clear;
  547. //    UserSettings.GetMRUDocuments(tmpFiles);
  548.     Canvas.Font.Size := 8;
  549.     for intIndex := 0 to tmpFiles.Count-1 do
  550.       if intIndex < 5*RECENT_TILESPERROW then
  551.         CreateSingleRecentItem(tmpFiles[intIndex]);
  552.   finally
  553.     FreeAndNil(tmpFiles);
  554.   end;
  555.  
  556.   FBackItem := THMTileItem.CreateEx(GDIPaintPanel, _x2(0), _y2(5), _w2(RECENT_TILESPAN), _h2(1), 100, 100, clBtnFace, clBlack, SUHMTileBackToWelcomeHeading, SUHMTileBackToWelcomeText, _media('back2.png'), clWhite, taRightJustify, 2);
  557.   FBackItem.OnClick := DoBack2Click;
  558. end;
  559.  
  560. function TWelcomePageFrame.CreateSingleRecentItem(const AFileName: String): THMTileItem;
  561. var
  562.   intIdx: Integer;
  563.   tmpX: Integer;
  564.   tmpY: Integer;
  565.   tmpW: Integer;
  566. begin
  567.   intIdx := GDIPaintPanel.GetItemCountByGroupIndex([2]);
  568.   tmpX := _x2((intIdx MOD RECENT_TILESPERROW) * RECENT_TILESPAN);
  569.   tmpY := _y2(intIdx DIV RECENT_TILESPERROW);
  570.   tmpW := _w2(RECENT_TILESPAN);
  571.  
  572.   Result := THMTileItem.CreateEx(GDIPaintPanel, tmpX, tmpY, tmpW, _h2(1), 100, 100, clSilver, clBlack, ExtractFileName(AFileName), HMEllipsifyText(True, AFileName, Canvas, tmpW-20), _media('recentitem.png'), clBlack, taLeftJustify, 2);
  573.   Result.TextGap := 7;
  574.   Result.DescriptionFontSize := Canvas.Font.Size;
  575.   Result.TitleFontSize := 14;
  576.   Result.PrepareItem;
  577.  
  578.   FRecentFileNames.AddObject(AFileName, Result);
  579.   Result.OnClick := DoOpenRecentClick;
  580. end;
  581.  
  582. function TWelcomePageFrame.CreateSingleRecentItem2(const AFileName: String; const AIndex, AScale, AHeightMultiplier: Integer): THMTileItem;
  583. var
  584.   tmpX: Integer;
  585.   tmpY: Integer;
  586.   tmpW: Integer;
  587.   tmpFileName: String;
  588.   tmpFilePath: String;
  589.   tmpIsFavorite: Boolean;
  590.   tmpImageName: String;
  591. begin
  592.   tmpX := _x(6); //
  593.   tmpY := _y2((AIndex * AHeightMultiplier) + 2);
  594.   tmpW := _w(2);
  595.  
  596.   Canvas.Font.Size := 14;
  597.   tmpFileName := HMEllipsifyText(False, ExtractFileName(AFileName), Canvas, tmpW - _dpi(20));
  598.   Canvas.Font.Size := 10;
  599.   tmpFilePath := HMEllipsifyText(True, ExtractFilePath(AFileName), Canvas, tmpW - _dpi(20));
  600.  
  601.   tmpIsFavorite := AIndex < 2;
  602.  
  603.   if tmpIsFavorite AND (AHeightMultiplier = 1) then
  604.     tmpImageName := 'recentitem_fav.png'
  605.   else
  606.     tmpImageName := 'recentitem.png';
  607.  
  608.   Result := THMTileItem.CreateEx(GDIPaintPanel, tmpX, tmpY, tmpW, _h2(AHeightMultiplier), AScale, AScale, FColorSet[3], clBlack, tmpFileName, tmpFilePath, _media(tmpImageName), clBlack, taLeftJustify, 1);
  609.   //Result := THMTileItem.CreateEx(GDIPaintPanel, tmpX, tmpY, tmpW, _h2(1), AScale, AScale, FColorSet[3], clBlack, ExtractFileName(AFileName), HMEllipsifyText(True, ExtractFilePath(AFileName), Canvas, tmpW-20), '' {_media('recentitem2.png')}, clWhite, taLeftJustify, 1);
  610.   Result.TextGap := 7;
  611.   Result.DescriptionFontSize := Canvas.Font.Size;
  612.   Result.TitleFontSize := 14;
  613.   Result.PrepareItem;
  614.  
  615.   FRecentFileNames.AddObject(AFileName, Result);
  616.   Result.OnClick := DoOpenRecentClick;
  617. end;
  618.  
  619. destructor TWelcomePageFrame.Destroy;
  620. begin
  621.   FreeAndNil(FRecentFileNames);
  622.   GDIPaintPanel.ClearItems;
  623.   FreeAndNil(FBkImage);
  624.  
  625.   inherited;
  626. end;
  627.  
  628. procedure TWelcomePageFrame.BackFromVideos(sender: TObject);
  629. begin
  630.   FreeAndNil(fVideosFrame);
  631.   CreateMainItems(100);
  632.   GDIPaintPanel.Redraw;
  633. end;
  634.  
  635. procedure TWelcomePageFrame.FormDestroy(Sender: TObject);
  636. begin
  637.   if assigned(fVideosFrame) then
  638.     FreeAndNil(fVideosFrame);
  639. end;
  640.  
  641. procedure TWelcomePageFrame.DisplayMainPage;
  642. begin
  643.   AnimateMainIcons;
  644. end;
  645.  
  646. procedure TWelcomePageFrame.DisplayUpdatePage;
  647. begin
  648.   AnimateNewsIcons;
  649. end;
  650.  
  651. procedure TWelcomePageFrame.DoBack2Click(Sender: TObject);
  652. begin
  653.   CreateMainItems(100);
  654.   GDIPaintPanel.MoveItemsInOut([1], [2, 3, 4], DIRECTION_RIGHT, 25);
  655.   GDIPaintPanel.ClearItemsByGroupIndex([2, 3, 4]);
  656. //  FRecentFileNames.Clear;
  657.   GDIPaintPanel.Redraw;
  658. end;
  659.  
  660.  
  661. procedure TWelcomePageFrame.DoFacebookClick(Sender: TObject);
  662. begin
  663.   ExecFrameCommand('!Facebook');
  664. end;
  665.  
  666. procedure TWelcomePageFrame.DoForumClick(Sender: TObject);
  667. begin
  668.   ShellExecute(Application.MainForm.Handle, 'open', 'http://www.denovosoftware.com/v4forums/', nil, nil, SW_SHOWNORMAL)
  669. end;
  670.  
  671. procedure TWelcomePageFrame.DoNewProjectClick(Sender: TObject);
  672. begin
  673.   ExecFrameCommand('!NewProject');
  674. end;
  675.  
  676. procedure TWelcomePageFrame.DoNewsClick(Sender: TObject);
  677. begin
  678.   FRecentFileNames.Clear;
  679.   CreateNewsItems(100);
  680.  
  681.   GDIPaintPanel.MoveItemsInOut([3], [1], DIRECTION_LEFT, 25);
  682.   GDIPaintPanel.ClearItemsByGroupIndex([1]);
  683.   GDIPaintPanel.Redraw;
  684. end;
  685.  
  686. procedure TWelcomePageFrame.DoOpenNewsClick(Sender: TObject);
  687. begin
  688.   ExecFrameCommand('!OpenSamples');
  689. end;
  690.  
  691. procedure TWelcomePageFrame.DoOpenNewsItemClick(Sender: TObject);
  692. var
  693.   tmpIdx: Integer;
  694. begin
  695.   if Assigned(Sender) AND (Sender is THMTileItem) then
  696.   begin
  697.     tmpIdx := THMTileItem(Sender).Tag;
  698.     if (tmpIdx >= Low(FNews)) AND (tmpIdx <= High(FNews)) then
  699.       ShellExecute(Application.MainForm.Handle, 'open', PChar(FNews[tmpIdx].Link), nil, nil, SW_SHOWNORMAL);
  700.   end;
  701.  
  702. end;
  703.  
  704. procedure TWelcomePageFrame.DoOpenRecentClick(Sender: TObject);
  705. var
  706.   intIndex: Integer;
  707. begin
  708.   for intIndex := 0 to FRecentFileNames.Count-1 do
  709.     if FRecentFileNames.Objects[intIndex] = Sender then
  710.       DoOpenRecentFile(FRecentFileNames[intIndex]);
  711. end;
  712.  
  713. procedure TWelcomePageFrame.DoOpenRecentFile(const AFileName: String);
  714. begin
  715.   if Assigned(FOnOpenRecentFile) and (AFileName <> '') then
  716.     FOnOpenRecentFile(Self, AFileName);
  717. end;
  718.  
  719. procedure TWelcomePageFrame.DoOpenSamplesClick(Sender: TObject);
  720. begin
  721. end;
  722.  
  723. procedure TWelcomePageFrame.DoSupportClick(Sender: TObject);
  724. begin
  725.   ShellExecute(Application.MainForm.Handle, 'open', 'http://www.denovosoftware.com/site/manual/index.html?tutorials.htm', nil, nil, SW_SHOWNORMAL)
  726. end;
  727.  
  728. procedure TWelcomePageFrame.DoUpdateClick(Sender: TObject);
  729. begin
  730.   ExecFrameCommand('!Update');
  731. end;
  732.  
  733. procedure TWelcomePageFrame.DoVideosClick(Sender: TObject);
  734. begin
  735.   GDIPaintPanel.ClearItemsByGroupIndex([1]);
  736.   GDIPaintPanel.Redraw;
  737.   fVideosFrame := TFrmVideos.Create(self);
  738.   fVideosFrame.OnBackButton := BackFromVideos;
  739.   fVideosFrame.parent := self;
  740.   fVideosFrame.align := alClient;
  741.   fVideosFrame.SetupFrame;
  742.   fVideosFrame.Show;
  743. end;
  744.  
  745. procedure TWelcomePageFrame.DoWelcomeClick(Sender: TObject);
  746. begin
  747.   if FileExists(ExamplesFilesDir+'Get Me Started Example\Get_Me_Started.hmxz') then
  748.     DoOpenRecentFile(ExamplesFilesDir+'Get Me Started Example\Get_Me_Started.hmxz')
  749.   else
  750.     ExecFrameCommand('!Welcome');
  751. end;
  752.  
  753. procedure TWelcomePageFrame.EvalImageSize;
  754. var
  755.   tmpScale: Extended;
  756.   tmpRect: TRect;
  757.   tmpImageWidth: Integer;
  758.   tmpImageHeight: Integer;
  759. begin
  760.   // position the panel with the tiles
  761.   GDIPaintPanel.Left := 0;
  762.   GDIPaintPanel.Width := ClientWidth - _dpi(32);
  763.   GDIPaintPanel.Height := _dpi(390 { 454 });
  764.   GDIPaintPanel.Top := (ClientHeight - GDIPaintPanel.Height) DIV 2;
  765.  
  766.   FreeAndNil(FBkImage);
  767.   if (ClientHeight > 100) AND (imgBackground.Picture.Width > 0) then
  768.   begin
  769.     // reposition the image to be stretched
  770.     tmpImageWidth := imgBackground.Picture.Width;
  771.     tmpImageHeight := imgBackground.Picture.Height;
  772.  
  773.     tmpScale := _min(tmpImageWidth / ClientWidth, tmpImageHeight / ClientHeight);
  774.     imgBackground.Width := Round(tmpImageWidth / tmpScale);
  775.     imgBackground.Height := Round(tmpImageHeight / tmpScale);
  776.  
  777.     if imgBackground.Width > ClientWidth then
  778.     begin
  779.       imgBackground.Left := (ClientWidth - imgBackground.Width) DIV 2;
  780.       imgBackground.Top := 0;
  781.     end else begin
  782.       imgBackground.Left := 0;
  783.       imgBackground.Top := (ClientHeight - imgBackground.Height) DIV 2;
  784.     end;
  785.  
  786.     tmpRect := Rect(0, 0, imgBackground.Width, imgBackground.Height);
  787.     OffsetRect(tmpRect, imgBackground.Left, imgBackground.Top-GDIPaintPanel.Top);
  788.  
  789.     FBkImage := HMCreateBitmap(GDIPaintPanel.Width, GDIPaintPanel.Height);
  790.     FBkImage.Canvas.Brush.Color := FBackgroundColor;
  791.     FBkImage.Canvas.FillRect(Rect(-1, -1, FBkImage.Width+2, FBkImage.Height+2));
  792.     FBkImage.Canvas.StretchDraw(tmpRect, imgBackground.Picture.Graphic);
  793.     GDIPaintPanel.OnBackgroundDraw := GDIPaintPanelBackgroundDraw;
  794.   end else
  795.     GDIPaintPanel.OnBackgroundDraw := nil;
  796. end;
  797.  
  798. function TWelcomePageFrame.ExecFrameCommand(const ACommand: String): boolean;
  799. begin
  800.   if Assigned(FOnFrameCommand) then
  801.     Result := FOnFrameCommand(ACommand)
  802.   else
  803.     Result := False;
  804. end;
  805.  
  806. procedure TWelcomePageFrame.FormCreate(Sender: TObject);
  807. begin
  808. {
  809.   Font.Size := 10; // this helps us to calculate ellipsified texts
  810.  
  811.   GDIPaintPanel := THMGDIPaintPanel.create(self);
  812.   with GDIPaintPanel do
  813.   begin
  814.     Parent := self;
  815.     BackgroundColor := clGray;
  816.     ControlState := [];
  817.     ControlStyle := [csCaptureMouse,csClickEvents,csSetCaption,csDoubleClicks,csGestures];
  818.     DockOrientation := doNoOrient;
  819.  
  820.     OnMouseDown := GDIPaintPanelMouseDown;
  821.     OnMouseLeave := GDIPaintPanelMouseLeave;
  822.     OnMouseMove := GDIPaintPanelMouseMove;
  823.     OnMouseUp := GDIPaintPanelMouseUp;
  824.   end;
  825. }
  826.   fVideosFrame := nil;
  827. end;
  828.  
  829. procedure TWelcomePageFrame.FormResize(Sender: TObject);
  830. begin
  831.   EvalImageSize;
  832. end;
  833.  
  834. procedure TWelcomePageFrame.FormShow(Sender: TObject);
  835. begin
  836.   GDIPaintPanel.Font.Assign(self.font);
  837.   EvalImageSize;
  838. end;
  839.  
  840. procedure TWelcomePageFrame.GDIPaintPanelBackgroundDraw(Sender: TObject; ADC: HDC; const AWidth, AHeight: Integer);
  841. begin
  842.   if Assigned(FBkImage) then
  843.     BitBlt(ADC, 0, 0, AWIdth, AHeight, FBkImage.Canvas.Handle, 0, 0, SRCCOPY)
  844. end;
  845.  
  846. procedure TWelcomePageFrame.GDIPaintPanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  847. var
  848.   tmpHitTest: THMTileHitTest;
  849. begin
  850.   tmpHitTest := GDIPaintPanel.HitTest;
  851.   if Assigned(tmpHitTest.HitTile) then
  852.   begin
  853.     tmpHitTest.HitTile.DoHoverIn;
  854.     FPressedItem := tmpHitTest.HitTile;
  855.   end;
  856. end;
  857.  
  858. procedure TWelcomePageFrame.GDIPaintPanelMouseLeave(Sender: TObject);
  859. begin
  860.   if Assigned(FSelectedItem) then
  861.   begin
  862.     HMAnimateInflate(FSelectedItem, 0, 0, FSelectedItem.X, FSelectedItem.Y, INFLATE_X, 90);
  863.     SelectedItem := nil;
  864.   end;
  865. end;
  866.  
  867. procedure TWelcomePageFrame.InternalCreateWhatsNewItem(const aScale, aIndex: Integer; caption, desc: string);
  868. var
  869.   tmpX: Integer;
  870.   tmpY: Integer;
  871.   tmpW: Integer;
  872.   result: THMTileItem;
  873. begin
  874.   tmpX := _x(0); //
  875.   tmpY := _y2(AIndex + 3);
  876.   tmpW := _w(2);
  877.  
  878.   Canvas.Font.Size := 12;
  879.   caption := HMEllipsifyText(False, caption, Canvas, tmpW - _dpi(20));
  880.   Canvas.Font.Size := 8;
  881.   desc := HMEllipsifyText(True, desc, Canvas, tmpW - _dpi(20));
  882.  
  883.   Result := THMTileItem.CreateEx(GDIPaintPanel, tmpX, tmpY, tmpW, _h2(1), AScale, AScale, FColorSet[2], clBlack, caption, desc, _media('whatsnew_item.png'), clGreen, taLeftJustify, 1);
  884.   Result.HeaderVerticalAlign := taAlignTop;
  885.   Result.TextGap := 7;
  886.   Result.DescriptionFontSize := Canvas.Font.Size;
  887.   Result.TitleFontSize := 14;
  888.   Result.PrepareItem;
  889. end;
  890.  
  891. procedure TWelcomePageFrame.GDIPaintPanelMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  892. var
  893.   tmpHitTest: THMTileHitTest;
  894. begin
  895.   tmpHitTest := GDIPaintPanel.HitTest;
  896.  
  897.   if tmpHitTest.HitTile <> FSelectedItem then
  898.   begin
  899.     if Assigned(FSelectedItem) then
  900.       HMAnimateInflate(FSelectedItem, 0, 0, FSelectedItem.X, FSelectedItem.Y, INFLATE_X, 90);
  901.     if Assigned(tmpHitTest.HitTile) then HMAnimateInflate(tmpHitTest.HitTile, INFLATE_X, INFLATE_Y, tmpHitTest.HitTile.X, tmpHitTest.HitTile.Y, INFLATE_X, 90);
  902.     SelectedItem := tmpHitTest.HitTile;
  903.   end;
  904. end;
  905.  
  906. procedure TWelcomePageFrame.GDIPaintPanelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  907. var
  908.   tmpHitTest: THMTileHitTest;
  909. begin
  910.   tmpHitTest := GDIPaintPanel.HitTest;
  911.   if Assigned(FPressedItem) then
  912.   begin
  913.     FPressedItem.DoHoverOut;
  914.     if tmpHitTest.HitTile = FPressedItem then
  915.       FPressedItem.DoClick;
  916.   end;
  917.   FPressedItem := nil;
  918. end;
  919.  
  920. procedure TWelcomePageFrame.objStartTimerTimer(Sender: TObject);
  921. begin
  922.   objStartTimer.Enabled := False;
  923.   GDIPaintPanel.BlendItemsIn([1, 2, 3, 4]);
  924. end;
  925.  
  926. procedure TWelcomePageFrame.RefreshDisplay;
  927. begin
  928.   EvalImageSize;
  929.   Invalidate;
  930.   GDIPaintPanel.Redraw;
  931. end;
  932.  
  933. procedure TWelcomePageFrame.SetBackgroundColor(const Value: TColor);
  934. begin
  935.   FBackgroundColor := Value;
  936.  
  937.   Color := Value;
  938.   GDIPaintPanel.BackgroundColor := FBackgroundColor;
  939.   EvalImageSize;
  940.   GDIPaintPanel.Redraw;
  941. end;
  942.  
  943. procedure TWelcomePageFrame.SetColorSet(const Value: THMTileColorSet);
  944. begin
  945.   FColorSet := Value;
  946.   if (GDIPaintPanel.ItemCount > 0) AND (GDIPaintPanel.Items[0].GroupIndex = 1) then
  947.   begin
  948.     GDIPaintPanel.ClearItems;
  949.     CreateMainItems(100);
  950.     GDIPaintPanel.Redraw;
  951.   end;
  952.  
  953. end;
  954.  
  955. procedure TWelcomePageFrame.SetSelectedItem(const Value: THMTileItem);
  956. begin
  957.   FSelectedItem := Value;
  958.   if Assigned(FSelectedItem) then
  959.     GDIPaintPanel.Cursor := crHandPoint
  960.   else
  961.     GDIPaintPanel.Cursor := crDefault;
  962. end;
  963.  
  964. procedure TWelcomePageFrame.SetWallpaper(const Value: String);
  965. begin
  966.   FWallpaper := Value;
  967.  
  968.   if FileExists(FWallpaper) then
  969.   begin
  970.     imgBackground.Picture.LoadFromFile(FWallpaper);
  971.     GDIPaintPanel.AlphaEnabled := True;
  972.   end
  973.   else begin
  974.     imgBackground.Picture.Assign(imgDefault.Picture);
  975.     GDIPaintPanel.AlphaEnabled := False;
  976.   end;
  977.  
  978.   EvalImageSize;
  979.   Invalidate;
  980.   GDIPaintPanel.Redraw;
  981. end;
  982.  
  983. procedure TWelcomePageFrame.ShowMainItems;
  984. begin
  985.   GDIPaintPanel.MoveItemsOut([2], DIRECTION_LEFT);
  986.   GDIPaintPanel.ClearItems;
  987.   FRecentFileNames.Clear;
  988.   CreateMainItems(100);
  989.   GDIPaintPanel.MoveItemsIn([1], DIRECTION_LEFT);
  990. end;
  991.  
  992. function TWelcomePageFrame._h(const AHCount: Integer): Integer;
  993. begin
  994.   Result := _dpi(AHCount * TILE_HEIGHT + (AHCount-1) * TILE_VGAP); //  298;
  995. end;
  996.  
  997. function TWelcomePageFrame._h2(const AHCount: Integer): Integer;
  998. begin
  999.   Result := _dpi(AHCount * TILE_HEIGHT2 + (AHCount-1) * TILE_VGAP2); //  298;
  1000. end;
  1001.  
  1002. {$IFDEF MEDIA_AS_FILES}
  1003. function TWelcomePageFrame._media(const AFileName: String): String;
  1004. begin
  1005.   Result := ExtractFilePath(Application.ExeName) + 'Media\' + AFileName;
  1006. end;
  1007. {$ELSE}
  1008. function TWelcomePageFrame._media(const AFileName: String): TStream;
  1009. begin
  1010.   if DM.Tiles.ContainsFile(AFileName) then
  1011.     Result := DM.Tiles.Files[AFileName]
  1012.   else
  1013.     Result := nil;
  1014. end;
  1015. {$ENDIF}
  1016.  
  1017. function TWelcomePageFrame._recentFiles: String;
  1018. var
  1019.   tmpFiles: TStringList;
  1020.   intIndex: Integer;
  1021. begin
  1022.   Canvas.Font.Size := 10;
  1023.   tmpFiles := TStringList.Create;
  1024.   try
  1025. //    UserSettings.GetMRUDocuments(tmpFiles);
  1026.     while tmpFiles.Count > 8 do
  1027.       tmpFiles.Delete(8);
  1028.  
  1029.     for intIndex := 0 to tmpFiles.Count-1 do
  1030.       tmpFiles[intIndex] := HMEllipsifyText(True, tmpFiles[intIndex], Self.Canvas, 200);
  1031.  
  1032.  
  1033.     Result := tmpFiles.Text;
  1034.   finally
  1035.     FreeAndNil(tmpFiles);
  1036.   end;
  1037. end;
  1038.  
  1039. function TWelcomePageFrame._w(const AWCount: Integer): Integer;
  1040. begin
  1041.   Result := _dpi(AWCount * TILE_WIDTH + (AWCount-1) * TILE_HGAP);
  1042. end;
  1043.  
  1044. function TWelcomePageFrame._w2(const AWCount: Integer): Integer;
  1045. begin
  1046.   Result := _dpi(AWCount * TILE_WIDTH2 + (AWCount-1) * TILE_HGAP2);
  1047. end;
  1048.  
  1049. function TWelcomePageFrame._x(const AXIndex: Integer): Integer;
  1050. begin
  1051.   Result := _dpi(H_OFFSET + AXIndex * TILE_WIDTH + (AXIndex-1) * TILE_HGAP); //  298;
  1052. end;
  1053.  
  1054. function TWelcomePageFrame._x2(const AXIndex: Integer): Integer;
  1055. begin
  1056.   Result := _dpi(H_OFFSET2 + AXIndex * TILE_WIDTH2 + (AXIndex-1) * TILE_HGAP2); //  298;
  1057. end;
  1058.  
  1059. function TWelcomePageFrame._y(const AYIndex: Integer): Integer;
  1060. begin
  1061.   Result := _dpi(V_OFFSET + AYIndex * TILE_HEIGHT + (AYIndex-1) * TILE_HGAP);
  1062. end;
  1063.  
  1064. function TWelcomePageFrame._y2(const AYIndex: Integer): Integer;
  1065. begin
  1066.   Result := _dpi(V_OFFSET2 + AYIndex * TILE_HEIGHT2 + (AYIndex-1) * TILE_HGAP2);
  1067. end;
  1068.  
  1069.  
  1070. initialization
  1071.   FileGetDateTimeInfo(Application.ExeName, AppFileDate);
  1072.  
  1073.   gDefaultTilesAlpha := 88;
  1074. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement