home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2003 April
/
Chip_2003-04_cd1.bin
/
ctenari
/
Balikova
/
prikl.bas
< prev
next >
Wrap
BASIC Source File
|
2003-01-29
|
6KB
|
288 lines
$APPTYPE GUI
$TYPECHECK ON
$OPTIMIZE ON
$ESCAPECHARS ON
'º!Incl
$INCLUDE "RAPIDQ.INC"
'º!Res
' V tomto programu nejsou ₧ßdnΘ grafickΘ soubory
'º!Const
CONST WM_SYSCOMMAND = &H0112
'º!DimVar
DIM FileName AS STRING
FileName = "UNTITLED"
DIM CountFiles AS BYTE
CountFiles = 0
'º!DecF
DECLARE FUNCTION Setfocus Lib "user32" Alias "SetFocus"(hwnd As Long) As Long
'º!DecSub
DECLARE SUB ExitEditorClick
DECLARE SUB NewClick
DECLARE SUB OpenClick
DECLARE SUB SaveAsClick
DECLARE SUB SaveClick
DECLARE SUB CopyClick
DECLARE SUB CutClick
DECLARE SUB PasteClick
DECLARE SUB SelectAllClick
DECLARE SUB Reopen1Click
DECLARE SUB Reopen2Click
DECLARE SUB Reopen3Click
DECLARE SUB FindText
DECLARE SUB FindClick
DECLARE SUB FormResize
DECLARE SUB RichShowXY
'º!CreateObj
CREATE DialogBox AS QForm
BorderStyle = bsDialog
Caption = "Search..."
Width = 300
Height = 80
Center
END CREATE
CREATE EditBox AS QEdit
Parent = DialogBox
Top = 15
Left = 20
Width = 170
END CREATE
CREATE Button AS QButton
Parent = DialogBox
Caption = "&OK"
Top = 13
Left = 210
Width = 70
END CREATE
CREATE MainForm AS QForm
Caption = "RQ Notepad"
Width = 500
Height = 400
Center
END CREATE
CREATE RichEdit AS QRichEdit
Parent = MainForm
Align = alClient
ScrollBars = ssBoth
PlainText = True
WordWrap = False
OnKeyUp = RichShowXY
OnMouseMove = RichShowXY
END CREATE
CREATE MainMenu AS QMainMenu
Parent = MainForm
CREATE File AS QMenuItem
Caption = "&File"
CREATE New AS QMenuItem
Caption = "&New"
OnClick = NewClick
END CREATE
CREATE Open AS QMenuItem
Caption = "&Open"
OnClick = OpenClick
END CREATE
CREATE ReOpen AS QMenuItem
Caption = "&ReOpen"
Enabled = False
END CREATE
CREATE Save AS QMenuItem
Caption = "&Save"
OnClick = SaveClick
END CREATE
CREATE SaveAs AS QmenuItem
Caption = "Save &As..."
OnClick = SaveAsClick
END CREATE
CREATE Break1 AS QMenuItem
Caption ="-"
END CREATE
CREATE ExitEditor AS QMenuItem
Caption = "E&xit"
OnClick = ExitEditorClick
END CREATE
END CREATE
CREATE Edit AS QMenuItem
Caption = "&Edit"
CREATE Copy AS QMenuItem
Caption = "&Copy"
OnClick = CopyClick
ShortCut = "CTRL+C"
END CREATE
CREATE Cut AS QMenuItem
Caption = "Cu&t"
OnClick = CutClick
ShortCut = "CTRL+X"
END CREATE
CREATE Paste AS QMenuItem
Caption = "&Paste"
OnClick = PasteClick
ShortCut = "CTRL+V"
END CREATE
CREATE SelectAll AS QMenuItem
Caption = "&Select All"
OnClick = SelectAllClick
ShortCut = "CTRL+A"
END CREATE
END CREATE
CREATE Search AS QMenuItem
Caption = "&Search"
CREATE Find AS QMenuItem
Caption = "&Find"
OnClick = FindClick
END CREATE
END CREATE
END CREATE
DIM ReOpen1 AS QMenuItem
ReOpen1.Caption = ""
ReOpen1.OnClick = Reopen1Click
DIM ReOpen2 AS QMenuItem
ReOpen2.Caption = ""
ReOpen2.OnClick = Reopen2Click
DIM ReOpen3 AS QMenuItem
ReOpen3.Caption = ""
ReOpen3.OnClick = Reopen3Click
CREATE StatusBar AS QStatusBar
Parent = MainForm
AddPanels "",""
Panel(0).Width = 100
Panel(0).Alignment = taCenter
END CREATE
'º!Func
' V tomto programu nejsou ₧ßdnΘ vlastnφ funkce
'º!Sub
SUB ExitEditorClick
MainForm.Close
END SUB
SUB NewClick
RichEdit.Clear
FileName = "UNTITLED"
END SUB
SUB OpenClick
DIM OpenDialog AS QOpenDialog
IF OpenDialog.Execute THEN
FileName = OpenDialog.FileName
RichEdit.LoadFromFile FileName
IF CountFiles = 0 THEN
ReOpen.Enabled = True
ReOpen1.Caption = "&1. "+FileName
ReOpen.Insert 0, ReOpen1
ELSEIF CountFiles = 1 THEN
ReOpen2.Caption = "&2. "+FileName
ReOpen.Insert 1, ReOpen2
ELSEIF CountFiles = 2 THEN
ReOpen3.Caption = "&3. "+FileName
ReOpen.Insert 2, ReOpen3
ELSE
CountFiles = CountFiles - 1
ReOpen1.Caption = "&1. "+RIGHT$(ReOpen2.Caption, LEN(ReOpen2.Caption)-4)
ReOpen2.Caption = "&2. "+RIGHT$(ReOpen3.Caption, LEN(ReOpen3.Caption)-4)
ReOpen3.Caption = "&3. "+FileName
END IF
CountFiles = CountFiles + 1
RichEdit.Modified = False
END IF
END SUB
SUB SaveAsClick
DIM SaveDialog AS QSaveDialog
IF SaveDialog.Execute THEN
RichEdit.SaveToFile SaveDialog.FileName
END IF
END SUB
SUB SaveClick
IF FileName = "UNTITLED" THEN
SaveAsClick
ELSE
RichEdit.SaveToFile FileName
END IF
END SUB
SUB CopyClick
RichEdit.CopyToClipBoard
END SUB
SUB CutClick
RichEdit.CutToClipBoard
END SUB
SUB PasteClick
RichEdit.PasteFromClipBoard
END SUB
SUB SelectAllClick
RichEdit.SelectAll
END SUB
SUB Reopen1Click
IF RichEdit.Modified THEN
SHOWMESSAGE "Abandoning changes"
END IF
RichEdit.LoadFromFile RIGHT$(ReOpen1.Caption, LEN(ReOpen1.Caption)-4)
RichEdit.Modified = False
END SUB
SUB Reopen2Click
IF RichEdit.Modified THEN
SHOWMESSAGE "Abandoning changes"
END IF
RichEdit.LoadFromFile RIGHT$(ReOpen2.Caption, LEN(ReOpen2.Caption)-4)
RichEdit.Modified = False
END SUB
SUB Reopen3Click
IF RichEdit.Modified THEN
SHOWMESSAGE "Abandoning changes"
END IF
RichEdit.LoadFromFile RIGHT$(ReOpen3.Caption, LEN(ReOpen3.Caption)-4)
RichEdit.Modified = False
END SUB
SUB FindText
RichEdit.SelStart = INSTR(UCASE$(RichEdit.Text), UCASE$(EditBox.Text))-1
IF RichEdit.SelStart > 0 THEN
DIM Font AS QFont
Font.AddStyles(fsBold, fsItalic)
RichEdit.SelLength = LEN(EditBox.Text)
RichEdit.SelAttributes = Font
DialogBox.Close
ELSE
SHOWMESSAGE EditBox.Text+" not found."
END IF
END SUB
SUB FindClick
DialogBox.ShowModal
END SUB
SUB FormResize
RichEdit.Width = MainForm.ClientWidth
RichEdit.Height = MainForm.ClientHeight
END SUB
SUB RichShowXY
StatusBar.Panel(0).Caption = STR$(RichEdit.WhereY+1)+" : "+STR$(RichEdit.WhereX+1)
END SUB
'º!Execute
MainForm.ShowModal