Sign in Join

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

Mailing lists / fpc-pascal / 2009-06

gtk+ linux-windows

13 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

kota kota

hello everybody. I am a new user of freepascal and i need some help. I have made my first GTK+ program that runs fine in linux(Ubuntu 8.10) but i encounter problems in windows XP.
You can find it here: http://files.getdropbox.com/u/1118452/testforum.7z I used the same source code for both of them.

There are 2 main problems:

-->Cannot show the Greek letters correctly (press help to see the problem) --> when the drawing has been done, if the user move a window over the drawing he will erase it.

Thank you

Graeme Geldenhuys
to kota kota
kota kota wrote
have made my first GTK+ program that runs fine in linux(Ubuntu 8.10) but i encounter problems in windows XP.

I can't really help with the GTK+ problem but I can make alternative recommendations. If you want to create applications that have the same look & feel and behaviour on various platforms, I suggest you try out fpGUI Toolkit (see my signature for the URL). It was specifically designed to have the same look and behaviour on all supported platforms.

Another alternative, if you want a more native behaviour in each platform, is to use the Lazarus LCL.

The benefit of the fpGUI Toolkit, is that it is much "lighter" than GTK1 or GTK2 or the Lazarus LCL. It's library dependencies are much smaller as well.

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

kota kota

I will try it.
The fpGui's link presents a *fpGUI Visual UI Designer*. Where can i find it?

Thanks*
*

kota kota
to Martin Schreiber
The fpGui's link presents a *fpGUI Visual UI Designer*. Where can i find

it?

OK I found it.

Then you possibly want to try MSEide+MSEgui too:

I already started with fpGui, but I will try it maybe later.

Thanks

2009/6/22 Martin Schreiber

Show quoted text 15 lines
On Monday 22 June 2009 17:10:45 kota kota wrote: > I will try it. Then you possibly want to try MSEide+MSEgui too: http://sourceforge.net/projects/mseide-msegui/ Questions and bug reports please to NNTP: news://news.grid-sky.com/public.mseide-msegui.talk Martin _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Graeme Geldenhuys
to kota kota: I will try it. The fpGui's link presents a *fpGUI Visual UI Designer*. Where can i find…
kota kota wrote
I will try it. The fpGui's link presents a *fpGUI Visual UI Designer*. Where can i find it?

If you check out the source code from the git repository (recommended), then the UI Designer is in the 'uidesigner' directory, in the root of the project.

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

kota kota
to Graeme Geldenhuys

Thank you very much.

Now i need some more specific information: Is there any way to show the drawing's steps(created on a Canvas) before the final image is ready?

2009/6/23 Graeme Geldenhuys

Show quoted text 21 lines
kota kota wrote: > I will try it. > The fpGui's link presents a *fpGUI Visual UI Designer*. Where can i find it? If you check out the source code from the git repository (recommended), then the UI Designer is in the 'uidesigner' directory, in the root of the project. Regards, - Graeme - _______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Graeme Geldenhuys
to kota kota
kota kota wrote
Now i need some more specific information: Is there any way to show the drawing's steps(created on a Canvas) before the final image is ready?

Sorry, I do not understand? What drawings?

Regards,
- Graeme -

________________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

kota kota
to Graeme Geldenhuys

ok here is an example,
(look the red letters)

///////////////////////////////////////////////////////////////////////////////////////
program drawtest;
{$mode objfpc}{$H+}

uses

  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,
  fpgfx,
  gfxbase,
  gui_form,
  math,crt,
  gfx_imgfmt_bmp;
type
  TMainForm = class(TfpgForm)
   public
  img: TfpgImage;
     constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
     procedure   HandlePaint; override;
      end;
Const
m=1000;
Var
 results : array [1..m] of integer;
   intS : array[1..m,1..2] of integer;
    i     :longint;
    x2,y2,l1,l2 :integer;
frm: TMainForm;
{ TMainForm }
FUNCTION logos(c,b :integer): integer;
BEGIN
  logos:= (l1*c+(l2-l1)*b) div (l2)
 END;
constructor TMainForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  WindowTitle := 'Ελληνικά γράμματα ';
  SetPosition(1000, 1000, 1024, 768);
   Sizeable := False;
end;
destructor TMainForm.Destroy;
begin
  img.Free;
  inherited Destroy;
end;
procedure MainProc;
begin
  fpgApplication.Initialize;
  frm := TMainForm.Create(nil);
  frm.Show;
  fpgApplication.Run;
  frm.Free;
end;
procedure TMainForm.HandlePaint;
var
x,R,y,u:real;
n,k:integer;
Begin
  Canvas.BeginDraw;
  inherited HandlePaint;
  Canvas.Clear(clWhite);
  Canvas.DrawImage(1024, 768, img);
l1:=1;
l2:=2;
    n:=3;
    R:=intpower(380,n);
    k:=0;
    u:=pi/2;
    For i:= 1 to n do
    Begin
        x:=power(R,(1/n))*cos(((2*k*pi+u)/n))+512;
        y:=power(R,(1/n))*sin(((2*k*pi+u)/n))+384;
        ints[i,1]:=trunc(x);
        ints[i,2]:=trunc(y);
        k:=k+1;
    end;{For-loop}
    Canvas.SetColor(clBlack);
    Canvas.DrawLine(intS[1,1], intS[1,2],intS[n,1], intS[n,2]);
    For i:=2 to n do
    Canvas.DrawLine(intS[i-1,1], intS[i-1,2],ints[i,1], intS[i,2]);
    Canvas.EndDraw;
    Randomize;
    For i:=1 to m do
    begin
        results[i]:=random(n)+1;
    end;{For-loop}
X2:= 500;
y2:=500;
For i:=1 to m do  *// if m is very big (e.g 1000000) the user gets a black
screen until all the points are drawn *
    Begin
        x2:=logos(x2,intS[results[i],1]);
        y2:=logos(y2,intS[results[i],2]);
    Canvas.BeginDraw;
         Canvas.Pixels[x2, y2] := clblack;
    Canvas.EndDraw;
    end;{For-loop}
end;
begin
  MainProc;
end.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

So is there any way to show to the user the points *the moment* they are drawn ? In other words i want to make a window which draws and shows points real-time.

Is these explanation good enough ? If it isn't, i can make a more simple example.

2009/6/24 Graeme Geldenhuys

Show quoted text 23 lines
kota kota wrote: > > Now i need some more specific information: Is there any way to show the > drawing's steps(created on a Canvas) before the final image is ready? > Sorry, I do not understand? What drawings? Regards, - Graeme - ________________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Graeme Geldenhuys
to kota kota
kota kota wrote
ok here is an example, (look the red letters)

OK, I see what you mean... I improved the performance very slightly by reducing the two for loops to a single one. I also updated the uses clause to the latest revision of fpGUI Toolkit. I also removed all the unnecessary .BeginDraw and .EndDraw calls. The whole HandlePaint method that you override is alread wrapped in a begindraw..enddraw call for double buffering support.

Unfortunately I am not sure how to show the image while it is being generated. How is this done in Delphi VCL or Lazarus LCL?

Also, fpGUI Toolkit doesn't support painting to a Image via Canvas calls. This is planned for later this year, when I implement support for the Free Pascal fpimage and fpcanvas units (part of Free Pascal's FCL packages).

PS:
I highly recommend you rather use the Source Code directly from the git repository, and not the last released version. The v0.6 is rather old. See the following url for more details:
http://opensoft.homeip.net/fpgui/index.html#Sourcecode

======================================
program drawtest;
{$mode objfpc}{$H+}

uses

  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,
  fpg_main,
  fpg_base,
  fpg_form,
  Math,
  crt,
  fpg_imgfmt_bmp;
type
  TMainForm = class(TfpgForm)
  private
    R: real;
    n: integer;
    procedure PreCalculations;
    procedure GenerateImage;
  protected
    procedure HandlePaint; override;
  public
    constructor Create(AOwner: TComponent); override;
  end;
const
  m = 10000;
  l1 = 1;
  l2 = 2;
var
  results: array [1..m] of integer;
  intS:    array[1..m, 1..2] of integer;
  i:   longint;
  x2, y2: integer;
  function logos(c, b: integer): integer;
  begin
    Result := (1 * c + 1 * b) div 2;
  end;
  { TMainForm }
  constructor TMainForm.Create(AOwner: TComponent);
  begin
    inherited Create(AOwner);
    WindowTitle := 'Ελληνικά γράμματα ';
    SetPosition(10, 10, 1024, 768);
    Sizeable := False;
    PreCalculations;
  end;
procedure MainProc;
var
  frm: TMainForm;
begin
  fpgApplication.Initialize;
  frm := TMainForm.Create(nil);
  try
    frm.Show;
    fpgApplication.Run;
  finally
    frm.Free;
  end;
