|
Post by pierre on Dec 6, 2020 9:10:19 GMT -5
I would like to change the text font of a menu, just in order to make it a little bigger.
Unfortunately, that is not possible. Menu bars and window title bars recieve automatically the LB default text font and cannot be changed.
This problem is perhaps related to a question already raised here on the forum about LB5 alpha's new grid control: A grid control seems to behave like a sub-window, where the content of the grid follows the text font defined for its main window, but the column names, representing apparently the grid's virtual 'title bar', remain unchanged.
Is there a workaround for this problem ?
pierre
|
|
|
Post by Brandon Parker on Dec 6, 2020 22:30:04 GMT -5
If you want to control the size of a menu's font then you will have to go through the process of creating and managing an owner-drawn menu using the Windows API in LB 4.xxx Creating Owner-Drawn Menu Items{:0) Brandon Parker
|
|
|
Post by pierre on Dec 7, 2020 7:08:13 GMT -5
Thank you Brandon. That doesn't seem to be as easy as I had wanted.... I already looked up all the menu manipulations by API in Alyce Watson's great book 'APIs for Liberty BASIC', nothing there about menu text fonts......but in any case, it was a good place to start.
Now I'll have to dig in the Microsoft Windows documentation.....
A simpler solution (for me) would have been to change just the LB's default text font, but I think that will be quite impossible.... Thanks for the help. pierre
|
|
|
Post by alincon on Dec 7, 2020 12:08:10 GMT -5
I use all Caps for the top menu, lower case for the other menus. r.m.
|
|
|
Post by pierre on Dec 10, 2020 17:21:44 GMT -5
I looked up Microsoft's documentation on 'ownerdrawn menus'. Unfortunately, I have to recognize that this is far beyond me...... I'll stick to Alincon's solution and use capitals for the menu text
pierre
|
|
|
Post by Rod on Dec 11, 2020 6:32:19 GMT -5
I might be wrong but the reason your finding this difficult is that you are going against the design criteria of Windows. The text that you are trying to amend is using the Windows default font, not any font setting within Liberty BASIC. It can change the editor font and the printer font but it adopts the default Windows font for controls and windows.
Yes we can amend the font in controls we create in our windows but the menu and the title seem to adopt the Windows default font.
This is the design issue, Windows is designed to allow the USER to choose the preferred display font, style and size. Programs should adopt that and that is what Liberty does.
You can change the default font but few users would thank you for messing up their display.
An alternative is to go graphical and have whatever fancy text color and style you like but draw it. You can mimic most buttons and controls fairly easily.
But Alinco's suggestion is by far the simplest fix.
|
|
|
Post by pierre on Dec 11, 2020 8:06:57 GMT -5
Thank you, Rod.
I understand what you mean. The fact of the matter is, I didn't want anything fancy with special characters, colors and so on. My only concern was to make the menu text a little bit more legible, because I find the Windows default font too small for my old eyes.
In Microsoft Windows' display settings, the user can adjust the size of the default text font according to his own preferences. This automatically adjusts the default font for Excel, Word etc. but it doesn't seem to change the default font in Liberty BASIC.
It is obvious that this would have consequences for the original design of title & menu bars, so it is not a critique, I just wanted to know if any change was possible.
My understanding is that the new grid control in LB5 alpha is presenting the same issue as far as the column names are concerned. That is why I repeated the same question in the LB5 section, what might be redundant, but I prefer to put every question in the right place.
pierre
|
|
|
Post by Carl Gundel on Dec 11, 2020 8:54:41 GMT -5
I should be able to address these concerns with LB5, but I don't think there will be another LB4 release.
|
|
|
Post by pierre on Dec 11, 2020 10:08:50 GMT -5
Hello Carl.
No problem, I accept LB4 'as it is'. If a change could be made in LB5, that would be great ! Thank you for all your efforts !
pierre
|
|
|
Post by Gordon Rahman on Dec 11, 2020 11:12:48 GMT -5
Hello Pierre, Have you tried an exclusive caption? We use exclusive captions here at our Liberty BASIC Workshop. We're making a game whereby you should not be able to move the screens. The different '(game scenes)' are on top of each other. First a popup window and than on top of that the graphicbox with an own design CAPTION in the original Windows look and feeling.
Gordon
|
|
|
Post by pierre on Dec 11, 2020 13:38:36 GMT -5
Hello Pierre, Have you tried an exclusive caption? We use exclusive captions here at our Liberty BASIC Workshop. We're making a game whereby you should not be able to move the screens. The different '(game scenes)' are on top of each other. First a popup window and than on top of that the graphicbox with an own design CAPTION in the original Windows look and feeling. Gordon No, I haven't. I humbly recognize that I don't really know how to do that ... I mainly use graphic windows to take advantage of the RGB colors and get rid of the basic 16 colors system. Then I put textboxes and comboboxes for data input (I do some very basic database programming). The truth is that I never went further into the graphic world.... I'll try to look up some of your posts. There must be something on this forum about your workshop project if I remember well. pierre
|
|
|
Post by tsh73 on Dec 11, 2020 14:09:17 GMT -5
I happen to have code that imitates menu (popup menu) with monospaced font It is a list box actually, and it supports moving by items with keyboard, selecting with Enter and closing with ESC. So I just went and added ability to use big font (set courier_new 20 bold) See if it could be useful for you.
' 'Nested popup demo 'tsh73 July 2012 ' 'v04 - looks ready 'v05- dec 2020 - means to increase font nomainwin POPUPfont$="courier_new 10" 'monospaced font POPUPfont$="courier_new 20 bold" gosub [getSlack]
WindowWidth = 400 WindowHeight = 300 UpperLeftX = (DisplayWidth - WindowWidth)/2 UpperLeftY = (DisplayHeight - WindowHeight)/2
button #main.btn1, "do stuff", [btn1Clicked], UL, 10, 220 open "test popup" for window as #main #main "trapclose [quit]"
menu$ = ""_ +"File/New|Open|Save|Save As|-|Exit" _ +"\Edit/Undo|Redo|-|Cut|Copy|Paste|Delete|-|Select All" _ +"\Help/Contents|-Disabled item|-|About" _ +"\-" _ +"\Quit"
#main.btn1 "!setfocus" wait
[quit] close #main end
[btn1Clicked] 'notice "Boo!" gosub [popup1] notice "Got: >";POPUPret$;"<" wait
[popup1] ' popup window ----------------------- POPUPret$="" nPopup = countWords(menu$, "\") dim popup$(nPopup) dim subMenu$(nPopup) for i = 1 to nPopup popup$(i) = word$(word$(menu$,i,"\"),1,"/") subMenu$(i)=word$(word$(menu$,i,"\"),2,"/") next
'for "font courier_new 10" 'POPUPcharWidth=8 'POPUPcharHeight=16
maxlen = 0 for i = 1 to nPopup if maxlen<len(popup$(i)) then maxlen=len(popup$(i)) next 'separator item for i = 1 to nPopup1 if popup$(i)="-" then popup$(i)=string$("-",maxlen) next listWidth=(1+maxlen)*POPUPcharWidth + 25 'scroll bar listHeight = nPopup*POPUPcharHeight+POPUPcharHeight/2
WindowWidth = listWidth + slackX WindowHeight = listHeight + slackY
UpperLeftX =1 UpperLeftY =1 listbox #POPUP1.listbox1, popup$(, [POPUP1listbox1DoubleClick], 0, 0, listWidth, listHeight BUTTON #POPUP1.default, "offscrenSelect", [POPUP1listbox1DoubleClick], UL, -100, -100 'offscren! open "Popup" for dialog_modal as #POPUP1 print #POPUP1, "trapclose [POPUP1quit]"
#POPUP1.listbox1, "font ";POPUPfont$ #POPUP1.listbox1 "selectindex 1" wait
[POPUP1quit] 'ESC pressed POPUPret$="" goto [POPUP1return]
[POPUP1listbox1DoubleClick] #POPUP1.listbox1, "selection? sel$" 'say disabled start from "-" if left$(sel$,1)="-" then wait 'disabled menu item, also separator #POPUP1.listbox1, "selectionindex? popupIndex1" POPUPret$ = popup$(popupIndex1) subMenu$ = subMenu$(popupIndex1) if subMenu$ = "" then goto [POPUP1return] 'no submenu 'else gosub [popup2] if retOk then goto [POPUP1return] end if 'else wait
[POPUP1return] close #POPUP1 return '// end of POPUP1 window -----------------------
[popup2] ' nested POPUP2 window ----------------------- nPopup2 = countWords(subMenu$, "|") dim popup2$(nPopup2) for i = 1 to nPopup2 popup2$(i) = word$(subMenu$,i,"|") next
maxlen2 = 0 for i = 1 to nPopup2 if maxlen2<len(popup2$(i)) then maxlen2=len(popup2$(i)) next 'separator item for i = 1 to nPopup2 if popup2$(i)="-" then popup2$(i)=string$("-",maxlen2) next
listWidth2 = (1+maxlen2)*POPUPcharWidth + 25 'scroll bar listHeight2 = nPopup2*POPUPcharHeight+POPUPcharHeight/2
WindowWidth = listWidth2 + slackX WindowHeight = listHeight2 + slackY
UpperLeftX =1 UpperLeftY =1 UpperLeftY = popupIndex1*POPUPcharHeight listbox #POPUP2.listbox1, popup2$(, [POPUP2listbox1DoubleClick], 0, 0, listWidth2, listHeight2 BUTTON #POPUP2.default, "offscrenSelect", [POPUP2listbox1DoubleClick], UL, -100, -100 'offscren! open POPUPret$ for dialog_modal as #POPUP2 print #POPUP2, "trapclose [POPUP2quit]"
#POPUP2.listbox1, "font ";POPUPfont$ #POPUP2.listbox1 "selectindex 1" wait
[POPUP2quit] 'ESC pressed retOk=0 goto [POPUP2return]
[POPUP2listbox1DoubleClick] #POPUP2.listbox1, "selection? sel$" 'say disabled start from "-" if left$(sel$,1)="-" then wait 'disabled menu item, also separator POPUPret$ = POPUPret$ +"|"+ sel$ retOk=1 goto [POPUP2return]
[POPUP2return] close #POPUP2 return '// end if nested POPUP2 window -----------------------
'======================================== 'aux functions and subs [getSlack] WindowWidth=200:WindowHeight=200 open "" for graphics_nsb as #t:#t,"home;posxy x y" 'get font dimensions #t,"font ";POPUPfont$ #t, "\" #t, "posxy dummy y1" POPUPcharHeight = y1 - y t$="0" #t, "stringwidth? t$ POPUPcharWidth" ' close#t slackX=WindowWidth-2*x:slackY=WindowHeight-2*y return
function string$(item$, count) for i = 1 to count string$ = string$+item$ next end function
function countWords(objStr$, delim$) token$ = "?" while token$ <> "" countWords = countWords + 1 token$ = word$(objStr$, countWords, delim$) wend countWords = countWords - 1 end function
|
|
|
Post by pierre on Dec 11, 2020 14:43:31 GMT -5
Oh, thank you, tsh73. That looks promising !
pierre
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Dec 13, 2020 5:05:07 GMT -5
|
|
|
Post by pierre on Dec 13, 2020 8:37:51 GMT -5
Yes, thank you, Tasp. The possibility to add images to menu items is indeed interesting but then I'll have to design my own bitmaps what (for me) will be another problem. According to information received from tsh73, something would be possible with pop-ups and listboxes. I took also a look at Chris's post about disabling menu controls. The truth is that all these articles, which are delving deep into the management of menu controls, never give any mention of a possible change in the menu text font. I think there is a good reason for this: Because apparently, this is impossible to achieve in LB....
Even if we might succeed in defining a whole owner drawn menu by API's we would always bump into the same problem: in LB, the default text font and the size of title bars and menu bars cannot be changed. We can change the font of a window or a control, but we cannot change the size of a window's title bar or menu bar.
So my understanding is that any user defined menu font, even if it were possible to realize via API, would crash against the limited height of the main menu bar.
However, Carl's answer may give us some hope: he could consider adressing this problem in LB5, so let us wait and see. In any case thanks for your help. pierre
|
|