有关信息:我使用Ada作为编程语言,而Windowing软件是Gtk和GtkAda。
我在有时不适合我的窗口的绘图区域上绘制了一个绘图,即使使用全屏也是如此。因此,我需要有一个滚动区域。我使用随附的代码来获得这样的窗口,但是滚动条始终无法移动,因此看不到我的绘图的一部分。我必须在程序中添加什么?在运行的程序中必须更改滚动条的范围时,该怎么办?
Gtk_New (MainWindow.Scrolledwindow);
Set_Policy (MainWindow.Scrolledwindow, Policy_Always, Policy_Always);
Set_Shadow_Type (MainWindow.Scrolledwindow, Shadow_None);
Set_Placement (MainWindow.Scrolledwindow, Corner_Top_Left);
Gtk_New (MainWindow.View_Port);
Gtk_New (MainWindow.DrawingArea);
MainWindow.Scrolledwindow.Add(MainWindow.View_Port);
MainWindow.View_Port.Add(MainWindow.DrawingArea);
Pack_Start
(MainWindow.Main_Box1,
MainWindow.Scrolledwindow,
Expand => True,
Fill => True,
Padding => 0);
答案 0 :(得分:2)
我认为您可以省略视口小部件,而只需将其替换为一个框。如@ lb90所述,您可以使用public List<Entity> getList() {
return Stream.of(
EntityService.filtermethod("AB"),
EntityService.filtermethod("BC"),
EntityService.filtermethod("CD")
)
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
设置绘图区域的大小。这似乎可以解决问题:
main.adb
Set_Size_Request
demo.ads
with Gtk.Main;
with Demo.Main_Window;
procedure Main is
use Demo.Main_Window;
Main_Window : Demo_Main_Window;
begin
Gtk.Main.Init;
Gtk_New (Main_Window);
Gtk.Main.Main;
end Main;
demo-main_window.ads
package Demo is
end Demo;
demo-main_window.adb
with Glib; use Glib;
with Gtk.Window;
with Gtk.Scrolled_Window;
with Gtk.Box;
with Gtk.Drawing_Area;
package Demo.Main_Window is
type Demo_Main_Window_Record is new Gtk.Window.Gtk_Window_Record with private;
type Demo_Main_Window is access all Demo_Main_Window_Record'Class;
------------------
-- Constructors --
------------------
procedure Gtk_New
(Main_Window : out Demo_Main_Window);
procedure Initialize
(Main_Window : not null access Demo_Main_Window_Record'Class);
private
use Gtk.Scrolled_Window;
use Gtk.Box;
use Gtk.Drawing_Area;
Window_Width : constant Gint := 640;
Window_Height : constant Gint := 480;
Draw_Area_Width : constant Gint := 1000;
Draw_Area_Height : constant Gint := 1000;
type Demo_Main_Window_Record is
new Gtk.Window.Gtk_Window_Record with
record
SW : Gtk_Scrolled_Window;
VB : Gtk_Vbox;
DA : Gtk_Drawing_Area;
end record;
end Demo.Main_Window;