Window (bottom) border

16 posts / 0 new
Last post
JosDuchIt
JosDuchIt's picture
Offline
Last seen: 7 years 4 months ago
Joined: 2012-01-08 20:57
Window (bottom) border

Is it possible to predict the height of a window's bottomborder (window opened on the frontmost public screen). The screenheight is depending notably if it has a resize gadget or not, and its size van be changed with the screens prefs (GUI)
Can one get acces to this value ?

sc->WBorBottom;
and
wn->BorderBottom
are probably equal if no resize gadget?

thomas
thomas's picture
Offline
Last seen: 13 hours 50 min ago
Joined: 2011-05-16 14:23
Screen->WBor#? is the right

Screen->WBor#? is the right place to look for window border dimensions.

To get the dimension of the sizing gadget you can create an object of sysiclass with SYSIA_Which,SIZEIMAGE and read its Width and Height attributes.

If the sizing gadget is included in the border (i.e. WFLG_SIZEBRIGHT and/or WFLG_SIZEBBOTTOM is set), then the size of the respective border is equal to the size of the sizing gadget. Screen->WBorBottom resp. WBorRight is only used when there is no gadget in the border.

JosDuchIt
JosDuchIt's picture
Offline
Last seen: 7 years 4 months ago
Joined: 2012-01-08 20:57
Thanks Thomas. I was really

Thanks Thomas. I was really stuck here.

JosDuchIt
JosDuchIt's picture
Offline
Last seen: 7 years 4 months ago
Joined: 2012-01-08 20:57
I came up with #define

I came up with

  1. #define __USE_INLINE__
  2. #include <exec/types.h>
  3. #include <proto/intuition.h>
  4. #include <intuition/intuition.h>
  5. #include <intuition/classes.h>
  6. #include <intuition/imageclass.h>
  7. #include <intuition/classusr.h>
  8.  
  9. #include <proto/dos.h> //Printf
  10.  
  11. int main (void) {
  12.  
  13. Object *sz;
  14.  
  15. sz = NewObject (NULL, "SYSICLASS" , SYSIA_Which, SIZEIMAGE, TAG_DONE);
  16. Printf("%d %d\n", IA_Width, IA_Height);
  17. DisposeObject (sz);
  18. }

which compiles ok with -lauto
I do get the result below
6.Datas:Gui4Cli/C> Borderheight
-32766 3

and this is independent of the screen i do position the shell 'Workbench with big borders, or some with very small window borders)
I guess the screen should be defined, locked or something ?

hypex
hypex's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 2011-09-09 16:20
@JosDuchIt First, where are

@JosDuchIt

First, where are IA_Width and IA_Height defined?

Second, you are using PrintF(), a DOS function that defaults to 16-bit integers. I suggest changing it to use "%ld" instead. :-)

thomas
thomas's picture
Offline
Last seen: 13 hours 50 min ago
Joined: 2011-05-16 14:23
#include
  1. #include <proto/dos.h>
  2. #include <proto/intuition.h>
  3. #include <intuition/imageclass.h>
  4.  
  5. int main (void)
  6.  
  7. {
  8. struct Screen *scr = LockPubScreen (NULL);
  9.  
  10. if (scr)
  11. {
  12. struct DrawInfo *drawinfo = GetScreenDrawInfo (scr);
  13.  
  14. if (drawinfo)
  15. {
  16. Object *sizeimg = NewObject (NULL,"sysiclass",
  17. SYSIA_DrawInfo,drawinfo,
  18. SYSIA_Which,SIZEIMAGE,
  19. TAG_END);
  20.  
  21. if (sizeimg)
  22. {
  23. ULONG width,height;
  24.  
  25. GetAttr (IA_Width,sizeimg,&width);
  26. GetAttr (IA_Height,sizeimg,&height);
  27.  
  28. Printf ("size = %ld x %ld\n",width,height);
  29.  
  30. DisposeObject (sizeimg);
  31. }
  32.  
  33. FreeScreenDrawInfo (scr,drawinfo);
  34. }
  35.  
  36. UnlockPubScreen (NULL,scr);
  37. }
  38.  
  39. return (RETURN_OK);
  40. }
