1 (edited by JohnWasilewski 2014-12-17 18:56:06)

Topic: AppGraphics - general comments

Jeff, on a very quick read of the additions to the on-line help file, this addition to SF is of the utmost importance.  When, oh when, have you ever managed to find time to write it?  The amount of code needed and, above all, the amount of work needed even for basic testing, must be somewhat huge, to say the least.

I am looking forward to trying this new library.

Not yet sure if it has any facilities for on-screen data entry using tables, but I rather imagine that this would not be something that would appear in the initial version.  Assuming it does not, I'll have to see how easy it will be to write a FORTRAN tables-handler for cell coordinates using AppGraphics for each cell.  Vertical scroll-bars are likely to defeat me though!

Interesting times ahead.  I foresee a flurry of activity as SF users start to get to grip with efficient ways of building their own GUIs.  Any chance you could post on the forum one or two simple examples of GUIs, for impatient punters like me to take as starting points to build on whilst learning what AppGraphics can do for us?

What a large leap forward this promises to be!
---
John

Re: AppGraphics - general comments

John,

Tabular display and data entry is probably going to end up outside the scope of AppGraphics.  The library is meant to be a small and limited package (in fact, it does not currently support scroll bars...).  Tabular data entry requires a significant amount background date handling, and something of that nature is probably best left to GTK+ rather than something this simple.  However, if enough people ask for it...

As for pointers, I would have a look at the Getting Started guide in the help file, which will at least get you to the point where you'd have a window and a menu.  For a more complicated example, you should have a look at Conway's Game of Life, included as an example project now with Simply Fortran.  I'll try to post some more code and examples as time permits.

AppGraphics is based on WinBGI, where much of the primitive drawing code originates.  However, the code is significantly different internally (for performance and simplicity), and all the new GUI elements such as buttons and menus is new code.  Writing up the complete documentation was quite time consuming, and I'm guessing there are plenty of typos present.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

I am trying to use AppGraphics. Could you, please, post some examples how to write text into graphics window? I was unable to find any such function in help. Thanks Petr.

Re: AppGraphics - general comments

Petr,

There appears to be a "bug" in the Help file that caused the page on Text output to not be referenced in the table of contents.   You can view the help file at:

http://simplyfortran.com/docs/appgraphics/text.html

That was an oversight on our part when creating the Help file.  We'll release an updated build next week with the text page referenced properly.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

Jeff, thanks a lot.
Petr

Re: AppGraphics - general comments

Jeff, could you post some example how to use dlgrequestselection?
I am unable to get selection for three or more items. And for some reasons it seems that calling sequence is  different.
Petr

Re: AppGraphics - general comments

JohnWasilewski wrote:

Not yet sure if it has any facilities for on-screen data entry using tables, but I rather imagine that this would not be something that would appear in the initial version.  Assuming it does not, I'll have to see how easy it will be to write a FORTRAN tables-handler for cell coordinates using AppGraphics for each cell.  Vertical scroll-bars are likely to defeat me though!

John,

I've been building another example using AppGraphics that I think actually fulfills your request for tabular data entry. It's not quite done, and it is using enhancements coming in the next version.   Here's a quick screenshot:

http://i.imgur.com/6RS3ONx.png

Still need to get cell editing and selection working.

-Jeff

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

pm1a wrote:

Jeff, could you post some example how to use dlgrequestselection?
I am unable to get selection for three or more items. And for some reasons it seems that calling sequence is  different.

Petr,

There were a number of bugs in the dlgrequestselection function.  The next version will be fixed.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

jeff wrote:

...using AppGraphics..for tabular data entry...screenshot:

I knew you wouldn't be able to resist the temptation to provide this important addition, Jeff!  I confess that I have been too busy with work commitments to start using AppGraphics, though I am certainly going to be using it - a lot - as soon as I can.

The tabular data entry screenshot looks excellent, and I dread to think how much work it must take to build it into AppGraphics.  Even the most basic tabular data entry facility will be great, but here's also a long-term wish-list for tabular data entry routines (which gives an indication of how much work it must take to develop, and I do not expect you to manage all of these - at least, not at first!):
(a) User-defined column widths, column by column
(b) User-defined column headers
(c) Integer, real and alpha cells
(d) Cells initialised to blank or zero
(e) User-defined initial values in particular cells
(f)  Vertical scrollbar
(g) Horizontal scrollbar
(h) Placing the table in part of a window, not just in a window of its own
(i)  Table size definable by users at runtime, not at compile-time
(j)  Users able to add rows or columns to an existing table
(k) Line thickness control (maybe just 'thick' and 'thin', for headers and cells)
(l)  Shading (maybe just for headers)
(m) Ability to program individual cells to trigger Callbacks
(n)  Ability to hide a table & reveal it again later, after using screen are for something else
(o)  Ability to delete a table and remove it from the screen
(p)  Data validation (eg cell data entry must be found in a delimited string or a 1-d array)
(q)  Ability to place buttons on a table next to (or in?) cells, for use with Callbacks

