Window widths/heights named correctly

This commit is contained in:
Владислав Джавадов 2020-06-07 22:30:49 +03:00
parent b366037e72
commit ec5f97eecf
10 changed files with 81 additions and 79 deletions

View File

@ -15,15 +15,15 @@ const
RED_BUTTON = 4000; RED_BUTTON = 4000;
var var
Left, Right, Top, Bottom: Integer; WndLeft, WndTop, WndWidth, WndHeight: Integer;
begin begin
with GetScreenSize do with GetScreenSize do
begin begin
Right := Width div 4; WndWidth := Width div 4;
Bottom := Height div 4; WndHeight := Height div 4;
Left := (Width - Right) div 2; WndLeft := (Width - WndWidth) div 2;
Top := (Height - Bottom) div 2; WndTop := (Height - WndHeight) div 2;
end; end;
while True do while True do
@ -31,7 +31,7 @@ begin
REDRAW_EVENT: REDRAW_EVENT:
begin begin
BeginDraw; BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Color Buttons', $00FFFFFF, DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Color Buttons', $00FFFFFF,
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE); WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
DrawButton(10, 20, 50, 30, COLOR_RED, 0, RED_BUTTON); DrawButton(10, 20, 50, 30, COLOR_RED, 0, RED_BUTTON);
DrawButton(70, 20, 50, 30, COLOR_GREEN, 0, GREEN_BUTTON); DrawButton(70, 20, 50, 30, COLOR_GREEN, 0, GREEN_BUTTON);

View File

@ -51,7 +51,7 @@ asm
end; end;
var var
Left, Right, Top, Bottom: Integer; WndLeft, WndTop, WndWidth, WndHeight: Integer;
TargaFile: PTargaFile; TargaFile: PTargaFile;
Image: Pointer; Image: Pointer;
FileSize: LongWord; FileSize: LongWord;
@ -69,10 +69,10 @@ begin
with GetScreenSize do with GetScreenSize do
begin begin
Right := Width div 4; WndWidth := Width div 4;
Bottom := Height div 4; WndHeight := Height div 4;
Left := (Width - Right) div 2; WndLeft := (Width - WndWidth) div 2;
Top := (Height - Bottom) div 2; WndTop := (Height - WndHeight) div 2;
end; end;
while True do while True do
@ -80,7 +80,7 @@ begin
REDRAW_EVENT: REDRAW_EVENT:
begin begin
BeginDraw; BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Draw Image', $00FFFFFF, DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Draw Image', $00FFFFFF,
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE); WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
with TargaFile.Header do with TargaFile.Header do
DrawImage(Image^, 30, 20, Width, Height); DrawImage(Image^, 30, 20, Width, Height);

View File

@ -71,7 +71,7 @@ asm
end; end;
var var
Left, Right, Top, Bottom: Integer; WndLeft, WndTop, WndWidth, WndHeight: Integer;
BitmapFile1, BitmapFile2, BitmapFile3: PBitmapFile; BitmapFile1, BitmapFile2, BitmapFile3: PBitmapFile;
Image1, Image2, Image3: Pointer; Image1, Image2, Image3: Pointer;
Padding1, Padding2, Padding3: LongWord; Padding1, Padding2, Padding3: LongWord;
@ -116,10 +116,10 @@ begin
with GetScreenSize do with GetScreenSize do
begin begin
Right := 340; WndWidth := 340;
Bottom := Height div 4; WndHeight := Height div 4;
Left := (Width - Right) div 2; WndLeft := (Width - WndWidth) div 2;
Top := (Height - Bottom) div 2; WndTop := (Height - WndHeight) div 2;
end; end;
while True do while True do
@ -128,7 +128,7 @@ begin
begin begin
BeginDraw; BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Draw Image Extended', $00FFFFFF, DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Draw Image Extended', $00FFFFFF,
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE); WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
(* these image files was saved with 'flip row order' parameter *) (* these image files was saved with 'flip row order' parameter *)

View File

