How do I add buttons to Polybios display

Discuss PDF file handling with the Polybios plugin here
Post Reply
User avatar
Redlion
Posts: 93
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

How do I add buttons to Polybios display

Post by Redlion »

Hi,

I was trying to create an app that would let me look at PDF files in a directory, but I can not get it to work.
I wanted a Image on the left hand side and a list of pdf file in a listbox in the middle and buttons on the right.
I want to click on the file in the list look at the PDF and then click on one of several buttons to move the PDF file to a new directory location.

Every time I setup a user interface, I can click on the PDF file in the list the PDF is displayed but all other gadget disappear.

I have had a look at the examples but it only has the Brush with the PDF image and that's all.

Is it even possible to do this, does Polybios not allow any other gadgets on the display.

Can anyone shine some light on this problem.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How do I add buttons to Polybios display

Post by airsoftsoftwair »

How do you create the buttons and the list widget? Are you using a toolkit like MUI Royale or RapaGUI or is it all implemented manually?
User avatar
Redlion
Posts: 93
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: How do I add buttons to Polybios display

Post by Redlion »

Hi,
Sorry for the late replay. I was trying a manually created GUI first but could not get it to work. I tried RapaGUI and now have a basic working version.

It seems to be the layers that are the problem.

Here is the cut down code I have working.

Code: Select all

; *** Make sure we have at least Hollywood 8.0 ****************************************************
@VERSION 8,0

; *** Required plugins ****************************************************************************
@REQUIRE "polybios"
@REQUIRE "RapaGUI"

; *** Give me a 1024x860 screen with a nice gradient **********************************************
@DISPLAY {Width = 620, Height = 860, Color = $888888 }

SearchResult = {}
Global SDir$ = "C:/Users/Leo/Documents/PROGRAMS/Hollywood/EZISCAN-Move/"
Global docloaded = False

; *** SearchDIR ************************************************************************************
Function SearchDir()
SearchNumber = 1
OpenDirectory(1, "C:/Users/Leo/Documents/PROGRAMS/Hollywood/EZISCAN-Move/")
e = NextDirectoryEntry(1)
While e <> Nil
	If e.type = #DOSTYPE_FILE
		If FindStr(e.name, ".pdf") > 0
			SearchResult[SearchNumber] = e.name
			pos = moai.DoMethod("listpdf", "Insert", "Bottom",  e.name)
			SearchNumber = SearchNumber + 1
		EndIf
	EndIf
	e = NextDirectoryEntry(1)
Wend
CloseDirectory(1)
EndFunction

; *** Show a new page *****************************************************************************
Function p_ShowPage(idx)
	; we use the new 7.1 failsafe syntax here to signal that it's ok if those commands fail
	?FreeBrush(2)
	?RemoveLayer("page")
	; get PDF page as a vector brush from Polybios
	pdf.GetBrush(3, idx, 2, loadalpha)
	; and draw it!
	DisplayBrush(2,1,1)	
EndFunction

; *** Main event handler **************************************************************************	
Function p_EventFunc(msg)
	Switch msg.action
	Case "RapaGUI":
		Switch msg.attribute
		Case "Active":
			Switch msg.id
				Case "listpdf"
					column1$ = moai.DoMethod("listpdf", "GetEntry", "Active")
					moai.Set("pdfname", "Text", column1$)
					; clean up old document
					If docloaded
						FreeLayers(False)
						FreeBrush(2)
						pdf.CloseDocument(3)
						docloaded = False
					EndIf							
					; open new PDF
					pdf.OpenDocument(3, SDir$ .. column1$)
					; query number of pages in PDF document
					PDFTYPE = pdf.GetObjectType()
					pages = GetAttribute(PDFTYPE, 3, #PDFATTRPAGES)
					; show page and move status bar to the front	
					p_ShowPage(1)
					; we're ready
					docloaded = True
					curpage = 1								
			EndSwitch 
		EndSwitch
	EndSwitch
EndFunction

; *** dynamically create GUI from an external *.xml file definition *******************************
moai.CreateApp(FileToString("Eziscan-move.xml"))

; *** set up event handlers ***********************************************************************
InstallEventHandler({RapaGUI = p_EventFunc})

SearchDir()

; *** Escape **************************************************************************************
EscapeQuit(True)

; *** Layers **************************************************************************************
EnableLayers

; *** Program Loop ********************************************************************************
Repeat
	WaitEvent
Forever

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
	<window title=" EZISCAN Move " id="window">       
		<hgroup>
			<vgroup title="image" FrameTitle="Tester">
				<text id="pdfname" align="left">File Name goes here</text>
				<rectangle/>
				<hollywood display="1"/>
			</vgroup>				
			<vgroup title="Listpdf">
				<label align="left">PDF File to Move</label>
				<label id="selectedpdf"></label>
				<vspace height="20"></vspace>
				<label align="left">PDF File in Directory</label>
				<listview notify="active" id="listpdf" multiSelect="true">
					<column/>
				</listview>
			</vgroup>										
		</hgroup>
	</window>
</application>

I will try and add drag and drop to move selected PDF file to an other directory.
I will also play with the manually create GUI code and see if I can get it to work.

;

Code: Select all

; we use the new 7.1 failsafe syntax here to signal that it's ok if those commands fail
	?FreeBrush(2)
	?RemoveLayer("page")

This bit of code I don't understand.


Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How do I add buttons to Polybios display

Post by airsoftsoftwair »

Redlion wrote: Sat Nov 16, 2019 2:26 am This bit of code I don't understand.
What is it that you don't understand? The question mark syntax? That's just making sure that Hollywood doesn't exit in case these commands fail. See here.
Post Reply