; --------------------------------------------------------------------------------------------; Copyright (c) Fantaisie Software. All rights reserved.; Dual licensed under the GPL and Fantaisie Software licenses.; See LICENSE and LICENSE-FANTAISIE in the project root for license information.; --------------------------------------------------------------------------------------------Procedure ActivateTool(Name$)Opened = 0If ToolsPanelMode; try the tools in the panel first;ForEach UsedPanelTools()*PanelToolData.ToolsPanelEntry = UsedPanelTools()If *PanelToolData\ToolID$ = Name$SetGadgetState(#GADGET_ToolsPanel, ListIndex(UsedPanelTools()))CurrentTool = UsedPanelTools()CurrentTool\ResizeHandler(GetPanelWidth(#GADGET_ToolsPanel), GetPanelHeight(#GADGET_ToolsPanel))Opened = 1BreakEndIfNext UsedPanelTools()If Opened And ToolsPanelAutoHide And ToolsPanelVisible = 0If ToolsPanelHideDelay < 2500ToolsPanelHideTime.q = ElapsedMilliseconds() + 2500 ; stay open for at least 2.5 seconds!ElseToolsPanelHideTime.q = ElapsedMilliseconds() + ToolsPanelHideDelayEndIfToolsPanel_Show()EndIfEndIfIf Opened = 0; now try the rest and open in external window;ForEach AvailablePanelTools()If AvailablePanelTools()\ToolID$ = Name$If AvailablePanelTools()\IsSeparateWindowSetWindowForeground(AvailablePanelTools()\ToolWindowID)SetActiveWindow(AvailablePanelTools()\ToolWindowID)ElseFlags = #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadgetIf AvailablePanelTools()\ToolWindowX = 0Flags | #PB_Window_ScreenCenteredEndIfIf AvailablePanelTools()\ExternalPluginTitle$ = AvailablePanelTools()\PanelTitle$ElseTitle$ = Language("ToolsPanel", AvailablePanelTools()\PanelTitle$)EndIfWindowWidth = AvailablePanelTools()\ToolWindowWidthIf WindowWidth < AvailablePanelTools()\ToolMinWindowWidthWindowWidth = AvailablePanelTools()\ToolMinWindowWidthEndIfWindowHeight = AvailablePanelTools()\ToolWindowHeightIf WindowHeight < AvailablePanelTools()\ToolMinWindowHeightWindowHeight = AvailablePanelTools()\ToolMinWindowHeightEndIfWindow = OpenWindow(#PB_Any, AvailablePanelTools()\ToolWindowX, AvailablePanelTools()\ToolWindowY, WindowWidth, WindowHeight, Title,ドル Flags)If WindowEnsureWindowOnDesktop(Window)WindowBounds(Window, AvailablePanelTools()\ToolMinWindowWidth, AvailablePanelTools()\ToolMinWindowHeight, #PB_Ignore, #PB_Ignore)AvailablePanelTools()\IsSeparateWindow = 1AvailablePanelTools()\ToolWindowID = WindowTool.ToolsPanelInterface = @AvailablePanelTools()Tool\CreateFunction()If #DEFAULT_CanWindowStayOnTop; CompilerIf #CompileWindows; AvailablePanelTools()\ToolStayOnTop = CheckBoxGadget(#PB_Any, 5, WindowHeight(Window)-23, WindowWidth(Window)-10, 23, Language("Misc","StayOnTop")); CompilerElse; AvailablePanelTools()\ToolStayOnTop = CheckBoxGadget(#PB_Any, 5, WindowHeight(Window)-25, WindowWidth(Window)-10, 25, Language("Misc","StayOnTop")); CompilerEndIfAvailablePanelTools()\ToolStayOnTop = CheckBoxGadget(#PB_Any, 5, WindowHeight(Window)-25, WindowWidth(Window)-10, 25, Language("Misc","StayOnTop"))Height = GetRequiredHeight(AvailablePanelTools()\ToolStayOnTop)ResizeGadget(AvailablePanelTools()\ToolStayOnTop, 5, WindowHeight(Window)-Height-5, WindowWidth(Window)-10, Height)SetGadgetState(AvailablePanelTools()\ToolStayOnTop, AvailablePanelTools()\IsToolStayOnTop)SetWindowStayOnTop(Window, AvailablePanelTools()\IsToolStayOnTop)Tool\ResizeHandler(WindowWidth(Window), WindowHeight(Window)-Height-5)ElseTool\ResizeHandler(WindowWidth(Window), WindowHeight(Window))EndIfEndIfEndIfBreakEndIfNext AvailablePanelTools()EndIfEndProcedure; Creates the "hidden panel" image. This procedure is used on OSX, and as fallback for the other os;Procedure ToolsPanel_CreateFake_Default()CatchImage(#IMAGE_ToolsPanelRight, ?Image_ToolsPanelRight)CatchImage(#IMAGE_ToolsPanelLeft, ?Image_ToolsPanelLeft)If ToolsPanelSide = 0ImageGadget(#GADGET_ToolsPanelFake, 0, 0, 0, 0, ImageID(#IMAGE_ToolsPanelRight))ElseImageGadget(#GADGET_ToolsPanelFake, 0, 0, 0, 0, ImageID(#IMAGE_ToolsPanelLeft))EndIfToolsPanelHiddenWidth = 16EndProcedure; Special Windows procedure for the vertical.; Does not work on XP, so windows still needs the default fallback;CompilerIf #CompileWindowsProcedure ToolsPanel_CreateFake_Windows()#TCS_VERTICAL = 80ドル#TCS_RIGHT = 2ドル; on windows we have a special replacement for the hidden panel (= vertical tab); which does not work on XP.; Intrestingly, this works ok on vista (though the gadget is displayed without skins there)If OSVersion() <> #PB_OS_Windows_XP; this frees the old fake panel created below as well, as it is its child.;ContainerGadget(#GADGET_ToolsPanelFake, 0, 0, 0, 0)CloseGadgetList()If ToolsPanelSide = 0style = #TCS_RIGHTElsestyle = 0EndIfFakeToolsPanelID = CreateWindowEx_(0, "SysTabControl32", "", #WS_VISIBLE|#WS_OVERLAPPED|#WS_CHILD|#WS_CLIPSIBLINGS|#TCS_MULTILINE|#TCS_VERTICAL|style, 0, 0, 0, 0, GadgetID(#GADGET_ToolsPanelFake), 0, GetModuleHandle_(#Null$) , 0)If FakeToolsPanelID; we use MS Sans serif for the vertical panel, as any other try to modify the; system default font looks ugly.; all this will not be done on XP anyway (were there is another default font);FontID = FontID(LoadFont(#PB_Any, "MS Sans Serif", 10, #PB_Font_HighQuality))SendMessage_(FakeToolsPanelID, #WM_SETFONT, FontID, 0)ForEach UsedPanelTools()*ToolData.ToolsPanelEntry = UsedPanelTools()If *ToolData\ExternalPluginText$ = *ToolData\PanelTitle$ElseText$ = Language("ToolsPanel", *ToolData\PanelTitle$)EndIfpanelitem.TC_ITEM\mask = #TCIF_TEXTpanelitem\pszText = @Text$SendMessage_(FakeToolsPanelID, #TCM_INSERTITEM, ListIndex(UsedPanelTools()), @panelitem)Next UsedPanelTools()EndIfToolsPanelHiddenWidth = 25 ; width of the vertical panelElse; use the fallback procedure on XPToolsPanel_CreateFake_Default()EndIfEndProcedureCompilerEndIf; Special linux procedure for the vertical panel;CompilerIf #CompileLinuxGtkImportC ""gtk_label_set_angle_(*Label.GtkWidget, angle.d) As "gtk_label_set_angle" ; Gtk 2.6+EndImportProcedure ToolsPanel_CreateFake_Linux(IsUpdate)PanelGadget(#GADGET_ToolsPanelFake, 0, 0, 0, 0); If the gadget is visible (toolspanel update), then we get the same warning as mentioned below; So just hide it (this is done after creation anyway, so it does not hurt)If IsUpdateHideGadget(#GADGET_ToolsPanelFake, 1)EndIfForEach UsedPanelTools()*ToolData.ToolsPanelEntry = UsedPanelTools()If *ToolData\ExternalPluginAddGadgetItem(#GADGET_ToolsPanelFake, -1, *ToolData\PanelTitle$)ElseAddGadgetItem(#GADGET_ToolsPanelFake, -1, Language("ToolsPanel", *ToolData\PanelTitle$))EndIf; set the needed orientation for the tab label; Note that the actual label is now inside a container (because of image support);*LabelContainer.GtkWidget = gtk_notebook_get_tab_label_(GadgetID(#GADGET_ToolsPanelFake), gtk_notebook_get_nth_page_(GadgetID(#GADGET_ToolsPanelFake), ListIndex(UsedPanelTools())))*Children = gtk_container_get_children_(*LabelContainer)*Label.GtkWidget = g_list_nth_data_(*Children, 1) ; label is the second child (image slot is always present)g_list_free_(*Children) ; free this listIf ToolsPanelSide = 0gtk_label_set_angle_(*Label, 270)Elsegtk_label_set_angle_(*Label, 90)EndIfNext UsedPanelTools()CloseGadgetList(); make it vertical;If ToolsPanelSide = 0gtk_notebook_set_tab_pos_(GadgetID(#GADGET_ToolsPanelFake), #GTK_POS_RIGHT)Elsegtk_notebook_set_tab_pos_(GadgetID(#GADGET_ToolsPanelFake), #GTK_POS_LEFT)EndIf; Note: ToolsPanelHiddenWidth cannot be set here, as the window is not shown; yet, and there is no way to calculate the tab height. This variable is set; in the main source when the PanelTabHeight is calculated as well.;; Note: We have to set this to a high enough value for the startup, else we get; a gtk warning by some theme engine (CRITICAL **: clearlooks_style_draw_box_gap: assertion `width >= -1' failed); The real value is set later in PureBasic.pb;If IsUpdate = #FalseToolsPanelHiddenWidth = 50EndIfEndProcedureCompilerEndIfProcedure ToolsPanel_Create(IsUpdate)UseGadgetList(WindowID(#WINDOW_Main)); create the gadget that represents the "hidden" panel;CompilerSelect #PB_Compiler_OSCompilerCase #PB_OS_Windows: ToolsPanel_CreateFake_Windows()CompilerCase #PB_OS_LinuxCompilerIf #CompileLinuxGtkToolsPanel_CreateFake_Linux(IsUpdate)CompilerElseToolsPanel_CreateFake_Default()CompilerEndIfCompilerCase #PB_OS_MacOS: ToolsPanel_CreateFake_Default() ; use same as windows fallbackCompilerEndSelectHideGadget(#GADGET_ToolsPanelFake, 1)If ToolsPanelModeIf IsGadget(#GADGET_ToolsPanel) ; we do not destroy the gadget anymoreOpenGadgetList(#GADGET_ToolsPanel)ElsePanelGadget(#GADGET_ToolsPanel, 0, 0, 0, 0)EndIfForEach UsedPanelTools()*ToolData.ToolsPanelEntry = UsedPanelTools()If *ToolData\ExternalPluginAddGadgetItem(#GADGET_ToolsPanel, -1, *ToolData\PanelTitle$)ElseAddGadgetItem(#GADGET_ToolsPanel, -1, Language("ToolsPanel", *ToolData\PanelTitle$))EndIfPanelTool.ToolsPanelInterface = UsedPanelTools()PanelTool\CreateFunction()Next UsedPanelTools()FirstElement(UsedPanelTools()) ; set the current tool.. very important!CurrentTool = UsedPanelTools()CloseGadgetList()CompilerIf #CompileWindowsSetWindowLongPtr_(GadgetID(#GADGET_ToolsPanel), #GWL_STYLE, GetWindowLongPtr_(GadgetID(#GADGET_ToolsPanel), #GWL_STYLE) | #TCS_MULTILINE)CompilerEndIfElseIf IsGadget(#GADGET_ToolsPanel) = 0PanelGadget(#GADGET_ToolsPanel, 0, 0, 0, 0) ; still create the gadget if we do not need a panelCloseGadgetList()EndIfHideGadget(#GADGET_ToolsPanel, 1)EndIfEndProcedureProcedure ToolsPanel_Update(); because you can also change the order of items in the ToolsPanel completely,; we destroy the whole ToolsPanel and recreate it.;ForEach UsedPanelTools()*ToolData.ToolsPanelEntry = UsedPanelTools()If *ToolData\NeedDestroyFunctionPanelTool.ToolsPanelInterface = UsedPanelTools()PanelTool\DestroyFunction()EndIfNext UsedPanelTools()ClearList(UsedPanelTools())If IsGadget(#GADGET_ToolsPanel)ClearGadgetItems(#GADGET_ToolsPanel) ; no more freegadgetEndIfIf ListSize(NewUsedPanelTools()) > 0ToolsPanelMode = 1ElseToolsPanelMode = 0EndIf; Close any tools in external tool windows to avoid any conflicts;ForEach AvailablePanelTools()If AvailablePanelTools()\IsSeparateWindowIf AvailablePanelTools()\NeedDestroyFunctionTool.ToolsPanelInterface = @AvailablePanelTools()Tool\DestroyFunction()EndIfIf MemorizeWindowWindow = AvailablePanelTools()\ToolWindowIDAvailablePanelTools()\ToolWindowX = WindowX(Window)AvailablePanelTools()\ToolWindowY = WindowY(Window)AvailablePanelTools()\ToolWindowWidth = WindowWidth(Window)AvailablePanelTools()\ToolWindowHeight = WindowHeight(Window)EndIfCloseWindow(AvailablePanelTools()\ToolWindowID)AvailablePanelTools()\ToolWindowID = -1AvailablePanelTools()\IsSeparateWindow = 0EndIfNext AvailablePanelTools(); copy the NewUsedPanelTools() to the UsedPanelTools();ForEach NewUsedPanelTools()AddElement(UsedPanelTools())UsedPanelTools() = NewUsedPanelTools()Next NewUsedPanelTools(); now re-create the whole thing;ToolsPanel_Create(#True); Swap the gadgets in the splitter if the Toolspanelside changed.; we need to check which is the toolspanel, as ToolsPanelSide is already updated,; we cannot use that one to know where the panel is now :);If GadgetType(GetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_FirstGadget)) = #PB_GadgetType_PanelOldSide = 1ElseOldSide = 0EndIfIf OldSide <> ToolsPanelSide; create a dummy gadget for the swapDummyGadget = ContainerGadget(#PB_Any, 0, 0, 0, 0)CloseGadgetList()FirstGadget = GetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_FirstGadget)SecondGadget = GetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_SecondGadget)SetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_FirstGadget, DummyGadget)SetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_SecondGadget, FirstGadget)SetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_FirstGadget, SecondGadget); reverse the sizes as wellSetGadgetState(#GADGET_ToolsSplitter, GadgetWidth(#GADGET_ToolsSplitter)-GetGadgetState(#GADGET_ToolsSplitter))FreeGadget(DummyGadget)EndIfIf ToolsPanelVisible = 0HideGadget(#GADGET_ToolsPanelFake, 0)EndIfIf ToolsPanelAutoHide Or ToolsPanelMode = 0 ; hide the panel if we do not need itToolsPanel_Hide()ElseIf ToolsPanelModeToolsPanel_Show()EndIf; Resize the currently displayed tool;If ToolsPanelVisible And CurrentToolCurrentTool\ResizeHandler(GetPanelWidth(#GADGET_ToolsPanel), GetPanelHeight(#GADGET_ToolsPanel))EndIfEndProcedure; checks the autohide state of the ToolsPanel.; If ToolsPanelAutoHide is set, the OS specific Event code must ensure that; this is called either on any mouse movement or in a timer interval; to ensure correct updates of this;Procedure ToolsPanel_CheckAutoHide()If ToolsPanelAutoHide And ToolsPanelModeMouseX = WindowMouseX(#WINDOW_Main)If MouseX <> -1 And WindowMouseY(#WINDOW_Main) <> -1 ; do nothing if mouse is outside of the window; Convert cursor X position from physical to logical pixels to ensure that scale is; consistent with editor and tool-panel widths.; This must be done only after it's determined to be in-frame; unscaling prior will; result in failure at high scale factors (where -1 becomes 0).;CompilerIf #CompileWindowsMouseX = DesktopUnscaledX(MouseX)CompilerEndIfIf ToolsPanelSide = 0 ; right sideOffset = EditorWindowWidth - MouseXToolsPanelWidth = GadgetWidth(#GADGET_ToolsSplitter) - GetGadgetState(#GADGET_ToolsSplitter)ElseOffset = MouseXToolsPanelWidth = GetGadgetState(#GADGET_ToolsSplitter)EndIf;Debug "Width: " + Str(ToolsPanelWidth) + ", X: "+Str(Offset)If ToolsPanelVisible And Offset > ToolsPanelWidth + 40If ToolsPanelHideTime = 0 ; first time the panel was leftToolsPanelHideTime.q = ElapsedMilliseconds() + ToolsPanelHideDelayElseIf ToolsPanelHideTime < ElapsedMilliseconds() ; the hide timeout has passedToolsPanel_Hide()ToolsPanelHideTime = 0EndIfElseIf ToolsPanelVisible = 0 And Offset < ToolsPanelHiddenWidthToolsPanel_Show()ToolsPanelHideTime = 0EndIfEndIfEndIfEndProcedureProcedure ToolsPanel_Hide()CompilerIf #CompileWindowsIf FakeToolsPanelIDSendMessage_(FakeToolsPanelID, #TCM_SETCURSEL, GetGadgetState(#GADGET_ToolsPanel), 0)EndIfCompilerEndIfCompilerIf #CompileLinuxGtkIf GadgetType(#GADGET_ToolsPanelFake) = #PB_GadgetType_Panel ; check if we used the vertical panelSetGadgetState(#GADGET_ToolsPanelFake, GetGadgetState(#GADGET_ToolsPanel))EndIfCompilerEndIfIf ToolsPanelVisible ; no check for ToolsPanelMode here, as we call this to hide the panel when ToolsPanelMode = 0If ErrorLogVisibleState = GetGadgetState(#GADGET_LogSplitter) ; somehow the reparenting makes the slider jump in the second splitter on linux, so only reset it after ResizeWindow()EndIfCompilerIf #CompileWindows; Temporarily disable painting to avoid flickering while reparenting.SendMessage_(WindowID(#WINDOW_Main), #WM_SETREDRAW, #False, 0)CompilerEndIfIf ToolsPanelSide = 0ToolsPanelWidth_Hidden = GadgetWidth(#GADGET_ToolsSplitter) - GetGadgetState(#GADGET_ToolsSplitter)SetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_FirstGadget, #GADGET_ToolsDummy)ElseToolsPanelWidth_Hidden = GetGadgetState(#GADGET_ToolsSplitter)SetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_SecondGadget, #GADGET_ToolsDummy)EndIfToolsPanelVisible = 0HideGadget(#GADGET_ToolsPanelFake, 0)ResizeMainWindow()CompilerIf #CompileWindows; Restore painting to have updated visuals reflected.SendMessage_(WindowID(#WINDOW_Main), #WM_SETREDRAW, #True, 0)CompilerEndIfHideGadget(#GADGET_ToolsSplitter, 1)If ErrorLogVisibleSetGadgetState(#GADGET_LogSplitter, State)EndIfEndIfEndProcedureProcedure ToolsPanel_Show()If ToolsPanelVisible = 0 And ToolsPanelModeIf ErrorLogVisibleState = GetGadgetState(#GADGET_LogSplitter) ; somehow the reparenting makes the slider jump in the second splitter on linux, so only reset it after ResizeWindow()OldGadget = #GADGET_LogSplitterElseOldGadget = #GADGET_SourceContainerEndIfHideGadget(#GADGET_ToolsSplitter, 0)If ToolsPanelSide = 0SetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_FirstGadget, OldGadget)ElseSetGadgetAttribute(#GADGET_ToolsSplitter, #PB_Splitter_SecondGadget, OldGadget)EndIfToolsPanelVisible = 1HideGadget(#GADGET_ToolsPanelFake, 1)ResizeMainWindow(); apply the old state again.If ToolsPanelSide = 0SetGadgetState(#GADGET_ToolsSplitter, GadgetWidth(#GADGET_ToolsSplitter)-ToolsPanelWidth_Hidden)ElseSetGadgetState(#GADGET_ToolsSplitter, ToolsPanelWidth_Hidden)EndIfIf ErrorLogVisibleSetGadgetState(#GADGET_LogSplitter, State)EndIfEndIfEndProcedureDataSectionImage_ToolsPanelRight:IncludeBinary "data/ToolsPanelRight.png"Image_ToolsPanelLeft:IncludeBinary "data/ToolsPanelLeft.png"EndDataSection
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。