The Progressbar_EX / Progressbar_BF, is also a canvas gadget (or an image / sprite)
It can be simple controlled in its primary functions with the PB Progressbar commands
Buttons and switches in innumerable variants can be easily defined as macros or procedures
Ultimate Canvas Gadget Library
-
- Enthusiast
- Posts: 617
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: Ultimate Canvas Gadget Library
it have some kind of gadget, where data can be changing like winhex editor do? it have some:
and when i click on 03 and put some data - pointer move to 04.
i am try to make this, but didnt understand how to detect third input symbol? for example you are click on 5:5 coordinates. it will open in a string gadget some value - and it is already selected value for easy replace by new 2 digits. so i press this 2 sybols - it replace old one... but i am continue press keyboard - so pointer must to shift to next value in a table - 6:5 and start replace his own value by this third symbols. yes, i know my explanation is suks... see as winhex work. you press some buttons on keyboard - cursour is jump between cells and replace old values. no need to press "next" value.
Code: Select all
00 01 02
03 04 05
i am try to make this, but didnt understand how to detect third input symbol? for example you are click on 5:5 coordinates. it will open in a string gadget some value - and it is already selected value for easy replace by new 2 digits. so i press this 2 sybols - it replace old one... but i am continue press keyboard - so pointer must to shift to next value in a table - 6:5 and start replace his own value by this third symbols. yes, i know my explanation is suks... see as winhex work. you press some buttons on keyboard - cursour is jump between cells and replace old values. no need to press "next" value.
Code: Select all
Enumeration
#Window
#PEEditorColorGadImg
#PEEditorPalitraImg
#PEEditorUpExportImg
#ButTank
#File
#IcEdKisto4kaImg
#IcEdZalivkaImg
#IcEdCopyImg
#IcEdPas
#IcEdPasteWithPalImgteImg
#IcEdPasteImg
#IcEdPasteWithPalImg
#IcEdOpenImg
#SndErr
#Grafic
#GraficCont1
#GraficCont2
;{
#GHMatrixCanvas
#GHLayerFrame
#GHLayerOption1
#GHLayerOption2
#GHLayerOption3
#GHHousesFrame
#GHAtr
#GHOrd
#GHHrk
#GHFrm
#GHSrd
#GHElementsList
#GHConfigList
#GHElementsListAdd
#GHElementsListDel
#GHConfigListAdd
#GHConfigListDel
;{
#GHPal1Canv01
#GHPal1Canv02
#GHPal1Canv03
#GHPal1Canv04
#GHPal1Canv05
#GHPal1Canv06
#GHPal1Canv07
#GHPal1Canv08
#GHPal1Canv09
#GHPal1Canv10
#GHPal1Canv11
#GHPal1Canv12
#GHPal1Canv13
#GHPal1Canv14
#GHPal1Canv15
;}
;{
#GHPal2Canv01
#GHPal2Canv02
#GHPal2Canv03
#GHPal2Canv04
#GHPal2Canv05
#GHPal2Canv06
#GHPal2Canv07
#GHPal2Canv08
#GHPal2Canv09
#GHPal2Canv10
#GHPal2Canv11
#GHPal2Canv12
#GHPal2Canv13
#GHPal2Canv14
#GHPal2Canv15
#GHPal3Canv01
#GHPal3Canv02
#GHPal3Canv03
#GHPal3Canv04
#GHPal3Canv05
#GHPal3Canv06
#GHPal3Canv07
#GHPal3Canv08
#GHPal3Canv09
#GHPal3Canv10
#GHPal3Canv11
#GHPal3Canv12
#GHPal3Canv13
#GHPal3Canv14
#GHPal3Canv15
#GHPal4Canv01
#GHPal4Canv02
#GHPal4Canv03
#GHPal4Canv04
#GHPal4Canv05
#GHPal4Canv06
#GHPal4Canv07
#GHPal4Canv08
#GHPal4Canv09
#GHPal4Canv10
#GHPal4Canv11
#GHPal4Canv12
#GHPal4Canv13
#GHPal4Canv14
#GHPal4Canv15
;}
#WindowMHHAddElem
#MHHAddElemNames
#MHHAddElemFilePath
#MHHAddElemFilePathOpen
#MHHAddElemWidth
#MHHAddElemHeight
#MHHAddElemMatrixList
#MHHAddElemMatrixSave
#MHHAddElemDraw
#MHHAddElemFont
#MHHAddElemMatrixCanvas
#MHHAddElemMatrixImg
#MHHAddElemMatrixImg2
#MHHAddElemMatrixEdit
#MHHAddElemMatrixEditL
#MHHAddElemMatrixEditR
;}
#GraficHrkGad
#GraficAtrGad
#GraficOrdGad
#GraficFrmGad
#GraficSrdGad
EndEnumeration
Structure matrarry
Array y.a(0)
EndStructure
Structure matrarr
filename$
width.a
height.a
Array x.matrarry(0)
EndStructure
Global Dim MHHMatrixArray.matrarr(0)
Procedure MHHFillMatrixArray(width.a, height.a)
sz = ArraySize(MHHMatrixArray()) + 1
ReDim MHHMatrixArray(sz)
MHHMatrixArray(sz)\width = width
MHHMatrixArray(sz)\height = height
ReDim MHHMatrixArray(sz)\x(width)
For x = 0 To width
ReDim MHHMatrixArray(sz)\x(x)\y(height)
Next
tylenum = 1
For y = 0 To height-1
For x = 0 To width-1
MHHMatrixArray(sz)\x(x)\y(y) = tylenum
tylenum + 1
Next
Next
EndProcedure
Procedure MHHAddElementWindow()
DisableWindow(#Window, 1)
LoadFont(#MHHAddElemFont, "Arial", 5)
If OpenWindow(#WindowMHHAddElem, 100, 200, 500, 300, "Element", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered, WindowID(#Window))
TextGadget(#MHHAddElemNames, 30, 10, 400, 20, "matrix width height gfx file")
y = 30
ComboBoxGadget(#MHHAddElemMatrixList, 10, y, 70, 20)
AddGadgetItem(#MHHAddElemMatrixList, 0, "new")
SetGadgetState(#MHHAddElemMatrixList, 0)
StringGadget(#MHHAddElemWidth, 90, y, 50, 20, "12")
StringGadget(#MHHAddElemHeight, 150, y, 50, 20, "12")
ButtonGadget(#MHHAddElemDraw, 210, y, 50, 20, "draw")
StringGadget(#MHHAddElemFilePath, 280, y, 120, 20, "", #PB_String_ReadOnly)
ButtonGadget(#MHHAddElemFilePathOpen, 400, y, 50, 20, "open")
;ButtonGadget(#MHHAddElemMatrixSave, 395, y, 70, 20, "save matrix")
StringGadget(#MHHAddElemMatrixEdit, 50, 250, 50, 20, "")
SetGadgetAttribute(#MHHAddElemMatrixEdit, #PB_String_MaximumLength, 2)
ButtonGadget(#MHHAddElemMatrixEditL, 30, 250, 20, 20, "<")
ButtonGadget(#MHHAddElemMatrixEditR, 100, 250, 20, 20, ">")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
EvGadget = EventGadget()
Select EvGadget
Case #MHHAddElemFilePathOpen ; view
file$ = OpenFileRequester("Load gfx file file", "", "(*.bin)|*.bin", 1)
If file$
SetGadgetText(#MHHAddElemFilePath, file$)
EndIf
Case #MHHAddElemDraw
height = Val(GetGadgetText(#MHHAddElemHeight))
width = Val(GetGadgetText(#MHHAddElemWidth))
If width And height
; when new matrix - fill 01,02,03,....
MHHFillMatrixArray(width, height)
; create canvas with new size
CanvasGadget(#MHHAddElemMatrixCanvas, 10, 60, width * 12 - 1, height * 12 - 1)
sz = ArraySize(MHHMatrixArray())
If IsImage(#MHHAddElemMatrixImg)
FreeImage(#MHHAddElemMatrixImg)
EndIf
If CreateImage(#MHHAddElemMatrixImg, width * 12 - 1, height * 12 - 1)
If StartDrawing(ImageOutput(#MHHAddElemMatrixImg))
Box(0, 0, width * 12 - 1, height * 12 - 1, 0)
DrawingFont(FontID(#MHHAddElemFont))
For y = 0 To height
For x = 0 To width
DrawText(x*12+1, y*12+1, RSet(Hex( MHHMatrixArray(sz)\x(x)\y(y) ), 2, "0"))
tylenum + 1
Next
Next
StopDrawing()
; backup
If IsImage(#MHHAddElemMatrixImg2)
FreeImage(#MHHAddElemMatrixImg2)
EndIf
CopyImage(#MHHAddElemMatrixImg, #MHHAddElemMatrixImg2)
SetGadgetAttribute(#MHHAddElemMatrixCanvas, #PB_Canvas_Image, ImageID(#MHHAddElemMatrixImg))
EndIf
EndIf
EndIf
Case #MHHAddElemMatrixCanvas
MHHMatrixCoordX = GetGadgetAttribute(#MHHAddElemMatrixCanvas, #PB_Canvas_MouseX)
MHHMatrixCoordY = GetGadgetAttribute(#MHHAddElemMatrixCanvas, #PB_Canvas_MouseY)
Select EventType()
Case #PB_EventType_MouseMove
; grid round
MHHMatrixCoordX / 12 * 12
MHHMatrixCoordY / 12 * 12
; repaint only when change coordinates
If MHHMatrixCoordX <> oldMHHMatrixCoordX Or MHHMatrixCoordY <> oldMHHMatrixCoordY
oldMHHMatrixCoordX = MHHMatrixCoordX
oldMHHMatrixCoordY = MHHMatrixCoordY
If StartDrawing(CanvasOutput(#MHHAddElemMatrixCanvas))
DrawImage(ImageID(#MHHAddElemMatrixImg), 0, 0)
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY, 10, 1)
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY, 1, 10)
Line(oldMHHMatrixCoordX+10, oldMHHMatrixCoordY, 1, 10)
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY+10, 10, 1)
StopDrawing()
EndIf
EndIf
Case #PB_EventType_LeftButtonUp
; count array coordinates
MHHSelX = MHHMatrixCoordX / 12
MHHSelY = MHHMatrixCoordY / 12
tmp = MHHMatrixArray(sz)\x(MHHSelX)\y(MHHSelY)
SetGadgetText(#MHHAddElemMatrixEdit, RSet(Hex(tmp), 2, "0"))
SetActiveGadget(#MHHAddElemMatrixEdit)
; select text in a gadget
SendMessage_(GadgetID(#MHHAddElemMatrixEdit), #EM_SETSEL, 0, -1)
oldMHHMatrixCoordX = MHHMatrixCoordX / 12 * 12
oldMHHMatrixCoordY = MHHMatrixCoordY / 12 * 12
If StartDrawing(ImageOutput(#MHHAddElemMatrixImg))
DrawImage(ImageID(#MHHAddElemMatrixImg2), 0, 0)
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY, 10, 1, RGB(0, 200, 0))
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY, 1, 10, RGB(0, 200, 0))
Line(oldMHHMatrixCoordX+10, oldMHHMatrixCoordY, 1, 10, RGB(0, 200, 0))
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY+10, 10, 1, RGB(0, 200, 0))
StopDrawing()
SetGadgetAttribute(#MHHAddElemMatrixCanvas, #PB_Canvas_Image, ImageID(#MHHAddElemMatrixImg))
EndIf
EndSelect
Case #MHHAddElemMatrixEditR
newvalue = Val("$"+GetGadgetText(#MHHAddElemMatrixEdit))
If newvalue <> MHHMatrixArray(sz)\x(MHHSelX)\y(MHHSelY)
MHHMatrixArray(sz)\x(MHHSelX)\y(MHHSelY) = newvalue
If StartDrawing(ImageOutput(#MHHAddElemMatrixImg2))
Box(MHHSelX*12, MHHSelY*12, 12, 12, 0)
DrawingFont(FontID(#MHHAddElemFont))
DrawText(MHHSelX*12+1, MHHSelY*12+1, RSet(Hex( MHHMatrixArray(sz)\x(MHHSelX)\y(MHHSelY) ), 2, "0"))
StopDrawing()
EndIf
EndIf
; next item in a array
If MHHSelX < width-1
MHHSelX + 1
ElseIf MHHSelY < height-1
MHHSelX = 0
MHHSelY + 1
EndIf
oldvalue = MHHMatrixArray(sz)\x(MHHSelX)\y(MHHSelY)
SetGadgetText(#MHHAddElemMatrixEdit, RSet(Hex(oldvalue), 2, "0"))
SetActiveGadget(#MHHAddElemMatrixEdit)
SendMessage_(GadgetID(#MHHAddElemMatrixEdit), #EM_SETSEL, 0, -1)
oldMHHMatrixCoordX = MHHSelX * 12
oldMHHMatrixCoordY = MHHSelY * 12
If StartDrawing(ImageOutput(#MHHAddElemMatrixImg))
DrawImage(ImageID(#MHHAddElemMatrixImg2), 0, 0)
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY, 10, 1, RGB(0, 200, 0))
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY, 1, 10, RGB(0, 200, 0))
Line(oldMHHMatrixCoordX+10, oldMHHMatrixCoordY, 1, 10, RGB(0, 200, 0))
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY+10, 10, 1, RGB(0, 200, 0))
StopDrawing()
SetGadgetAttribute(#MHHAddElemMatrixCanvas, #PB_Canvas_Image, ImageID(#MHHAddElemMatrixImg))
EndIf
Case #MHHAddElemMatrixEditL
newvalue = Val("$"+GetGadgetText(#MHHAddElemMatrixEdit))
If newvalue <> MHHMatrixArray(sz)\x(MHHSelX)\y(MHHSelY)
MHHMatrixArray(sz)\x(MHHSelX)\y(MHHSelY) = newvalue
If StartDrawing(ImageOutput(#MHHAddElemMatrixImg2))
Box(MHHSelX*12, MHHSelY*12, 12, 12, 0)
DrawingFont(FontID(#MHHAddElemFont))
DrawText(MHHSelX*12+1, MHHSelY*12+1, RSet(Hex( MHHMatrixArray(sz)\x(MHHSelX)\y(MHHSelY) ), 2, "0"))
StopDrawing()
EndIf
EndIf
; back in a array
If MHHSelX > 0
MHHSelX - 1
ElseIf MHHSelY > 0
MHHSelX = width-1
MHHSelY - 1
EndIf
oldvalue = MHHMatrixArray(sz)\x(MHHSelX)\y(MHHSelY)
SetGadgetText(#MHHAddElemMatrixEdit, RSet(Hex(oldvalue), 2, "0"))
SetActiveGadget(#MHHAddElemMatrixEdit)
SendMessage_(GadgetID(#MHHAddElemMatrixEdit), #EM_SETSEL, 0, -1)
oldMHHMatrixCoordX = MHHSelX * 12
oldMHHMatrixCoordY = MHHSelY * 12
If StartDrawing(ImageOutput(#MHHAddElemMatrixImg))
DrawImage(ImageID(#MHHAddElemMatrixImg2), 0, 0)
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY, 10, 1, RGB(0, 200, 0))
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY, 1, 10, RGB(0, 200, 0))
Line(oldMHHMatrixCoordX+10, oldMHHMatrixCoordY, 1, 10, RGB(0, 200, 0))
Line(oldMHHMatrixCoordX, oldMHHMatrixCoordY+10, 10, 1, RGB(0, 200, 0))
StopDrawing()
SetGadgetAttribute(#MHHAddElemMatrixCanvas, #PB_Canvas_Image, ImageID(#MHHAddElemMatrixImg))
EndIf
EndSelect
Case #PB_Event_CloseWindow
ElementQuit = 1
CloseWindow(#WindowMHHAddElem)
EndSelect
Until ElementQuit = 1
EndIf
DisableWindow(#Window, 0)
SetActiveWindow(#Window)
UseGadgetList(WindowID(#Window))
EndProcedure
If OpenWindow(#Window, 100, 200, 10, 10, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
MHHAddElementWindow()
EndIf
Re: Ultimate Canvas Gadget Library
If you know, when the second key is pressed.... do the same, that you do if the user klicks on the "next" button automaticly.
Maybe you can see, how Celtic88 made it on his HexEdit Gadget
Maybe you can see, how Celtic88 made it on his HexEdit Gadget
-
- Enthusiast
- Posts: 617
- Joined: Fri Feb 20, 2009 9:24 am
- Location: Almaty (Kazakhstan. not Borat, but Triple G)
- Contact:
Re: Ultimate Canvas Gadget Library
cool hex editor... but probably it is hex viewer, than editor... or i am just didnt see how to change some data on that field.
so how to detect that pressing 2 symbols for activate shift? by event - on change + Len? on every change check Len - if it is = 2, make shift? and probably i need direction switcher. i mean now i am shift to left. but sometimes my data need to lay as vertical.
will try to do that.
btw - now, when size of field is changes - i am press draw button and it is create Canvas gadget again with same id. it is safely? or i need to before use freegadget, then recreate again, for avoid memory leak?
so how to detect that pressing 2 symbols for activate shift? by event - on change + Len? on every change check Len - if it is = 2, make shift? and probably i need direction switcher. i mean now i am shift to left. but sometimes my data need to lay as vertical.
will try to do that.
btw - now, when size of field is changes - i am press draw button and it is create Canvas gadget again with same id. it is safely? or i need to before use freegadget, then recreate again, for avoid memory leak?