It is currently Wed Dec 11, 2019 7:27 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Editor box heights wrong
PostPosted: Tue Feb 14, 2017 2:43 pm 
Offline
User
User

Joined: Mon Jul 18, 2016 6:43 pm
Posts: 35
On my LinuxMint 17.3 I noticed that the form designer defaulted to a height of 20 for editor boxes. When I actually run the code, the heights are more than double what they are in the designer. I can't seem to shrink them any. Code below creates three editor boxes of different heights but they are the same visual height when run. It seems there is some minimum height enforced behind the scenes.
Code:
Global Window_0 = OpenWindow(#PB_Any, 0, 0, 150, 150, "Window_0", #PB_Window_SystemMenu)
Global Editor_0 = EditorGadget(#PB_Any, 5, 0, 140, 10)
Global Editor_1 = EditorGadget(#PB_Any, 5, 50, 140, 20)
Global Editor_2 = EditorGadget(#PB_Any, 5, 100, 140, 30)
Repeat
    Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
CloseWindow(Window_0)


Top
 Profile  
Reply with quote  
 Post subject: Re: Editor box heights wrong
PostPosted: Mon Oct 30, 2017 4:25 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jun 26, 2014 9:17 am
Posts: 308
Location: Germany
With a slight delay ...
Since you didn't specify anything, I assume that you are working under gtk3.

It's a general problem under gtk3 that EditorGadgets cannot fall below a certain height.
Since it is of general interest, here is a possibility to patch the min. possible height under gtk3:
Code:
ImportC ""
   gtk_scrolled_window_set_min_content_height(*scrolled_window.GtkScrolledWindow, height)
EndImport


; Object constants
#Win_Main = 0

#Edt1    = 0
#Edt2    = 1


#ScrolledWindowChildMinHeight= 40

Global.i gEvent, gQuit
Global.s S1= "This is a multiline text in the EditorGadget which demonstrates the minimal EditorGadget height on gtk3 on your current system."
Global.s S2= "This is a multiline text in the EditorGadget which demonstrates under gtk3 how the minimal EditorGadget height can be patched. I don't know if it works in gtk3.20+! "

Procedure ScrolledWindow_SetMinHeight(Gadget, Height)
   Protected *ScrolledWindow.GtkScrolledWindow= gtk_widget_get_parent_(GadgetID(Gadget))
   gtk_scrolled_window_set_min_content_height(*ScrolledWindow, Height)
EndProcedure

If OpenWindow(#Win_Main, 0, 0, 600, 200, "Editor - reduce min height on gtk3", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   EditorGadget (#Edt1,   5,   5, 290,  40, #PB_Editor_WordWrap)
   AddGadgetItem(#Edt1,  -1, S1)
   EditorGadget (#Edt2, 305,   5, 290,  40, #PB_Editor_WordWrap)
   AddGadgetItem(#Edt2,  -1, S2)
   
   ScrolledWindow_SetMinHeight(#Edt2, #ScrolledWindowChildMinHeight)
   
   Repeat
      gEvent= WaitWindowEvent()
      
      Select gEvent
         Case #PB_Event_CloseWindow
            gQuit= #True
            
      EndSelect
      
   Until gQuit
EndIf
If there are no side effects in the future, the team could set it generally when creating an EditorGadget with a more practical value than the Default-setting!
Regards, Charly

ps:
Maybe it works with ListIconGadget/ListViewGadget/... too. I'll give it a shot.

ps2:
Confirmed! This patch works for ListIconGadget/ListViewGadget/... (All Gadgets which are placed by the gtk in a GtkScrolledWindow) too.
If a too large ScrollBarSlider should be a problem then, I would have a solution - please contact me.
Changed procedure name to a more common term, since it can be used for several gadget types.

_________________
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de


Top
 Profile  
Reply with quote  
 Post subject: Re: Editor box heights wrong
PostPosted: Tue Oct 31, 2017 7:42 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jun 26, 2014 9:17 am
Posts: 308
Location: Germany
The pimped-up version :wink: :

Unfortunately, in order to reach even smaller heights like in the first example, the minimum slider length must also be reduced.
But the extension for adjusting the slider length in gtk3 works only up to gtk3.16 or gtk3.18, because the CSS calling conventions have changed again!
My version for gtk3.20+ is currently working unfortunately only with side effects and is still held back.
This version should be reducable to a 1 line height ...
Code:
;Could do the job on gtk3 up to 3.16 or 3.18. Then the CSS method has changed again :-(

ImportC ""
   gtk_css_provider_load_from_data(*css_provider, data_.p-utf8, length, *error.GError)
   gtk_css_provider_new()
   gtk_style_context_add_provider_for_screen(*screen.GdkScreen, *provider, priority)
   
   gtk_scrolled_window_set_min_content_height(*scrolled_window.GtkScrolledWindow, height)
EndImport

#GTK_STYLE_PROVIDER_PRIORITY_APPLICATION = 600


; Object constants
#Win_Main = 0

#Edt1     = 0
#Edt2     = 1


#ScrolledWindowChildMinHeight= 20
#ScrollBarSliderMinLength    = 15


Global.i gEvent, gQuit
Global.s S1= "This is a multiline text in the EditorGadget which demonstrates the minimal EditorGadget height on gtk3 on your current system."
Global.s S2= "This is a multiline text in the EditorGadget which demonstrates under gtk3 how the minimal EditorGadget height can be patched. It won't work on Gtk3.18/3.20+! "

Procedure ScrollBar_SetSliderMinLength(MinLength.l); For Gtk3 -> Gtk3.16 or 3.18
   Protected   *provider        = gtk_css_provider_new()
   Protected   *screen.GdkScreen= gdk_display_get_default_screen_(gdk_display_get_default_())
   Protected.s Css
   
   Css= "GtkScrollbar {" + #LF$ +
        "-GtkScrollbar-min-slider-length: "+ Str(MinLength) +"px;" + #LF$ +
        "}"
   
   gtk_css_provider_load_from_data(*provider, Css, -1, 0)
   gtk_style_context_add_provider_for_screen(*screen, *provider, #GTK_STYLE_PROVIDER_PRIORITY_APPLICATION)
   g_object_unref_(*provider)
EndProcedure

Procedure ScrolledWindow_SetMinHeight(Gadget, Height)
   Protected *ScrolledWindow.GtkScrolledWindow= gtk_widget_get_parent_(GadgetID(Gadget))
   gtk_scrolled_window_set_min_content_height(*ScrolledWindow, Height)
EndProcedure

If OpenWindow(#Win_Main, 0, 0, 600, 200, "Editor - reduce min height on gtk3", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   
   ;General setting, execute only once in advance ...
   ScrollBar_SetSliderMinLength(#ScrollBarSliderMinLength)
   
   EditorGadget (#Edt1,   5,   5, 290,  40, #PB_Editor_WordWrap)
   AddGadgetItem(#Edt1,  -1, S1)
   EditorGadget (#Edt2, 305,   5, 290,  20, #PB_Editor_WordWrap)
   AddGadgetItem(#Edt2,  -1, S2)
   
   ScrolledWindow_SetMinHeight(#Edt2, #ScrolledWindowChildMinHeight)
   
   Repeat
      gEvent= WaitWindowEvent()
      
      Select gEvent
         Case #PB_Event_CloseWindow
            gQuit= #True
            
      EndSelect
      
   Until gQuit
EndIf
Regards, Charly

_________________
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye