예제 #1
0
NS_IMETHODIMP
EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
			   const PRUnichar *aTipText)
{
  nsAutoString tipText ( aTipText );
  const char* tipString = ToNewCString(tipText), *font = "TextFont08";
  PtArg_t args[10];
  PhRect_t extent;
  PhDim_t dim;
  PhPoint_t pos = {0, 0};
  int n = 0, w, h;

  if (sTipWindow)
    PtDestroyWidget(sTipWindow);
  
  // get the root origin for this content window
  nsCOMPtr<nsIWidget> mainWidget;
  mBaseWindow->GetMainWidget(getter_AddRefs(mainWidget));
  PtWidget_t *window;
  window = static_cast<PtWidget_t *>(mainWidget->GetNativeData(NS_NATIVE_WINDOW));

  PgExtentText(&extent, &pos, font, tipString, 0);
  w = extent.lr.x - extent.ul.x + 1;
  h = extent.lr.y - extent.ul.y + 1;

  n = 0;
  pos.x = aXCoords;
  pos.y = aYCoords + 10; /* we add 10 so that we don't position it right under the mouse */
	dim.w = w + 6; dim.h = h + 6;
  PtSetArg(&args[n++], Pt_ARG_POS, &pos, 0);
  PtSetArg(&args[n++], Pt_ARG_DIM, &dim, 0);
	PtSetArg( &args[n++], Pt_ARG_REGION_OPAQUE,   Ph_EV_EXPOSE, Ph_EV_EXPOSE);
  sTipWindow = PtCreateWidget(PtRegion, Pt_NO_PARENT, n, args);

  n = 0;
  pos.x = pos.y = 0;
	dim.w = w; dim.h = h;
  PtSetArg(&args[n++], Pt_ARG_POS, &pos, 0);
  PtSetArg(&args[n++], Pt_ARG_DIM, &dim, 0);
  PtSetArg(&args[n++], Pt_ARG_FLAGS, Pt_HIGHLIGHTED, -1 );
  PtSetArg(&args[n++], Pt_ARG_FILL_COLOR, 0xfeffb1, 0);
  PtSetArg(&args[n++], Pt_ARG_TEXT_FONT, font, 0);
  PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, tipString, 0);
  PtSetArg(&args[n++], Pt_ARG_BASIC_FLAGS, Pt_STATIC_GRADIENT | Pt_TOP_OUTLINE | Pt_LEFT_OUTLINE |
      Pt_RIGHT_OUTLINE | Pt_BOTTOM_OUTLINE, -1 );
  PtCreateWidget(PtLabel, sTipWindow, n, args);

  // realize the widget
  PtRealizeWidget(sTipWindow);

  nsMemory::Free( (void*)tipString );

  return NS_OK;
}
예제 #2
0
static int ph_SetupWindow(_THIS, int w, int h, int flags)
{
    PtArg_t     args[32];
    PhPoint_t   pos = {0, 0};
    PhDim_t     dim = {w, h};
    int         nargs = 0;
    const char* windowpos;
    const char* iscentered;
    int         x, y;

    PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);

    if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE)
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_MOVE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
    }

    if (((flags & SDL_NOFRAME)==SDL_NOFRAME) || ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN))
    {
       if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
       {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
       }
       else
       {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_BORDER);
       }
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE |
                                 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN);
    }

    if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
    {
        PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
        PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
    }
    else
    {
        windowpos = getenv("SDL_VIDEO_WINDOW_POS");
	iscentered = getenv("SDL_VIDEO_CENTERED");

        if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0)))
        {
            pos.x = (desktop_mode.width - w)/2;
            pos.y = (desktop_mode.height - h)/2;
            PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
	}
        else
        {
            if (windowpos)
            {
                if (sscanf(windowpos, "%d,%d", &x, &y) == 2 )
                {
                    pos.x=x;
                    pos.y=y;
                    PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
                }
	    }
        }


        PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISMAX | Ph_WM_STATE_ISALTKEY);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
        PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
    }

    PtSetResources(window, nargs, args);
    PtRealizeWidget(window);
    PtWindowToFront(window);

    return 0;
}
예제 #3
0
static int ph_SetupWindow(_THIS, int w, int h, int flags)
{
    PtArg_t     args[32];
    PhPoint_t   pos = {0, 0};
    PhDim_t*    olddim;
    PhDim_t     dim = {w, h};
    PhRect_t    desktopextent;
    int         nargs = 0;
    const char* windowpos;
    const char* iscentered;
    int         x, y;

    /* check if window size has been changed by Window Manager */
    PtGetResource(window, Pt_ARG_DIM, &olddim, 0);
    if ((olddim->w!=w) || (olddim->h!=h))
    {
       PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);
    }

    if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE)
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_CLOSE | Ph_WM_MAX | Ph_WM_RESTORE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
        PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED);
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_MOVE | Ph_WM_CLOSE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
        PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
    }

    if (((flags & SDL_NOFRAME)==SDL_NOFRAME) || ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN))
    {
       if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
       {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
       }
       else
       {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_BORDER);
       }
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE |
                                 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN);
    }

    if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
    {
        PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
        PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
    }
    else
    {
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_FFRONT | Ph_WM_CONSWITCH);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY);

        if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE)
        {
            PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
        }
        else
        {
            PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
        }
        if (!currently_maximized)
        {
            windowpos = SDL_getenv("SDL_VIDEO_WINDOW_POS");
            iscentered = SDL_getenv("SDL_VIDEO_CENTERED");

            if ((iscentered) || ((windowpos) && (SDL_strcmp(windowpos, "center")==0)))
            {
                PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
                if (desktop_mode.width>w)
                {
                    pos.x = (desktop_mode.width - w)/2;
                }
                if (desktop_mode.height>h)
                {
                    pos.y = (desktop_mode.height - h)/2;
                }

                pos.x+=desktopextent.ul.x;
                pos.y+=desktopextent.ul.y;
                PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
            }
            else
            {
                if (windowpos)
                {
                    if (SDL_sscanf(windowpos, "%d,%d", &x, &y) == 2)
                    {
                        if ((x<desktop_mode.width) && (y<desktop_mode.height))
                        {
                            PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
                            pos.x=x+desktopextent.ul.x;
                            pos.y=y+desktopextent.ul.y;
                        }
                        PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
                    }
                }
            }
        }

        /* if window is maximized render it as maximized */
        if (currently_maximized)
        {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISMAX);
        }
        else
        {
           PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISMAX);
        }

        /* do not grab the keyboard by default */
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);

        /* bring the focus to the window */
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFOCUS);

        /* allow to catch hide event */
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
        PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
    }

    PtSetResources(window, nargs, args);
    PtRealizeWidget(window);
    PtWindowToFront(window);

