paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/test animation.cpp,NONE,1.1 dropdown.cpp,NONE


From: Alexander Pipelka <address@hidden>
Subject: [paragui-cvs] CVS: paragui/test animation.cpp,NONE,1.1 dropdown.cpp,NONE,1.1 windowresize.cpp,NONE,1.1 Makefile.am,1.1.1.1,1.2 configure.in,1.1.1.1,1.2 paratest.cpp,1.1.1.1,1.2
Date: Mon, 15 Apr 2002 09:31:35 -0400

Update of /cvsroot/paragui/paragui/test
In directory subversions:/tmp/cvs-serv21582/test

Modified Files:
        Makefile.am configure.in paratest.cpp 
Added Files:
        animation.cpp dropdown.cpp windowresize.cpp 
Log Message:
imported version 1.0.1



--- NEW FILE ---
/* GOAL: Test various paragui features.
*/

/* Interesting; when InitScreen is given invalid parameters along with 
SDL_FULLSCREEN,
 * the program hangs rather than giving a reasonable error message. */

/* Ask: How do you create a custom theme? */

/*
    Submitted by: Mark Krosky <address@hidden>
*/

#include <pgapplication.h>
#include <pgpopupmenu.h> 
#include <pgbutton.h>
#include <pgmenubar.h> 
#include <pgscrollbar.h> 

#define ID_APP_EXIT             1

PARAGUI_CALLBACK(exit_handler) {

        // we can pass in some pointer to any userdata
        // (in this case we get a pointer to the application object)
        PG_Application* app = (PG_Application*) clientdata;

        // exit the application eventloop
        app->Quit();

        // return true to signal that we have processed this message
        return true;
}

PARAGUI_CALLBACK_SELECTMENUITEM(handle_menu_click) {

        switch (id) {
          case ID_APP_EXIT:
                static_cast<PG_Application*>(clientdata)->Quit();
                break;
        }

        return true;
}

class PlayField : public PG_ThemeWidget {
public:

        // the constructor
        PlayField(PG_Widget* parent, PG_Rect r);

        // the destructor
        ~PlayField();

        void timer_callback(void);

protected:

        // our custom event handler to redraw our stuff
        void eventBlit(SDL_Surface* surface, const PG_Rect& src, const PG_Rect& 
dst);

private:

        // the color we want to draw the lines with
        SDL_Color my_color;

        int tickstate;
};

// implementation of MyWidget

PlayField::PlayField(PG_Widget* parent, PG_Rect r) : PG_ThemeWidget(parent, r) {
        // here we do some initialization e.g the color :)

        // the red value
        my_color.r = 200;

        // the green value
        my_color.g = 50;

        // the blue value
        my_color.b = 10;

        tickstate = 0;
}

PlayField::~PlayField() {
        // here we could do some cleanup
}


// implementation of the draw event
// (fills the widget with some nice gfx)

void PlayField::eventBlit(SDL_Surface* surface, const PG_Rect& src, const 
PG_Rect& dst) {

        SDL_FillRect(my_srfScreen, (SDL_Rect*)&dst, 0);
        
        if (tickstate==0) {
                // we draw our first line
                DrawLine(
                        0,
                        0,
                        my_width-1,
                        my_height-1,
                        my_color,
                        1
                        );

                // we draw our second line
                DrawLine(
                        my_width-1,
                        0,
                        0,
                        my_height-1,
                        my_color,
                        1
                        );
        }
        else if (tickstate == 1) {
                DrawHLine(0, my_height/2, my_width-1, my_color.r, my_color.g, 
my_color.b);
        }
}

void PlayField::timer_callback(void) {

        int prev_tickstate = tickstate;

        tickstate = (SDL_GetTicks()/1000)%3;

        if (tickstate != prev_tickstate) {
                Update();
        }
}

class PlayField2 : public PG_ThemeWidget
{
public:

        // the constructor
        PlayField2(PG_Widget* parent, PG_Rect r);

        // the destructor
        ~PlayField2();

        void timer_callback(void);

protected:

        // our custom event handler to redraw our stuff
        void eventBlit(SDL_Surface* surface, const PG_Rect& src, const PG_Rect& 
dst);

private:

        // the color we want to draw the lines with
        SDL_Color my_color;

        int tickstate;
};

PlayField2::PlayField2(PG_Widget* parent, PG_Rect r) : PG_ThemeWidget(parent, 
r) {
        // here we do some initialization e.g the color :)

        // the red value
        my_color.r = 0;

        // the green value
        my_color.g = 0;

        // the blue value
        my_color.b = 255;

        tickstate = 0;
}

PlayField2::~PlayField2() {
        // here we could do some cleanup
}


// implementation of the draw event
// (fills the widget with some nice gfx)

