# Kiosk GUI Screens



## Phishfry (May 18, 2022)

Now that I have some luck in getting touchscreen working I have a programming question.
Currently I have kiosk with video running in loop.
I want to expand to kiosk with input. Lets say address entry for a mailing list.

So I need GUI forms. I could go with some simple X application like motif or athena for basic buttons.
Option 2 is web form. Use the browser as a front end.

What do you think? I have no idea how to do either but I am willing to learn.
Front end for postgreSQL. Html or tcl/tk?


----------



## Geezer (May 18, 2022)

Use the browser. Html, cgi. Portable. Get on with it.


----------



## Phishfry (May 18, 2022)

Geezer said:


> Get on with it.


Yea I been here before. wxWidgets, Glade, QTbuilder, Anjuta....

Now all the talk recently by sidetone about Athena and I was researching motif.

I started playing with this tool. I want basic low level GUI.

x11-toolkits/xforms and its IDE `fdesign.`

I don't know about an html approach... Still skirting.


----------



## Jose (May 18, 2022)

I would  take a look at kpedersen's work with FLTK:


			https://forums.freebsd.org/members/kpedersen.5532/#profile-post-3425


----------



## covacat (May 18, 2022)

tcl/tk rules
super fast to develop, portable win/nix/mac, no dependency bs, extremly light compared with anything else
speed is not great but for UI to DB rocks


----------



## obsigna (May 18, 2022)

Phishfry said:


> Yea I been here before. wxWidgets, Glade, QTbuilder, Anjuta....
> 
> Now all the talk recently by sidetone about Athena and I was researching motif.
> 
> ...


Your UI project is crying for HTML - I hear it so loudly, that it hurts.

You would run a web server on localhost and some sort of backend which processes the user’s input and updates the presentation. You need some sort of CGI or PHP for this. You can write CGI’s in most common languages, and you would simply choose the one which you are most comfortable with. 

Nowadays I do CGI’ing in C, however, decades ago I used even Pascal for this. In case you got no language preferences, I suggest to do it in PHP. If you stay on the narrow road with PHP (don’t use fancy extensions), then nothing worse can happen than with any other language as well.


----------



## eternal_noob (May 18, 2022)

obsigna said:


> nothing worse can happen


Remember to properly prepare your SQL statements in order to prevent SQL injections.








						Prevent SQL injection vulnerabilities in PHP applications and fix them
					

This post will focus on how to prevent SQL injection vulnerabilities within PHP applications and fix them.




					www.acunetix.com


----------



## Phishfry (May 19, 2022)

Ha how silly. I thought xforms was a basic programming tool for X.. The 'x' here is for xml or xhtml.
I need to checkout Xm now. I want to explore the lowest level even if ugly. I guess no IDE for Motif?
What was "Application Builder"? Only on CDE?

That you all for the suggestions. I am disappointed that nearly 2 years after a similar post I am still ignorant.
I bought 4 or 5 books on TCL/TK. I could really use a professional tutor.
I do enjoy several tk applications including TKdiff, TkDVD and ClamTk.

FLTK is nice and light. How does it handle runtime executables? Can I embedded all needed files for portable app?

As for a web application I really appreciate the pointers. I was grasping with the concept.
I haven't tackled CGI or PHP yet.


----------



## Holger (May 19, 2022)

Use motif, it's the industry standard:

```
% pkg search open-motif
open-motif-2.3.8_2             Motif X11 Toolkit (industry standard GUI (IEEE 1295))
```


----------



## Phishfry (May 19, 2022)

That is my starting point. Hello_World on open motif.








						hello-world-x11-motif/Makefile at master · spartrekus/hello-world-x11-motif
					

hello-world-x11-motif. Contribute to spartrekus/hello-world-x11-motif development by creating an account on GitHub.




					github.com
				




I don't understand why the paths are wrong for libs and include.
Nevertheless I have a start.
I wanted to use base complier instead of gcc
`cc -x c -Wall -DLITTLE_ENDIAN -DINT_64 -O2 -I/usr/local/include -L/usr/local/lib -lm -lMrm -lXm -lXpm -lXext -lXt -lSM -lICE -lX11 hello-motif.c -o hello-motif`


----------



## Geezer (May 19, 2022)

obsigna said:


> Nowadays I do CGI’ing in C, however, decades ago I used even Pascal for this. In case you got no language preferences, I suggest to do it in PHP. If you stay on the narrow road with PHP (don’t use fancy extensions), then nothing worse can happen than with any other language as well.





