lainz пре 9 година
родитељ
комит
7ed0c051ca

+ 84 - 0
test/test_paperlistbox/paperlistbox.lpi

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+  <ProjectOptions>
+    <Version Value="10"/>
+    <PathDelim Value="\"/>
+    <General>
+      <SessionStorage Value="InProjectDir"/>
+      <MainUnit Value="0"/>
+      <Title Value="Paper ListBox"/>
+      <ResourceType Value="res"/>
+      <UseXPManifest Value="True"/>
+      <XPManifest>
+        <DpiAware Value="True"/>
+        <TextName Value="CompanyName.ProductName.AppName"/>
+        <TextDesc Value="Your application description."/>
+      </XPManifest>
+    </General>
+    <VersionInfo>
+      <StringTable ProductVersion=""/>
+    </VersionInfo>
+    <BuildModes Count="1">
+      <Item1 Name="Default" Default="True"/>
+    </BuildModes>
+    <PublishOptions>
+      <Version Value="2"/>
+    </PublishOptions>
+    <RunParams>
+      <local>
+        <FormatVersion Value="1"/>
+      </local>
+    </RunParams>
+    <RequiredPackages Count="2">
+      <Item1>
+        <PackageName Value="bgracontrols"/>
+      </Item1>
+      <Item2>
+        <PackageName Value="LCL"/>
+      </Item2>
+    </RequiredPackages>
+    <Units Count="2">
+      <Unit0>
+        <Filename Value="paperlistbox.lpr"/>
+        <IsPartOfProject Value="True"/>
+      </Unit0>
+      <Unit1>
+        <Filename Value="umain.pas"/>
+        <IsPartOfProject Value="True"/>
+        <ComponentName Value="Form1"/>
+        <ResourceBaseClass Value="Form"/>
+      </Unit1>
+    </Units>
+  </ProjectOptions>
+  <CompilerOptions>
+    <Version Value="11"/>
+    <PathDelim Value="\"/>
+    <Target>
+      <Filename Value="paperlistbox"/>
+    </Target>
+    <SearchPaths>
+      <IncludeFiles Value="$(ProjOutDir)"/>
+      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
+    </SearchPaths>
+    <Linking>
+      <Options>
+        <Win32>
+          <GraphicApplication Value="True"/>
+        </Win32>
+      </Options>
+    </Linking>
+  </CompilerOptions>
+  <Debugging>
+    <Exceptions Count="3">
+      <Item1>
+        <Name Value="EAbort"/>
+      </Item1>
+      <Item2>
+        <Name Value="ECodetoolError"/>
+      </Item2>
+      <Item3>
+        <Name Value="EFOpenError"/>
+      </Item3>
+    </Exceptions>
+  </Debugging>
+</CONFIG>

+ 22 - 0
test/test_paperlistbox/paperlistbox.lpr

@@ -0,0 +1,22 @@
+program paperlistbox;
+
+{$mode objfpc}{$H+}
+
+uses
+  {$IFDEF UNIX}{$IFDEF UseCThreads}
+  cthreads,
+  {$ENDIF}{$ENDIF}
+  Interfaces, // this includes the LCL widgetset
+  Forms, umain
+  { you can add units after this };
+
+{$R *.res}
+
+begin
+  Application.Title:='Paper ListBox';
+  RequireDerivedFormResource:=True;
+  Application.Initialize;
+  Application.CreateForm(TForm1, Form1);
+  Application.Run;
+end.
+

BIN
test/test_paperlistbox/shadow.png


+ 92 - 0
test/test_paperlistbox/umain.lfm

@@ -0,0 +1,92 @@
+object Form1: TForm1
+  Left = 424
+  Height = 486
+  Top = 156
+  Width = 696
+  Caption = 'Paper ListBox'
+  ClientHeight = 486
+  ClientWidth = 696
+  DesignTimePPI = 120
+  OnCreate = FormCreate
+  OnDestroy = FormDestroy
+  LCLVersion = '1.7'
+  object BGRAVirtualScreen1: TBGRAVirtualScreen
+    Left = 0
+    Height = 486
+    Top = 0
+    Width = 696
+    Align = alClient
+    Alignment = taLeftJustify
+    ClientHeight = 486
+    ClientWidth = 696
+    Color = 16448250
+    ParentColor = False
+    TabOrder = 0
+    object BGRAVirtualScreen2: TBGRAVirtualScreen
+      Left = 16
+      Height = 450
+      Top = 16
+      Width = 330
+      OnRedraw = BGRAVirtualScreen2Redraw
+      Alignment = taLeftJustify
+      ChildSizing.LeftRightSpacing = 16
+      ChildSizing.TopBottomSpacing = 16
+      ClientHeight = 450
+      ClientWidth = 330
+      Color = clBlack
+      ParentColor = False
+      TabOrder = 0
+      object ListBox1: TListBox
+        Left = 17
+        Height = 416
+        Top = 17
+        Width = 296
+        Align = alClient
+        BorderStyle = bsNone
+        Items.Strings = (
+          'Inbox'
+          'Starred'
+          'Sent mail'
+          'Drafts'
+        )
+        ItemHeight = 0
+        OnDrawItem = ListBox1DrawItem
+        Style = lbOwnerDrawFixed
+        TabOrder = 0
+      end
+    end
+    object BGRAVirtualScreen3: TBGRAVirtualScreen
+      Left = 352
+      Height = 128
+      Top = 16
+      Width = 330
+      OnRedraw = BGRAVirtualScreen2Redraw
+      Alignment = taLeftJustify
+      ChildSizing.LeftRightSpacing = 16
+      ChildSizing.TopBottomSpacing = 16
+      ClientHeight = 128
+      ClientWidth = 330
+      Color = clBlack
+      ParentColor = False
+      TabOrder = 1
+      object ListBox2: TListBox
+        Left = 17
+        Height = 94
+        Top = 17
+        Width = 296
+        Align = alClient
+        BorderStyle = bsNone
+        Items.Strings = (
+          'Inbox'
+          'Starred'
+          'Sent mail'
+          'Drafts'
+        )
+        ItemHeight = 0
+        OnDrawItem = ListBox1DrawItem
+        Style = lbOwnerDrawFixed
+        TabOrder = 0
+      end
+    end
+  end
+end

+ 107 - 0
test/test_paperlistbox/umain.pas

@@ -0,0 +1,107 @@
+unit umain;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
+  BGRAVirtualScreen, BGRABitmap, BCTypes, BGRASliceScaling, Types, LCLType;
+
+type
+
+  { TForm1 }
+
+  TForm1 = class(TForm)
+    BGRAVirtualScreen1: TBGRAVirtualScreen;
+    BGRAVirtualScreen2: TBGRAVirtualScreen;
+    BGRAVirtualScreen3: TBGRAVirtualScreen;
+    ListBox1: TListBox;
+    ListBox2: TListBox;
+    procedure BGRAVirtualScreen2Redraw(Sender: TObject; Bitmap: TBGRABitmap);
+    procedure FormCreate(Sender: TObject);
+    procedure FormDestroy(Sender: TObject);
+    procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
+      ARect: TRect; State: TOwnerDrawState);
+  private
+    shadow: TBGRASliceScaling;
+  public
+
+  end;
+
+var
+  Form1: TForm1;
+
+implementation
+
+{$R *.lfm}
+
+{ TForm1 }
+
+procedure TForm1.BGRAVirtualScreen2Redraw(Sender: TObject; Bitmap: TBGRABitmap);
+begin
+  if Assigned(shadow) then
+    shadow.Draw(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
+end;
+
+procedure TForm1.FormCreate(Sender: TObject);
+begin
+  shadow := TBGRASliceScaling.Create(ProgramDirectory + 'shadow.png');
+  shadow.Margins := Margins(6, 9, 6, 9);
+
+  with BGRAVirtualScreen2.ChildSizing do
+  begin
+    ControlsPerLine := 1;
+    LeftRightSpacing := 4;
+    TopBottomSpacing := 5;
+  end;
+
+  ListBox1.ItemHeight := ScaleY(48, 96);
+  ListBox1.Style := lbOwnerDrawFixed;
+
+  with BGRAVirtualScreen3.ChildSizing do
+  begin
+    ControlsPerLine := 1;
+    LeftRightSpacing := 4;
+    TopBottomSpacing := 5;
+  end;
+
+  ListBox2.ItemHeight := ScaleY(48, 96);
+  ListBox2.Style := lbOwnerDrawFixed;
+end;
+
+procedure TForm1.FormDestroy(Sender: TObject);
+begin
+  shadow.Free;
+end;
+
+procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
+  ARect: TRect; State: TOwnerDrawState);
+var
+  lb: TListBox;
+  hg: integer;
+begin
+  lb := TListBox(Control);
+
+  lb.Canvas.Clipping := False;
+
+  if odSelected in State then
+  begin
+    lb.Canvas.Brush.Color := $00e4e4e4;
+    lb.Canvas.Font.Style := [fsBold];
+  end
+  else
+  begin
+    lb.Canvas.Brush.Color := clWhite;
+  end;
+  lb.Canvas.FillRect(ARect);
+  hg := lb.Canvas.TextHeight(lb.Items[Index]);
+  lb.Canvas.Font.Color := clBlack;
+  lb.Canvas.TextOut(ARect.Left + ScaleX(16, 96), ARect.Top + (lb.ItemHeight - hg) div 2, lb.Items[Index]);
+
+  lb.Canvas.Clipping := True;
+  lb.Canvas.ClipRect := Rect(0, 0, 0, 0);
+end;
+
+end.
+