@ -4,16 +4,16 @@ uses
KolibriOS; KolibriOS;
var var
Left, Right, Top, Bottom, CurX, CurY: Integer; WndLeft, WndTop, WndWidth, WndHeight, CurX, CurY: Integer;
Key: TKeyboardInput; Key: TKeyboardInput;
begin begin
with GetScreenSize do with GetScreenSize do
begin begin
Right := Width div 4; WndWidth := Width div 4;
Bottom := Height div 4; WndHeight := Height div 4;
Left := (Width - Right) div 2; WndLeft := (Width - WndWidth) div 2;
Top := (Height - Bottom) div 2; WndTop := (Height - WndHeight) div 2;
end; end;
CurX := 0; CurX := 0;
@ -26,7 +26,7 @@ begin
CurX := 0; CurX := 0;
CurY := 0; CurY := 0;
BeginDraw; BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Please type text to draw', $00FFFFFF, DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Please type text to draw', $00FFFFFF,
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE); WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
EndDraw; EndDraw;
end; end;

View File

@ -4,23 +4,24 @@ uses
KolibriOS; KolibriOS;
var var
Window, Rectangle: TRect; WndLeft, WndTop, WndWidth, WndHeight: Integer;
Rect: TRect;
Point: TPoint; Point: TPoint;
begin begin
with Window, GetScreenSize do with GetScreenSize do
begin begin
Right := Width div 4; WndWidth := Width div 4;
Bottom := Height div 4; WndHeight := Height div 4;
Left := (Width - Right) div 2; WndLeft := (Width - WndWidth) div 2;
Top := (Height - Bottom) div 2; WndTop := (Height - WndHeight) div 2;
end; end;
with Rectangle do with Rect do
begin begin
Left := 10; Left := 10;
Top := 10; Top := 10;
Right := Window.Right - 20; Right := WndWidth - 20;
Bottom := Window.Bottom - 40; Bottom := WndHeight - 40;
end; end;
SetEventMask(EM_REDRAW + EM_BUTTON + EM_MOUSE); SetEventMask(EM_REDRAW + EM_BUTTON + EM_MOUSE);
@ -31,11 +32,10 @@ begin
begin begin
BeginDraw; BeginDraw;
with Window do DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Get Pixel', $00FFFFFF,
DrawWindow(Left, Top, Right, Bottom, 'Get Pixel', $00FFFFFF,
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE); WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
with Rectangle do with Rect do
begin begin
DrawLine(Left, Top, Left, Bottom, 0); DrawLine(Left, Top, Left, Bottom, 0);
DrawLine(Right, Top, Right, Bottom, 0); DrawLine(Right, Top, Right, Bottom, 0);
@ -48,7 +48,7 @@ begin
MOUSE_EVENT: MOUSE_EVENT:
begin begin
Point := GetMousePos; Point := GetMousePos;
with Rectangle, Point do with Rect, Point do
DrawRectangle(Left + 1, Top + 1, Right - Left - 1, Bottom - Top - 1, GetPixel(X, Y)); DrawRectangle(Left + 1, Top + 1, Right - Left - 1, Bottom - Top - 1, GetPixel(X, Y));
end; end;
BUTTON_EVENT: BUTTON_EVENT:

View File

@ -4,15 +4,15 @@ uses
KolibriOS; KolibriOS;
var var
Left, Right, Top, Bottom: Integer; WndLeft, WndTop, WndWidth, WndHeight: Integer;
begin begin
with GetScreenSize do with GetScreenSize do
begin begin
Right := Width div 4; WndWidth := Width div 4;
Bottom := Height div 4; WndHeight := Height div 4;
Left := (Width - Right) div 2; WndLeft := (Width - WndWidth) div 2;
Top := (Height - Bottom) div 2; WndTop := (Height - WndHeight) div 2;
end; end;
while True do while True do
@ -20,7 +20,7 @@ begin
REDRAW_EVENT: REDRAW_EVENT:
begin begin
BeginDraw; BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Hello!', $00FFFFFF, DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Hello!', $00FFFFFF,
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE); WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
EndDraw; EndDraw;
end; end;
@ -28,6 +28,6 @@ begin
GetKey; GetKey;
BUTTON_EVENT: BUTTON_EVENT:
if GetButton.ID = 1 then if GetButton.ID = 1 then
Break; TerminateThread;
end; end;
end. end.

