Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-08

getdevicecaps

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Larry Dalton

I am converting a program from windows to linux mint. The following unit won't compile under linux because uses the windows unit. I have replaced windows unit with linux unit. Now it can't find GetDeviceCaps. Enclosed is the following unit. What do I have to rewrite to get it to compile under linux?

unit baseformRt;
interface
uses
StringRt,sysutils,StdCtrls,graphics,d_print,person_type,laz_procs,AddressUnit;
type
form_adjust_record=record
form_name:string[20];
form_number:integer;
form_vert_adjust:double;
form_horiz_adjust:double;
filled:boolean;
end;{ends form_adjust_record}
baseform_Writer=object
this_adjust:form_adjust_record;
Top_of_bank:Double;
Last_line:double;
right_side:double;
Bank_Font:TFont;
Bank_Canvas:TCanvas;
vert_adjust:double;
horiz_adjust:double;
Bank_x_pixels:integer;
Bank_Y_Pixels:integer;
b_printer:printrec;
last_pay:tdatetime;
form_horiz_adjust:double;
form_vert_adjust:double;
ppix,ppiy:integer;
b_width:double;
{Del_counter:integer;
del_string:string;}
total_down:currency;
warrantyline:string;
scalex,scaley:double;
var today:tdatetime;
constructor init(var BankCanvas:TCanvas);
procedure stringinit(a_line:string;a_vert:double;a_horiz:double);
procedure set_font_size(const dog:double);
procedure set_font_by_length(const dog:double;const hite:double;const
cat:string);
procedure bottomstring_init(a_line:string;a_vert:double;a_horiz:double);
procedure int_init(a_int:integer;a_vert:double;a_horiz:double);
procedure long_init(a_long:longint;a_vert:double;a_horiz:double);
procedure double_init(a_double:double;a_vert:double;a_horiz:double);
procedure perc_init(a_perc:double;a_vert:double;a_horiz:double);
procedure dollar_init(a_dollar:currency;a_vert:double;a_horiz:double);
procedure x_init(a_vert:double;a_horiz:double);
procedure big_x_init(a_vert:double;a_horiz:double);
procedure dot_init(a_vert:double;a_horiz:double);
procedure na_init(a_vert:double;a_horiz:double);
procedure phn_init(a_phone:phone_record;a_vert:double;a_horiz:double);
procedure date_init(a_date:tdatetime;a_vert:double;a_horiz:double);
procedure street_init(a_street:address_record;a_vert:double;a_horiz:double);
procedure city_init(a_city:address_record;a_vert:double;a_horiz:double);
procedure start_line(vert_start:double;horz_start:double);
procedure draw_line(vert_end:double;horz_end:double);
procedure draw_thin_line(vert_end:double;horz_end:double);
end;
implementation
uses printers,numtools,messages,linux,
forms,dialogs,controls,new_dates;
procedure baseform_writer.draw_line(vert_end:double;horz_end:double);
var b_x,b_y:integer;
test_height:double;
test_string:string;
begin
bank_canvas.Pen.Width:=bank_canvas.pen.width*6;
test_string:='My String';
test_height:=inchheight(bank_canvas,ppiy,test_string);
b_x:=round((form_horiz_adjust+horz_end)*ppix);
b_y:=round((test_height+vert_end+form_vert_adjust)*ppiy);
bank_canvas.LineTo(b_x,b_y);
bank_canvas.pen.width:=round(bank_canvas.pen.width/6);
end;{ends baseform_writer.draw_line}
procedure baseform_writer.draw_thin_line(vert_end:double;horz_end:double);
var b_x,b_y:integer;
test_height:double;
test_string:string;
begin
bank_canvas.Pen.Width:=bank_canvas.pen.width*2;
test_string:='My String';
test_height:=inchheight(bank_canvas,ppiy,test_string);
b_x:=round((form_horiz_adjust+horz_end)*ppix);
b_y:=round((test_height+vert_end+form_vert_adjust)*ppiy);
bank_canvas.LineTo(b_x,b_y);
bank_canvas.pen.width:=round(bank_canvas.pen.width/2);
end;
procedure baseform_writer.start_line(vert_start:double;horz_start:double);
var b_x,b_y:integer;
test_line:string;
test_height:double;
begin
test_line:='My String';
test_height:=inchheight(bank_canvas,ppiy,test_line);
b_y:=round((test_height+vert_start+form_vert_adjust)*ppiy);
b_x:=round((form_horiz_adjust+horz_start)*ppix);
bank_canvas.MoveTo(b_x,b_y);
end;{ends start_line}
constructor baseform_writer.init(var BankCanvas:TCanvas);
var right_marg:double;
message_string:string;
dealer_only:boolean;
line:string;
label end_form;
begin
bank_canvas:=bankcanvas;
b_width:=0;
top_of_bank:=0;
Last_line:=0;
right_side:=0;
Bank_Font:=tfont.Create;
bank_font.Size:=10;
bank_font.Style:=[fsbold];
bank_font.Name:='Times New Roman';
ppix:=GetDeviceCaps(Bank_Canvas.Handle,logpixelsX);
ppiy:=GetDeviceCaps(bank_canvas.Handle,logpixelsY);
bank_x_pixels:=GetDeviceCaps(bank_canvas.Handle,LogPixelsX);
Bank_Y_pixels:=GetDeviceCaps(bank_canvas.Handle,LogPixelsY);
line:='This printer';
vert_adjust:=inchHeight(Bank_Canvas,Bank_Y_Pixels,line);
horiz_adjust:=inchWidth(bank_canvas,bank_x_pixels,line);
Bank_Font.Style:=bank_font.Style-[fsUnderline];
form_horiz_adjust:=0;
form_VERT_ADJUST:=0;

