I want to change my blackberry screen GUI When i go from portrait to landscape mode.
protected void sublayout(int width, int height) {
// TODO Auto-generated method stub
if(Display.getOrientation()==Display.DIRECTION_PORTRAIT)
{
label.setText("Portrait");
}
else
{
label.setText("Landscape");
}
super.sublayout(width, height);
}
any help would be appreciated
Override sublayout on your screen, this is called whenever the orientation changes so you can use it to add/remove/change fields.
You can also use Display.getOrientation() to check the current orientation. You should also track the previous orientation within your application in case sublayout was called for a different reason.
You need to handle it manually. Whenever orientation changes in blackberry it calls the subLayout() method. There you can call invalidate method which will refresh your screen. But make sure that you are using relative layout instead of absolute layouts. It will automatically arrange the UI elements in your screen.
Related
I'm developing an application using GWT 2.3.0 and GXT 2.2.5.
I've got a LayoutContainer with ScrollMode set to AUTO and layout set to RowLayout with a horizontal orientation. It's used as the display window for my application.
The problem is that when the browser is resized so that the vertical scrollbar is displayed, the contents do not resize to account for it, causing the horizontal scrollbar to also appear even if it's not needed.
Is there a way to have the layout account for the space taken up by the scrollbar when rendering the widgets?
Ok that is a bit tricky to accomplise. I would do it like this:
On the Entry point (so that you know it is always active) add a resize handler to the Window
Window.addResizeHandler(new ResizeHandler() {
#Override
public void onResize(ResizeEvent event) {
// Fire Event containing the new size informing the application of the change
// Or resize the Layout container
}
}
If you choose to fire the event and you are using the MVP pattern then it is pretty simple to fire the event via the event bus and catch it wherever you like in the application.
The only catch here is that you might want to run the functions in onResize() inside a timer as in many cases the Window width/height reported have not the final value, due to the event being fired before the resizing completes.
I have a UISplitViewController which has a UINavigationController in the master and a UIViewController in the detail. When the device is orientated into landscape mode I want the normal behaviour to be preserved. I.e. The master gets shown in landscape and hidden in portrait.
However depending what the user clicks in the master depends on which UIViewController is loaded into the detail part of the UISplitViewController. What I would like is for the master to be hidden in landscape mode when a user clicks on a button in the detail UIViewController. The problem is I can't get this to work.
My delegate looks like this (have removed some lines for simpler viewing):
public class SplitControllerDelegate : UISplitViewControllerDelegate {
SplitViewController incomingController;
private bool hideMaster = false;
public override bool ShouldHideViewController (UISplitViewController svc,
UIViewController viewController,
UIInterfaceOrientation inOrientation) {
return hideMaster;
}
public void SetHideMaster(bool value) {
hideMaster = value;
}
}
I then call it from the detail UIViewController like
splitControllerDelegate.SetHideMaster(value);
However nothing changes. I'm unsure of how to make it perform the change? Should the master disappear immediately? What causes the WillHideViewController to fire?
Thanks
Mike
What you're trying to do cannot be done officially. ShouldHideViewController() is called only upon device rotation. So unless you rotate forth and back, your controller won't disappear.
You have various options:
Don't use UIListViewController but some other third party replacement
Use UIViewController containment feature of iOS5 and implement your own split view
Apply a hack to UISplitViewController
About the last point. You should be able to force ShouldHideViewController() being called if you set the Delegate property to NULL and then assign a new delegate. Afterwards, call the WillRotate() method of the split view controller using the current orientation.
I'd go for the 2nd option.
By design you cannot do much with the standard UISplitView, try that third party control :
https://github.com/mattgemmell/MGSplitViewController
I want to create a JavaFX table that, in the cells of one column, allows the user to edit XHTML text. I only need very basic formatting capabilities like bold, italic, striketrough.
I have already managed to implement this by using my own subclass of TableCell and using a WebView for each cell (HTMLEditor would of course have been another choice, but my guess is that for my requirements, WebView should be sufficient).
However, to make editing comfortable for the user, I need the following features:
1. The cell height needs to resize if the user enters multi-line text.
2. A context menu (or, if not possible, some other menu or button) should allow formatting parts of the text in a cell as described above (bold, italic..)
Has anybody been successful in implementing something similar ? I have seen suggestions on the web, but they rarely included code samples.
I have succedded doing something similar.
I figured I can share some of the basic clues that allowed me to achieve it.
Resize the whole WebView. For that, the whole WebView must be an editable html page. You achive that by setting contenteditable to true:
<body contenteditable='true' id='content'></body>
You can have a context menu over a webview. But it is something tricky, as you must first disable the original context menu associated to it.
WebView editView;
...
EventDispatcher originalDispatcher = editView.getEventDispatcher();
editView.setEventDispatcher(new WebmenuEventDispatcher(originalDispatcher));
And this is the event dispatcher class:
public class WebmenuEventDispatcher implements EventDispatcher {
private EventDispatcher originalDispatcher;
public WebmenuEventDispatcher(EventDispatcher originalDispatcher) {
this.originalDispatcher = originalDispatcher;
}
#Override
public Event dispatchEvent(Event event, EventDispatchChain tail) {
if (event instanceof MouseEvent) {
MouseEvent mouseEvent = (MouseEvent) event;
if (MouseButton.SECONDARY == mouseEvent.getButton()) {
mouseEvent.consume();
// Show our own menu
cmEdit.show(editView.getScene().getWindow(), mouseEvent.getScreenX(), mouseEvent.getScreenY());
}
}
return originalDispatcher.dispatchEvent(event, tail);
}
}
Now, for setting the font from within that menu, you need a bidirectional Java<->javascript bridge and use some javascript in the webview side.
My current understanding is that I have to assign the coordinates in the code itself instead of using the interface-builder. Is there a better way to do this?
Currently I am trying to handle a login view. It works well in portrait mode but in landscape mode few of the contents are hidden. Please suggest how to handle this.
Thanks
GuruPrasad R Gujjar.
You can handle this one of two ways. The first is what you suggested and change all of their frames, and second is to just have a separate view that is in landscape mode and switch it out on rotation.
For both cases you need to implement these two methods
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if (toInterfaceOrientation==UIInterfaceOrientationPortrait || toInterfaceOrientation== UIInterfaceOrientationPortraitUpsideDown) {
//put the portrait orientation here
self.usernameField.frame=CGRectMake(xPortraitLocation, yPortraitLocation, xWidth, yWidth);
...
}
else{
//do the same thing with everything but for landscape mode
}
With a seperate view you just switch them out by saying self.view=self.lanscapeView or self.portraitView.
If I am going to use the first method I sometimes like to create a fake view in the interface builder so that I can put all my items in the correct locations and look under the location tab which eliminates the guess and check of assigning the numbers.
Hope this helps.
I have a C++/CLI System::Windows::Forms::UserControl derived control which should only redraw (a small portion of) itself as new data is fed into it. For some reason though, the OnPaint mechanism is being called even when there's nothing to cause it external to the app.
Here's a snippet:
void Spectrogram::OnPaint(System::Windows::Forms::PaintEventArgs ^e)
{
// Overidden to stop the background being painted(?)
}
void Spectrogram::AddNewFFTData( float* data, int fataWidth )
{
Graphics^ gfx = CreateGraphics();
//now do some drawing
gfx->Dispose();
}
So I call the add data method to add some new data which should in theory write over the previous entry (which clears some highlighting) and write the new entry.
Back in the day I used to develop MFC/OpenGL apps and one of the first things I'd do would be to override the OnEraseBackground method. As far as I can see though, there's no obvious way of stopping it being erased. What have I missed?
You may be looking for Control.OnPaintBackground(). I've had to override that to do nothing for a custom control I wrote to bring a legacy MFC control into a Winforms project. Otherwise it would paint the background on top of the MFC control's paint job.
Essentially, in the .cpp:
void MyControl::OnPaintBackground(System::Windows::Forms::PaintEventArgs ^pevent)
{
// Do nothing, we don't want to paint over the native control.
// You may want to do something a little fancier for DesignMode
// if you use the winforms designer, though.
}
On the prototype:
protected:
void virtual OnPaintBackground(System::Windows::Forms::PaintEventArgs ^pevent) override;
What rectangle is being passed in to you via the event args? Is the entire control being invalidated, or just a portion of it?
Maybe it's a statement like this in the Form's constructor:
//do own background painting
this.SetStyle(ControlStyles.Opaque, true);
I think that prevents OnPaintBackground being invoked at all: so you don't need to override OnPaintBackground, and instead you can erase the background (or not) yourself in your OnPaint.
I did some stuff with the OnPaint lately (C#, if that matters), and I noticed it literally is drawn when a area of the control is revealed.
A better solution is to draw on a cached Bitmap, and draw it to the control every time dotNet asks for it.