diff --git a/app/src/gambas3/.src/Search/FSearch.class b/app/src/gambas3/.src/Search/FSearch.class index 35451c459..e2c1d2e50 100644 --- a/app/src/gambas3/.src/Search/FSearch.class +++ b/app/src/gambas3/.src/Search/FSearch.class @@ -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)) diff --git a/comp/src/gb.form.editor/.src/TextEditor.class b/comp/src/gb.form.editor/.src/TextEditor.class index b3cc00bbf..6d15812a6 100644 --- a/comp/src/gb.form.editor/.src/TextEditor.class +++ b/comp/src/gb.form.editor/.src/TextEditor.class @@ -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 diff --git a/comp/src/gb.form/.info b/comp/src/gb.form/.info index c0a0bdaca..5a4f5d35f 100644 --- a/comp/src/gb.form/.info +++ b/comp/src/gb.form/.info @@ -2340,6 +2340,10 @@ Arrow_Click m +WatchTimer_Timer +m + + DrawingArea_GotFocus m diff --git a/comp/src/gb.form/.project b/comp/src/gb.form/.project index a64a212da..eb80da064 100644 --- a/comp/src/gb.form/.project +++ b/comp/src/gb.form/.project @@ -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 diff --git a/comp/src/gb.form/.src/Button/MenuButton.class b/comp/src/gb.form/.src/Button/MenuButton.class index d4c2dddae..9a1c0e826 100644 --- a/comp/src/gb.form/.src/Button/MenuButton.class +++ b/comp/src/gb.form/.src/Button/MenuButton.class @@ -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 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 + + 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() - Dim hMenu As Menu - - hMenu = Main.FindMenu(Me, $sMenu) - If hMenu Then - hMenu.Popup(Me.ScreenX, Me.ScreenY + Me.H) - Else + 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 diff --git a/comp/src/gb.form/.src/Test/FTestMenuButton.class b/comp/src/gb.form/.src/Test/FTestMenuButton.class new file mode 100644 index 000000000..0a5fa73ac --- /dev/null +++ b/comp/src/gb.form/.src/Test/FTestMenuButton.class @@ -0,0 +1,2 @@ +' Gambas class file + diff --git a/comp/src/gb.form/.src/Test/FTestMenuButton.form b/comp/src/gb.form/.src/Test/FTestMenuButton.form new file mode 100644 index 000000000..6962654bc --- /dev/null +++ b/comp/src/gb.form/.src/Test/FTestMenuButton.form @@ -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" + } + } +} diff --git a/gb.gtk/src/CMenu.cpp b/gb.gtk/src/CMenu.cpp index 11d6d7495..ad963e0d2 100644 --- a/gb.gtk/src/CMenu.cpp +++ b/gb.gtk/src/CMenu.cpp @@ -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), diff --git a/gb.gtk/src/gmenu.cpp b/gb.gtk/src/gmenu.cpp index 43bb8f1a8..ccac61902 100644 --- a/gb.gtk/src/gmenu.cpp +++ b/gb.gtk/src/gmenu.cpp @@ -776,6 +776,13 @@ void gMenu::popup() doPopup(false); } +void gMenu::close() +{ + if (!child) + return; + + gtk_menu_popdown(child); +} int gMenu::winChildCount(gMainWindow *par) { diff --git a/gb.gtk/src/gmenu.h b/gb.gtk/src/gmenu.h index 57c2d3686..c68368d01 100644 --- a/gb.gtk/src/gmenu.h +++ b/gb.gtk/src/gmenu.h @@ -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; } diff --git a/gb.gtk/src/gmouse.cpp b/gb.gtk/src/gmouse.cpp index 4e3958adb..401c572e5 100644 --- a/gb.gtk/src/gmouse.cpp +++ b/gb.gtk/src/gmouse.cpp @@ -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 diff --git a/gb.qt4/src/CMenu.cpp b/gb.qt4/src/CMenu.cpp index 8a45f60c2..a3845230f 100644 --- a/gb.qt4/src/CMenu.cpp +++ b/gb.qt4/src/CMenu.cpp @@ -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), diff --git a/gb.qt4/src/CMouse.cpp b/gb.qt4/src/CMouse.cpp index ca97b2d38..aba2af169 100644 --- a/gb.qt4/src/CMouse.cpp +++ b/gb.qt4/src/CMouse.cpp @@ -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