forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using %sp and %gp for text window positioning

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Wed Dec 17, 2014 6:05 pm    Post subject: Using %sp and %gp for text window positioning Reply with quote

I want to be able to allow the user to move the starting position of a text window (%tx) so that the next time the text window appears, it will be where the user "left it".

I tried using %sp and %gp, but the window moves around. I suspect that this is due to the %sp being relative to a parent window. However, I don't have a parent window that contains the text window. I assumed that the coordinates would be relative to the screen itself, but this is clearly not the case.

I must be missing something in the use of the %sp and %gp commands. Can anyone shed light on what I am doing incorrectly, or can suggest a change/addition to achieve the desired effect?

Thanks,
Bill
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Wed Dec 17, 2014 6:52 pm    Post subject: Reply with quote

Additional info:
I removed the %sp command from the %tx and made a call to GET_WINDOW_LOCATION@ (GWL) at time of window closure. The screen onto which the window is being created is 1680x1050. The %tx window appears to be precisely centered on the screen.

Allowing the window to normally create and close yielded the following data.

%gp (x,y) = 1262,315
GWL (x,y,h,w)= 419,250,550,842

Moving the window to the upper left corner of the monitor yields:
%gp (x,y)=847,71
GWL (x,y,h,w)= 4,6,550,842

At first blush, it would appear that the %gp is yielding the right side X coordinate (plus some room for the frame), and the bottom of the caption bar (upper edge of the addressable window) as the Y coordinate. The GET_WINDOW_LOCATION@ seems to be yielding the proper values in absolute coordinate space.

If I write the window as "naked",

%gp (x,y) = 1240,282
GWL (x,y,h,w) = 440,282,486,800

As a naked window, I lost the capability to move it, so this is all I got, but it certainly is revealing, with the X coordinate from %gp being off on the right hand side.
Back to top
View user's profile Send private message Visit poster's website
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Wed Dec 17, 2014 7:46 pm    Post subject: Reply with quote

I solved this some years ago with lots of help from Paul.

Code:
       INTEGER FUNCTION Sticky_Help_FUNCTION()
       IMPLICIT DOUBLE PRECISION (A-H, O-Z)
       INTEGER, EXTERNAL ::  GET_POSITION_FN
       COMMON/PLACE/  IWINDPOS_X(80), IWINDPOS_Y(80)
       COMMON/STICKY/ NPOS, KHAND, JUMPX1,JUMPY1, INFX(10), INFY(10)
       INCLUDE <WINDOWS.INS>
       NSAVE = NPOS
       KSAVE = KHAND
       NPOS  = 2
       IA=WINIO@('%ca[Help routine]&')
       IA=WINIO@('%sp&', IWINDPOS_X(NPOS), IWINDPOS_Y(NPOS))
       IA=WINIO@('%hw%cc&', KHAND, GET_POSITION_FN)
       IA=WINIO@('%ff%nl%rj%8`bt[Close]')
       NPOS  = NSAVE
       KHAND = KSAVE
       QHelp02_FUNCTION = 1
       RETURN
       END

      INTEGER FUNCTION GET_POSITION_FN()
C     ... called on closure control %cc of a sticky window to get final
C         position, so window can be restored there when next opened.
      COMMON  /PLACE/   IWINDPOS_X(80),     IWINDPOS_Y(80)
      COMMON  /STICKY/  NPOS,     KHAND,    JUMPX1,   JUMPY1,           
     &                  INFX(10), INFY(10)
      COMMON  /FOR_NOW/ NSCREEN,  IXSCRN,   IYSCRN
      INCLUDE <WINDOWS.INS>

      CALL GET_WINDOW_LOCATION@ (KHAND, IX, IY, IWID, IHT)
      IF (NPOS .GT. 0 .AND. NPOS .LE. 80) THEN
         IF (IX .GE. 1 .AND. IX .LE. IXSCRN-100) THEN
         IWINDPOS_X(NPOS) = IX
         ELSE
         IWINDPOS_X(NPOS) = 100
         ENDIF
         IF (IY .GE. 1 .AND. IY .LE. IYSCRN-100) THEN
         IWINDPOS_Y(NPOS) = IY
         ELSE
         IWINDPOS_Y(NPOS) = 100
         ENDIF
      ENDIF
      GET_POSITION_FN = 0                  ! Guarantees continue to exit
      RETURN
      END


The program has 80 windows that when relaunched appear were they were last closed. The routine is No 2 in ths list, so NPOS is set to 2 at startup. The window is positioned with IWINDPOSX and Y. The exchange of handle and window number is done in case a sticky window calls a sticky window, and this works as each is closed. The window handle is KHAND, fond with %hw.

The stuff in GET_POSITION_FN is all about making sure that a sensible position is saved, and the constant offsets are what works for me. It is called when the window closes via %cc.

Hope this helps.

Eddie

PS: I had 1680x1050 on an Acer laptop. Standard setting was large fonts. This is another minefield.
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Wed Dec 17, 2014 8:47 pm    Post subject: Reply with quote

Eddie, thanks for the code segment.

I modified the code to use just the GET_WINDOW_LOCATION@ data and it is working fine.

Still begs the question of why the %gp function returns the upper right of the addressable area in a window, though!

A fix is a fix, however, and I am grateful.
Bill
Back to top
View user's profile Send private message Visit poster's website
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Dec 18, 2014 5:29 pm    Post subject: Reply with quote

I only ever used it for 'whole' windows and never for individual controls.

The help file says about the window coordinates:

Quote:
For main windows the X,Y location is in absolute screen coordinates. For child windows attached by %aw to a frame, the coordinates are relative to the top left corner of the frame. For controls and other child (%ch) windows X and Y are relative to the parent window.


Eddie
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Thu Dec 18, 2014 6:24 pm    Post subject: Reply with quote

The %aw was the confusing part, because the %gp returned such a strange value, I figured it was attached to a parent.

All is good now!
Bill
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group