Page 1 of 1
Position of the toolbar
Posted: Fri Nov 11, 2011 6:14 pm
by Rossine
Hello,
How to know the position of the toolbar ?
Example: msgstop( MainForm:Toolbar1:position ) 0=Left / 1=Right / 2=Top / 3=Bottom
Regards,
Rossine.
Re: Position of the toolbar
Posted: Fri Nov 11, 2011 7:38 pm
by l3whmg
Hi Rossine,
at this moment, there isn't this ability. With HMG3, only at bottom or top you can "put"
But, when I rewrited source code I have introduced TBarPlace() method to positioning ToolBar.
Code: Select all
....:ToolBar:TBarPlace( nPosition )
Where nPoistion can be: Qt_LeftToolBarArea, Qt_RightToolBarArea, Qt_TopToolBarArea, Qt_BottomToolBarArea
Do you think it's important to know where is? If yes, ASAP, I open the ability to know position.
Remember: you also has this properties:
....:ToolBar:AllowedAreas[:= nValue] to know or to set where can be placed (see hbqtgui.ch related with Qt_AllToolBarAreas)
....:ToolBar:MoveAble[:= lValue] to know or to set if moveable
Cheers
Re: Position of the toolbar
Posted: Sat Nov 12, 2011 1:36 pm
by Rossine
Hi Luigi,
Do you think it's important to know where is? If yes, ASAP, I open the ability to know position.
Yes, it would be interesting
I'm working on a program where I have an image that is resized with the window and when I change the toolbar place the image is not resized. By this I thought to know this property. I know the correct thing to know the free area of the window ({top, left, width, height}) and resize the image in this area. Is that possible?
Below I leave an example: Put it in the folder: "\hmg.4\svn\samples\image"
Code: Select all
#translate CRLF => HB_OsNewLine() // <- It would be possible to include this in "hmg.ch" or another. "Ch" ?
#include "hmg.ch"
#include "hbqtgui.ch"
MEMVAR MainForm
FUNCTION Main
PUBLIC MainForm
HbQt_ErrorSys()
WITH OBJECT MainForm := MAINWINDOW():New( "MainForm" )
:Row := 30
:Col := 10
:Width := 800
:Height := 700
:Title := "Show bitmap usage"
:OnInit := { || ( MainForm:Center(), RESIZE_IMG() ) }
:Onsize := { || RESIZE_IMG() }
WITH OBJECT MAINMENU():New( "mainmenu" )
WITH OBJECT MENUITEM():New()
:Caption := "&show dim."
:OnClick := {|| ShowDim() }
END WITH
END WITH // end PopUp
WITH OBJECT Bitmap():New( "image1" )
:Row := 20
:Col := 10
:Width := 780
:Height := 585
:Picture := 'sea.jpg' // ':SEA'
:BackColor := { 0 , 255 , 0 }
:Alignment := LBL_CENTER
:VAlignment := LBL_VCENTER
:Stretch := .T.
END WITH
MainForm:Image1:ScaledToWidth := .T.
MainForm:Image1:ScaledToHeight := .T.
MainForm:Image1:stretch := .T.
MainForm:Image1:row := 0
MainForm:Image1:col := 0
MainForm:Image1:Smoothing := Qt_SmoothTransformation
MainForm:Image1:AspectRatio := Qt_IgnoreAspectRatio
ON KEY ALT+A OF MainForm ACTION ( eval( MainForm:oToolBar:oButton1:OnClick() ), MainForm.setfocus )
ON KEY ALT+B OF MainForm ACTION ( eval( MainForm:oToolBar:oButton2:OnClick() ), MainForm.setfocus )
ON KEY ALT+C OF MainForm ACTION ( eval( MainForm:oToolBar:oButton3:OnClick() ), MainForm.setfocus )
DEFINE TOOLBAR oToolBar IMAGESIZE 80, 80 MOVEABLE .T. RIGHTTEXT TBARPLACE Qt_LeftToolBarArea
TOOLBUTTON oButton1 ;
Caption 'new' + CRLF + "ALT+A" ;
picture 'hmg.png' ;
ACTION MsgInfo( 'New!' ) ;
tooltip 'tooltip new 2'
TOOLBUTTON oButton2 ;
Caption 'open' + CRLF + "ALT+B" ;
picture 'hmg.png' ;
ACTION MsgInfo( 'Open!' ) ; // HMGAPP():ShowObjectsTree() ;
tooltip 'tooltip open 2'
TOOLBUTTON oButton3 ;
Caption 'save' + CRLF + "ALT+C" ;
picture 'hmg.png' ;
ACTION MsgInfo( 'save!' ) ;
tooltip 'tooltip save 2'
END TOOLBAR
END WITH
MainForm:Activate()
RETURN NIL
/*..............................................................................
ShowDim
..............................................................................*/
STATIC FUNCTION ShowDim()
MsgStop( " W= " + hb_ValToExp( MainForm:Image1:ImageWidth() ) + " x H= " + hb_ValToExp( MainForm:Image1:ImageHeight() ) )
RETURN NIL
**************************
static function RESIZE_IMG
**************************
MainForm:Image1:Width := MainForm:Width
MainForm:Image1:Height := MainForm:Height
MainForm:Image1:refresh()
return NIL
Free area = area marked red
It is possible to know what the dimensions of this area and not the window ?
Best Regards,
Rossine.
Re: Position of the toolbar
Posted: Sat Nov 12, 2011 6:06 pm
by l3whmg
Hi Rossine
Rossine wrote:It is possible to know what the dimensions of this area and not the window ?
In this moment I don't have a qualified answer because this is the "centralwidget area". I must investigate with QT. Your question sounds like Ricci's question: you can try this MainForm:QtParent:Width() and MainForm:QtParent:Height(). But this dim. are stable after all widgets are painted. To know when all events are done (at this moment) it's impossible because we need to use singleshot technique...and AFAIK not possible with current HbQt.
Luigi
Re: Position of the toolbar
Posted: Sun Nov 13, 2011 11:14 am
by l3whmg
Hi Rossine.
I try to find a solution about current toolbar position....but without a good answer. The only way is "oQtObjectToolbar:pos()", but this is a spatial position, not as Top, Bottom, Right, Left.
On the other hand, I can't store its value because it can be moveable and I don't found a related function.
I read about Qmainwindow:getlocation(.....) but I don't found a good Qt documentation and I don't understand if is a (real) supported function.
Cheers