View Single Post
Old 29 August 2017, 21:28   #17
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 46
Posts: 360
I still don't get what you are trying to do!

Are you doing all this to avoid clipping? So, that PrintIText doesn't (over)write on window borders?

if that's the case all you need to do is

Code:
    struct Region *reg;
    struct Region *oldreg;
    struct Rectangle rect;
    
    rect.MinX = myWindow->BorderLeft;
    rect.MinY = myWindow->BorderTop;
    rect.MaxX = myWindow->Width-myWindow->BorderRight-1;
    rect.MaxY = myWindow->Height-myWindow->BorderBottom-1;
    if (reg = NewRegion()) {
      OrRectRegion(reg, &rect);
      oldreg = InstallClipRegion(myWindow->WLayer, reg);
    }
and then you can use PrintIText and not worry about the borders.


full example code follows:
Code:
#include <intuition/intuition.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <proto/layers.h>

#include <stdio.h>

int main(int argc, char *argv[])
{
  struct Window *myWindow;
  int closewin = FALSE;       /* Flag used to end program */
  struct IntuiMessage *msg;   /* Structure to store Intuition message data */
  ULONG msgClass;             /* Class value */
  /* For printing in Window */
  UBYTE result[255];
  struct IntuiText WinText = {1, 0, JAM1, 0, 0, NULL, &result[0], NULL};
  int x,y;

  if (myWindow = OpenWindowTags(NULL,
                           WA_Left,   100,
                           WA_Top,    100,
                           WA_Width,  100,
                           WA_Height, 100,
                           WA_MaxWidth, 600,
                           WA_MaxHeight, 400,
                           WA_Activate, TRUE,
                           WA_IDCMP,  IDCMP_CLOSEWINDOW | IDCMP_MOUSEMOVE | IDCMP_NEWSIZE,
                           WA_Flags,  WFLG_SMART_REFRESH | WFLG_SIZEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET    | WFLG_ACTIVATE | WFLG_REPORTMOUSE,
                           TAG_END))
  {
    struct Region *reg;
    struct Region *oldreg;
    struct Rectangle rect;
    
    rect.MinX = myWindow->BorderLeft;
    rect.MinY = myWindow->BorderTop;
    rect.MaxX = myWindow->Width-myWindow->BorderRight-1;
    rect.MaxY = myWindow->Height-myWindow->BorderBottom-1;
    if (reg = NewRegion()) {
      OrRectRegion(reg, &rect);
      oldreg = InstallClipRegion(myWindow->WLayer, reg);
    }    
    while (closewin == FALSE) { /* Run program until window is closed */
      Wait(1L << myWindow->UserPort->mp_SigBit);     /* Wait for an event! */
      msg = GT_GetIMsg(myWindow->UserPort);
      msgClass = msg->Class;
      GT_ReplyIMsg(msg);

      switch (msgClass) {
        case IDCMP_CLOSEWINDOW: /* Close window? */
          closewin = TRUE;
          break;
        case IDCMP_MOUSEMOVE: /* Mouse moved? */
          x = msg->MouseX;
          y = msg->MouseY;
          /* Print selection in window */
          sprintf(result, "X-coord: %d Y-coord: %d", x, y);
          SetRast(myWindow->RPort, 0);
          PrintIText(myWindow->RPort, &WinText, x, y);

          break;
        case IDCMP_NEWSIZE:
          if (reg) {
            InstallClipRegion(myWindow->WLayer, oldreg);
            DisposeRegion(reg);

            rect.MinX = myWindow->BorderLeft;
            rect.MinY = myWindow->BorderTop;
            rect.MaxX = myWindow->Width-myWindow->BorderRight-1;
            rect.MaxY = myWindow->Height-myWindow->BorderBottom-1;
            if (reg = NewRegion()) {
              OrRectRegion(reg, &rect);
              oldreg = InstallClipRegion(myWindow->WLayer, reg);
            }
          }
          break;
        }
    }
    if (reg) {
      InstallClipRegion(myWindow->WLayer, oldreg);
      DisposeRegion(reg);
    }
    CloseWindow(myWindow);
  }
  return 0;
}
alkis is offline  
 
Page generated in 0.05192 seconds with 10 queries