Silverfrost Forums

Welcome to our forums

Scrollable format window?

22 Nov 2013 10:00 #13347

I have uploaded a new ClearWin+ beta to http://www.silverfrost.com/beta/salflibc.exe

This contains new options that provide a window with scrolling controls.

Here is a sample that illustrates how it works...

!FTN95$WINAPP
program main
  integer ii, ctrl, wd, ht
  !child window with controls...
  ii=winio@('%sh&',ctrl)
  !Add your controls here...
  ii=winio@('Sample containing scrolling child window..&')
  ii=winio@('%3nl%cn%6bb[OK]&')
  ii=winio@('%3nl%cn%6bb[Cancel]')
  !Main window to display child with vertical scroll bar...
  ii=winio@('%ww[no_maxbox]&')
  ii=winio@('%ca[Scroll demo]&')
  wd = 280;  ht = 150
  ii=winio@('%sz&',wd,ht)
  ii=winio@('%ch[vscrollbar]',ctrl)
end program

RESOURCES
1 24 default.manifest
23 Nov 2013 6:21 #13348

Nice! All these features (and now options to set transparency and font and line smoothing I found in the archive) are very welcome. That antialiasing makes 2D scientific graphs look very professional and transparency opens the way to do things before possible only with OpenGL. Scrolling is needed for making more complex GUIs. Just for full happiness would be great also to have few options for scroll bars of different styles/widths and colors like we now see in current mobile applications.

Follow up: Also i noticed that CWP texts became transparent (the ones like i=winio@('Here is some text') ) when they are written on wallpaper textures. A lot of good additions lately!

27 Nov 2013 12:26 #13365

Followup2 The couple problems with this SALFLIBC i found is that older compiled EXEs do not start now with the message 'The procedure entry point _export_pcx could not be located in dynamic link library'. If i recompile the files all works OK

And another is under investigation (preliminary, the default thickness of the lines equal to one pixel plotted by draw_line@ has been changed to 2 or even 3 or most probably i have an error somewhere because this takes place only on one part of the code)

27 Nov 2013 7:06 #13366

Dan

If you don't manage to fix this problem in your code, can you post a sample to illustrate it.

28 Nov 2013 7:56 #13377

I have uploaded a new salflibc.dll (same URL as above). This brings the GDI+ additions (for smoothing and opacity) up to date. draw_characters can now use the GDI+ library for rotated text.

28 Nov 2013 11:30 #13382

I was not able to reproduce yet the first mentioned problem (better say annoyance, since after recompilation all works fine. But in the future when some problems will happen with my code and I will try to run older versions of it to find the difference I will need to use older salflibc to run) with export_pcx on smaller program. The second one is most probably my own bug. This latest salflibc does not yet fix some conflict with something in pcx part. Did not looked yet at smoothing and opacity in detail

7 Dec 2013 11:42 #13422

UPDATE

I've ran the example shown in ENH file which adds GDI+ and transparency which works but when i added user_resize to %gr i got just empty screen.

winapp 
program main
include <windows.ins>
c_external nARGB@              '__nargb'(VAL,VAL,VAL,VAL):integer
c_external SET_SMOOTHING_MODE@ '__set_smoothing_mode'(VAL):integer
integer  cb
external cb

!
!  iw = winio@('%pv%^gr[black,full_mouse_input,box_selection,user_resize,rgb_colours,popup]&',450,200, cb)
!  iw = winio@('%pv%gr[black,full_mouse_input,box_selection,rgb_colours,popup]&',450,200)
  iw = winio@('%pv%^gr[user_resize]&',450,200,cb)

  iw = winio@('%ac[esc]&','exit')
  call draw_line_between@(5,158,440,188,         RGB@(0,20,0))


  call select_font@('Arial')
  call size_in_pixels@(16,0)
