[DEVELOPMENT ENVIRONMENT]
* BUG: Remove old console search code. [GB.FORM] * NEW: MenuButton controls now automatically pop up when one of their sibling is already opened. [GB.FORM.EDITOR] * NEW: TextEditor: The cursor position label background is now semi-transparent. [GB.GTK] * BUG: Mouse.ScreenX and Mouse.ScreenY now always query the pointer. * NEW: Menu.Close() is a new method that hides a popup menu from the screen. [GB.GTK3] * BUG: Mouse.ScreenX and Mouse.ScreenY now always query the pointer. * NEW: Menu.Close() is a new method that hides a popup menu from the screen. [GB.QT4] * BUG: Mouse.ScreenX and Mouse.ScreenY now always query the pointer. * NEW: Menu.Close() is a new method that hides a popup menu from the screen. [GB.QT5] * BUG: Mouse.ScreenX and Mouse.ScreenY now always query the pointer. * NEW: Menu.Close() is a new method that hides a popup menu from the screen. git-svn-id: svn://localhost/gambas/trunk@7751 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
0b928f80ef
commit
5da7ed1c4e
@ -89,9 +89,9 @@ Private Sub UpdateTitle()
|
||||
|
||||
Dim sWhere As String
|
||||
|
||||
If $hCurrent Is FOutput Then
|
||||
sWhere = ("Console")
|
||||
Else If $hCurrent Then
|
||||
' If $hCurrent Is FOutput Then
|
||||
' sWhere = ("Console")
|
||||
If $hCurrent Then
|
||||
sWhere = $hCurrent.Title
|
||||
Else
|
||||
sWhere = ("Project")
|
||||
@ -114,14 +114,14 @@ Public Sub Update(Optional bForce As Boolean)
|
||||
If hWindow = Me Then Return
|
||||
$hCurrent = hWindow
|
||||
|
||||
If $hCurrent Is FOutput Then
|
||||
radCurrentProcedure.Enabled = False
|
||||
radCurrentFile.Enabled = True
|
||||
radCurrentFile.Value = True
|
||||
btnReplace.Enabled = False
|
||||
btnReplaceAll.Enabled = False
|
||||
cmbReplace.Enabled = False
|
||||
Else
|
||||
' If $hCurrent Is FOutput Then
|
||||
' radCurrentProcedure.Enabled = False
|
||||
' radCurrentFile.Enabled = True
|
||||
' radCurrentFile.Value = True
|
||||
' btnReplace.Enabled = False
|
||||
' btnReplaceAll.Enabled = False
|
||||
' cmbReplace.Enabled = False
|
||||
' Else
|
||||
$hCurrent = Project.ActiveForm
|
||||
If $hCurrent Then
|
||||
If $hCurrent Is FEditor Or If $hCurrent Is FTextEditor Then
|
||||
@ -138,7 +138,7 @@ Public Sub Update(Optional bForce As Boolean)
|
||||
btnReplace.Enabled = True
|
||||
btnReplaceAll.Enabled = True
|
||||
cmbReplace.Enabled = True
|
||||
Endif
|
||||
'Endif
|
||||
|
||||
If radCurrentProcedure.Value And If Not radCurrentProcedure.Enabled Then
|
||||
radCurrentFile.Value = True
|
||||
@ -318,13 +318,13 @@ Private Sub GrepFile(hFile As Object, Optional sPath As String, Optional bUseRep
|
||||
hResult = New CFindResult
|
||||
|
||||
If hFile Then
|
||||
If hFile Is FOutput Then
|
||||
hResult.Path = ""
|
||||
hResult.File = "Console"
|
||||
Else
|
||||
' If hFile Is FOutput Then
|
||||
' hResult.Path = ""
|
||||
' hResult.File = "Console"
|
||||
' Else
|
||||
hResult.Path = sPath
|
||||
hResult.File = hFile.Name
|
||||
Endif
|
||||
'Endif
|
||||
Else
|
||||
hResult.Path = sPath
|
||||
hResult.File = If(Project.IsSourcePath(sPath), File.BaseName(sPath), File.Name(sPath))
|
||||
|
@ -2749,7 +2749,7 @@ Private Sub ShowPosition_Write(Value As Boolean)
|
||||
If $bShowPosition Then
|
||||
If Not $hLabel Then
|
||||
$hLabelFrame = New Panel(Me)
|
||||
$hLabelFrame.Background = $hStyles[Highlight.Background].Color
|
||||
$hLabelFrame.Background = Color.SetAlpha($hStyles[Highlight.Background].Color, 128)
|
||||
$hLabelFrame.Ignore = True
|
||||
$hLabel = New Label($hLabelFrame) ' TODO: NULL + gb.gtk => crash!
|
||||
$hLabel.AutoResize = True
|
||||
|
@ -2340,6 +2340,10 @@ Arrow_Click
|
||||
m
|
||||
|
||||
|
||||
WatchTimer_Timer
|
||||
m
|
||||
|
||||
|
||||
DrawingArea_GotFocus
|
||||
m
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 3.8.90
|
||||
Title=More controls for graphical components
|
||||
Startup=FTestDateChooser
|
||||
Startup=FTestMenuButton
|
||||
Version=3.8.90
|
||||
VersionFile=1
|
||||
Component=gb.image
|
||||
Component=gb.gui
|
||||
Component=gb.settings
|
||||
Authors="Benoît Minisini"
|
||||
Environment="GB_GUI=gb.qt4"
|
||||
Environment="GB_GUI=gb.gtk"
|
||||
TabSize=2
|
||||
Translate=1
|
||||
Language=en
|
||||
|
@ -41,6 +41,9 @@ Private $bArrow As Boolean
|
||||
Private $bAutoResize As Boolean
|
||||
Private $bMenuOnly As Boolean
|
||||
|
||||
Static Private $hCurrent As MenuButton
|
||||
Static Private $hCurrentMenu As Menu
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
'Dim hObs As Observer
|
||||
@ -141,17 +144,72 @@ Public Sub Button_Click()
|
||||
|
||||
End
|
||||
|
||||
Public Sub Arrow_Click()
|
||||
Public Sub WatchTimer_Timer()
|
||||
|
||||
Dim hMenuButton As MenuButton
|
||||
Dim X As Integer
|
||||
Dim Y As Integer
|
||||
|
||||
X = Mouse.ScreenX - Me.Parent.ScreenX
|
||||
Y = Mouse.ScreenY - Me.Parent.ScreenY
|
||||
|
||||
'Debug X;; Y
|
||||
|
||||
If X < 0 Or If Y < 0 Or If X >= Me.Parent.W Or If Y >= Me.Parent.H Then Return
|
||||
|
||||
Try hMenuButton = Me.Parent.FindChild(X, Y)
|
||||
If hMenuButton And If hMenuButton <> $hCurrent Then
|
||||
If Main.FindMenu(hMenuButton, hMenuButton.Menu) Then
|
||||
$hCurrentMenu.Close
|
||||
$hCurrent.Refresh
|
||||
$hCurrent = hMenuButton
|
||||
Endif
|
||||
Endif
|
||||
|
||||
End
|
||||
|
||||
Static Private Sub HandleMenu(hCurrent As MenuButton)
|
||||
|
||||
Dim hMenu As Menu
|
||||
Dim hWatch As Timer
|
||||
|
||||
hMenu = Main.FindMenu(Me, $sMenu)
|
||||
If hMenu Then
|
||||
hMenu.Popup(Me.ScreenX, Me.ScreenY + Me.H)
|
||||
Else
|
||||
hWatch = New Timer As "WatchTimer"
|
||||
hWatch.Delay = 50
|
||||
hWatch.Start
|
||||
|
||||
Do
|
||||
|
||||
hMenu = Main.FindMenu(hCurrent, hCurrent.Menu)
|
||||
|
||||
$hCurrent = hCurrent
|
||||
$hCurrentMenu = hMenu
|
||||
|
||||
hMenu.Popup(hCurrent.ScreenX, hCurrent.ScreenY + hCurrent.H)
|
||||
|
||||
If $hCurrent = hCurrent Then Break
|
||||
hCurrent = $hCurrent
|
||||
|
||||
Loop
|
||||
|
||||
$hCurrent.Refresh
|
||||
hWatch.Stop
|
||||
hWatch = Null
|
||||
$hCurrent = Null
|
||||
$hCurrentMenu = Null
|
||||
|
||||
End
|
||||
|
||||
|
||||
|
||||
Public Sub Arrow_Click()
|
||||
|
||||
If Not Main.FindMenu(Me, $sMenu) Then
|
||||
Raise Click
|
||||
Return
|
||||
Endif
|
||||
|
||||
HandleMenu(Me)
|
||||
|
||||
End
|
||||
|
||||
' Public Sub ShowMenu()
|
||||
@ -321,7 +379,12 @@ Public Sub DrawingArea_Draw()
|
||||
Dim bDrawArrow As Boolean
|
||||
|
||||
iFlag = Style.StateOf(Last)
|
||||
If $bInside Or If $bPressed Then iFlag = iFlag Or Draw.Hover
|
||||
|
||||
If $hCurrent Then
|
||||
If $hCurrent = Me Then iFlag = iFlag Or Draw.Hover
|
||||
Else
|
||||
If $bInside Then iFlag = iFlag Or Draw.Hover
|
||||
Endif
|
||||
'If $bInside And If Me.Enabled And If Not Me.Design Then iFlag += Draw.Hover
|
||||
'If Not Me.Enabled Then iFlag += Draw.Disabled
|
||||
'If $hDrawingArea.HasFocus Then iFlag += Draw.Focus
|
||||
|
2
comp/src/gb.form/.src/Test/FTestMenuButton.class
Normal file
2
comp/src/gb.form/.src/Test/FTestMenuButton.class
Normal file
@ -0,0 +1,2 @@
|
||||
' Gambas class file
|
||||
|
77
comp/src/gb.form/.src/Test/FTestMenuButton.form
Normal file
77
comp/src/gb.form/.src/Test/FTestMenuButton.form
Normal file
@ -0,0 +1,77 @@
|
||||
# Gambas Form File 3.0
|
||||
|
||||
{ Form Form
|
||||
MoveScaled(0,0,64,64)
|
||||
{ mnuProject Menu
|
||||
Text = ("Project")
|
||||
Visible = False
|
||||
{ Menu1 Menu
|
||||
Text = ("Menu1")
|
||||
}
|
||||
{ Menu2 Menu
|
||||
Text = ("Menu2")
|
||||
}
|
||||
{ Menu3 Menu
|
||||
Text = ("Menu3")
|
||||
}
|
||||
}
|
||||
{ mnuView Menu
|
||||
Text = ("View")
|
||||
Visible = False
|
||||
{ Menu4 Menu
|
||||
Text = ("Menu4")
|
||||
}
|
||||
{ Menu5 Menu
|
||||
Text = ("Menu5")
|
||||
}
|
||||
{ Menu6 Menu
|
||||
Text = ("Menu6")
|
||||
}
|
||||
}
|
||||
{ mnuTools Menu
|
||||
Text = ("Tools")
|
||||
Visible = False
|
||||
{ Menu7 Menu
|
||||
Text = ("Menu7")
|
||||
}
|
||||
{ Menu8 Menu
|
||||
Text = ("Menu8")
|
||||
}
|
||||
{ Menu9 Menu
|
||||
Text = ("Menu9")
|
||||
{ Menu10 Menu
|
||||
Text = ("Menu10")
|
||||
}
|
||||
{ Menu11 Menu
|
||||
Text = ("Menu11")
|
||||
}
|
||||
}
|
||||
}
|
||||
{ HBox1 HBox
|
||||
MoveScaled(3,14,56,5)
|
||||
{ MenuButton1 MenuButton
|
||||
MoveScaled(0,0,17,4)
|
||||
AutoResize = True
|
||||
Text = ("Project")
|
||||
Arrow = False
|
||||
Border = False
|
||||
Menu = "mnuProject"
|
||||
}
|
||||
{ MenuButton2 MenuButton
|
||||
MoveScaled(18,0,16,4)
|
||||
AutoResize = True
|
||||
Text = ("View")
|
||||
Arrow = False
|
||||
Border = False
|
||||
Menu = "mnuView"
|
||||
}
|
||||
{ MenuButton3 MenuButton
|
||||
MoveScaled(35,0,16,4)
|
||||
AutoResize = True
|
||||
Text = ("Tools")
|
||||
Arrow = False
|
||||
Border = False
|
||||
Menu = "mnuTools"
|
||||
}
|
||||
}
|
||||
}
|
@ -386,6 +386,12 @@ BEGIN_METHOD(Menu_Popup, GB_INTEGER x; GB_INTEGER y)
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD_VOID(Menu_Close)
|
||||
|
||||
MENU->close();
|
||||
|
||||
END_METHOD
|
||||
|
||||
|
||||
BEGIN_PROPERTY(Menu_Tag)
|
||||
|
||||
@ -496,6 +502,7 @@ GB_DESC CMenuDesc[] =
|
||||
MENU_DESCRIPTION,
|
||||
|
||||
GB_METHOD("Popup", 0, Menu_Popup, "[(X)i(Y)i]"),
|
||||
GB_METHOD("Close", NULL, Menu_Close, NULL),
|
||||
GB_METHOD("Delete", 0, Menu_Delete, 0),
|
||||
GB_METHOD("Show", 0, Menu_Show, 0),
|
||||
GB_METHOD("Hide", 0, Menu_Hide, 0),
|
||||
|
@ -776,6 +776,13 @@ void gMenu::popup()
|
||||
doPopup(false);
|
||||
}
|
||||
|
||||
void gMenu::close()
|
||||
{
|
||||
if (!child)
|
||||
return;
|
||||
|
||||
gtk_menu_popdown(child);
|
||||
}
|
||||
|
||||
int gMenu::winChildCount(gMainWindow *par)
|
||||
{
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
//"Methods"
|
||||
void popup();
|
||||
void popup(int x, int y);
|
||||
void close();
|
||||
void destroy();
|
||||
static bool insidePopup() { return _in_popup > 0; }
|
||||
static gMenu *currentPopup() { return _current_popup; }
|
||||
|
@ -140,9 +140,6 @@ int gMouse::screenX()
|
||||
{
|
||||
gint x;
|
||||
|
||||
if (_isValid)
|
||||
x = _screen_x;
|
||||
else
|
||||
#ifdef GTK3
|
||||
gdk_device_get_position(get_pointer(), NULL, &x, NULL);
|
||||
#else
|
||||
@ -156,9 +153,6 @@ int gMouse::screenY()
|
||||
{
|
||||
gint y;
|
||||
|
||||
if (_isValid)
|
||||
y = _screen_y;
|
||||
else
|
||||
#ifdef GTK3
|
||||
gdk_device_get_position(get_pointer(), NULL, NULL, &y);
|
||||
#else
|
||||
|
@ -741,6 +741,11 @@ BEGIN_METHOD(Menu_Popup, GB_INTEGER x; GB_INTEGER y)
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD_VOID(Menu_Close)
|
||||
|
||||
THIS->menu->close();
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_PROPERTY(Menu_Window)
|
||||
|
||||
@ -826,6 +831,7 @@ GB_DESC CMenuDesc[] =
|
||||
MENU_DESCRIPTION,
|
||||
|
||||
GB_METHOD("Popup", NULL, Menu_Popup, "[(X)i(Y)i]"),
|
||||
GB_METHOD("Close", NULL, Menu_Close, NULL),
|
||||
GB_METHOD("Delete", NULL, Menu_Delete, NULL),
|
||||
GB_METHOD("Show", NULL, Menu_Show, NULL),
|
||||
GB_METHOD("Hide", NULL, Menu_Hide, NULL),
|
||||
|
@ -182,22 +182,14 @@ END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(Mouse_ScreenX)
|
||||
|
||||
#ifdef QT5
|
||||
GB.ReturnInteger(QCursor::pos().x());
|
||||
#else
|
||||
GB.ReturnInteger(MOUSE_info.valid ? MOUSE_info.screenX : QCursor::pos().x());
|
||||
#endif
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
|
||||
BEGIN_PROPERTY(Mouse_ScreenY)
|
||||
|
||||
#ifdef QT5
|
||||
GB.ReturnInteger(QCursor::pos().y());
|
||||
#else
|
||||
GB.ReturnInteger(MOUSE_info.valid ? MOUSE_info.screenY : QCursor::pos().y());
|
||||
#endif
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user