Hi All,
I got another step in the layout management, especially the device orietation change challenge.
Yes, the *NEW* jPanel simplifies and actually makes this task very easy and "smart".
Follows code and image just for exemplification....
Achieved that goal I inclose the first part of my work and will try to available the new version of my LazAndroidWizard
with support for simonsayz's Controls (including my own extensions..
Now I will focus on writing a more complete readme.txt/tutorial.... I want to complete this task as quickly as possible (03 days?)
Thank to All and special thanks to Simonsayz!
*.dfm
object AndroidModule1: TAndroidModule1
OnCreate = DataModuleCreate
OldCreateOrder = False
BackButton = True
Title = 'jForm'
BackgroundColor = colbrBlack
OnRotate = DataModuleRotate
OnJNIPrompt = DataModuleJNIPrompt
Height = 424
HorizontalOffset = 424
VerticalOffset = 125
Width = 265
object jPanel1: jPanel
Id = 139436
PosRelativeToAnchor = []
PosRelativeToParent = []
LayoutParamWidth = lpMatchParent
LayoutParamHeight = lpOneThirdOfParent
MarginLeft = 0
MarginTop = 0
MarginRight = 0
MarginBottom = 0
Visible = True
BackgroundColor = colbrLightSteelBlue
left = 64
top = 8
end
object jPanel2: jPanel
Id = 0
Anchor = jPanel1
PosRelativeToAnchor = [raBelow]
PosRelativeToParent = []
LayoutParamWidth = lpMatchParent
LayoutParamHeight = lpMatchParent
MarginLeft = 0
MarginTop = 0
MarginRight = 0
MarginBottom = 0
Visible = True
BackgroundColor = colbrWhite
left = 64
top = 304
end
object jTextView1: jTextView
Id = 3313746
PosRelativeToAnchor = []
PosRelativeToParent = [rpCenterHorizontal]
LayoutParamWidth = lpWrapContent
LayoutParamHeight = lpWrapContent
MarginLeft = 10
MarginTop = 10
MarginRight = 10
MarginBottom = 10
ParentPanel = jPanel1
Alignment = taLeft
Visible = True
Enabled = True
BackgroundColor = colbrDefault
FontColor = colbrRed
FontSize = 0
Text = 'jPanel Demo'
left = 136
top = 8
end
object jButton1: jButton
Id = 2882086
Anchor = jTextView1
PosRelativeToAnchor = [raBelow]
PosRelativeToParent = []
LayoutParamWidth = lpMatchParent
LayoutParamHeight = lpWrapContent
MarginLeft = 5
MarginTop = 5
MarginRight = 5
MarginBottom = 5
ParentPanel = jPanel1
Visible = True
BackgroundColor = colbrDefault
Text = 'Show Image Light'
FontColor = colbrDefault
FontSize = 0
OnClick = jButton1Click
left = 136
top = 72
end
object jImageView1: jImageView
Id = 0
Anchor = jTextView3
PosRelativeToAnchor = [raBelow]
PosRelativeToParent = []
LayoutParamWidth = lpMatchParent
LayoutParamHeight = lpMatchParent
MarginLeft = 0
MarginTop = 0
MarginRight = 0
MarginBottom = 0
ParentPanel = jPanel2
ImageIndex = 0
Images = jImageList1
Visible = True
BackgroundColor = colbrDefault
BackgroundImage = False
left = 120
top = 360
end
object jImageList1: jImageList
Images.Strings = (
'Lazarus_Logo_Light.png'
'Lazarus_Logo_Dark.png'
)
left = 192
top = 360
end
object jButton2: jButton
Id = 4091625
Anchor = jButton1
PosRelativeToAnchor = [raBelow]
PosRelativeToParent = []
LayoutParamWidth = lpMatchParent
LayoutParamHeight = lpWrapContent
MarginLeft = 5
MarginTop = 5
MarginRight = 5
MarginBottom = 5
ParentPanel = jPanel1
Visible = True
BackgroundColor = colbrDefault
Text = 'Show Image Dark'
FontColor = colbrDefault
FontSize = 0
OnClick = jButton2Click
left = 136
top = 134
end
object jTextView2: jTextView
Id = 0
PosRelativeToAnchor = []
PosRelativeToParent = [rpBottom, rpRight]
LayoutParamWidth = lpWrapContent
LayoutParamHeight = lpWrapContent
MarginLeft = 10
MarginTop = 10
MarginRight = 10
MarginBottom = 10
ParentPanel = jPanel1
Alignment = taLeft
Visible = True
Enabled = True
BackgroundColor = colbrDefault
FontColor = colbrMidnightBlue
FontSize = 0
Text = 'Panel 1'
left = 136
top = 192
end
object jTextView3: jTextView
Id = 9682626
PosRelativeToAnchor = []
PosRelativeToParent = [rpTop, rpLeft]
LayoutParamWidth = lpWrapContent
LayoutParamHeight = lpWrapContent
MarginLeft = 10
MarginTop = 10
MarginRight = 10
MarginBottom = 10
ParentPanel = jPanel2
Alignment = taLeft
Visible = True
Enabled = True
BackgroundColor = colbrDefault
FontColor = colbrSlateBlue
FontSize = 0
Text = 'Lazarus_Logo'
left = 120
top = 304
end
object jTextView4: jTextView
Id = 5428635
Anchor = jTextView3
PosRelativeToAnchor = [raAlignBaseline, raAlignRight]
PosRelativeToParent = [rpRight]
LayoutParamWidth = lpWrapContent
LayoutParamHeight = lpWrapContent
MarginLeft = 10
MarginTop = 10
MarginRight = 10
MarginBottom = 10
ParentPanel = jPanel2
Alignment = taLeft
Visible = True
Enabled = True
BackgroundColor = colbrDefault
FontColor = colbrMidnightBlue
FontSize = 0
Text = 'Panel 2'
left = 192
top = 304
end
end
*.pas
{Hint: save all files to location: C:\adt32\eclipse\workspace\AppDemo2\jni }
unit unit1;
{$mode delphi}
interface
uses
Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls;
type
{ TAndroidModule1 }
TAndroidModule1 = class(jForm)
jButton1: jButton;
jButton2: jButton;
jImageList1: jImageList;
jImageView1: jImageView;
jPanel1: jPanel;
jPanel2: jPanel;
jTextView1: jTextView;
jTextView2: jTextView;
jTextView3: jTextView;
jTextView4: jTextView;
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleJNIPrompt(Sender: TObject);
procedure DataModuleRotate(Sender: TObject; rotate: integer;
var rstRotate: integer);
procedure jButton1Click(Sender: TObject);
procedure jButton2Click(Sender: TObject);
private
{private declarations}
public
{public declarations}
end;
var
AndroidModule1: TAndroidModule1;
implementation
{$R *.lfm}
{ TAndroidModule1 }
procedure TAndroidModule1.DataModuleCreate(Sender: TObject);
begin
OnJNIPrompt:= DataModuleJNIPrompt; {<-- delphi mode...}
OnRotate:= DataModuleRotate; {<-- delphi mode...}
end;
procedure TAndroidModule1.DataModuleJNIPrompt(Sender: TObject);
begin
jTextView3.Text:= jImageView1.ImageName; //Lazarus_Logo_Light.png
Self.Show;
end;
procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
jImageView1.ImageIndex:= 0;
jTextView3.Text:= jImageView1.ImageName; //Lazarus_Logo_Light.png
end;
procedure TAndroidModule1.jButton2Click(Sender: TObject);
begin
jImageView1.ImageIndex:= 1;
jTextView3.Text:= jImageView1.ImageName; //Lazarus_Logo_Dark.png
end;
{rotate=1 --> device is on vertical/default position; rotate=2 device is on horizontal position}
procedure TAndroidModule1.DataModuleRotate(Sender: TObject; rotate: integer; var rstRotate: integer);
begin
if rotate = 2 then //after rotation device is on horizontal
begin
jPanel1.LayoutParamHeight:=lpMatchParent;
jPanel1.LayoutParamWidth:= lpHalfOfParent;
jPanel2.PosRelativeToAnchor:= [raToRightOf,raAlignBaseline];
end
else {1} //after rotation device is on vertical/default
begin
jPanel1.LayoutParamHeight:= lpOneThirdOfParent;
jPanel1.LayoutParamWidth:= lpMatchParent;
jPanel2.PosRelativeToAnchor:= [raBelow];
end;
Self.UpdateLayout;
end;
end.