!  call italic_font@(1)
  call bold_font@(1)
  call draw_characters@('No antiAlias Smoothing', 65, 200, RGB@(0,20,0,255)) 

  call set_line_width@(8)
  call set_line_style@(PS_GEOMETRIC+PS_ENDCAP_SQUARE)
  call draw_line_between@(5,4,5,108,  nARGB@(255,0,0,255))
  call draw_line_between@(25,4,25,108,  RGB@(255,0,0))
  call draw_line_between@(5,10,25,10, nARGB@(255,0,255,0))
  call draw_line_between@(5,30,25,30, nARGB@(112,0,255,0))
  call draw_line_between@(5,50,25,50,   RGB@(255,0,255))
  call set_line_style@(PS_GEOMETRIC+PS_ENDCAP_FLAT)
  call set_line_width@(16)
  iw = set_smoothing_mode@(5)        !SmoothingModeAntiAlias8x8
  call draw_line_between@(50,4,150,104,         RGB@(255,0,0))
  call draw_line_between@(150,4,50,104,       nARGB@(192,0,0,255))
  call draw_ellipse@(225,60,50,50,            nARGB@(255,0,255,0))
  call draw_filled_ellipse@(225,60,50,50,     nARGB@(192,255,0,0))
  call draw_rectangle@(320,10,420,110,        nARGB@(255,255,0,0))
  call draw_filled_rectangle@(320,10,420,110, nARGB@(192,0,255,0))
  call set_line_width@(1)
  call draw_line_between@(5,154,440,184,         RGB@(255,0,0))

  call select_font@('Arial')
  call size_in_pixels@(16,0)
!  call italic_font@(1)
  call bold_font@(1)
  call draw_characters@('AntiAlias Smoothing', 65, 150, RGB@(255,0,0,255)) 

  iw = winio@(' ')
end

  integer function cb()
  cb=1
  end function cb		

Also seems Windows 8 already has all fonts antialiased by default so using AA option does not change anything - or i have done something wrong5,10,25,10, nARGB@

8 Dec 2013 9:21 #13424

As I recall, with %gr[user_resize], you need to do the redrawing in the callback function.

8 Dec 2013 2:38 (Edited: 9 Dec 2013 1:51) #13427

Not sure this is the case here but my another error is definitely present in the code above. Here is modified code with just one line moved up and introduction of %lw. Since it works fine with user_resize my first suspicion was wrong. Well, will try to search for another reason i do not get transparency in my larger code where i have tried to add this transparency feature. And this was actual reason for my post above. Since the change in the code to add GDI+ is mere 2-3 more lines of code plus the substitution of RGB@ to nARGB@, i'm still puzzling where is problem - i get all the plots as if there is no transparency at all. The line AA smoothing works perfect, all curves now look unusually great. Plotting goes slower though, clearly visible with 100 curves plotted simultaneously. Since OpenGL would do that instantly great would be to try to accelerate GDI+ if possible.