View File

@ -17,23 +17,23 @@ type
TRGBTripleArray = array[0..0] of TRGBTriple; TRGBTripleArray = array[0..0] of TRGBTriple;
var var
Left, Right, Top, Bottom: Integer; WndLeft, WndTop, WndWidth, WndHeight: Integer;
Screen: TSize; ScreenSize: TSize;
Image, Preview: PRGBTripleArray; Image, Preview: PRGBTripleArray;
function Red(A, B: LongWord): LongWord; function Red(A, B: LongWord): LongWord;
begin begin
Red := Image[(Screen.Width * B + A)].Red; Red := Image[(ScreenSize.Width * B + A)].Red;
end; end;
function Green(A, B: LongWord): LongWord; function Green(A, B: LongWord): LongWord;
begin begin
Green := Image[(Screen.Width * B + A)].Green; Green := Image[(ScreenSize.Width * B + A)].Green;
end; end;
function Blue(A, B: LongWord): LongWord; function Blue(A, B: LongWord): LongWord;
begin begin
Blue := Image[(Screen.Width * B + A)].Blue; Blue := Image[(ScreenSize.Width * B + A)].Blue;
end; end;
procedure ResizeImage; procedure ResizeImage;
@ -41,12 +41,12 @@ var
A, B, I: LongWord; A, B, I: LongWord;
begin begin
A := 0; A := 0;
while A < Screen.Width do while A < ScreenSize.Width do
begin begin
B := 0; B := 0;
while B < Screen.Height do while B < ScreenSize.Height do
begin begin
I := ((Screen.Width div 2) * B + A) div 2; I := ((ScreenSize.Width div 2) * B + A) div 2;
Preview[i].Red := (Red(A, B) + Red(A+ 1, B) + Red(A, B + 1) + Red(A + 1, B + 1)) div 4; Preview[i].Red := (Red(A, B) + Red(A+ 1, B) + Red(A, B + 1) + Red(A + 1, B + 1)) div 4;
Preview[i].Green := (Green(A, B) + Green(A + 1, B) + Green(A, B + 1) + Green(A + 1, B + 1)) div 4; Preview[i].Green := (Green(A, B) + Green(A + 1, B) + Green(A, B + 1) + Green(A + 1, B + 1)) div 4;
Preview[i].Blue := (Blue(A, B) + Blue(A + 1, B) + Blue(A, B + 1) + Blue(A + 1, B + 1)) div 4; Preview[i].Blue := (Blue(A, B) + Blue(A + 1, B) + Blue(A, B + 1) + Blue(A + 1, B + 1)) div 4;
@ -59,14 +59,14 @@ end;
begin begin
HeapInit; HeapInit;
Screen := GetScreenSize; ScreenSize := GetScreenSize;
with Screen do with ScreenSize do
begin begin
Right := BORDER_SIZE * 2 + Width div 2 - 1; WndWidth := BORDER_SIZE * 2 + Width div 2 - 1;
Bottom := BORDER_SIZE + GetSkinHeight + Height div 2 - 1; WndHeight := BORDER_SIZE + GetSkinHeight + Height div 2 - 1;
Left := (Width - Right) div 2; WndLeft := (Width - WndWidth) div 2;
Top := (Height - Bottom) div 2; WndTop := (Height - WndHeight) div 2;
Image := HeapAllocate(Width * Height * 3); Image := HeapAllocate(Width * Height * 3);
Preview := HeapAllocate(Width * Height * 3 div 2); Preview := HeapAllocate(Width * Height * 3 div 2);
@ -80,9 +80,9 @@ begin
REDRAW_EVENT: REDRAW_EVENT:
begin begin
BeginDraw; BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Screenshot', $00FFFFFF, DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Screenshot', $00FFFFFF,
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION + WS_TRANSPARENT_FILL, CAPTION_MOVABLE); WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION + WS_TRANSPARENT_FILL, CAPTION_MOVABLE);
with Screen do with ScreenSize do
DrawImage(Preview^, 0, 0, Width div 2, Height div 2); DrawImage(Preview^, 0, 0, Width div 2, Height div 2);
EndDraw; EndDraw;
end; end;