So far as I know, even Dislin can't do all of the above.  For example, it won't do (j).  I have to write a subroutine to read all the data from the table into array variables, then remove the table and redraw it with more rows or columns, hten populate it from the arrays (all of which is not a problem).  I'm not sure but I don't think Dislin can do (m).  What I have in mind here is, for example, where a cell must contain a value from a delimited string, or a user-defined array, the programmer could code a popup selector for users to choose a value from the permitted list.

This is, as I say, just a wish-list.  We do want to have this table facility, though, so please do not try to get even half of this in SF 2.20.
---
J.

Re: AppGraphics - general comments

Hello John,
I think that I have something which likes on many of your listed requirements. I call it "Edit Sheet".   ... But its written in CVF66 and I am new in using SF with AppGraphics.
So first I try to let some basics work with SF2. Next I have a lot to translate and I don't know when I have time to make the edit sheet working in SF.
It must be possible also to maken an interface to EXEL. But using CVF I found it too complicated.

In general my "Editsheet" works with a scroll window with text and a header to describe the columns. The "|" restricts the columns width. The header has to be defiend by the program developper. Each column may contain characters, reals of integers; they are checked while typing. Also unchangable columns and special types can be used. In CVF the problem of using keybord ans mouse as wel needed a specal approach. May be that it has to be solved different in SF.
Interested?
Klaus

Re: AppGraphics - general comments

Yes, please, Klaus, I should very much like to see an 'edit sheet' function using AppGraphics.

Like you, I am a refugeee from CVF.  What a shame it was that that did not survive Win7x64.  However, I think Simply Fortran is a superb replacement.

I taught myself to use Dislin so that I could program my own GUI, including on-screen tabulated input data fields, push-buttons, drop-down menus and vector graphics, but it was very hard work, and this was before Jeff added AppGraphics to SF.

I think this is a superb addition and I am very keen to start using it as my only GUI-programming method but I have been excessively busy with my professional work over the last three months and can only make plans for when I can next get back to Fortran programming.  I'm going to need to learn AppGraphics, but it looks excellent. 

I for one would absolutely welcome any extensions to AppGraphics, written in Fortran, for which we could share the source codes, such as the function you are thinking of developing.
----
John

Re: AppGraphics - general comments

As I've shown in a previous post, I did work out a very basic tabular view.  The implementation is quite limited, though.  Right now you can't edit any entries, and it currently only support floating point numbers.

I do plan on working on it more, but I don't know about directly integrating it into AppGraphics.  I was thinking a site with some code samples or addons might be better.  That way you could simply grab the Fortran that implements the table or maybe the Progress Bar code, amongst other things.

We're in the process of upgrading the compiler once again (to GNU Fortran 5.1.0) along with fixing all these reported bugs with AppGraphics.  A site with some AppGraphics addons will be a month or two out at the very least.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

I assume you mean writing F95 code using AppGraphics, which can be imported as subroutines and functions to make extensions to AppGraphics.  If the subprograms have arguments for all parameters, can you not then just add them into AppGraphics, and are you not then, in effect, using AppGrahics to extend AppGraphics?

I haven't yet tried this so my question is purely theoretical/philosophical, so please put me straight if I'm talking nonsense here, for I do that a lot!

I was, in any case, thinking that code written by users could be shared, if it could be put somewhere where we all know where to look.  You have already been leading the way with this, with the examples you have kindly written and made available to everyone.  Have you considered setting up a new division of the forum for people to post useful code?  You could maybe have sub-sections, such as these:
(A) code examples illustrating something quirky, useful or entertaining
(B) portable subprograms able to be plugged into a program and used as-found

It would obviously be necessary to have some rules, especially for (B)
eg All code to be inside BBCode code frames
All code must be fully complete, and fully commented.  If it's not ready yet, post it in (A) not (B).
Comments must be embedded in the code not just posted above it,
      - classifying the subprogram type
        (string handling, GUI, linear equations, curve-fitting etc)
      - describing its purpose in words
      - listing the IN and OUT arguments (with any range-tested limits)
      - identifying anything still needing toi be fixed.
      - naming the author
      - giving a date and version

As only the person posting an entry can edit it, the original author will retain full control.  Other contributors may well post suggested new versions, and the original author can decide whether to 'edit' his or her original post to incorporate suggestions received. 

I do get carried away sometimes, don't I?
---
J.

Re: AppGraphics - general comments

Hi Jeff,

You wrote on January 15, 2015,

"I've been building another example using AppGraphics that I think actually fulfills your request for tabular data entry. It's not quite done, and it is using enhancements coming in the next version. "

This is the missing link to Appgraphics.  An editable tabular data grid to display, enter, and revise data is much needed.

