Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   VCL (http://www.delphipages.com/forum/forumdisplay.php?f=4)
-   -   GUI programming (http://www.delphipages.com/forum/showthread.php?t=211754)

mmx64 02-04-2012 01:20 PM

GUI programming
 
1 Attachment(s)
Hallo,
I have started a more complex program, and i would like some guidance.

I have a array of word, and i need to display its contents in a chart.

I had been dooing some testing and here is what i came up to:

on myform i create a scrollbar named sb
on myform i create a Timage named img
on img i create and load a bitmap named bm

and i browse the array up and down with the following code:
Code:

procedure TForm1.sbChange(Sender: TObject);
var increment,i,myData,addrIncrement:integer;
begin
increment:=0;
bm.Canvas.MoveTo(0,327);
clearbm; //i clear bitmap to base color.

bm.Canvas.Font.Color:=clWhite;
bm.Canvas.Font.Size:=8;


for i  := sb.Position to  sb.Position+700 do
  begin
    inc(increment,1);
    inc(addrIncrement,50);
    if oData[i] >= 32769 then
    myData:=oData[i] div 2
    else
    myData:=oData[i];


    myData:=327-(myData div 100);
    bm.Canvas.Pen.Color:=clWhite;
    bm.Canvas.lineTo(increment,myData);
    bm.Canvas.TextOut(AddrIncrement-50,329,inttohex((i+50)*2,6));
    bm.Canvas.MoveTo(increment,myData);
end;

  bm.Canvas.MoveTo(0,329);
  bm.Canvas.pen.Color:=$A0A0A0;
  bm.Canvas.lineTo(1024,329);
  pb.canvas.draw(0,0,bm);
end;


The output looks like file in attach.


All this works but i have some problem:

1. After i minimize the form them i restore it back the bitmap is cleared.
2. somehow i need to able to make a selection on that chart from point A to point B, and to have a vertical cursor so i can move it around the chart.
3. I need to draw vertical and horizontal grids on that chart.

This is my first interactive GUI programing , so i need for someone to tell me the method in how this GUI's are programmed. Thanks!!!

pengo 02-04-2012 07:05 PM

A couple of thoughts
 
Well done with this. I've usually stuck with charting components to do the hard yards; they're a lot easier, and there are some good free ones available. I'm impressed that you're doing this yourself.

I think you'll need to redraw the image every time it's invalidated. Minimising and restoring will require that, and also (completed or partial) hiding and showing. You could create your bitmap and save it to a temporary file, then load it into a TImage for display; that way you don't need to redraw it. Or you could just call your existing code from the OnPaint event. At least this is what I expect is going on here: try it and see.

Draw your grid lines (MoveTo, LineTo) before drawing your data. The data lines will be drawn over the grid lines.

The selection is more complex, and I'm not sure what kind of selection you want ... but you can set the cursor for the displaying TImage to the one you want (although I'm not sure what a vertical cursor is).

mmx64 02-04-2012 07:51 PM

Thanks for reply, well technically what i want to do is not a chart, its more like a file editor, but more advanced.
Let me be more explicit about what i want here:
i have an array of word.
I display it as shown above.
Maybe to you the lines on the screen doesn't tell you much, but for me (as i was trained to work with similar file editing software) tells me a lot.
When i see the part im interested in, i want to select it, so the selection should give me the begin-end address of the data from array.
The so called "vertical cursor", i want a line from top to bottom to act as a cursor, to be able to move it around the screen, where its position will be the position from array.

And about the grid lines you give me in idea:
Instead of clearing bp , i will clear it and draw the grid at the same time, then will draw my data on it. Hows that sounds?

BaraoZemo 02-05-2012 02:02 PM

take a look in the component called "heartmachine", it will fit all your needs
and comes with full sources... so you can "learn" how to do some advanced features that will be very usefull to you.

http://www.torry.net/vcl/indicat/ind...artmachine.zip

you can modify it , learn the code, implement your code or modify and publish the original component with the modifications

mmx64 02-16-2012 06:42 PM

1 Attachment(s)
Hi, thanks that helps a lot.

I have created a component, where i draw my background, my grid lines..... Everything is ok.(i have a bitmap, where i draw my things and on paint event i draw it to canvas)
I am displaying data from an array of byte.
Code:

for i := offset to offset+width do
      begin
        ...draw(myDataArray[i]);
      end;


I still need:
1. to create a line from top to bottom of my bitmap, and to be able to drag (left - right) by mouse, where the location on the bitmap is the address from my array.
2. If i click on my "line" and drag it , i need to make a selection with it.

If anyone has any idea how should i implement it, please share. Thanks!!!


All times are GMT. The time now is 05:30 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.