end;
  procedure TMainForm.PreCalculations;
  begin
    n  := 3;
    R  := intpower(380, n);
  end;
  procedure TMainForm.GenerateImage;
  begin
  end;
  procedure TMainForm.HandlePaint;
  var
    x, y, u: real;
    k: integer;
  begin
//    inherited HandlePaint;
    { We are doing all the painting, so no need to call inherited }
    Canvas.Clear(clWhite);
    k := 0;
    u := pi / 2;
    for i := 1 to n do
    begin
      x := power(R, (1 / n)) * cos(((2 * k * pi + u) / n)) + 512;
      y := power(R, (1 / n)) * sin(((2 * k * pi + u) / n)) + 384;
      ints[i, 1] := trunc(x);
      ints[i, 2] := trunc(y);
      k := k + 1;
    end;{For-loop}
    Canvas.SetColor(clBlack);
    Canvas.DrawLine(intS[1, 1], intS[1, 2], intS[n, 1], intS[n, 2]);
    for i := 2 to n do
      Canvas.DrawLine(intS[i - 1, 1], intS[i - 1, 2], ints[i, 1],
intS[i, 2]);
    { if m is very big (e.g 1000000) the user gets a black screen until
      all the points are drawn }
    X2 := 500;
    y2 := 500;
    for i := 1 to m do
    begin
      results[i] := random(n) + 1;
      x2 := logos(x2, intS[results[i], 1]);
      y2 := logos(y2, intS[results[i], 2]);
      Canvas.Pixels[x2, y2] := clBlack;
    end;{For-loop}
  end;
begin
  Randomize;
  MainProc;
end.

======================================

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Alan Krause
to Graeme Geldenhuys

On Wed, Jun 24, 2009 at 7:01 AM, Graeme Geldenhuys <

Show quoted text 12 lines
wrote: OK, I see what you mean... I improved the performance very slightly by reducing the two for loops to a single one. I also updated the uses clause to the latest revision of fpGUI Toolkit. I also removed all the unnecessary .BeginDraw and .EndDraw calls. The whole HandlePaint method that you override is alread wrapped in a begindraw..enddraw call for double buffering support. Unfortunately I am not sure how to show the image while it is being generated. How is this done in Delphi VCL or Lazarus LCL?

If I understand the problem correctly, then I am guessing that the paint event is not being called until after the loop is completed. In Delphi (and I think also in the LCL), if you have a time consuming loop, it is always wise to put an Application.ProcessMessages call in the loop so that the application yields a bit of time to process other application messages which may have been generated during the loop.

Hope this helps,
Alan

Graeme Geldenhuys
to kota kota: (look the red letters) ///////////////////////////////////////////////////////////////////…
kota kota wrote
ok here is an example, (look the red letters)

As an alternative, I quickly converted the triangle painting into a component, which produces an OnProgress event. I then added a ProgressBar to the main form which indicates the progress of the calculation before the next paint occurs.

Here is a screenshot, showing the previous paint and it's busy calculating the new triangles.

http://opensoft.homeip.net/~graemeg/generate_triangles.png

I also attached the new code for you.

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

kota kota
to Graeme Geldenhuys

Thank you very much for the code!! I added some new features, like user-defined number of sides for the polygon and colors. http://files.getdropbox.com/u/1118452/Screenshot.png

I want to ask something about the colors :

Is it possible to fill an array with colors using a loop? For example

I have this array ---> color array [1..20] of TfpgColor

I want to replace this:

*Color[1]:=TfpgColor($000000); //Black
Color[2]:=TfpgColor($0000FF);  //Blue
Color[3]:=TfpgColor($FF0000); //Red
Color[4]:=TfpgColor($FFFF00);//Yellow
Color[5]:=TfpgColor($00FFFF);//Aqua
Color[6]:=TfpgColor($008000);//Green
Color[7]:=TfpgColor($808080);//Gray*
.
.
.
.

With a loop

Thank you

2009/6/24 Graeme Geldenhuys

Show quoted text 30 lines
kota kota wrote: > ok here is an example, > (look the red letters) > As an alternative, I quickly converted the triangle painting into a component, which produces an OnProgress event. I then added a ProgressBar to the main form which indicates the progress of the calculation before the next paint occurs. Here is a screenshot, showing the previous paint and it's busy calculating the new triangles. http://opensoft.homeip.net/~graemeg/generate_triangles.png<http://opensoft.homeip.net/%7Egraemeg/generate_triangles.png> I also attached the new code for you. Regards, - Graeme - _______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal