; Module/File: Editor_GetTextViewSize.pb ; Function: Get the width of the TextView-Area (without scrollbars, not the whole GtkScrolledWindow like PB-GadgetWidth()) - Linux ; Author: Omi ; Date: Jan. 01, 2016 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31/5.40 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- EnableExplicit ImportC "" ; gtk_widget_get_allocated_width(*widget.GtkWidget); for gtk3 ; gtk_widget_get_allocated_height(*widget.GtkWidget); for gtk3 gtk_widget_get_allocation(*widget.GtkWidget, *allocation.GtkAllocation); gtk2 + gtk3 EndImport ; Object constants #Win_Main = 0 #But1 = 0 #But2 = 1 #Edt1 = 2 Global.i gEvent, gQuit Global gAllocation.GtkAllocation Global.s S1= "A little Text to demonstrate a multiple view of the same text being shown and editable in 2 (or more) PureBasic-EditorGadget. " + #LF$ + #LF$ + "To make this possible it is necessary To use the same 'TextBuffer' for several EditorGadgets (TextViews)!" + #LF$ + #LF$ + "Enter some new text here and change the Editor to type in your text ..." + #LF$ + #LF$ + "Some lines to fill the place:" + #LF$ + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. "+ #LF$ + "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. "+ #LF$ + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua." Procedure Editor_GetWidth(Gadget) gtk_widget_get_allocation(GadgetID(Gadget), @gAllocation) ProcedureReturn gAllocation\width ;only gtk3 ... ; ProcedureReturn gtk_widget_get_allocated_width(GadgetID(Gadget)) EndProcedure Procedure Editor_GetHeight(Gadget) gtk_widget_get_allocation(GadgetID(Gadget), @gAllocation) ProcedureReturn gAllocation\height ;only gtk3 .. ; ProcedureReturn gtk_widget_get_allocated_height(GadgetID(Gadget)) EndProcedure If OpenWindow(#Win_Main, 0, 0, 500, 235, "Editor-Area - Size", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ButtonGadget(#But1, 5, 5, 190, 26, "Line wrap", #PB_Button_Toggle) ButtonGadget(#But2, 205, 5, 190, 26, "Debug size") SetGadgetState(#But1, #True) EditorGadget(#Edt1, 5, 40, 490, 190) AddGadgetItem(#Edt1, -1, S1) gtk_text_view_set_wrap_mode_(GadgetID(#Edt1), #GTK_WRAP_WORD) Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True Case #PB_Event_Gadget Select EventGadget() Case #But1 If GetGadgetState(#But1) gtk_text_view_set_wrap_mode_(GadgetID(#Edt1), #GTK_WRAP_WORD) Else gtk_text_view_set_wrap_mode_(GadgetID(#Edt1), #GTK_WRAP_NONE) EndIf Case #But2 Debug "Width (PB, = GtkScrolledWindow): " + GadgetWidth(#Edt1, #PB_Gadget_ActualSize) Debug "Height (PB, = GtkScrolledWindow): " + GadgetHeight(#Edt1, #PB_Gadget_ActualSize) Debug "Width (Editor area) : " + Editor_GetWidth(#Edt1) Debug "Height (Editor area) : " + Editor_GetHeight(#Edt1) Debug " ---" EndSelect EndSelect Until gQuit EndIf ; IDE Options = PureBasic 5.45 LTS (Linux - x86) ; CursorPosition = 3 ; Folding = - ; EnableUnicode ; EnableXP