Do you plan MDIGadget() to Linux and MacOs ?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
thyphoon
Enthusiast
Enthusiast
Posts: 345
Joined: Sat Dec 25, 2004 2:37 pm

Do you plan MDIGadget() to Linux and MacOs ?

Post by thyphoon »

Hello

Do you plan MDIGadget() to Linux and MacOs ?

Do Somebody know a solution to emulate it on Linux and MacOs ?

Best regards

Thy
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Do you plan MDIGadget() to Linux and MacOs ?

Post by Foz »

Well, for Linux, MDI is not available, as it isn't in their thinking - if you want multiple windows, then you can let the window manager deal with multiple windows.

And in some ways I agree with the idea - when I open two spreadsheets on my dual monitor setup, for me to compare and adjust, I used to resort to stretching excel across both monitors, and then aligning two sheet files in excel. That's time consuming and fugly. My current method is much better - open one in excel, and then other in OO.org. Both methods irritate the hell out of me.

This is the reason that GIMP has been multi windowed for such a long time, and the plan to make it an integrated environment is taking massive amounts of rewriting.

Now I did a way of loading a dll and then displaying it's own "window" in the exe's window (I don't think I did any api fudging, it was just all pb commands), but that was a very long time ago, and if I remember correctly, a pain in the backside - ropey too. If you want I can dig it out and see if I can make it workable.
User avatar
thyphoon
Enthusiast
Enthusiast
Posts: 345
Joined: Sat Dec 25, 2004 2:37 pm

Re: Do you plan MDIGadget() to Linux and MacOs ?

Post by thyphoon »

Thanks !
Your answer is very interesting !
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Do you plan MDIGadget() to Linux and MacOs ?

Post by Foz »

Well, I've brushed off the dust, and now... well, it simply doesn't work.

Whether it's a change in PB or GTK I don't know, and I can't go back due to earlier versions of the IDE causing a segmentation fault in Ubuntu 9.10.

The idea behind it was the main form is created and then the WindowID is then passed in to the dll which would then use that WindowID to assign it's gadgets to.
Events were then passed through from the main exe into the dll to be processed, and then when the close is signalled from the dll, it would then release the gadgets.

Very cludgy and hacky.

I tried it in windows and it... mostly works, it just throws up an invalid memory access error when trying to close the dll down.
In Linux, it creates the gadgets (I get gadget id's) but I get warnings from GTK and no gadgets appear.

Here is the windows version. For the Linux version remember to change the dll to "app1.so"

main.pb

Code: Select all

EnableExplicit

;- Window Constants
;
Enumeration
  #Window_Main
EndEnumeration

;- Gadget Constants
;
Enumeration
  #UserArea
EndEnumeration

Procedure OpenMainWindow()
  If OpenWindow(#Window_Main, 0, 0, 640, 480, "Central",  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
    HyperLinkGadget(1, 20, 20, 80, 30, "Hello World", RGB(0, 0, 255))
  EndIf
EndProcedure

Procedure Main()
  OpenMainWindow()
  
  Protected dllLoaded.b = #False
  Protected dll.i
  
  Protected Event
  Protected WindowID
  Protected GadgetID
  Protected EventType
  
  Repeat ; Start of the event loop
    
    Event = WaitWindowEvent()
    WindowID = EventWindow()
    GadgetID = EventGadget()
    EventType = EventType()
    
    Select Event
      Case #PB_Event_Gadget
        If GadgetID > 0
          If Not dllLoaded
            dll = OpenLibrary(#PB_Any, "app1.dll")
            CallFunction(dll, "HelloWorld_New", WindowID(#Window_Main))
            
            dllLoaded = #True
          EndIf
        EndIf
        

        If dllLoaded
          Protected rv.l = CallFunction(dll, "HelloWorld", Event, WindowID, GadgetID, EventType)
          
          If Not rv
            CallFunction(dll, "HelloWorld_Release")
            CloseLibrary(dll)
            
            dllLoaded = #False
          EndIf
        EndIf
        
      Default
        
    EndSelect
    
  Until Event = #PB_Event_CloseWindow

EndProcedure

Main()

End
app1.pb

Code: Select all

; app1.dll

Global HelloWorld_btnHelloWorld
Global HelloWorld_btnQuit

ProcedureDLL.l HelloWorld_New(pGadgetArea)
  UseGadgetList(pGadgetArea)
  HelloWorld_btnHelloWorld = ButtonGadget(#PB_Any, 170, 60, 80, 40, "Hello World")
  HelloWorld_btnQuit = ButtonGadget(#PB_Any, 120, 10, 80, 30, "Quit")
EndProcedure

ProcedureDLL HelloWorld_Release()
  FreeGadget(HelloWorld_btnHelloWorld)
  FreeGadget(HelloWorld_btnQuit)
EndProcedure

ProcedureDLL.b HelloWorld(Event, WindowID, GadgetID, EventType)
  If Event = #PB_Event_Gadget
    Select GadgetID
      Case HelloWorld_btnHelloWorld
        MessageRequester("Test", "Hello World", #PB_MessageRequester_Ok)
      Case HelloWorld_btnQuit
        ProcedureReturn #False
    EndSelect
  EndIf
  
  ProcedureReturn #True
EndProcedure
Post Reply