View File

@ -63,7 +63,7 @@ asm
end; end;
var var
Left, Right, Top, Bottom: Integer; WndLeft, WndTop, WndWidth, WndHeight: Integer;
ArrowBitmapFile, PointBitmapFile, WaitBitmapFile: PBitmapFile; ArrowBitmapFile, PointBitmapFile, WaitBitmapFile: PBitmapFile;
ArrowBitmap, PointBitmap, WaitBitmap: Pointer; ArrowBitmap, PointBitmap, WaitBitmap: Pointer;
@ -91,10 +91,10 @@ begin
with GetScreenSize do with GetScreenSize do
begin begin
Right := Width div 4; WndWidth := Width div 4;
Bottom := Height div 4; WndHeight := Height div 4;
Left := (Width - Right) div 2; WndLeft := (Width - WndWidth) div 2;
Top := (Height - Bottom) div 2; WndTop := (Height - WndHeight) div 2;
end; end;
while True do while True do
@ -103,7 +103,7 @@ begin
begin begin
BeginDraw; BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Set Cursor', $00FFFFFF, DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Set Cursor', $00FFFFFF,
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE); WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
DrawText( 8, 8, 'Click on picture buttons', 0, $00FFFFFF, DT_CP866_8x16 + DT_FILL_OPAQUE + DT_ZSTRING, 0); DrawText( 8, 8, 'Click on picture buttons', 0, $00FFFFFF, DT_CP866_8x16 + DT_FILL_OPAQUE + DT_ZSTRING, 0);

View File

@ -4,16 +4,16 @@ uses
KolibriOS; KolibriOS;
var var
Left, Right, Top, Bottom: Integer; WndLeft, WndTop, WndWidth, WndHeight: Integer;
X, Y: Integer; X, Y: Integer;
begin begin
with GetScreenSize do with GetScreenSize do
begin begin
Right := 180; WndWidth := 180;
Bottom := 180; WndHeight := 180;
Left := (Width - Right) div 2; WndLeft := (Width - WndWidth) div 2;
Top := (Height - Bottom) div 2; WndTop := (Height - WndHeight) div 2;
end; end;
while True do while True do
@ -22,7 +22,7 @@ begin
begin begin
BeginDraw; BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Set Pixel', $00FFFFFF, DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Set Pixel', $00FFFFFF,
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE); WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
for Y := 0 to 50 do for Y := 0 to 50 do

View File

@ -52,15 +52,17 @@ begin
end; end;
var var
Left, Right, Top, Bottom: Integer; WndLeft, WndTop, WndWidth, WndHeight: Integer;
begin begin
with GetScreenSize do with GetScreenSize do
begin begin
Right := Width div 4; WndWidth := Width div 4;
Bottom := Height div 4; if WndWidth < 280 then
Left := (Width - Right) div 2; WndWidth := 280; // to center the prompt
Top := (Height - Bottom) div 2; WndHeight := Height div 4;
WndLeft := (Width - WndWidth) div 2;
WndTop := (Height - WndHeight) div 2;
end; end;
while True do while True do
@ -68,7 +70,7 @@ begin
REDRAW_EVENT: REDRAW_EVENT:
begin begin
BeginDraw; BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Set Window Position', $00FFFFFF, DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Set Window Position', $00FFFFFF,
WS_SKINNED_SIZABLE + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE); WS_SKINNED_SIZABLE + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
DrawText(24, 26, 'Use arrow keys(Left, Right, Up, Down)', $00000000, $00FFFFFF, DT_ZSTRING, 0); DrawText(24, 26, 'Use arrow keys(Left, Right, Up, Down)', $00000000, $00FFFFFF, DT_ZSTRING, 0);
DrawText(24, 35, 'to move the window.', $00000000, $00FFFFFF, DT_ZSTRING, 0); DrawText(24, 35, 'to move the window.', $00000000, $00FFFFFF, DT_ZSTRING, 0);