end_form:
end;{ends baseform_writer.init}

procedure
baseform_writer.stringinit(a_line:string;a_vert:double;a_horiz:double);
const this_checker=false;
begin
today:=now;
if this_checker then if messagedlg('now testing
stringinit',mtconfirmation,[mbok,mbabort],0)=mrabort then halt;
IF A_LINE'' THEN
b_printer.init('S',today,0,a_line,a_vert,
a_horiz,bank_font,form_vert_adjust,form_horiz_adjust,bank_canvas);
if this_checker then if messagedlg('stringinit
performed',mtconfirmation,[mbok,mbabort],0)=mrabort then halt;
end;{ends stringinit}
  procedure
baseform_writer.bottomstring_init(a_line:string;a_vert:double;a_horiz:double);
var string_height:double;
test_double:double;
begin
string_height:=inchHeight(bank_canvas,ppiy,a_line);
string_height:=string_Height*0.80;
test_double:=a_vert-string_height;
stringinit(a_line,test_double,a_horiz);
end;{ends bottomstring_init}
procedure
baseform_writer.date_init(a_date:tdatetime;a_vert:double;a_horiz:double);
begin
b_printer.init('D',a_date,0,'',a_vert,a_horiz,
bank_font,form_vert_adjust,form_horiz_adjust,bank_canvas);
end;
procedure
baseform_writer.int_init(a_int:integer;a_vert:double;a_horiz:double);
var integer_width:double;
line:string;
begin
str(a_int,line);
integer_width:=inchWidth(Bank_canvas,Ppix,line);
b_printer.init('S',today,0,line,a_vert,
a_horiz-integer_width,bank_font,
form_vert_adjust,form_horiz_adjust,bank_canvas);
end;
procedure
baseform_writer.long_init(a_long:longint;a_vert:double;a_horiz:double);
var longint_width:double;
line:string;
begin
str(a_long,line);
longint_width:=inchWidth(Bank_canvas,Ppix,line);
a_horiz:=a_horiz-longint_width;
b_printer.init('S',today,0,line,a_vert,a_horiz,bank_font,
form_vert_adjust,form_horiz_adjust,bank_canvas);
end;
procedure
baseform_writer.dollar_init(a_dollar:currency;a_vert:double;a_horiz:double);
var string_dollar:string;
dollar_width:double;
check_int:integer;
line_counter:integer;
test_string_length:integer;
message_string:string;
begin
test_string_length:=1;
if abs(a_dollar)>1 then test_string_length:=2;
if abs(a_dollar)>10 then test_string_length:=3;
if abs(a_dollar)>100 then test_string_length:=4;
if abs(a_dollar)>1000 then test_string_length:=5;
if abs(a_dollar)>10000 then test_string_length:=6;
if abs(a_dollar)>100000 then test_string_length:=7;
if abs(a_dollar)>1000000 then test_string_length:=8;
if abs(a_dollar)>10000000 then test_string_length:=9;
dollar_width:=inchWidth(Bank_Canvas,Bank_X_pixels,string_dollar);
b_printer.init('c',today,a_dollar,'',a_vert,
a_horiz-dollar_width,
bank_font,form_vert_adjust,form_horiz_adjust,bank_canvas);
end;
procedure
baseform_writer.double_init(a_double:double;a_vert:double;a_horiz:double);
var string_double:string;
double_width:double;
test_string:string;
test_string_length:integer;
dec_string_length:integer;
period_pos:integer;
copy_string:string;
begin
test_string_length:=1;
if abs(a_double)>1 then test_string_length:=2;
if abs(a_double)>10 then test_string_length:=3;
if abs(a_double)>100 then test_string_length:=4;
if abs(a_double)>1000 then test_string_length:=5;
if abs(a_double)>10000 then test_string_length:=6;
if abs(a_double)>100000 then test_string_length:=7;
if abs(a_double)>1000000 then test_string_length:=8;
if abs(a_double)>10000000 then test_string_length:=9;
str(a_Double:test_string_length:6,string_double);
dec_string_length:=2;
period_pos:=pos('.',string_double);
copy_string:=copy(string_double,period_pos,7);
if copy_string[3]'0' then dec_string_length:=3;
if copy_string[4]'0' then dec_string_length:=4;
if copy_string[5]'0' then dec_string_length:=5;
if copy_string[6]'0' then dec_string_length:=6;
 str(a_double:test_string_length:dec_string_length,string_double);
double_width:=inchWidth(Bank_Canvas,Bank_x_pixels,string_double);
b_printer.init('R',today,a_double,'',a_vert,a_horiz-double_width,
bank_font,form_vert_adjust,form_horiz_adjust,bank_canvas);
end;
procedure
baseform_writer.perc_init(a_perc:double;a_vert:double;a_horiz:double);
var string_double:string;
double_width:double;
begin
str(a_perc:3:2,string_double);
double_width:=inchWidth(Bank_Canvas,Bank_x_pixels,string_double);
b_printer.init('A',today,a_perc,'',a_vert,a_horiz-double_width,
bank_font,form_vert_adjust,form_horiz_adjust,bank_canvas);
end;
procedure baseform_writer.x_init(a_vert:double;a_horiz:double);
begin
b_printer.init('S',today,0,'X',a_vert,a_horiz,bank_font,form_vert_adjust,form_horiz_adjust,bank_canvas);
end;
procedure baseform_writer.big_x_init(a_vert:double;a_horiz:double);
var hold_font:integer;
this_font_size:integer;
font_line:string;
test_height:double;
x_width:double;
begin{starts procedure big_x_init}
hold_font:=bank_font.Size;
this_font_size:=BANK_FONT.Size;
dec(this_font_size);
this_font_size:=1;
REPEAT
font_line:='X';
inc(this_font_size);
bank_font.size:=this_font_size;
bank_canvas.Font.Size:=bank_font.size;
test_height:=inchheight(bank_canvas,ppiy,font_line);
x_width:=inchwidth(bank_canvas,ppiy,font_line);
str(test_height:3:3,font_line);
font_line:='test_height:='+font_line;
{if messagedlg(font_line,mtconfirmation,[mbok,mbabort],0)=mrabort then
exit;}
until test_height>=0.30;
x_init(a_vert-(test_height/2),a_horiz-(x_width/2));
bank_font.Size:=hold_font;
end;{ends procedure big_x_init}
procedure baseform_writer.dot_init(a_vert:double;a_horiz:double);
begin
b_printer.init('S',today,0,'*',a_vert,a_horiz,bank_font,form_vert_adjust,form_horiz_adjust,bank_canvas);
end;
procedure baseform_writer.na_init(a_vert:double;a_horiz:double);
begin
b_printer.init('S',today,0,'N/A',a_vert,a_horiz,bank_font,form_vert_adjust,form_horiz_adjust,bank_canvas);
end;
procedure
baseform_writer.phn_init(a_phone:phone_record;a_vert:double;a_horiz:double);
var phoneline:string;
begin
with a_phone do begin
phoneline:=areacode+'-'+prefix+'-'+numm;
end;
stringinit(phoneline,a_vert,a_horiz);
end;
procedure
baseform_writer.street_init(a_street:address_record;a_vert:double;a_horiz:double);
var x:integer;
line:string;
begin
LINE:=ADD_LINE(a_street);
X:=POS(a_street.CITY,LINE);
LINE:=COPY(LINE,1,X-1);
stringinit(line,a_vert,a_horiz);
end;
procedure
baseform_writer.city_init(a_city:address_record;a_vert:double;a_horiz:double);
var line:string;
begin
with a_city do begin
line:=city+' '+state+' '+zip;
end;
stringinit(line,a_vert,a_horiz);
end;
procedure baseform_writer.set_font_size(const dog:double);
var this_font_size:integer;
font_line:string;
test_height:double;
x_width:double;
begin{starts procedure baseform_writer.set_font_size;}
this_font_size:=60;
REPEAT
font_line:='X';
dec(this_font_size);
bank_font.size:=this_font_size;
bank_canvas.Font.Size:=bank_font.size;
test_height:=inchheight(bank_canvas,ppiy,font_line);
x_width:=inchwidth(bank_canvas,ppiy,font_line);
str(test_height:3:3,font_line);
font_line:='test_height:='+font_line;
until dog>=test_height;

end;{ends procedure baseform_writer.set_font_size;}

procedure baseform_writer.set_font_by_length(const dog:double;const
hite:double;const cat:string);
var font_line:string;
test_height:double;
x_width:double;
this_font_size:integer;
base_font_size:integer;
begin{starts procedure baseform_writer.set_font_by_length;}
this_font_size:=60;
REPEAT
font_line:=cat;
dec(this_font_size);
bank_font.size:=this_font_size;
bank_canvas.Font.Size:=bank_font.size;
test_height:=inchheight(bank_canvas,ppiy,font_line);
x_width:=inchwidth(bank_canvas,ppiy,font_line);
str(test_height:3:3,font_line);
font_line:='test_height:='+font_line;
until dog>=x_width;;
bank_font.size:=this_font_size;
base_font_size:=this_font_size;
if test_height>hite then
set_font_size(hite);
if bank_font.size>base_font_size then
bank_font.size:=base_font_size;

end;{ends procedure baseform_writer.set_font_by_length;}

end.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150804/4dd81ebe/attachment-0001.html>

Reply by email

Juha Manninen
to Larry Dalton
Larry Dalton wrote
I am converting a program from windows to linux mint. The following unit won't compile under linux because uses the windows unit.

Do you mean you are converting a program from Delphi? FPC / Lazarus is a cross-platform system. A properly made program can be compiled for different platforms without changing the code. Use the Delphi converter and see what it does for your program.

Juha

Reply by email

Larry Dalton
to Juha Manninen

That has already been converted and the unit compiles and runs on window 7 platform, but will not compile on linux

Sent from my iPhone

Show quoted text 18 lines
On Aug 4, 2015, at 12:21, Juha Manninen wrote: > On Tue, Aug 4, 2015 at 8:06 PM, Larry Dalton wrote: > I am converting a program from windows to linux mint. The following unit > won't compile under linux because uses the windows unit. Do you mean you are converting a program from Delphi? FPC / Lazarus is a cross-platform system. A properly made program can be compiled for different platforms without changing the code. Use the Delphi converter and see what it does for your program. Juha -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Juha Manninen
to Larry Dalton
Larry Dalton wrote
That has already been converted and the unit compiles and runs on window 7 platform, but will not compile on linux

The converter has a checkbox "Cross-platform" which is checked by default. Why did you uncheck it?
Please try again.

Juha

Reply by email