Page 2 of 2

Posted: Fri Oct 27, 2006 11:58 pm
by Shannara
no problem, just wondering :) Either or, I think i'll be using this in a more recent project to see what I can come up with. The screenie above gave me mundo ideas.

Posted: Sat Oct 28, 2006 11:59 pm
by utopiomania
I saw your thread here: http://www.purebasic.fr/german/viewtopi ... 60&start=0 and am deeply
impressed with your lib.

Do you know if this is something similar to what Cyberlink uses in their PowerCinema App? (I'm impressed
with that as well)

Anyway, please keep up the good work :)

Posted: Mon Oct 30, 2006 3:24 am
by Shannara
Here is basically code from one of the examples you posted the code for. The differences is encapsolating the init and shutdown methods into their own procedures. However, unfortunately, the program freezes everytime you alt tab to another process ..

Do you know of a way to fix that? Or what I have done wrong?

Code: Select all

#SCREEN_WIDTH = 800
#SCREEN_HEIGHT = 600

Global frmMain.l
Global Dim GadgNr.l(4)

Global sprMouse.l
Global imgButton.l

Procedure ShutDown()
  If IsWindow(frmMain)
    CloseWindow(frmMain)
  EndIf
  
  End
EndProcedure

Procedure Init()
  If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse()= 0
    Debug "Unable to init sprite/keyboard/mouse"
    ShutDown()
  EndIf
  
  frmMain = OpenWindow(#PB_Any, 0, 0, #SCREEN_WIDTH, #SCREEN_HEIGHT, "", #PB_Window_ScreenCentered)
  If frmMain
  Else
    Debug "unable to open window"
    ShutDown()
  EndIf
  
  If OpenWindowedScreen(WindowID(frmMain), 0,0, #SCREEN_WIDTH, #SCREEN_HEIGHT, 0, 0, 0)
  Else
    Debug "unable to open screen"
    ShutDown()
  EndIf
  
  ; create a mouse
  sprMouse = CreateSprite(#PB_Any, 8, 8)
  If sprMouse
    If StartDrawing(SpriteOutput(sprMouse))
      Circle(4, 4, 4, RGB(255, 255, 255))
      StopDrawing()
    EndIf
  EndIf
  
  ; build Screengadgets
  ; set the appearance for the Imagebutton-gadget
  imgButton = CreateImage(#PB_Any, 100, 60)
  StartDrawing(ImageOutput(imgButton))
  Box(0, 0, 100, 60, $00FFFF)
  DrawingMode(4)
  For x = 0 To 200
    Circle(Random(90) + 5, Random(50) + 5, Random(4) + 1, RGB(Random(255), Random(255), Random(255)))
  Next
  StopDrawing()
  
  SG_SetBackground(0)
  SG_SetColor($00FFFF)
  
  GadgNr(0) = SG_ListIconGadget(#PB_Any, 430, 80, 250, 315, "Column0", 100, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_GridLines) ;
  SG_AddGadgetColumn(GadgNr(0), 1, "Column1", 100)
  For x = 1 To 8
    SG_AddGadgetItem(GadgNr(0), -1, "test " + Str(x) + Chr(10) + "Part 2 / " + Str(x))
  Next
  SG_SetGadgetItemColor(GadgNr(0), 0, $FF0000, -1)
  SG_SetGadgetItemColor(GadgNr(0), 1, $00FF00, -1)
  
  CreateImage(201, 16, 16)
  StartDrawing(ImageOutput(201))
  Box(0, 0, 16, 16, $FF00FF)
  StopDrawing()
  SG_AddGadgetItem(GadgNr(0), 5, "test 5 new", ImageID(201))
  CreateImage(200, 16, 16)
  StartDrawing(ImageOutput(200))
  Box(0, 0, 16, 16, $0000FF)
  StopDrawing()
  SG_AddGadgetItem(GadgNr(0), 8, "test 8 new", ImageID(200))
  SG_SetGadgetBackground(GadgNr(0), 0)
  SG_SetGadgetColor(GadgNr(0), $00FFFF)
  
  
  GadgNr(1) = SG_ListIconGadget(#PB_Any, 700, 80, 100, 100, "Column0",100, #PB_ListIcon_GridLines)
  
  
  GadgNr(2) = SG_ButtonGadget(#PB_Any, 650, 550, 120, 40, "OK")
  SG_SetGadgetColor(GadgNr(2), $FFFFFF)
  SG_SetGadgetBackground(GadgNr(2), 0)
  
  GadgNr(3) = SG_ButtonGadget(#PB_Any, 690, 560, 120, 40, "Toggle", #PB_Button_Toggle)
  
  GadgNr(4) =  SG_ButtonImageGadget(#PB_Any, 450, 450, 100, 60, ImageID(imgButton), 0)
  
  
EndProcedure


Init()
    
  ; Eventloop
  Repeat ; Start of the event loop
    ClearScreen(0)

    DisplaySprite(sprMouse, 0, 0) ; play with this to see a background
    
    SG_DrawGadgets(-1, 0)
    ExamineMouse ()
    DisplayTransparentSprite(sprMouse, MouseX(), MouseY())
    
    FlipBuffers(0)

    ; standard loop
    Event = SG_ScreenGadgetEvent() ; This line checks if an event happened
    GadgetID = SG_EventScreenGadgetID() ; Is it a gadget event?
    EventType = SG_EventType() ; The event type
    ;You can place code here, and use the result as parameters for the procedures
    If Event = #PB_Event_Gadget
      
      If GadgetID = GadgNr(2)
        If EventType = #SG_EventType_LeftRelease
          SG_FreeAllGadgets()
          Event = #PB_Event_CloseWindow
        EndIf
        
      ElseIf GadgetID = GadgNr(4)
        If EventType = #SG_EventType_LeftRelease
          SG_FreeGadget(GadgNr(3))
          
        EndIf
      EndIf
    EndIf
    Delay(10)
  Until Event = #PB_Event_CloseWindow Or MouseButton(2) ; End of the event loop

ShutDown()

Posted: Mon Oct 30, 2006 3:45 am
by Shannara
I got it. Event need to return first from WindowEvent(), and then check if closewindow is called. You need a global Quit.b = #false. Set to true if the above event happens. Plus, MouseEvent(2) freezes the application if the app does not have focus..

Thus, it need to be wrapped in an GetActiveWindow() = (window), so does MouseX and MouseY called functions.

Or else the application freezes.

Posted: Mon Oct 30, 2006 5:28 am
by Intrigued
Hurga wrote:
Isn't this really a Windowed application, just not having a boarder, titlebar? Sorry to be ruff or come off that way. But, I would believe a Screen gadget Lib would be just that, where you would code directly onto the Screen and not inside of a Window. Am I missing something?
The windowed screen is only for better debugging (as Shannara said its horrible to debug in full screen. But you can change the example to fullscreen, no probs). All gadgets are drawn directly to the screen (and made out of Boxes, lines and so on)

You can have a look at the source (the old version) - you can found it in the PBOSL. I tried not to use any API, so it should be useable under Linux (and MAc, if 4.0 comes out)

//EDIT:
I´m using the screengadgetlib with my current project. If you are interested to see it working, look here (screenshots and a demo):
http://www.purebasic.fr/german/viewtopi ... 60&start=0
The game itself is in english, the thread in german

@ricardo
No, I used windowed screen, and so foxmail bar was on top of it. Its a screen shot of the screen, I opened, would be precise :-)

@Shannara
I agree, thats why I use Windowed Screen for testing too.
Let me see if I understand now: So you want to make it as Windowed game, but dont want to use any window-controls. And you prefer WindowMousex/Y. Is this right.
Hm, this would mean, that you can move your mose freely around. But you have problems(is it right) if you use Windomousex/y in fullscreen?[/url]
Ah, I see.

Posted: Mon Oct 30, 2006 8:50 am
by Hurga
I saw your thread here: http://www.purebasic.fr/german/viewtopi ... 60&start=0 and am deeply
impressed with your lib.
Thx.
Do you know if this is something similar to what Cyberlink uses in their PowerCinema App? (I'm impressed
with that as well)
Hu ... no idea.. didnt even know the software ... sorry
I got it. Event need to return first from WindowEvent(), and then check if closewindow is called. You need a global Quit.b = #false. Set to true if the above event happens. Plus, MouseEvent(2) freezes the application if the app does not have focus..

Thus, it need to be wrapped in an GetActiveWindow() = (window), so does MouseX and MouseY called functions.

Or else the application freezes.
Hm, I never lost an thought about that. But you´r right, that not really "nice". Will try to see, if its possible to build-in some checks for this.