eternal_noob said:


> Remember to properly prepare your SQL statements in order to prevent SQL injections.
> 
> 
> 
> ...



Always done it in C.

SQL, PHP. No, you don't need two towering inverted pyramids of third party overkillware.


----------



## Jose (May 19, 2022)

Phishfry said:


> I wanted to use base complier instead of gcc




```
$ doas pkg install fltk                                             
Updating FreeBSD repository catalogue...
...
The following 2 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    fftw3-float: 3.3.10 [FreeBSD]
    fltk: 1.3.8 [FreeBSD]
Number of packages to be installed: 2

The process will require 11 MiB more space.
2 MiB to be downloaded.

Proceed with this action? [y/N]: y
...
$ cat <<EOF >hello.cxx
> #include <FL/Fl.H>
> #include <FL/Fl_Window.H>
> #include <FL/Fl_Box.H>
> 
> int main(int argc, char **argv) {
>   Fl_Window *window = new Fl_Window(340,180);
>   Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
>   box->box(FL_UP_BOX);
>   box->labelfont(FL_BOLD+FL_ITALIC);
>   box->labelsize(36);
>   box->labeltype(FL_SHADOW_LABEL);
>   window->end();
>   window->show(argc, argv);
>   return Fl::run();
> }
> EOF
$ c++ `fltk-config --cxxflags --ldflags` hello.cxx
$ ./a.out
```

Even simpler, and shows the full compiler invocation:

```
$ fltk-config --compile hello.cxx                                                                                               
c++ -I/usr/local/include -I/usr/local/include -D_THREAD_SAFE -pthread -I/usr/local/include/freetype2 -I/usr/local/include/libpng16 -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -fvisibility-inlines-hidden -I/usr/local/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -o 'hello' 'hello.cxx' -fstack-protector-strong -L/usr/local/lib -lm /usr/local/lib/libfltk.a -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -lm -L/usr/local/lib -lX11
$ ./hello
```

Edit: hello.cxx is from here https://www.fltk.org/doc-1.3/basics.html


----------



## sidetone (May 19, 2022)

Holger said:


> Use motif, it's the industry standard:
> 
> ```
> % pkg search open-motif
> ...


That description is obsolete. IEEE 1295 for Modular Toolkit Environment (MTE) was an industry standard on top of X Toolkit Intrinsics (Xt) from 1993 until 2000 that Motif used. (https://ieeexplore.ieee.org/document/7362077)

From looking at x11-toolkits/open-motif, there was an attempted name change to Motif in 2012, but that broke dependencies, so it was reverted back. The file source location was changed from Integrated Computer Solution's (ICS's) page to Sourceforge. Before the date this happened, there's no details of Makefile changes except for summaries. This is the same year that the Hungry Programmers used the clone LessTif to convince ICS to change Motif's license to LGPL. (http://lesstif.sourceforge.net/)

Open Group also contained a sourcecode copy of ICS's Motif called Open Motif, which has been around since 2000. (http://www.opengroup.org/openmotif/faq.html) This part is unclear to me, as my theory is that ICS had a license (perhaps IBM Public License or an Open Group License) for Motif that allowed this since 2000, while at the same time wasn't LGPL. This part needs clarification or confirmation. Open Motif was also restricted for use only on open source operating systems.

LessTif is obsolete. OpenGroup's Open-Motif isn't or is no longer relevant to FreeBSD's ports, except perhaps for clarifications or historical purposes.


----------



## drhowarddrfine (May 19, 2022)

obsigna said:


> Nowadays I do CGI’ing in C


We did everything in C for nearly 20 years. When people started questioning our sanity versus questioning our performance, I knew it was time to get out. Now I question their sanity as their budgets have more than tripled.


----------



## obsigna (May 19, 2022)

drhowarddrfine said:


> We did everything in C for nearly 20 years. When people started questioning our sanity versus questioning our performance, I knew it was time to get out. Now I question their sanity as their budgets have more than tripled.


Well, I switched from Pascal-CGI to C-CGI 18 years ago - better late than never :-D


----------



## Phishfry (May 19, 2022)

I am the guy running the drill-bit backwards for years. I don't even know if a tutor would help.
Looking back this is my third post on gui programming. I do want to learn it. Just not sure what _it_ is.
I want something so simple I can read the code but need a IDE to give me a push.


----------



## sidetone (May 19, 2022)

From what I understand it's the programming language of C, C++ or another language, plus a library such as a GUI toolkit.


----------



## Phishfry (May 19, 2022)

Yes I hope to learn _it_ one day.
I see I was wrong about xforms. There is an xhtml/xml tool with the same name.
What I am crying out for is a Microsoft Access VBA toolkit on FreeBSD for postgresql.
Form would have been designed and query created. Drop boxes, Combo Lists and fireworks.....
My mind is resisting this new training.


----------



## Phishfry (May 19, 2022)

Ok I admit it. I need professional help. Maybe a class would be best. I can't find anything local that teaches C.








						C Programming: Getting Started
					

Start learning one of the most powerful and widely used programming languages: C.




					www.edx.org
				




Any suggestions on computer classes for C ?


----------



## kpedersen (May 20, 2022)

Phishfry said:


> Any suggestions on computer classes for C ?


For GUI, as much as it pains me to say, C++ does provide more options. For C you have Motif (which is fantastic albeit old) and Gtk (which is typical GNU ever mutating crap).

For Motif, this book is great: https://www.amazon.co.uk/Motif-Programming-Essentials-More-Technologies/dp/1555580890

The author (who also started the "How Things Work" website) makes it quite a fun experience as you cover the library. The style encourages you to have a play and tinker with the UI elements as you go.

With C++, I mainly go for FLTK because it is simple and has barely any dependencies (wxWidgets is a close second!). It is also consistent which is important. Qt has a few potential lifespan issues here, considering non-standard C++ extensions via MOC.

But they are all basically similar enough that your skills transfer across. So I would recommend sitting down with one (might as well be FLTK ) and set yourself a small challenge project to start with. Perhaps a clone of Microsoft Notepad or an app launcher.


----------



## Jose (May 20, 2022)

Phishfry said:


> Any suggestions on computer classes for C ?


K&R. Yes, seriously. Read the very first "Hello, World!" program in the book in which it was introduced.

From its preface:


> This book is meant to help the reader learn how to program in C. It con-
> tains a tutorial introduction to get new users started as soon as possible,
> separate chapters on each major feature, and a reference manual. Most of the
> treatment is based on reading, writing and revising examples, rather than on
> ...


----------



## Holger (May 20, 2022)

kpedersen said:


> For Motif, this book is great: https://www.amazon.co.uk/Motif-Programming-Essentials-More-Technologies/dp/1555580890


Here is another book covering a more modern version of Motif (2.1):
http://www.ist.co.uk/motif/download/6A/6A_book.pdf


----------



## ccammack (May 20, 2022)

If you're just trying to create a simple UI over a looping video, you might also consider _immediate mode GUI_ rendering, originally intended for game development.

Libraries that follow this paradigm, like Nuklear and Dear ImGui, sit on top of OpenGL and allow you to keep the creation of the GUI element and event handling together, so your code looks like this:


```
ImGui::Text("Do you really want to quit?");
if(ImGui::Button("Yes"))
   ExitProgram();
if(ImGui::Button("No"))
   CloseThisWindow();
```


----------



## Phishfry (May 20, 2022)

ccammack said:


> Dear ImGui, sit on top of OpenGL


Interesting. OpenGL and I saw something in /x11-toolkits that mentioned OpenGL.
Looking at examples what would be preferred on FreeBSD for simplicity?
glut_opengl2 or maybe sdl_opengl?

First I have read of glut(3) So that was an SGI thing?


----------



## kpedersen (May 20, 2022)

Phishfry said:


> First I have read of glut(3) So that was an SGI thing?


These days freeglut is the most maintained option. I quite like it; it opens a window, creates an OpenGL rendering context and nothing more. Its simplicity does improve its portability and reduce dependencies.

SDL (1 and 2) are also quite good. With OpenGL you end up using very little of the SDL API anyway.


----------



## ccammack (May 20, 2022)

I just tested Nuklear in a VM to see how it does. Not all of the demos compile as written, and if you're new to C, there will definitely be a lot to learn.


```
$ cd
$ mkdir -p work && cd work
$ git clone https://github.com/Immediate-Mode-UI/Nuklear.git
$ cd Nuklear/demo/x11
$ export CPATH=/usr/local/include && export LIBRARY_PATH=/usr/local/lib && make
$ ./bin/zahnrad
```


----------



## Jose (May 20, 2022)

kpedersen's Fl_Flow is even easier:




```
doas pkg install fltk
git clone https://github.com/osen/Fl_Flow.git
cd Fl_Flow
make
./tutorial &
./sample &
./advanced &
```


----------