#if 0 /* FIXME */
    PtGetResource(window, Pt_ARG_POS, &olddim, 0);
    fprintf(stderr, "POSITION: %d, %d\n", olddim->w, olddim->h);
#endif

    return 0;
}
예제 #4
0
파일: vout.c 프로젝트: FLYKingdom/vlc
/*****************************************************************************
 * QNXCreateWnd: create and realize the main window
 *****************************************************************************/
static int QNXCreateWnd( vout_thread_t * p_vout )
{
    PtArg_t args[8];
    PhPoint_t pos = { 0, 0 };
    PgColor_t color = Pg_BLACK;

    if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY )
    {
        if( p_vout->p_sys->i_vc_flags & Pg_SCALER_CAP_DST_CHROMA_KEY )
        {
            color = PgGetOverlayChromaColor();
        }
    }

    /* fullscreen, set dimension */
    if( p_vout->b_fullscreen )
    {
        p_vout->p_sys->old_dim.w = p_vout->p_sys->dim.w;
        p_vout->p_sys->old_dim.h = p_vout->p_sys->dim.h;
        p_vout->output.i_width = p_vout->p_sys->dim.w = p_vout->p_sys->screen_dim.w;
        p_vout->output.i_height = p_vout->p_sys->dim.h = p_vout->p_sys->screen_dim.h;
    }

    /* set window parameters */
    PtSetArg( &args[0], Pt_ARG_POS, &pos, 0 );
    PtSetArg( &args[1], Pt_ARG_DIM, &p_vout->p_sys->dim, 0 );
    PtSetArg( &args[2], Pt_ARG_FILL_COLOR, color, 0 );
    PtSetArg( &args[3], Pt_ARG_WINDOW_TITLE, "VLC media player", 0 );
    PtSetArg( &args[4], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE );
    PtSetArg( &args[5], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE,
              Ph_WM_MOVE | Ph_WM_RESIZE | Ph_WM_CLOSE );
    PtSetArg( &args[6], Pt_ARG_WINDOW_RENDER_FLAGS,
              p_vout->b_fullscreen ? Pt_FALSE : Pt_TRUE,
              Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE );

    /* create window */
    p_vout->p_sys->p_window = PtCreateWidget( PtWindow, Pt_NO_PARENT, 7, args);
    if( p_vout->p_sys->p_window == NULL )
    {
        msg_Err( p_vout, "unable to create window" );
        return( 1 );
    }

    /* realize the window widget */
    if( PtRealizeWidget( p_vout->p_sys->p_window ) != 0 )
    {
        msg_Err( p_vout, "unable to realize window widget" );
        PtDestroyWidget( p_vout->p_sys->p_window );
        return( 1 );
    }

    /* get window frame size */
    if( PtWindowFrameSize( NULL, p_vout->p_sys->p_window,
                           &p_vout->p_sys->frame ) != 0 )
    {
        msg_Err( p_vout, "unable to get window frame size" );
        PtDestroyWidget( p_vout->p_sys->p_window );
        return( 1 );
    }

    return( 0 );
}
int main( int argc, char *argv[] )
{
  PtWidget_t *window, *container, *grid, *divider, *column00, *column01;
  PtArg_t args[20];
  int i = 0;

  /* Create a window */
  i = 0;
  PtSetArg( &args[i++], Pt_ARG_WINDOW_TITLE, "demo window", 0 );
  if ( NULL == ( window = PtAppInit( NULL, &argc, argv, i, args ) ) ) {
    perror( "PtAppInit()" );
    return 1;
  }

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_ANCHOR_FLAGS,
      Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP |
      Pt_LEFT_ANCHORED_LEFT     | Pt_RIGHT_ANCHORED_RIGHT,
      Pt_IS_ANCHORED);
  container = PtCreateWidget( PtContainer, window, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_ANCHOR_FLAGS,
      Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP |
      Pt_LEFT_ANCHORED_LEFT     | Pt_RIGHT_ANCHORED_RIGHT,
      Pt_IS_ANCHORED);
  grid = PtCreateWidget( PtScrollContainer, container, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtSetArg( &args[i++], Pt_ARG_DIVIDER_FLAGS, Pt_FALSE, Pt_DIVIDER_RESIZE_BOTH );
  //PtSetArg( &args[i++], Pt_ARG_CONTAINER_FLAGS,
  //    Pt_ENABLE_CUA | Pt_ENABLE_CUA_ARROWS | Pt_AUTO_EXTENT, 0 );
  divider = PtCreateWidget( PtDivider, grid, i, args );

  /* Set layout type and layout info */
  PtRowLayoutInfo_t info;
  info.type = Pt_LAYOUT_VERTICAL;
  info.flags = 0;  // all widgets will have the same size
  info.margin.ul.x = 0;  // upper left
  info.margin.ul.y = 0;
  info.margin.lr.x = 0;  // lower right
  info.margin.lr.y = 0;
  info.h_spacing = 0;
  info.v_spacing = 0;

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_CONTAINER_FLAGS,
      Pt_AUTO_EXTENT | Pt_ENABLE_CUA | Pt_ENABLE_CUA_ARROWS, 0 );
  PtSetArg( &args[i++], Pt_ARG_LAYOUT, PtRowLayout, &info );
  column00 = PtCreateWidget( PtContainer, divider, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_CONTAINER_FLAGS,
      Pt_AUTO_EXTENT | Pt_ENABLE_CUA | Pt_ENABLE_CUA_ARROWS, 0 );
  PtSetArg( &args[i++], Pt_ARG_LAYOUT, PtRowLayout, &info );
  column01 = PtCreateWidget( PtContainer, divider, i, args );

  /* column00 buttons */

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "T1", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtText, column00, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Button 2 (two)", 0);
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column00, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Butt 3", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column00, i, args );

  /* column01 buttons */

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "B4", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column01, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Butt 5", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column01, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Buttonchen 6", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column01, i, args );

  PtRealizeWidget( window );
  PtMainLoop();

  return 0;
}
예제 #6
0
NS_METHOD nsWidget::Show( PRBool bState ) {

    if( !mWidget ) return NS_OK; // Will be null durring printing

    PtArg_t   arg;

    if( bState ) {

        if( mWindowType != eWindowType_child ) {

            if (PtWidgetIsRealized(mWidget)) {
                mShown = PR_TRUE;
                return NS_OK;
            }

            //EnableDamage( mWidget, PR_FALSE );
            PtRealizeWidget(mWidget);

            if( mWidget->rid == -1 ) {
                //EnableDamage( mWidget, PR_TRUE );
                NS_ASSERTION(0,"nsWidget::Show mWidget's rid == -1\n");
                mShown = PR_FALSE;
                return NS_ERROR_FAILURE;
            }

            PtSetArg(&arg, Pt_ARG_FLAGS, 0, Pt_DELAY_REALIZE);
            PtSetResources(mWidget, 1, &arg);
            //EnableDamage( mWidget, PR_TRUE );
            PtDamageWidget(mWidget);
#ifdef Ph_REGION_NOTIFY
            PhRegion_t region;
            PtWidget_t *mWgt;
            mWgt = (PtWidget_t*) GetNativeData( NS_NATIVE_WIDGET );
            region.flags = Ph_REGION_NOTIFY | Ph_FORCE_BOUNDARY;
            region.rid = PtWidgetRid(mWgt);
            PhRegionChange(Ph_REGION_FLAGS, 0, &region, NULL, NULL);
#endif
        }
        else {
            PtWidgetToFront( mWidget );
            if( !mShown || !( mWidget->flags & Pt_REALIZED ) ) PtRealizeWidget( mWidget );
        }
    }
    else {
        if( mWindowType != eWindowType_child ) {
            //EnableDamage( mWidget, PR_FALSE );
            PtUnrealizeWidget(mWidget);

            //EnableDamage( mWidget, PR_TRUE );

            PtSetArg(&arg, Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_DELAY_REALIZE);
            PtSetResources(mWidget, 1, &arg);
        }
        else {
            //EnableDamage( mWidget, PR_FALSE );
            PtWidgetToBack( mWidget );
            if( mShown ) PtUnrealizeWidget( mWidget );
            //EnableDamage( mWidget, PR_TRUE );
        }
    }

    mShown = bState;
    return NS_OK;
}
예제 #7
0
int ph_window_create_display (int bitmap_depth)
{
	PtArg_t arg[9];
	PhRect_t rect;
    PhRegion_t region_info;
    
    // Only image_height??!!
    int image_height;
    int window_width, window_height;

	// Create the Photon Window

	view_size.w = widthscale * visual_width;
	view_size.h = heightscale * visual_height;
	
    image_width      = widthscale  * visual_width;
    image_height     = heightscale * visual_height;
    
    // TODO: Finish always ontop (Make phearbear happy)
	PtSetArg( &arg[0], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 );
	PtSetArg( &arg[1], Pt_ARG_WINDOW_MANAGED_FLAGS, 0, Ph_WM_MAX | Ph_WM_RESIZE | Ph_WM_MENU | Ph_WM_CLOSE | Ph_WM_HIDE );
	PtSetArg( &arg[2], Pt_ARG_DIM, &view_size, 0 );
	PtSetArg( &arg[3], Pt_ARG_WINDOW_NOTIFY_FLAGS, Ph_WM_FOCUS, Ph_WM_FOCUS | Ph_WM_RESIZE | Ph_WM_CLOSE );
	PtSetArg( &arg[4], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_MENU | Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_MIN | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RESIZE );
	PtSetArg( &arg[5], Pt_ARG_WINDOW_TITLE, title, 0);
	//PtSetArg( &arg[6], Pt_ARG_WINDOW_STATE, 0, Ph_WM_STATE_ISFRONT );
	
	PtSetParentWidget(NULL);
	if((P_mainWindow = PtCreateWidget(PtWindow, NULL, 6, arg)) == NULL)
		fprintf(stderr,"error: could not create main photon window.\n");

	/* add raw callback handler */
	PtAddEventHandler( P_mainWindow,
		Ph_EV_BUT_PRESS |
		Ph_EV_BUT_RELEASE |
		Ph_EV_BOUNDARY |
		Ph_EV_EXPOSE |
		Ph_EV_PTR_MOTION |
		Ph_EV_KEY |
		Ph_EV_INFO,
		I_GetEvent,
		NULL );

	/* set draw buffer size */
	PgSetDrawBufferSize( 0xFF00 );

	PtRealizeWidget( P_mainWindow );

	if (show_cursor == FALSE)
	{
    	region_info.cursor_type = Ph_CURSOR_NONE;
    	region_info.rid = PtWidgetRid(P_mainWindow);
    	PhRegionChange (Ph_REGION_CURSOR, 0, &region_info, NULL, NULL); // turn off cursor
	}


	/* create and setup the image */
	switch (ph_window_update_method)
	{
		case PH_NORMAL:

//		image = PdCreateOffscreenContext(0, ((view_size.w+7) & ~7), view_size.h, Pg_OSC_MEM_PAGE_ALIGN);
		image = PdCreateOffscreenContext(0, view_size.w, view_size.h, Pg_OSC_MEM_PAGE_ALIGN);
	 	if (image == NULL)
	 	{
			fprintf(stderr_file, "error: failed to create offscreen context\n");
			return OSD_NOT_OK;
		}

		scaled_buffer_ptr = PdGetOffscreenContextPtr (image);
		if (!scaled_buffer_ptr)
		{
			fprintf (stderr_file, "error: failed get a pointer to offscreen context.\n");
			PhDCRelease (image);
			return OSD_NOT_OK;
		}

		depth = 0;

		switch (image->format)
		{
			case Pg_IMAGE_PALETTE_BYTE   :
			// TODO :
			break;
			case Pg_IMAGE_DIRECT_565  :
				depth = 16;
				pixels_per_line = image->pitch >> 1;
			break;
			case Pg_IMAGE_DIRECT_555  :
			// TODO:
			break;
			case Pg_IMAGE_DIRECT_888  :
				depth = 24;
				pixels_per_line = image->pitch / 3;
			break;	
			case Pg_IMAGE_DIRECT_8888 :
				depth = 32;
				pixels_per_line = image->pitch >> 2;
			break;
		}
		break;
	
		default:
			fprintf (stderr_file, "error: unknown photon update method, this shouldn't happen\n");
		return OSD_NOT_OK;
	}

	/* setup the palette_info struct now we have the depth */
	if (ph_init_palette_info() != OSD_OK)
	return OSD_NOT_OK;

	fprintf(stderr_file, "Actual bits per pixel = %d...\n", depth);
    if (bitmap_depth == 32)
   {
      if (depth == 32)
         ph_window_update_display_func = ph_window_update_32_to_32bpp_direct;
   }
	else if (bitmap_depth == 16)
	{
		switch(depth)
		{
			case 16:
				ph_window_update_display_func = ph_window_update_16_to_16bpp;
			break;
			case 24:
				ph_window_update_display_func = ph_window_update_16_to_24bpp;
			break;
			case 32:
				ph_window_update_display_func = ph_window_update_16_to_32bpp;
			break;
		}
	}

	if (ph_window_update_display_func == NULL)
	{
		fprintf(stderr_file, "error: unsupported\n");
		return OSD_NOT_OK;
	}

	fprintf(stderr_file, "Ok\n");

	return OSD_OK;
}
예제 #8
0
main(int argc,char *argv[])
{
	CoolImage *image;
	int x,y;
	int i,j;
	PtWidget_t *win;
	PtArg_t args[3];
	PhDim_t dim={m_W,m_H};
	PhPoint_t pos={50,250};
	int fd; //Bt878 driver file descriptor
	int fd_temp;
	int size_read;
	struct timeval tv;
    fd_set rfd;
    int n;
	int error;
	int counter = 0;
	int counter_mean = 0;
	int file = 0;


	//Timing calculation
    uint64_t cps, cycle1, cycle2, ncycles;
    float sec;
    float msec;

	// if a paramater was passed, grab it as the blit type 
	if (argc>1) blittype=atoi(argv[1]);

	// initialize our connection to Photon, and create/realize a window 
	//PtInit("/net/irene2/dev/photon");
	PtInit("/dev/photon");
	PtSetArg(&args[0],Pt_ARG_POS,&pos,0);
	PtSetArg(&args[1],Pt_ARG_DIM,&dim,0);
	win=PtCreateWidget(PtWindow,Pt_NO_PARENT,2,args);
	PtRealizeWidget(win);

	// Allocate and fill a series of NUMIMAGES images with a little 
	// fading type animation.  Put your own animation in here if you like.


	/*
     *    Set a 5 second timeout.
     */
    tv.tv_sec = 5;
    tv.tv_usec = 0;

	image = AllocBuffer(m_W,m_H,fd);	
	assert(image!=0);
	
	if (file != 2)
	{
	init_bttvx(2,0, m_W,m_H,0,0);
	open_bttvx();
	
	BttvxSetImageBuffer(0, image->buffer);
	}
	fd_temp = fd;
	FD_ZERO( &rfd );
	FD_SET( fd, &rfd );
	
	
	while(1)
	{
		//fd = open("/net/europa/dev/bttvx0",O_RDWR);
		//if ( fd > 0 )
		//{
			
			///switch ( n = select( 1 + max( fd,0 ),
			///   &rfd, 0, 0, &tv ) ) 
			///{
			///  case -1:
			///	perror( "select" );
			///	return EXIT_FAILURE;
			///  case  0:
			///	puts( "select timed out" );
			///	break;
			///  default:
				//printf( "descriptor ready ...\n");
				//if( FD_ISSET( console, &rfd ) )
				//  puts( " -- console descriptor has data pending" );
				//if( FD_ISSET( serial, &rfd ) )
				//  puts( " -- serial descriptor has data pending" );
				/* Read the text */

				cycle1=ClockCycles( );

				//lseek(fd,0L,SEEK_SET);
			///	size_read = read( fd, image->buffer, W*H*deep );
		   if (file != 2)
		   {
		   BttvxWaitEvent();
		   BttvxAcquireBuffer(image->buffer);	
		    }
		   
		   switch(file)
		   {
		   	case 0:
		   		BlitBuffer(win,image);
		   		break;
		   	case 1:
		   		SaveImage(counter,image);
		   		break;
		   	case 2:
		   		
		   		LoadImage(counter,image);
		   		BlitBuffer(win,image);
		   		getchar();
		   		break;
		   };
		   
		   if (file!=2)
		   	BttvxReleaseBuffer();
		   cycle2=ClockCycles( );
		   counter++;
		   counter_mean++;

		   
		   ncycles=cycle2-cycle1;
		   //printf("%lld cycles elapsed \n", ncycles);

		   /* find out how many cycles per second */
		
		   cps = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
		   //printf( "This system has %lld cycles/sec.\n",cps );
		   sec=(float)ncycles/cps;
		   msec +=sec;
		   if (counter_mean == 250 )
		   {
		   	msec = msec/counter_mean;
		   	printf("The cycles in seconds is %f \n",msec);
		   	counter_mean = 0;
		   	msec = 0;
		   }
		//}else
			//sleep(2);
		}

	//printf("Blitted %d frames using method %d\n",REPS*NUMIMAGES,blittype);

	// now free the images
	FreeBuffer(image);
	close( fd );
	/// hide the window and destroy it.
	PtUnrealizeWidget(win);
	PtDestroyWidget(win);
}