JosDuchIt
JosDuchIt's picture
Offline
Last seen: 7 years 4 months ago
Joined: 2012-01-08 20:57
@Thomas Thanks, it was a bit

@Thomas

Thanks, it was a bit more complicated than i thought.
I tested the program starting it from a KCON shell that i could reposition on other screens.
The result was always size 24x24 Those other screens mostly just copied the settings of the "Standard" screen of "screens" preferences and showed rather thin window borders and 'resize' gadget.
Now 24x24 seems to be correct for the Workbench screen from which i started.
Jumping to another screen makes this one the frontmost though, so i can't explain the results.

Hope you can.

thomas
thomas's picture
Offline
Last seen: 13 hours 50 min ago
Joined: 2011-05-16 14:23
If you use my example

If you use my example unchanged you will always get the properties of the Workbench screen because LockPubScreen(NULL) locks the default public screen, not the frontmost one. The default public screen is always Workbench unless an application changes it.

JosDuchIt
JosDuchIt's picture
Offline
Last seen: 7 years 4 months ago
Joined: 2012-01-08 20:57
@thomas So the problem left

@thomas

So the problem left is to identify the frontmost public screen.
I vaguely remember the frontmost public screen could be set as default public screen. I can't find that info again.
Till now i did not find either where the info is hidden identifying a screen as frontmost. It is not in the stuct Screen. I continue to look but if somebody knows ??
edited:

Seem to have found it :

  1. struct IntuitionBase
  2. {
  3.  
  4. //...
  5.  
  6. /* the FirstScreen variable points to the frontmost Screen. Screens are
  7.   * then maintained in a front to back order using Screen.NextScreen
  8.   */
  9. struct Screen *FirstScreen; /* for linked list of all screens */
  10. ///....
  11. }
JosDuchIt
JosDuchIt's picture
Offline
Last seen: 7 years 4 months ago
Joined: 2012-01-08 20:57
@all I am stuck again the

@all
I am stuck again the only thing that i can get till now is the frontmost
Printf(" %s\n", (((struct IntuitionBase *)IntuitionBase)->FirstScreen)->Title);

This gives me the title of the frontmost public screen. It is not the name of the Screen required with LockPubScreen.

It seems rather (very) strange to me that this name does not appear in struct Screen ???

thomas
thomas's picture
Offline
Last seen: 13 hours 50 min ago
Joined: 2011-05-16 14:23
This gives me the title of

This gives me the title of the frontmost public screen.

No, it does not. It gives you the title of the frontmost screen. Not every screen is public. In fact quite a lot of programming effort is necessary to make a screen public. Only a minority of applications make their screen public.

I am not sure what you are trying but I imagine that it is something that is not allowed.

It is possible to find out the frontmost public screen. But this screen is not necessarily visible. It might be hidden by another custom screen.

In order to open on the frontmost screen you might need to use IntuitionBase->FirstScreen without locking it. This is an illegal hack but it is the only way to open on the currently visible screen. It will get you into trouble when the application which owns the screen tries to close it before you closed your window. The owner of a private screen usually does not check for failure of CloseScreen().

JosDuchIt
JosDuchIt's picture
Offline
Last seen: 7 years 4 months ago
Joined: 2012-01-08 20:57
Hi Thomas it is really the

