File: w_statusbar.srw
Size: 7789
Date: Sat, 25 Jun 2022 04:21:56 +0200
$PBExportHeader$w_statusbar.srw
forward
global type w_statusbar from window
end type
type st_encoding_border from statictext within w_statusbar
end type
type st_encoding from statictext within w_statusbar
end type
type st_linecol_border from statictext within w_statusbar
end type
type st_overtype_border from statictext within w_statusbar
end type
type ln_far_left from line within w_statusbar
end type
type st_overtype from statictext within w_statusbar
end type
type st_linecol from statictext within w_statusbar
end type
end forward

global type w_statusbar from window
integer width = 846
integer height = 100
boolean border = false
windowtype windowtype = child!
long backcolor = 67108864
st_encoding_border st_encoding_border
st_encoding st_encoding
st_linecol_border st_linecol_border
st_overtype_border st_overtype_border
ln_far_left ln_far_left
st_overtype st_overtype
st_linecol st_linecol
end type
global w_statusbar w_statusbar

type prototypes
Function integer GetClassName ( &
   ulong hWind, &
   Ref string name, &
   int cbmax &
   ) Library "user32.dll" Alias For "GetClassNameW"

Function ulong GetWindow ( &
   ulong hWind, &
   uint fuRel &
   ) Library "user32.dll"

Function ulong SetParent ( &
   ulong hChild, &
   ulong hParent &
   ) Library "user32.dll"

end prototypes

type variables
String is_classname
Integer ii_width

end variables

forward prototypes
public subroutine wf_reposition ()
public subroutine wf_setparent ()
public subroutine wf_setlinecol (string as_linecol)
public subroutine wf_setencoding (string as_encoding)
public subroutine wf_updateui (readonly u_scintilla au_scintilla)
end prototypes

public subroutine wf_reposition ();Integer li_share

// if the window would be more than 2/3
// of width hide it off to the right
li_share = (gw_frame.width / 3) * 2
If this.ii_width > li_share Then
   this.x = gw_frame.width
Else
   If gw_frame.WindowState = Maximized! Then
      this.x = gw_frame.width - ii_width - 25
   Else
      this.x = gw_frame.width - ii_width - 90
   End If
End If
this.y = 5

end subroutine

public subroutine wf_setparent ();String ls_name
ULong lul_hwnd
Integer li_rc

// find the microhelp handle
lul_hwnd = GetWindow(Handle(gw_frame), 5)
DO UNTIL lul_hwnd = 0
   ls_name = Space(25)
   li_rc = GetClassName(lul_hwnd, ls_name, Len(ls_name))
   If ls_name = is_classname Then
      lul_hwnd = SetParent(Handle(this), lul_hwnd)
      lul_hwnd = 0
   Else
      lul_hwnd = GetWindow(lul_hwnd, 2)
   End If
LOOP

end subroutine

public subroutine wf_setlinecol (string as_linecol);// set linecol
st_linecol.text = " " + Trim(as_linecol)

end subroutine

public subroutine wf_setencoding (string as_encoding);// set encoding
st_encoding.text = " " + Trim(as_encoding)

end subroutine

public subroutine wf_updateui (readonly u_scintilla au_scintilla);Long ll_line, ll_col

ll_line = au_scintilla.of_GetCurrentLine()
ll_col  = au_scintilla.of_GetCurrentColumn()

wf_SetLinecol(String(ll_line) + ":" + String(ll_col))

choose case au_scintilla.#Encoding
   case EncodingAnsi!
      wf_SetEncoding("ANSI")
   case EncodingUTF16BE!
      wf_SetEncoding("Unicode BE")
   case EncodingUTF16LE!
      wf_SetEncoding("Unicode")
   case EncodingUTF8!
      wf_SetEncoding("UTF-8")
end choose

If au_scintilla.of_IsOverType() Then
   st_overtype.Text = "OVR"
Else
   st_overtype.Text = "INS"
End If

end subroutine

on w_statusbar.create
this.st_encoding_border=create st_encoding_border
this.st_encoding=create st_encoding
this.st_linecol_border=create st_linecol_border
this.st_overtype_border=create st_overtype_border
this.ln_far_left=create ln_far_left
this.st_overtype=create st_overtype
this.st_linecol=create st_linecol
this.Control[]={this.st_encoding_border,&
this.st_encoding,&
this.st_linecol_border,&
this.st_overtype_border,&
this.ln_far_left,&
this.st_overtype,&
this.st_linecol}
end on

on w_statusbar.destroy
destroy(this.st_encoding_border)
destroy(this.st_encoding)
destroy(this.st_linecol_border)
destroy(this.st_overtype_border)
destroy(this.ln_far_left)
destroy(this.st_overtype)
destroy(this.st_linecol)
end on

event open;Environment le_env

GetEnvironment(le_env)

// determine position of window within microhelp bar
ii_width = st_overtype.x + st_overtype.width + 25
this.width = ii_width

// set object class name
choose case le_env.PBMajorRevision
   case 10, 11, 12, 17
      choose case le_env.PBMinorRevision
         case 5
            is_classname = "FNHELP" + &
               String(le_env.PBMajorRevision) + "5"
         case 6
            is_classname = "FNHELP" + &
               String(le_env.PBMajorRevision) + "6"
         case else
            is_classname = "FNHELP" + String(le_env.PBMajorRevision * 10)
      end choose
   case 19
      If le_env.PBMinorRevision < 2 Then
         is_classname = "FNHELP190"
      Else
         is_classname = "FNHELP"
      End If
   case else
      is_classname = "FNHELP"
end choose

// set parenthood
this.wf_setparent()

// position the window
this.wf_reposition()

end event

type st_encoding_border from statictext within w_statusbar
integer x = 334
integer y = 4
integer width = 311
integer height = 64
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
boolean border = true
borderstyle borderstyle = stylelowered!
boolean focusrectangle = false
end type

type st_encoding from statictext within w_statusbar
integer x = 338
integer y = 8
integer width = 302
integer height = 56
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long backcolor = 67108864
alignment alignment = center!
boolean focusrectangle = false
end type

type st_linecol_border from statictext within w_statusbar
integer x = 14
integer y = 4
integer width = 311
integer height = 64
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
boolean border = true
borderstyle borderstyle = stylelowered!
boolean focusrectangle = false
end type

type st_overtype_border from statictext within w_statusbar
integer x = 654
integer y = 4
integer width = 169
integer height = 64
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
boolean border = true
borderstyle borderstyle = stylelowered!
boolean focusrectangle = false
end type

type ln_far_left from line within w_statusbar
long linecolor = 16777215
integer linethickness = 4
integer beginy = 4
integer endy = 68
end type

type st_overtype from statictext within w_statusbar
integer x = 658
integer y = 8
integer width = 155
integer height = 56
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long backcolor = 79741120
alignment alignment = center!
boolean focusrectangle = false
end type

type st_linecol from statictext within w_statusbar
integer x = 18
integer y = 8
integer width = 302
integer height = 56
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long backcolor = 67108864
alignment alignment = center!
boolean focusrectangle = false
end type