Appgraphics works well for creating menus, opening files, running regression routines, and displaying text data, and plotting graphs of data and curves. 

But the application falls short without a tabular data grid that is editable with a means to enter and revised the data  (e.g., x1, x2,x3, y...).

Any chance you could share your prototype data grid with the users of Appgraphics?

Thank you for considering the development of a tabular data entry routine.

Frank

Re: AppGraphics - general comments

Hi,
I will start my big job again to translate all my source from CVF using Quickwindows to SF using AppGraphics.
One of the first items is to translate my tabular input called Edit Sheet. It is already a working application I use in many programs built with Quickwindows. Because the restricted possibilities of QW and other requirements of AppGraphics it's hard to say how much time I need to do this job.
Klaus

Re: AppGraphics - general comments

Why oh why did CVF have to keel over and sink when Win7 x64 arrived?  It is such a great shame.  However, losing CVF has meant finding SF - think for a lot of SF users - which must have boosted the number of registrations and has led to the superb product Jeff has now turned it into.  This, and quite unparalleled support on the forum is a huge gain for Fortran.  If CVF came back to life, I'd stay with SF.

I hope you complete the port of your project, Klaus.  Do tell us all how you deal with editable  data entry tables.
---
John

Re: AppGraphics - general comments

Hi John,
The most nasty thing of CVF is the dependency of MS visual studio without continuity to higher windows versions.....
I am starting my translation work and try to find the equivalence between CVF/QW and AppGrapics  for mouse handling but it may be not a straight forward way. Quickwindow had no keyboard buffer and a special peek start and stop procedure for the mouse thread was necessary.
For explanation how it works I can send a programmers guide (quickly translated from my dutch guide from 2007) and a image how it looks like but i think it should not be done by this forum?? (To much text)

Klaus

Re: AppGraphics - general comments

drfrank wrote:

Hi Jeff,
This is the missing link to Appgraphics.  An editable tabular data grid to display, enter, and revise data is much needed.
...
Any chance you could share your prototype data grid with the users of Appgraphics?

Frank,

I'll see if I can clean up the tabular data interface.  At the moment it is quite limited.  It currently only supports floating point numbers, and entry is handled through a text entry that is displayed above the table, similar to a spreadsheet.  Its formatting options are also quite limited.  I'll have a look over the next couple of days.  I've been thinking of setting up a website with some AppGraphics code for download.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

JohnWasilewski wrote:

Why oh why did CVF have to keel over and sink when Win7 x64 arrived?  It is such a great shame.

CVF was a nice product.  I actually spent quite a bit of time with it in the past.  However, it didn't keep up with the times, it was exceptionally expensive, and there was serious controversy when Intel inherited the product.

We'll continue doing our best to keep Simply Fortran running for years to come.  We're certified to run on Windows 10, but everything continues to work fine on Windows 2000 (although we don't officially support Windows 2000 since it's quite old at this point).

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

Hi Jeff,
Some questions regarding my CVF-> SF translation:
1) I have a  Function RECTANGLE (BORDER, ulx,uly, lrx,lry)
The compiler gives an error because en AppGraphics routine with the same name but I cannot find it in the on line manual
2) Is there any way to get a single character input from keyboard equivalent to CVF where I used a function "incharqq"?
3) To register the  mouse i try to use: subroutine registermousehandler (mouseevent, h)
    I don't understand the function of "h"; is this an input position?
Could you give me some hints?
Thanks, Klaus

Re: AppGraphics - general comments

Klaus,

I'll answer your questions below:

1) I have a  Function RECTANGLE (BORDER, ulx,uly, lrx,lry)
The compiler gives an error because en AppGraphics routine with the same name but I cannot find it in the on line manual

There is a rectangle function that generates an unfilled rectangle on the screen using the current line settings:

subroutine rectangle(left, top, right, bottom)

For some reason the documentation wasn't generated for the function.  I'll see that it's fixed.

2) Is there any way to get a single character input from keyboard equivalent to CVF where I used a function "incharqq"?

You can use the function:

function getch()

The function will return the ASCII code as an integer of the last key pressed.  Again, for some reason, it doesn't appear to have an entry in the documentation. 

3) To register the  mouse i try to use: subroutine registermousehandler (mouseevent, h)
    I don't understand the function of "h"; is this an input position?

Registering a mouse handler basically allows you to specify a subroutine to be called whenever a mouse event occurs.  In this case, the argument h would be a subroutine that accepts two integer representing the mouse position when the event occurs.  A simple example in a window would be:

program main
use appgraphics
implicit none

    ! Create your window and other code...
    ...

    ! Register your mouse handler
    call registermousehandler(MOUSE_LB_DOWN , handle_click)

contains

subroutine handle_click(x, y)
implicit none

    integer::x, y

    print *, "Mouse position: ", x, y

