File: w_find.srw
Size: 8819
Date: Mon, 08 Jul 2019 20:16:42 +0200
$PBExportHeader$w_find.srw
forward
global type w_find from window
end type
type cbx_ignorecomment from checkbox within w_find
end type
type cbx_regex from checkbox within w_find
end type
type cb_markall from commandbutton within w_find
end type
type ddlb_find from u_ddlb_history within w_find
end type
type cbx_wordstart from checkbox within w_find
end type
type cbx_backwards from checkbox within w_find
end type
type cbx_whole from checkbox within w_find
end type
type cbx_case from checkbox within w_find
end type
type st_find from statictext within w_find
end type
type cb_close from commandbutton within w_find
end type
type cb_findnext from commandbutton within w_find
end type
end forward

global type w_find from window
integer width = 1806
integer height = 564
boolean titlebar = true
string title = "Find Text"
boolean controlmenu = true
windowtype windowtype = response!
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cbx_ignorecomment cbx_ignorecomment
cbx_regex cbx_regex
cb_markall cb_markall
ddlb_find ddlb_find
cbx_wordstart cbx_wordstart
cbx_backwards cbx_backwards
cbx_whole cbx_whole
cbx_case cbx_case
st_find st_find
cb_close cb_close
cb_findnext cb_findnext
end type
global w_find w_find

type variables

end variables

on w_find.create
this.cbx_ignorecomment=create cbx_ignorecomment
this.cbx_regex=create cbx_regex
this.cb_markall=create cb_markall
this.ddlb_find=create ddlb_find
this.cbx_wordstart=create cbx_wordstart
this.cbx_backwards=create cbx_backwards
this.cbx_whole=create cbx_whole
this.cbx_case=create cbx_case
this.st_find=create st_find
this.cb_close=create cb_close
this.cb_findnext=create cb_findnext
this.Control[]={this.cbx_ignorecomment,&
this.cbx_regex,&
this.cb_markall,&
this.ddlb_find,&
this.cbx_wordstart,&
this.cbx_backwards,&
this.cbx_whole,&
this.cbx_case,&
this.st_find,&
this.cb_close,&
this.cb_findnext}
end on

on w_find.destroy
destroy(this.cbx_ignorecomment)
destroy(this.cbx_regex)
destroy(this.cb_markall)
destroy(this.ddlb_find)
destroy(this.cbx_wordstart)
destroy(this.cbx_backwards)
destroy(this.cbx_whole)
destroy(this.cbx_case)
destroy(this.st_find)
destroy(this.cb_close)
destroy(this.cb_findnext)
end on

event open;Long ll_len

If Len(gn_app.is_findstr) > 0 Then
   If gn_app.ib_RegEx = False Then
      ddlb_find.text = gn_app.is_findstr
      ddlb_find.AddItem(gn_app.is_findstr)
   End If
End If

cbx_case.checked           = gn_app.ib_MatchCase
cbx_whole.checked          = gn_app.ib_WholeWord
cbx_wordstart.checked      = gn_app.ib_WordStart
cbx_regex.checked          = gn_app.ib_RegEx
cbx_backwards.checked      = gn_app.ib_Backwards
cbx_ignorecomment.checked  = gn_app.ib_IgnoreComment

ll_len = Len(ddlb_find.Text)
If ll_len = 0 Then
   ddlb_find.of_load("find_string", True)
Else
   ddlb_find.SelectText(1, ll_len + 1)
   ddlb_find.of_load("find_string", False)
End If

If Len(ddlb_find.Text) > 0 Then
   cb_findnext.enabled = True
End If

end event

type cbx_ignorecomment from checkbox within w_find
integer x = 622
integer y = 352
integer width = 517
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Ignore Comment"
end type

type cbx_regex from checkbox within w_find
integer x = 37
integer y = 352
integer width = 535
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Regular Expression"
end type

type cb_markall from commandbutton within w_find
integer x = 1390
integer y = 168
integer width = 334
integer height = 92
integer taborder = 30
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "&Mark All"
end type

event clicked;// search for all occurrences

Integer li_hits

gn_app.is_findstr = ddlb_find.text

gn_app.ib_MatchCase     = cbx_case.checked
gn_app.ib_WholeWord     = cbx_whole.checked
gn_app.ib_WordStart     = cbx_wordstart.checked
gn_app.ib_RegEx         = cbx_regex.checked
gn_app.ib_Backwards     = cbx_backwards.checked
gn_app.ib_IgnoreComment = cbx_ignorecomment.checked

ddlb_find.of_save("find_string")

w_main.uo_editor.of_SetFindOptions(gn_app.ib_MatchCase, gn_app.ib_WholeWord, &
                     gn_app.ib_WordStart, gn_app.ib_RegEx, &
                     gn_app.ib_Backwards, gn_app.ib_IgnoreComment)

li_hits = w_main.uo_editor.of_FindAll(gn_app.is_findstr)

w_main.SetMicroHelp("Number of items found: " + String(li_hits))

Close(Parent)

end event

type ddlb_find from u_ddlb_history within w_find
integer x = 183
integer y = 36
integer width = 1138
boolean autohscroll = true
integer accelerator = 110
end type

event editchanged;call super::editchanged;If this.text = "" Then
   cb_findnext.enabled = False
   cb_findnext.default = False
Else
   cb_findnext.enabled = True
   cb_findnext.default = True
End If

end event

event selectionchanged;call super::selectionchanged;If this.text = "" Then
   cb_findnext.enabled = False
   cb_findnext.default = False
Else
   cb_findnext.enabled = True
   cb_findnext.default = True
End If

end event

type cbx_wordstart from checkbox within w_find
integer x = 622
integer y = 256
integer width = 517
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Word Starts With"
end type

type cbx_backwards from checkbox within w_find
integer x = 622
integer y = 160
integer width = 517
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Search Backwards"
end type

type cbx_whole from checkbox within w_find
integer x = 37
integer y = 256
integer width = 375
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Whole word"
end type

type cbx_case from checkbox within w_find
integer x = 37
integer y = 160
integer width = 361
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Match case"
end type

type st_find from statictext within w_find
integer x = 37
integer y = 48
integer width = 151
integer height = 68
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Fi&nd:"
boolean focusrectangle = false
end type

type cb_close from commandbutton within w_find
integer x = 1390
integer y = 304
integer width = 334
integer height = 92
integer taborder = 40
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "&Close"
boolean cancel = true
end type

event clicked;Close(Parent)

end event

type cb_findnext from commandbutton within w_find
integer x = 1390
integer y = 32
integer width = 334
integer height = 92
integer taborder = 20
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
boolean enabled = false
string text = "&Find Next"
boolean default = true
end type

event clicked;gn_app.is_findstr = ddlb_find.text

gn_app.ib_MatchCase     = cbx_case.checked
gn_app.ib_WholeWord     = cbx_whole.checked
gn_app.ib_WordStart     = cbx_wordstart.checked
gn_app.ib_RegEx         = cbx_regex.checked
gn_app.ib_Backwards     = cbx_backwards.checked
gn_app.ib_IgnoreComment = cbx_ignorecomment.checked

ddlb_find.of_save("find_string")

w_main.Event m_findnext()

end event