Hi Thomas it is really the 'frontmost pubscreen i am after.
I'll take care of other screens in front if needed.
I need it to test how well Gui4Cli windows can be drawn on different public screens.(say with correct inner widths and gadgets that don't change after a redraw )
Simple goal: open a window and know in advance what the borders will look like.

I did find this however and compiled it for OS4 :
http://os4.aminet.net/util/batch/FrontPubScreen.lha

  1. //compile with -lauto
  2. // http://os4.aminet.net/util/batch/FrontPubScreen.lha
  3. // 12 Apr 1992 john fieber (jfieber@sophia.smith.edu)
  4.  
  5.  
  6. #define __USE_INLINE__
  7.  
  8. #include <exec/types.h>
  9. #include <intuition/intuition.h>
  10. #include <intuition/intuitionbase.h>
  11. #include <proto/intuition.h>
  12. #include <proto/dos.h>
  13. #include <proto/exec.h>
  14. #include <string.h>
  15. //struct IntuitionBase*IntuitionBase;
  16. char public_screen_name[MAXPUBSCREENNAME];
  17. struct Screen*public_screen_address;
  18. ULONG intuition_lock;
  19. struct Screen*front_screen_address;
  20. struct List*public_screen_list;
  21. struct PubScreenNode*public_screen_node;
  22.  
  23.  
  24.  
  25. int main(int argc, char * argv[])
  26. {
  27.  
  28.  
  29.  
  30.  
  31. if(argc)
  32. {
  33.  
  34.  
  35. if(!IntuitionBase)
  36. {
  37. return(0);
  38. }
  39.  
  40. public_screen_name[0]= '\0';
  41.  
  42. intuition_lock= LockIBase(0L);
  43. front_screen_address= ((struct IntuitionBase *)IntuitionBase)->FirstScreen;
  44. if((front_screen_address->Flags&PUBLICSCREEN)||(front_screen_address->Flags&WBENCHSCREEN))
  45. {
  46. UnlockIBase(intuition_lock);
  47. public_screen_list= LockPubScreenList();
  48. public_screen_node= (struct PubScreenNode*)public_screen_list->lh_Head;
  49. while(public_screen_node)
  50. {
  51. if(public_screen_node->psn_Screen==front_screen_address)
  52. {
  53. strcpy(public_screen_name,public_screen_node->psn_Node.ln_Name);
  54. break;
  55. }
  56. public_screen_node= (struct PubScreenNode*)public_screen_node->psn_Node.ln_Succ;
  57. }
  58. UnlockPubScreenList();
  59.  
  60. }
  61. else
  62. {
  63. UnlockIBase(intuition_lock);
  64. }
  65.  
  66. if(public_screen_name[0]=='\0')
  67. {
  68. GetDefaultPubScreen(public_screen_name);
  69. }
  70. public_screen_address= LockPubScreen(public_screen_name);
  71. if(public_screen_address)
  72. {
  73. (void)PutStr(public_screen_name);
  74. (void)PutStr("\n");
  75. UnlockPubScreen(NULL,public_screen_address);
  76. }
  77. else
  78. {
  79. (void)PutStr("Workbench\n");
  80. }
  81. CloseLibrary((struct Library*)IntuitionBase);
  82. }
  83. return(1);
  84. }

I think together with your code the problem is solved.

BillEaves
BillEaves's picture
Offline
Last seen: 11 years 2 months ago
Joined: 2012-02-14 21:55
@Thomas, Is it possible

@Thomas,

Is it possible using something like this to CHANGE the image used for a Sysiclass gadget ?

Or when you create the object does it only copy the image info from the sysiclass type ?

(See my query about using a different SBARLOGO for an application's publc screen).

jabirulo
jabirulo's picture
Offline
Last seen: 8 hours 31 min ago
Joined: 2013-05-30 00:53
GREAT!!! Such piece of code

GREAT!!!
Such piece of code (added to Mixer) help to show Mixer on frontpubscreen after uniconifying :-) THX

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

trixie
trixie's picture
Offline
Last seen: 5 months 10 hours ago
Joined: 2011-02-03 13:58
@jabirulo Such piece of code

@jabirulo

Such piece of code (added to Mixer) help to show Mixer on frontpubscreen after uniconifying

Programs can only iconify on the Workbench screen. If you uniconify them manually by clicking on the icon, Workbench must be your frontmost screen then. If the program uniconifies upon receiving an ARexx or Application Library message, you are supposed to bring the program's screen to front - so why do you need extra code to ensure Mixer reopens on the frontmost screen? It always will.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

jabirulo
jabirulo's picture
Offline
Last seen: 8 hours 31 min ago
Joined: 2013-05-30 00:53
Mixer has popkey (acts/is a

Mixer has popkey (acts/is a commodity too), thus user can have Mixer on frontscreen (public) he's working/using, change/see seetings and hide/iconify again.

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

Log in or register to post comments