RibbonGadget, but need some help

Just starting out? Need help? Post your questions and find answers here.
User avatar
Jac de Lad
Enthusiast
Enthusiast
Posts: 106
Joined: Wed Jul 15, 2020 7:10 am
Contact:

RibbonGadget, but need some help

Post 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.
User avatar
Bisonte
Addict
Addict
Posts: 1232
Joined: Tue Oct 09, 2007 2:15 am

Re: RibbonGadget, but need some help

Post 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.
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
Jac de Lad
Enthusiast
Enthusiast
Posts: 106
Joined: Wed Jul 15, 2020 7:10 am
Contact:

Re: RibbonGadget, but need some help

Post 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.
infratec
Always Here
Always Here
Posts: 6869
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: RibbonGadget, but need some help

Post 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()
Last edited by infratec on Sun Sep 13, 2020 5:12 pm, edited 1 time in total.
User avatar
Jac de Lad
Enthusiast
Enthusiast
Posts: 106
Joined: Wed Jul 15, 2020 7:10 am
Contact:

Re: RibbonGadget, but need some help

Post by Jac de Lad »

Thanks, I'll test that. It didn't come to my mind to just define them in the Declare section.
User avatar
Jac de Lad
Enthusiast
Enthusiast
Posts: 106
Joined: Wed Jul 15, 2020 7:10 am
Contact:

Re: RibbonGadget, but need some help

Post by Jac de Lad »

Works fine that way, thanks, now I know how to use it.
User avatar
Jac de Lad
Enthusiast
Enthusiast
Posts: 106
Joined: Wed Jul 15, 2020 7:10 am
Contact:

Re: RibbonGadget, but need some help

Post 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?
infratec
Always Here
Always Here
Posts: 6869
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: RibbonGadget, but need some help

Post by infratec »

Code: Select all

 BindEvent(#PB_Event_SizeWindow, @SizeWindowHandler())
User avatar
Jac de Lad
Enthusiast
Enthusiast
Posts: 106
Joined: Wed Jul 15, 2020 7:10 am
Contact:

Re: RibbonGadget, but need some help

Post by Jac de Lad »

Yes, but what if the programmer wants to use it too?
infratec
Always Here
Always Here
Posts: 6869
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: RibbonGadget, but need some help

Post 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.
User avatar
Jac de Lad
Enthusiast
Enthusiast
Posts: 106
Joined: Wed Jul 15, 2020 7:10 am
Contact:

Re: RibbonGadget, but need some help

Post by Jac de Lad »

Oh very great, thanks. That'll help alot.
User avatar
Jac de Lad
Enthusiast
Enthusiast
Posts: 106
Joined: Wed Jul 15, 2020 7:10 am
Contact:

Re: RibbonGadget, but need some help

Post by Jac de Lad »

How do I get systemcolors on Linux and Mac OS similar to windows, e.g. GetSysColor_(COLOR_BTNFACE)?
User avatar
jacdelad
Addict
Addict
Posts: 1475
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: RibbonGadget, but need some help

Post 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.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Post Reply