void PlayField2::eventBlit(SDL_Surface* surface, const PG_Rect& src, const 
PG_Rect& dst) {

        SDL_FillRect(my_srfScreen, (SDL_Rect*)&dst, 0);
        
        for (int i=0; i<3; i++)
        {
          DrawLine(
                i*40 + tickstate,
                0,
                i*40 + tickstate,
                my_height/2,
                my_color,
                1
                );
        }

        SDL_Color temp_color;
        PG_Rect temp_rect;
        Uint32 temp_int;

        temp_rect.x = dst.x;
        temp_rect.y = dst.y+(dst.h/2);
        temp_rect.w = dst.w;
        temp_rect.h = dst.h-(dst.h/2);

        temp_color.r = (my_color.r * tickstate)/40;
        temp_color.g = (my_color.g * tickstate)/40;
        temp_color.b = (my_color.b * tickstate)/40;

        temp_int = SDL_MapRGB(my_srfScreen->format, temp_color.r, temp_color.g, 
temp_color.b);
        SDL_FillRect(my_srfScreen, (SDL_Rect *)&temp_rect, temp_int);
}

void PlayField2::timer_callback(void) {

        int prev_tickstate = tickstate;

        tickstate = (SDL_GetTicks()%1000)/25;

        if (tickstate != prev_tickstate) {
                Update();
        }
}

Uint32 timer_callback(Uint32 interval, void* parameter) {
        ((PlayField2 *)parameter)->timer_callback();
        return interval;
}

PARAGUI_CALLBACK(appidle_handler) {
        ((PlayField *)clientdata)->timer_callback();
        return true;
}

int main(int argc, char* argv[]) {

        // every ParaGUI application need an application-object
        PG_Application app;

        // let us escape with "ESC"
        app.SetEmergencyQuit(true);
        
        // every application needs a theme (the look & feel of the widgets)
        //app.LoadTheme("default");
        app.LoadTheme("simple");

        // we must initialize the screen where we want to draw on

        // 640 - screen width
        // 480 - screen height
        // 0 - use screen bitdepth
        // SDL_SWSURFACE - PG_ option to generate surface in system memory

        app.InitScreen(800, 600, 0, SDL_SWSURFACE);

        // ok - now we have a nice 640x480x16 window on the screen :)

        PG_Rect rect(0, 0, 80, 30);

        PG_Button myButton(
                NULL,           // an optional parent widget for our button - 
NULL for no parent
                1,              // the widget id (used to identify events)
                rect,           // the screen position where the button should 
appear
                "Quit"          // some textlabel for the button
                );

        // this defines our callback handler for the message MSG_BUTTONCLICK,
        // we pass a pointer to the app object as userdata

        PG_MenuBar menubar(NULL, PG_Rect(100, 0, 400, 30));
        PG_PopupMenu   popmenu(NULL, 425, 140, "File");

        popmenu.addMenuItem("Nail", 99, handle_menu_click).
        addMenuItem("Quit", ID_APP_EXIT, handle_menu_click, &app);
 
        menubar.Add("File", &popmenu);

        menubar.Show();

        myButton.SetEventCallback(MSG_BUTTONCLICK, exit_handler, &app);

        // now we have to make the button visible

        myButton.Show();

        // Every ParaGUI application is event driven, so we need a loop where
        // we process all events (like mouse handling, keystrokes,...)

        // usually this is done with PG_Application::Run()

        PG_Rect sc_rect(50, 50, 100, 300);
        PG_ScrollBar myscroll(NULL, 100, sc_rect, PG_SB_VERTICAL);
        myscroll.Show();

        PG_Rect sc_rect2(200, 200, 300, 100);
        PG_ScrollBar myscroll2(NULL, 101, sc_rect2, PG_SB_HORIZONTAL);

        myscroll2.SetWindowSize(10);
        myscroll2.SetRange(0, 100);
        myscroll2.SetPageSize(10);
        myscroll2.SetLineSize(5);

        myscroll2.Show();

        // Attempt to get animation
        PlayField anim_test(
                // still no parent widget
                NULL,
                // a static function to create rects
                PG_Rect(260,120,120,50)
                );

        // show me your .... lines ;-)

        anim_test.Show();

    PlayField2 anim_test2(
          NULL,
          PG_Rect(260, 300, 120, 100)
          );
        anim_test2.Show();

        SDL_Init(SDL_INIT_TIMER);
        SDL_AddTimer(20, timer_callback, (void *)&anim_test2);

        app.SetEventCallback(MSG_APPIDLE, appidle_handler, (void *)&anim_test);
        app.EnableAppIdleCalls();

        app.Run();

        // this function will only exit when the application was closed

        return 0;
}

// Maybe should use #define and ID #s for widet IDs.

--- NEW FILE ---
/*
This sample app demonstrates a really ugly bug
Submitted by: Andrew Ford <address@hidden>
*/

#include "paragui.h"
#include "pgdropdown.h"
#include "pgapplication.h"

