Welcome, Guest. Please login or register.

Author Topic: WA_BackFill on a Reaction Window  (Read 1186 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline dcr8520Topic starter

  • Full Member
  • ***
  • Join Date: Mar 2002
  • Posts: 107
    • Show only replies by dcr8520
    • http://Amiga.SourceForge.net
WA_BackFill on a Reaction Window
« on: March 27, 2007, 07:34:36 PM »
Hello all!,

I'm having some trouble creating my first Reaction-based application, it is
just by using the WA_BackFill tag which I want to use to draw some border,
background, and logo on my own.

While I use WA_BackFill, objects disappear after the window gets opened, like
if the background gets drawed above them... but this does not happend with
all objects, just from the second Child and beyond, and if I remove the first
Child to check if it is causing something, the same appears with the others!

There is the example Im working with:

--- backfill hook:
Code: [Select]

{
 SetAPen( rp, 3 );
 RectFill( rp, 1, 1, WIDTH-1, HEIGHT-1 );
 ....
}


--- window creation:
Code: [Select]

{
 .....
   window_obj = NewObject( WINDOW_GetClass(), NULL,
    WA_Width,  WIDTH,
    WA_Height,  HEIGHT,
    WA_BackFill,  (ULONG) &BackFillHook,
    WINDOW_Layout,(ULONG)NewObject(LAYOUT_GetClass(),NULL,
     GA_DrawInfo,  (ULONG) drinfo,
     //LAYOUT_DeferLayout, TRUE,
     LAYOUT_Orientation,   LAYOUT_ORIENT_VERT,
     LAYOUT_AddChild, (ULONG)NewObject(LAYOUT_GetClass(),NULL,
      LAYOUT_BevelStyle, BVS_GROUP,
      LAYOUT_AddImage,(ULONG)NewObject(LABEL_GetClass(),NULL,
       LABEL_DrawInfo, (ULONG) drinfo,
       LABEL_Text,     (ULONG) "Reaction is funny... =]",
      TAG_DONE),
     TAG_DONE),
     LAYOUT_AddChild, (ULONG)NewObject(LAYOUT_GetClass(),NULL,
      GA_DrawInfo,  (ULONG) drinfo,
      LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
      //LAYOUT_VertAlignment, LAYOUT_ALIGN_CENTER,
      //LAYOUT_BevelStyle, BVS_GROUP,
      LAYOUT_EvenSize,    TRUE,
      LAYOUT_BevelStyle,  BVS_SBAR_VERT,
      LAYOUT_AddChild, (ULONG)NewObject(CHECKBOX_GetClass(),NULL,
       GA_DrawInfo,  (ULONG) drinfo,
       GA_Text, (ULONG)"checkbox gadget 1",
       GA_RelVerify, TRUE,
      TAG_DONE),
      LAYOUT_AddChild, (ULONG)NewObject(CHECKBOX_GetClass(),NULL,
       GA_DrawInfo,  (ULONG) drinfo,
       GA_Text, (ULONG)"checkbox gadget 2",
       GA_RelVerify, TRUE,
      TAG_DONE),
     TAG_DONE),
     LAYOUT_AddChild, (ULONG)NewObject(LAYOUT_GetClass(),NULL,
      LAYOUT_BevelStyle, BVS_GROUP,
      LAYOUT_HorizAlignment, LAYOUT_ALIGN_CENTER,
      LAYOUT_AddChild,(ULONG)NewObject(NULL,"button.gadget",
       GA_Text,        (ULONG)"_A",
       GA_RelVerify,   TRUE,
      TAG_DONE),
      LAYOUT_AddChild,(ULONG)NewObject(NULL,"button.gadget",
       GA_Text,        (ULONG)"_B",
       GA_RelVerify,   TRUE,
      TAG_DONE),
      LAYOUT_AddChild,(ULONG)NewObject(NULL,"button.gadget",
       GA_Text,        (ULONG)"_C",
       GA_RelVerify,   TRUE,
      TAG_DONE),
     TAG_DONE),
     LAYOUT_AddChild, (ULONG)NewObject(LAYOUT_GetClass(),NULL,
      LAYOUT_BevelStyle, BVS_GROUP,
      LAYOUT_AddImage,(ULONG)NewObject(GLYPH_GetClass(),NULL,
       GLYPH_Glyph, GLYPH_UPARROW,
      TAG_DONE),
     TAG_DONE),
    TAG_DONE),
   TAG_DONE);
 .....
}


Please help me, what im doing wrong?

btw, it is the first time as well im using a BackFill hook, but I assume
there shouldn't be any problem with it as it seems too simple, or may im
missing some drawing modes or something from here...(I've tryed some with
same results, though)...?

Thanks a lot for your time and any help.

Gretz.

 

Offline Thomas

Re: WA_BackFill on a Reaction Window
« Reply #1 on: March 27, 2007, 10:05:49 PM »
Quote

--- backfill hook:
Code: [Select]

{
 SetAPen( rp, 3 );
 RectFill( rp, 1, 1, WIDTH-1, HEIGHT-1 );
 ....
}



This is deadly wrong:

1. your must not use the RastPort given. It is for information only. You may only use rp->BitMap for rendering. If you need a RastPort, create your own one or copy the one given and move NULL to temp_rp->Layer.

2. you must respect the bounds given in the message. If you always fill the entire window, you overwrite everything including gadgets already drawn.

See Intuition/OpenWindow autodocs for a description of WA_BackFill and follow its link to layers/InstallLayerHook autodocs to read the essential hints.

Bye,
Thomas

Offline dcr8520Topic starter

  • Full Member
  • ***
  • Join Date: Mar 2002
  • Posts: 107
    • Show only replies by dcr8520
    • http://Amiga.SourceForge.net
Re: WA_BackFill on a Reaction Window
« Reply #2 on: March 28, 2007, 05:49:11 PM »
Thanks a lot Thomas!, it is working fine now :-)

btw, I also misunderstood the WA_BackFill usage... I thought it is just to fill the window background with whatever I want (and gadgets adapt itself to my background), but the hook gets called with each object my window has, nice...while there is no problem (from system to system) on using (message->bounds.MaxX-message->bounds.MinX == WIDTH-1) all together with WINDOW_LockWidth,TRUE, if what I want is to work with the window background only... (all objects get the background color drawn, but only the window will have the logo drawn)



Gretz.