Page 1 of 1

RibbonGadget, but need some help

Posted: Sun Sep 13, 2020 11:27 am
by Jac de Lad
Hello,
as I wrote some time ago I just started with PureBasic. I hoped for a RibbonGadget, but it's not natively implemented and all efforts creating this have stopped due to legal issues or something else (at least as far as I know). So I took the wheel and started it yesterday. I think my work is already doing great, however, I need some help. This is also my first module, so I need to understand some things that are currently unclear to me. I wanted to seek help in the German forum but again I cannot contact an admin and don't get any email for account reset. My english account works, so here I am.
Image
Here are my questions:
1. Can I use "UseModule" for always just one module at a given time?
2. How can I use constants effectively. I now declare them in the DeclareModule-section and the module itself. This seems not as intended. same question with structures.
3. I want a function "CheckRibbonActivity()" to return the ribbon-item-id and activity. I now use said function just for checking if something has happened at all and "RibbonID()" plus "RibbonEvent()" for further information. Can I pass a variable that is filled with that data, like (and certainly wrong):

Code: Select all

Structure RibbonEvent
  event.i
  id.i
EndStructure
Global RE.RibbonEvent

;Module...
procedure CheckRibbonActivity(event,id)
PeekL(event,#Ribbon_Event_Something)
PeekL(id,my_id)
;...Code
;EndModule...

;Creation etc.
CheckRibbonActivity(@RE\event,@RE\id);or CheckRibbonActivity(@RE)
;More Code...

4. I know how to create threads and stuff. At the moment the function "CheckRibbonActivity()" is called after "WaitWindowEvent()". I know I can remap the processing to my own function (via "SetWindowCallback(...)") and then return to normal. But what if someone wants to use it in the porgram too? Do multiple calls of the function stack and process all functions until the original windowproc is called?
5. Can I make my module publicly accessible (if there is demand) without releasing the source code or creating a DLL? XProfan is able to precompile the code into a precompiled include file that is not readable, but can be included like a normal inc.

Re: RibbonGadget, but need some help

Posted: Sun Sep 13, 2020 11:33 am
by Bisonte
1. If you have e.g. two modules with the same function names.... don't use "UseModule".... use it direct "MyModule::Function()"

2. You have only declare the "public" stuff in the declaremodule section. You don't need to declare the Constants and other declare twice....

3. I think you are using gadgets to build this ribbon.... Is BindGadgetEvent an option ?

4. See 3.

5. No ;) modules with the source only.

Re: RibbonGadget, but need some help

Posted: Sun Sep 13, 2020 11:47 am
by Jac de Lad
Hello Bisonte,
thanks for the answers.

1. It's a hypothetical question.
2. So I always have to declare my constants in the Declare module section AND the module itself if I want to use them in the main program and the module.
3. Nope, hand drawn on a canvas. This way I have full control over behaviour and drawing, colours etc. For now Buttons, Checkboxes, PushButtons work. Also hovering, changing tabs, custom color (not just blue), multiple ribbons in multiple windows. The control is only drawn when something changes, totally flicker fee. I can upload a demo if you want to see it live. But it's still in earliest stage.
4. See 3.
5. Ah crap. I'm not sure if I want to release the source code, but we'll see. There will be a solution.

I also don't plan to clone the ms ribbons but give it a touch of a unique look. That's why some things look a bit different, plus like I wrote above, it's still in its earliest stage.

Re: RibbonGadget, but need some help

Posted: Sun Sep 13, 2020 1:37 pm
by infratec
Hm... simple test:

Code: Select all

DeclareModule Test
  #Test = 666
  
  Declare.i Test()
    
EndDeclareModule

Module Test
  
  Procedure.i Test()
    Debug #Test
  EndProcedure
  
EndModule


#Test = 999

Debug Test::#Test

Test::Test()

Re: RibbonGadget, but need some help

Posted: Sun Sep 13, 2020 1:43 pm
by Jac de Lad
Thanks, I'll test that. It didn't come to my mind to just define them in the Declare section.

Re: RibbonGadget, but need some help

Posted: Sun Sep 13, 2020 6:31 pm
by Jac de Lad
Works fine that way, thanks, now I know how to use it.

Re: RibbonGadget, but need some help

Posted: Tue Sep 15, 2020 7:42 pm
by Jac de Lad
Just to mention: you can now deactivate elements, change the colour on the fly and the renderer is optimized.

I need a push into right direction regarding message processing and such: of course the ribbon needs to be repainted when the window is resized. Thus is something that is not actively caused by the programming, like adding an element or changing the colour. So I'm thinking about bindgadgetevent() for my canvas. However, there may be too many messages incoming, so when one is processed and the gadget is repainted there's already another coming, repainting and interfering with the first one which is still running. Is there an easy and safe way to process that?
Can I get information like window resizing without redirecting the windowproc or without having the programmer add much code?

Re: RibbonGadget, but need some help

Posted: Tue Sep 15, 2020 7:50 pm
by infratec

Code: Select all

 BindEvent(#PB_Event_SizeWindow, @SizeWindowHandler())

Re: RibbonGadget, but need some help

Posted: Tue Sep 15, 2020 7:51 pm
by Jac de Lad
Yes, but what if the programmer wants to use it too?

Re: RibbonGadget, but need some help

Posted: Tue Sep 15, 2020 8:19 pm
by infratec
I don't think that this is a problem:

Code: Select all

Procedure Size1()
  Debug "Size1"
EndProcedure


Procedure Size2()
  Debug "Size2"
EndProcedure


If OpenWindow(0, 100, 200, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
  
  BindEvent(#PB_Event_SizeWindow, @Size1())
  BindEvent(#PB_Event_SizeWindow, @Size2())
  
  
  Repeat
    Event = WaitWindowEvent()

    If Event = #PB_Event_CloseWindow  ; If the user has pressed on the close button
      Quit = 1
    EndIf

  Until Quit = 1
  
EndIf
They are cascaded.

Re: RibbonGadget, but need some help

Posted: Tue Sep 15, 2020 8:20 pm
by Jac de Lad
Oh very great, thanks. That'll help alot.

Re: RibbonGadget, but need some help

Posted: Wed Sep 16, 2020 5:29 am
by Jac de Lad
How do I get systemcolors on Linux and Mac OS similar to windows, e.g. GetSysColor_(COLOR_BTNFACE)?

Re: RibbonGadget, but need some help

Posted: Tue Nov 28, 2023 7:15 pm
by jacdelad
So, I've changed a lot of things, didn't write a documentation and uploaded its current state to GitHub: https://github.com/jacdelad/RibbonGadget
I use this in two programs on a daily basis and completed all the features I need. No guarantee for anything. You just need the pbi-file, the demo, the code to create a DLL and all resources are included. The DLL is mainly aimed for XProfan which still uses ASCII, but this can be changed by changing one line. I don't know if I'll ever release some kind of official release, because I mainly add the stuff I need. Maybe it's useful for someone. And yes, it's surely full of bugs and oddities.