int main()
{
   PG_Application app;
   app.LoadTheme( "default" );
   app.InitScreen( 640, 480 );

   PG_DropDown *dd1, *dd2;

   dd1 = new PG_DropDown( NULL, 1, PG_Rect( 10, 10, 100, 20 ) );
   dd2 = new PG_DropDown( NULL, 2, PG_Rect( 120, 10,100, 20 ) );

   for( int i = 0; i < 10; i++ )
   {
      dd1->AddItem( "poop" );
      dd2->AddItem( "yeah" );
   }
    
   dd1->Show();
   dd2->Show();

   app.Run();

   return 0;
}

--- NEW FILE ---
#include "paragui.h"
#include "pgapplication.h"
#include "pgwindow.h"

int main( int argc, char **argv )
{
   PG_Application app;

   app.LoadTheme( "default" );

   app.InitScreen( 640, 480 );

   PG_Window a( NULL, PG_Rect( 10, 10, 100, 100 ),
"Window 98, the most reliable window yet." );
   PG_Window b( NULL, PG_Rect( 60, 110, 100, 100 ),
"Window XP, ." );

   a.SizeWidget( 400, 200 );

   b.SizeWidget( 400, 200 );

   a.Show();
   b.Show();

   app.Run();

   return 0;
}

Index: Makefile.am
===================================================================
RCS file: /cvsroot/paragui/paragui/test/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** Makefile.am 15 Apr 2002 13:22:29 -0000      1.1.1.1
--- Makefile.am 15 Apr 2002 13:31:31 -0000      1.2
***************
*** 1,5 ****
  AUTOMAKE_OPTIONS = foreign
  
! bin_PROGRAMS = paratest dblbuffer navtest windowtest layouttest
  
  dblbuffer_SOURCES = dblbuffer.cpp
--- 1,14 ----
  AUTOMAKE_OPTIONS = foreign
  
! bin_PROGRAMS = animation dropdown paratest dblbuffer navtest windowtest 
layouttest windowresize
! 
! windowresize_SOURCES = windowresize.cpp
! windowresize_LDADD = $(PARAGUI_LIBS)
! 
! dropdown_SOURCES = dropdown.cpp
! dropdown_LDADD = $(PARAGUI_LIBS)
! 
! animation_SOURCES = animation.cpp
! animation_LDADD = $(PARAGUI_LIBS)
  
  dblbuffer_SOURCES = dblbuffer.cpp
***************
*** 21,24 ****
--- 30,37 ----
  
  $(PACKAGE)-$(VERSION).tar.gz: dist
+ 
+ EXTRA_DIST = \
+       pokus.xml \
+       icon.bmp
  
  dist-hook:

Index: configure.in
===================================================================
RCS file: /cvsroot/paragui/paragui/test/configure.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** configure.in        15 Apr 2002 13:22:29 -0000      1.1.1.1
--- configure.in        15 Apr 2002 13:31:31 -0000      1.2
***************
*** 14,18 ****
  dnl Check for tools
  
- dnl AM_PROG_LIBTOOL
  AC_PROG_MAKE_SET
  AC_PROG_CC
--- 14,17 ----
***************
*** 24,28 ****
  
  AC_C_CONST
- EXEEXT=""
  
  case "$target" in
--- 23,26 ----
***************
*** 31,44 ****
        AC_MINGW32
        AC_EXEEXT
-       EXEEXT=".exe"
-         SYS_GL_LIBS="-lopengl32"
          ;;
      *-*-beos*)
        ac_default_prefix=/boot/develop/tools/gnupro
-       SYS_GL_LIBS="-lGL"
        ;;
  esac
- 
- AC_SUBST(EXEEXT)
  
  dnl Check for PARAGUI
--- 29,37 ----

Index: paratest.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/test/paratest.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** paratest.cpp        15 Apr 2002 13:22:29 -0000      1.1.1.1
--- paratest.cpp        15 Apr 2002 13:31:31 -0000      1.2
***************
*** 108,112 ****
  {
        WidgetList = new PG_WidgetList(this, PG_Rect(30, 40, 220, 250));
!       WidgetList->SetTransparency(255);
        WidgetList->EnableScrollBar(true, PG_SB_VERTICAL);
        WidgetList->EnableScrollBar(true, PG_SB_HORIZONTAL);
--- 108,116 ----
  {
        WidgetList = new PG_WidgetList(this, PG_Rect(30, 40, 220, 250));
!       WidgetList->SetDirtyUpdate(false);
!       WidgetList->SetTransparency(0);
!       WidgetList->SetBackground("default/wnd_close.bmp", BKMODE_TILE, 0xFF);
!       WidgetList->SetBackgroundBlend(0);
!                       
        WidgetList->EnableScrollBar(true, PG_SB_VERTICAL);
        WidgetList->EnableScrollBar(true, PG_SB_HORIZONTAL);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]