(By the way this search in the dark forest is typical for programming with CWP. For example, i just noticed another puzzle -- why %pv does not resize in this demo code? For everyone who wants some warm up in non-normative language try to fix that in less then 1 hour. That is why i lovely call it Swearwin. 😃. Things like %pv happen 10 times per day, so don't actually lose your time to answer that question! )

winapp 
program main
include <windows.ins>
!use clrwin
c_external nARGB@              '__nargb'(VAL,VAL,VAL,VAL):integer
c_external SET_SMOOTHING_MODE@ '__set_smoothing_mode'(VAL):integer
integer  cb
external cb

!
!  iw = winio@('%pv%^gr[black,full_mouse_input,box_selection,user_resize,rgb_colours,popup]&',ix,iy,cb)
!  iw = winio@('%pv%gr[black,full_mouse_input,box_selection,rgb_colours,popup]&',ix,iy,cb)

  ix=450;iy=200
  iw = winio@('%pv%^gr[user_resize]&',ix,iy,cb)
  iw = winio@('%ac[esc]&','exit')
  iw = winio@('%lw',ilw)

  call draw_line_between@(5,158,440,188,         RGB@(0,20,0))


  call select_font@('Arial')
  call size_in_pixels@(16,0)
  call italic_font@(1)
  call bold_font@(1)
  call draw_characters@('No AntiAlias Smoothing', 165, 200, RGB@(0,20,0)) 

  call set_line_width@(8)
  call set_line_style@(PS_GEOMETRIC+PS_ENDCAP_SQUARE)
  call draw_line_between@(5,4,5,108,  nARGB@(255,0,0,255))
  call draw_line_between@(25,4,25,108,  RGB@(255,0,0))
  call draw_line_between@(5,10,25,10, nARGB@(255,0,255,0))
  call draw_line_between@(5,30,25,30, nARGB@(112,0,255,0))
  call draw_line_between@(5,50,25,50,   RGB@(255,0,255))
  call set_line_style@(PS_GEOMETRIC+PS_ENDCAP_FLAT)
  call set_line_width@(16)
  iw = set_smoothing_mode@(5)        !SmoothingModeAntiAlias8x8
  call draw_line_between@(50,4,150,104,         RGB@(255,0,0))
  call draw_line_between@(150,4,50,104,       nARGB@(192,0,0,255))
  call draw_ellipse@(225,60,50,50,            nARGB@(255,0,255,0))
  call draw_filled_ellipse@(225,60,50,50,     nARGB@(192,255,0,0))
  call draw_rectangle@(320,10,420,110,        nARGB@(255,255,0,0))
  call draw_filled_rectangle@(320,10,420,110, nARGB@(192,0,255,0))
  call set_line_width@(1)
  call draw_line_between@(5,154,440,184,         RGB@(255,0,0))

  call select_font@('Arial')
  call size_in_pixels@(16,0)
  call italic_font@(1)
  call bold_font@(1)
  call draw_characters@('AntiAlias Smoothing', 165, 156, RGB@(255,0,0,255)) 


end
  integer function cb()
  cb=1
  end function cb		
9 Dec 2013 8:21 #13428

I have tried your sample and cannot see any problems.

However, my DLLs are more recent so I have uploaded the new versions to http://www.silverfrost.com/beta/clearwin64.exe and http://www.silverfrost.com/beta/salflibc.exe.

To make the (%pv) pivot effective with %gr you need [metafile_resize] or [user_resize] with a redraw in the callback function.

9 Dec 2013 2:36 #13430
  1. As i wrote, my latest example above works fine. It's my own larger code hiccups. But i am still looking at it. Do i have to use also SET_OPACITY@(Opacity) and USE_GDIPLUS@(state)? It is not used in the above example and opacity works fine. BTW, these functions are not recognized by the compiler probably because are not in the CLRWIN/windows.ins include file (?)

  2. From the text above i see that developers prefer using function draw_line_between@ instead of just simpler draw_line@. Any reason for that? Do draw_lineD also exist?

  3. I think the solution of %pv is an example that some things in Clearwin+ are still anti-intuitive and need polishing if even Paul does not immediately catch the twist. I made some plotting in callback below. Unless you have meant something different, this does not fix %pv. Solution though is as always simple but needs one hour of healthy non-stop swearing preferably in Russian 😃

    winapp program main include <windows.ins> !use clrwin c_external nARGB@ '__nargb'(VAL,VAL,VAL,VAL):integer c_external SET_SMOOTHING_MODE@ '__set_smoothing_mode'(VAL):integer integer cb external cb

    ix=450;iy=200
    

    ! iw = winio@('%pv%^gr[black,full_mouse_input,box_selection,user_resize,rgb_colours,popup]&',ix,iy,cb) ! iw = winio@('%pv%gr[black,full_mouse_input,box_selection,rgb_colours,popup]&',ix,iy,cb) iw = winio@('%pv%^gr[user_resize]&',ix,iy,cb) iw = winio@('%ac[esc]&','exit') iw = winio@('%lw',ilw)

    call draw_line_between@(5,158,440,188, RGB@(0,200,0))

    call select_font@('Arial') call size_in_pixels@(16,0) call italic_font@(1) call bold_font@(1) call draw_characters@('No antiAlias Smoothing', 165, 200, RGB@(0,200,0))

    call set_line_width@(8) call set_line_style@(PS_GEOMETRIC+PS_ENDCAP_SQUARE) call draw_line_between@(5,4,5,108, nARGB@(255,0,0,255)) call draw_line_between@(25,4,25,108, RGB@(255,0,0)) call draw_line_between@(5,10,25,10, nARGB@(255,0,255,0)) call draw_line_between@(5,30,25,30, nARGB@(112,0,255,0)) call draw_line_between@(5,50,25,50, RGB@(255,0,255)) call set_line_style@(PS_GEOMETRIC+PS_ENDCAP_FLAT) call set_line_width@(16) iw = set_smoothing_mode@(5) !SmoothingModeAntiAlias8x8 call draw_line_between@(50,4,150,104, RGB@(255,0,0)) call draw_line_between@(150,4,50,104, nARGB@(192,0,0,255)) call draw_ellipse@(225,60,50,50, nARGB@(255,0,255,0)) call draw_filled_ellipse@(225,60,50,50, nARGB@(192,255,0,0)) call draw_rectangle@(320,10,420,110, nARGB@(255,255,0,0)) call draw_filled_rectangle@(320,10,420,110, nARGB@(192,0,255,0)) call set_line_width@(1) call draw_line_between@(5,154,440,184, RGB@(255,0,0))

    call select_font@('Arial') call size_in_pixels@(16,0) call italic_font@(1) call bold_font@(1) call draw_characters@('AntiAlias Smoothing', 165, 156, RGB@(255,0,0,255))

    end integer function cb() include <windows.ins> call set_line_width@(7) call draw_line@ (1,1,450,200, RGB@(0,0,0)) call draw_line@ (1,200,450,1, RGB@(0,0,0)) call set_line_width@(1) cb=1 end function cb

9 Dec 2013 3:46 #13432
  1. There are various different ways to set the opacity and smoothing. These are described in a text file that should be in the download. Also the latest download has a new cwplus.enh that contains a description.

  2. draw_line@ is the old 16 bit DBOS form. There is no draw_lineD@.

12 Dec 2013 5:44 #13463

[quote='DanRRight']Followup2 The couple problems with this SALFLIBC i found is that older compiled EXEs do not start now with the message 'The procedure entry point _export_pcx could not be located in dynamic link library'. If i recompile the files all works OK

Solved: Version 7.0 fixes that

13 Dec 2013 7:29 #13471

By the way the answer why the demo above does not react on resizing despite of used %pv is because of missing %ww. Here is where you can not omit %ww I do not know why. Probably the Clearwin+ should allow resizing without %ww because not using %ww is very common

28 Jan 2014 8:50 #13636

Here is an example of a scrollable window that only shows scroll bars when some of the controls lie outside the window. The window is resizable by the user.

The post is in 2 parts

PART 1 - The example program which creates a sample window

!  --------------------------------------------------
!  FTN95 Source File for a scrollable window
!  --------------------------------------------------

      PROGRAM MAIN
      INTEGER MENUFUNC
      CHARACTER BUTTONLABEL(20)*20,COLOURS(8)*7,COLOURARRAY(8,20)*7
     *,CURRCOLOR(20)*7
      REAL*8 VALUE(20)
      EXTERNAL MENUFUNC
      DATA COLOURS/
     *   'Red    ','Green  ','Blue   ','White  ','Black  ',
     *   'Yellow ','Cyan   ','Magenta'/
c*** create a window which is initially invisble and 
c***  big enough to hold all the controls etc
      I=WINIO@('%ww[not_fixed_size]%ca[A SCROLLABLE WINDOW]&')
      I=WINIO@('%bg[grey]&')
c*** create simple menu
      I=WINIO@('%mn[Alpha,Beta[beta1,beta2,beta3],gamma]&'
     *,MENUFUNC,MENUFUNC,MENUFUNC,MENUFUNC,MENUFUNC)
c***  add a selection of controls to the window
      DO JROW=1,20
        WRITE(BUTTONLABEL(JROW),100)JROW
100     FORMAT('Button ',I2)
        I=WINIO@('%bt@&',BUTTONLABEL(JROW))
        VALUE(JROW)=JROW
        DO KOLOR=1,8
          COLOURARRAY(KOLOR,JROW)=COLOURS(KOLOR)
        ENDDO
        I=WINIO@('%`bg[yellow]&')       
        I=WINIO@('%ta%12sl[horizontal]&',VALUE(JROW),0d0,30d0) 
        I=WINIO@('%taValue= &')
        I=WINIO@('%df%fl%`bg[white]%rf&',1d0,0d0,30d0,VALUE(JROW))
        I=WINIO@('%`bg[white]&')          
        CURRCOLOR(JROW)='Red'
        I=WINIO@('%ta%7.8el&',COLOURARRAY(1,JROW),8,CURrCOLOR(JROW))
        I=WINIO@('%ta%gr[RED]&',30,20)
        I=WINIO@('%2nl&')
      ENDDO
c*** finalize creation of the window, 
c     making it visible and set to the required size 
      CALL SETUPWINDOW(200,50,500,300)
      STOP
      END
    


      INTEGER FUNCTION MENUFUNC()
      INCLUDE <win32api.ins>
      CALL MESSAGEBOX(0,'Menu item selected','test',0)
      MENUFUNC=1
      RETURN
      END
28 Jan 2014 8:51 #13637

Here are the scrolling functions for the example

PART 2

c------------------------
c*** scrolling functions
c------------------------


      MODULE SCROLLER
        INTEGER IVOFFSET,IHOFFSET,IVS,IHS,IHWND
     *  ,IVERTEXTENT,IHORIZEXTENT,IWINDOWWIDTH,IWINDOWHITE
      END MODULE SCROLLER



      SUBROUTINE SETUPWINDOW(IX,IY,IWIDTH,IHITE)
      USE SCROLLER
      INCLUDE <win32api.ins>
      INCLUDE <win32prm.ins>
      INTEGER RECT(4),SCROLLFUNC,RESIZEFUNC
      EXTERNAL SCROLLFUNC,RESIZEFUNC
C*** finalise the creation of the window
c*** add scrollbars
      IHS=0
      IVS=0
      I=WINIO@('%^`hs&',0,100,IHS,SCROLLFUNC) 
      I=WINIO@('%^`vs&',0,100,IVS,SCROLLFUNC) 
c*** get the window handle.
      I=WINIO@('%hw&',IHWND)
c*** provide a callback function for resizing the window 
      I=WINIO@('%`mv&',RESIZEFUNC)
c*** return with closing window - so that we can modify it
      I=WINIO@('%lw',ICTRL)
c*** get the size of the invisble window which is needed for 
c    scrolling calculations, and initialise the scrolling offset
      CALL GETWINDOWRECT(IHWND,RECT)
      IHORIZEXTENT=RECT(3)-RECT(1)
      IVERTEXTENT=RECT(4)-RECT(2)
      IHOFFSET=0
      IVOFFSET=0
c*** set the window to the position size we want and make it visible
      IWINDOWWIDTH=IWIDTH
      IWINDOWHITE=IHITE
      CALL SETWINDOWPOS(IHWND,HWND_TOP,IX,IY,
     *IWINDOWWIDTH,IWINDOWHITE,SWP_NOZORDER+SWP_SHOWWINDOW)
C***  call resize to show/hide scrollbars
      i= RESIZEFUNC()      
      RETURN
      END  


      INTEGER FUNCTION RESIZEFUNC()
      USE SCROLLER
      INCLUDE <win32api.ins>
      INCLUDE <win32prm.ins>
      INTEGER RECT(4)
      RESIZEFUNC=3
c***  the user has resized the window -get the new size 
      CALL GETWINDOWRECT(IHWND,RECT)
      IWINDOWWIDTH=RECT(3)-RECT(1)
      IWINDOWHITE=RECT(4)-RECT(2)
C*** show or hide the scroll bars
      IF(IWINDOWWIDTH.GT.IHORIZEXTENT)THEN
        CALL SHOWSCROLLBAR(IHWND,SB_HORZ,0)
      ELSE
        CALL SHOWSCROLLBAR(IHWND,SB_HORZ,1)
      ENDIF
      IF(IWINDOWHITE.GT.IVERTEXTENT)THEN
        CALL SHOWSCROLLBAR(IHWND,SB_VERT,0)
      ELSE
        CALL SHOWSCROLLBAR(IHWND,SB_VERT,1)
      ENDIF
      RETURN
      END 



      INTEGER FUNCTION SCROLLFUNC()
      USE SCROLLER
      INCLUDE <win32api.ins>
      INCLUDE <win32prm.ins>
      INTEGER CHILDWINDOWRECT(4),POINT(2)
      SCROLLFUNC=1
C** set the offsets from the top of the scrollable client area
      NEWHOFFSET=  IHS*(IHORIZEXTENT-IWINDOWWIDTH)/100
      NEWVOFFSET=  IVS*(IVERTEXTENT-IWINDOWHITE)/100
c*** set offset of client area from top left hand corner of window
       POINT=0
       CALL CLIENTTOSCREEN(IHWND,POINT)
c**** find all child windows for parent (ihwnd) - find first child 
      ICHILD=GETWINDOW(IHWND,GW_CHILD) 
1     IF(ICHILD.NE.0)THEN
C*** reposition child without repainting screen
        CALL GETWINDOWRECT(ICHILD,CHILDWINDOWRECT)
        IXCLIENT=CHILDWINDOWRECT(1)-POINT(1)
        IYCLIENT=CHILDWINDOWRECT(2)-POINT(2)
        IWID=CHILDWINDOWRECT(3)-CHILDWINDOWRECT(1)
        IHITE=CHILDWINDOWRECT(4)-CHILDWINDOWRECT(2)
        CALL MOVEWINDOW(ICHILD,IXCLIENT-NEWHOFFSET+IHOFFSET,
     *  IYCLIENT-NEWVOFFSET+IVOFFSET,IWID,IHITE,.FALSE.)
c** find next child
        ICHILD=GETWINDOW(ICHILD,GW_HWNDNEXT)
        GOTO 1
      ENDIF
      IVOFFSET=NEWVOFFSET
      IHOFFSET=NEWHOFFSET
C*** now repaint window
      CALL INVALIDATERGN(IHWND,0,0)
      CALL UPDATEWINDOW(IHWND)
      RETURN
      END
 
     
16 Mar 2018 3:59 #21623

I am experimenting with the techniques found in this thread.

If I attach a callback to the OK button and allow it to yield a result (say -10 to close the child), I don't get that result when the parent window closes.

How does one get the result from the child to be passed along to the parent?

	WINAPP 
	integer ii, ctrl, wd, ht 
        integer,external:: button10
	!child window with controls... 
	ii=winio@('%sh&',ctrl) 
	!Add your controls here... 
	ii=winio@('Sample containing scrolling child window..&') 
	ii=winio@('%3nl%cn%^6bb[OK]&',button10) 
	ii=winio@('%3nl%cn%6bb[Cancel]') 
	!Main window to display child with vertical scroll bar... 
	ii=winio@('%ww[no_maxbox]&') 
	ii=winio@('%ca[Scroll demo]&') 
	wd = 280;  ht = 150 
	ii=winio@('%sz&',wd,ht) 
	ii=winio@('%ch[vscrollbar,hscrollbar]',ctrl) 
	print *,ii
        stop
        end
        integer function button10()
        button10 = -10
        return
        end
16 Mar 2018 4:33 #21625

Is the return value from the child returned in the variable ctrl? Documentation says this is an input variable, but looking at it after the parent is closed yields the value of 10.

Coincidence??

16 Mar 2018 4:41 #21626

Not sure that I understand what the problem is. Surely it's easy to pass values back from child to parent. Simplest way is to use COMMON. Otherwise use variables defined in a MODULE.

   WINAPP
   integer ii, ctrl, wd, ht
   common/aaa/jvalue
        integer,external:: button10

   jvalue = 0

   !child window with controls...
   ii=winio@('%sh&',ctrl)
   !Add your controls here...
   ii=winio@('Sample containing scrolling child window..&')
   ii=winio@('%3nl%cn%^6bb[OK]&',button10)
   ii=winio@('%3nl%cn%6bb[Cancel]')
   !Main window to display child with vertical scroll bar...
   ii=winio@('%ww[no_maxbox]&')
   ii=winio@('%ca[Scroll demo]&')
   wd = 280;  ht = 150
   ii=winio@('%sz&',wd,ht)
   ii=winio@('%ch[vscrollbar,hscrollbar]',ctrl)
   print *,ii
   print *,'jvalue=',jvalue
        stop
        end
        integer function button10()
        common/aaa/jvalue

        jvalue = 1

        button10 = -10
        return
        end    
16 Mar 2018 6:08 #21627

Actually, the simplest way is to get the result of a button press from the last winio@ call, and then use that result.

That said, if the %ch control will then return the value of the button press from within the child, I'm OK with that. And, it does appear that is the case!

Please login to reply.