Teechart ZoomIn and ZoomOut Button - activex

I am using the zooming of TCHART. In our application we have a Next and Prev Button using which user can do Zoom and UndoZoom. Can you let me know how I can fire zoom and undozoom event on click on this two Buttons

You can either call the even methods directly (see code below) or use the calls that will fire the events (see commented code below).
Private Sub Command1_Click()
TChart1_OnZoom
'TChart1.Zoom.ZoomRect 0, 0, 100, 100
End Sub
Private Sub Command2_Click()
TChart1_OnUndoZoom
'TChart1.Zoom.Undo
End Sub
Private Sub TChart1_OnUndoZoom()
TChart1.Header.Text.Clear
TChart1.Header.Text.Add "Unzoom!"
End Sub
Private Sub TChart1_OnZoom()
TChart1.Header.Text.Clear
TChart1.Header.Text.Add "Zoom!"
End Sub

Related

Scroll bar in LibreOffice dialog

I am trying to make an image picker component in LibreOffice.
I have a dialog that is dynamically filled with images. When the user clicks on one images, it should be selected and the dialog should be closed.
The problem is that the number of images is variable. So I need to enable scrolling in the dialog (so that the user can navigate through all images).
There seems to be some properties on the dialog object (Scrollbars, Scroll width, Scroll height, etc)
However, I cannot find a way to use them anywhere.
Any ideas?
The scrollbar is one of the Controls available through the dialog box editor. That is the easier way to put a ScrollBar on a dialog box. Just insert it like any other control. There is a harder way via DialogModel.addControl but that seems non-essential to answering this question.
If you add a scrollbar to the dialog box and run the dialog box, you will find it does nothing by default. The functionality (apparently) must be written into a macro. The appropriate triggering event is the While Adjusting event on the ScrollBar object, although it does not trigger the macro simply with the "Test Mode" function in the dialog editor. Running the dialog box through a macro triggers the While Adjusting event when the scroll arrows are triggered, when the slider area is clicked to move the slider, and when the slider itself is dragged. The Object variable returned by the scrollbar event contains a property .Value which is an absolute value between 0 and the EventObject.Model.ScrollValueMax, which allows you to manipulate the other objects on the page manually based on the position of the slider.
Yes, that's right, manipulate objects manually. The sole example I found, from the LibreOffice 4.5 SDK, does precisely this. Of course, it is not as bad as it sounds, because one can iterate through all of the objects on the page by reading the array Dialog.getControls(). In any event, the secret sauce of the example provided in the SDK is to define Static variables to save the initial positions of all of the objects you manipulate with the scrollbar and then simply index those initial positions based on a ratio derived from the scrollbar Value divided by the ScrollValueMax.
Here is a very simple working example of how to scroll. This requires a saved Dialog1 in the Standard library of your document, which contains an object ScrollBar1 (a vertical scrollbar) and Label1 anywhere in the dialog. The ScrollBar1 must be configured to execute the macro ScrBar subroutine (below) on the While Adjusting event. Open the dialog by executing the OpenDialog macro and the scrollbar will move the Label1 control up and down in proportion to the page.
Sub OpenDialog
DialogLibraries.LoadLibrary("Standard")
oVariable = DialogLibraries.Standard.Dialog1
oDialog1 = CreateUnoDialog( oVariable )
oDialog1.Execute()
End Sub
Sub ScrBar (oEventObj As Object)
Static bInit As Boolean
Static PositionLbl1Y0 As Long
oSrc = oEventObj.Source
oSrcModel = oSrc.Model
scrollRatio = oEventObj.Value / oSrcModel.ScrollValueMax
oContx = oSrc.Context
oContxModl = oContx.Model
oLbl1 = oContx.getControl("Label1")
oLbl1Model = oLbl1.Model
REM on initialization remember the position of the label
If bInit = False Then
bInit = True
PositionLbl1Y0 = oLbl1Model.PositionY
End If
oLbl1Model.PositionY = PositionLbl1Y0 - (scrollRatio * oContx.Size.Height)
End Sub
The example provided by the SDK does not run on my setup, but the principles are sound.
There appears to be a second improvised method closer to the functionality one might expect. This method uses the DialogModel.scrollTop property. The property appears to iterate the entire box up or down as a scroll based on the user input. There are two problems using this methodology, however. First, unless you put the scrollbar somewhere else, the scroll bar will scroll away along with the rest of the page. You will need to adjust the location of the scrollbar precisely to compensate for/negate the scrolling of the entire page. In the example below I tried but did not perfect this. Second, the property seems to miss inputs with frequency and easily goes out of alignment/ enters a maladjusted state. Perhaps you can overcome these limitations. Here is the example, relying on the same setup described above.
Sub ScrBar (oEventObj As Object)
Static scrollPos
oSrc = oEventObj.Source
oSrcModel = oSrc.Model
scrollRatio = oEventObj.Value / oSrcModel.ScrollValueMax
If IsEmpty(scrollPos) = False Then
scrollDiff = oEventObj.Value - scrollPos
Else
scrollDiff = oEventObj.Value
End If
scrollPos = oEventObj.Value
oContx = oSrc.Context
oContxModl = oContx.Model
oContxModl.scrollTop = scrollDiff * -1
oSrcModel.PositionY=(scrollRatio * oContx.Size.Height/5) * -1
End Sub
This (sort of) will scroll the contents of the entire dialog box, within limits and with the caveats noted above.

combobox steal keyboard from main window in pyqt

I'm writing a small pyqt program. I want the main window to to react to arrow movement. I added an event to my MainGui class, keyPressEvent, that handle this. The event work fine as long as I don't press certain buttons such as Key_Up or Key_Down are directed to my (currently only) QComboBox and not to my mainGui. I tried to give the focus to mainGui after each paintEvent but then I need to double click on buttons/comboBox.
Then I tried to use the MousePressEvent to check if a certain element is under the mouse. This work fine with the comboBox, but not with the button.
So, how can I direct key events to the mainGui or give the focus to QButtons?
I used eventFilter to identify when the mouse enter the QPushButton and give it focus:
def eventFilter(self,source,event):
if event.type() == QtCore.QEvent.HoverMove:
if self.execButton.underMouse():
self.execButton.setFocus()
self.keepFocus=False
else :
self.keepFocus=True
keepFocus is a flag I initialized in the __init__ function of the class. I added this part at the paintEvent function
if self.keepFocus:
self.setFocus()
else:
self.keepFocus = True
Now, I keep the focus at the MainGui and I only give it to the button when the mouse hove over it. If I do another action (like pressing a mouse button or a keyboard key) the focus is given back to the MainGui. This will create some buggy filling (For example, I need to press twice a keyboard key before the first response) but this is workable.

Stop a controlling object to move in Corona sdk

I have 2 controls in a space shooter-like game, which are left and right.
The ship does move left and right and when the ship moves to the left of x=40 (far left), it will revert back to x=40 and disable the "move left" function temporarily, BUT my problem is that whenever I move to the far left or the far right of the screen, from the middle of the screen, the ship moves further than x=40(about x=35) then moves back and continues this until I let go of the button.
How can I make it so that when I move the ship to the far left, it stops completely and only lets me to move right?
Here is my code:
function left:touch()
if(car01.x>40 and car01.x<280) then
motionx=-speed;
return false
end
end
left:addEventListener("touch",left)
function left:touch2()
motionx=0;
end
local function movecar(event)
if(car01.x>40 and car01.x<280) then
car01.x=car01.x+motionx
return false
elseif(car01.x==40) then
car01.angularVelocity=0
left:addEventListener("touch2",left)
car01.x=car01.x+motionx
elseif(car01.x<40) then
car01.x=40
end
end
Runtime:addEventListener("enterFrame",movecar)
local function stop(event)
if (event.phase=="ended") then
motionx=0;
return true
end
end
Runtime:addEventListener("touch",stop)
Is is is what you are looking for..?
Create a background(bg), left and right controls(left and right resp.). Then:
local function moveLeft()
if(car01.x>40)then
car01.x = car01.x - 40
end
end
left:addEventListener("tap",moveLeft)
local function moveRight()
if(car01.x<280)then
car01.x = car01.x + 40
end
end
right:addEventListener("tap",moveRight)
Keeo coding....... :)

How to display Half screen?

I am working on a project where I need to display a ListField that takes the top half of the screen when the user clicks on a menu item. It should display on top of the earlier screen. How can I implement it?
Here are my ideas:
Use ListField directly with the above screen size to required screen.
Use PopupScreen with ListField
Use some screensplit functionality to display half of the screen
PopupScreen is best fit for your question. Can you try and post the code that didn't work?
Another option is to use managers to split the screen (higher manager and lower manager) and to hold another two managers: one that will be displayed on click and one that will be used as a pointer to the displayed Manager. Then, when ever the replace event is fired you should call the following function:
void updateManagers(boolean click)
{
if(click)
{
currentManager = afterClickManager;
}
else
{
currrentManager = beforeClickManager;
}
invalidate();
}
Where currentManager is an instance of Manager and afterClickManager & beforeClickManager are instances of some class which extends Manager (no need to be the same class).
Note that you should add currentManager to your screen layout before using the invalidate function.

How to create the screen in optimized way?

Hello everybody I am trying to create a screen (to see the image click here)
I have set it's backround image also created required list components which are click able by extending Field class. Now my problem is I am not able to set that rounded white color as backround of the list. Please help me. And also because I am new to the blackberry please also tell me the optimized way to create this screen.
i think like this
1) header bar - create manager and embed 2 buttons and 1 label in it
2) bottom bar - create a global class that contains the buttons and define a method that responds to the click event of these buttons
call that class in this main screen
3) for middle part use a list field which is scrollable

Resources