end subroutine handle_click

end program main

So now whenever the left mouse button is clicked, the subroutine handle_click is called and the mouse coordinates are printed to the console.  I'll try to work on a better example at some point that's complete.  The mouse handling is somewhat non-obvious.

Sorry about all the undocumented functions that keep cropping up too.  I'm sure it's quite frustrating to users.  We'll get the documentation fixed as soon as possible.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

Thanks Jeff,
for your good explanations. May be the mouse handler subroutine gives me an easier way than used in my CVF source!
Klaus

Re: AppGraphics - general comments

Hi Jeff,
Translating my Edit Sheet from CVF to SF2 I have further questions:
1) testing function getch () for my application I found the following:
      readable character >= inchar(32) are working perfect as well as TAB, ESC,    ENTER and BS!
      The arrow keys up, down, back, fwd have a first key of zero and needs a second key with the correct ascii value
      The INS/DEL keypad will give the 2nd ascii value only if ENTER follows and the function key's have no response on getch()
Is there a solution to get the INS/DEL/HOME... keys as well as the function key's?

2) There is no cursor in my graphic window. How to get a text cursor(ins and del) as well an arrow and cross? ( I made a preliminary cursor for testing but it is complicated in refreshing on the good position)

3) the input is lager than the visible rows of the window or the edit sheet and will not be available for editing.
Do I have to make the window size so large that it contains all rows make a scroll bar and re size is after that to a handsome visible scrollable window?

Klaus

Re: AppGraphics - general comments

Klaus,

It sounds like you're moving on to quite non-trivial matters.  I'll address each below:

1.  I'll have to debug what's occurring, but you're saying that getch is not working for special keys?  Looking at the code, special keys should first return.  The second call should return a special key code.  I'll make sure this is actually occurring, but it appears to be working properly for insert, delete, the arrow keys, or the function keys. 

2.  There is currently no function for setting the mouse cursor properly (using native Windows calls, I mean).  I can look into adding it.  You could then set the cursor based on mouse position if you wanted.

3.  The AppGraphics model for resizing Windows is quite primitive. Unlike many other toolkits, the available drawing surface is exactly what you see in the Window, nothing more or less.  The developer must manage any redraws based on redrawing and scrolling.  Simply adding scroll bars will not do what you're asking; the scroll bars are, again, managed by the developer, not AppGraphics.

This behavior is somewhat counter-intuitive, so I'll need to explain.  Let's assume that you're creating a spreadsheet-like application with 1200 rows.  Obviously these rows will not all fit on the screen.  When it first opens the window, we'll say we can display the first 20 rows.  The application needs to draw these rows to the window.  We also need to add a scroll bar.  Because we have 1200 rows, our scrollbar initialization will look something like:

    iscrollbar = createscrollbar (630, 0, 10, 480, SCROLL_VERTICAL, handle_scroll)
    call setscrollrange(iscrollbar, 0, 1200)
    call setscrollposition(iscrollbar, 0)

Above after creating the scrollbar, we've also explicitly stated it can scroll from a position of 0 to 1200 based on our spreadsheet rows.  The handle_scroll subroutine will then handle redrawing the window whenever it moves.  In the spreadsheet case, it will need to redraw everything.  The code would be something like:

subroutine handle_scroll(newPos)
implicit none
    top_row = newPos
    call redraw_window()
end subroutine handle_scroll

The above assumes that some global top_row variable exists storing the topmost row of our spreadsheet to display.

This design requires the developer to do quite a bit more work as compared to other toolkits, but it also allows for drastically more control over the behavior of a graphical application.

I'm sure my explanation above is probably not sufficient, so please feel free to ask more questions.  I'll be happy to provide a more thorough scrolling example if you'd like.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

Hi Jeff,
Thanks for your help. Generally I know what I have to do next.
But first of all my edit sheet is working!!! Of course there is some work to do and there are some restrictions like function key's, text cursor and scrolling. Also some bugs must be removed.
My text cursor can be worked out for better use in this application and the use of special key's I'll  see later. Scrolling. I'll work our according your explanations.
I did put Createmutex prior to register the mouse. It 's much lesser work than in CVF; also the mouse handle is much easier and more straight forward:

    Call Open_edit_window           ! open the edit_sheet window in separate procedure
   !Call peekstart                          ! start command thread in CVF 
    threadid = createmutex ( )
   Call registermousehandler (MOUSE_RB_DOWN, handle_click)
   Call registermousehandler (MOUSE_LB_DOWN, handle_click)
   ..........
At the end of the input loop for the key strokes I wrote:
   thread_wait= lockmutex (threadid, 100)

I hope that's a legal way to work with mouse  and keyboard together - and it works! no bugs found regarding this item. It was much more complicated in CVF - so I am not sure - it likes too easy!!!

Thanks so far, Klaus