Skip to content
Snippets Groups Projects
Commit 99b261a6 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

- encode all strings as UTF8

- always show the parameters on iPad, even in portrait
parent 6c2a681f
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
@end @end
@interface ModelViewController () @interface ModelViewController ()
@property (strong, nonatomic) UIPopoverController *masterPopoverController;
- (void)configureView; - (void)configureView;
@end @end
...@@ -34,10 +33,6 @@ ...@@ -34,10 +33,6 @@
// Update the view. // Update the view.
[self configureView]; [self configureView];
} }
if (self.masterPopoverController != nil) {
[self.masterPopoverController dismissPopoverAnimated:YES];
}
} }
- (void)configureView - (void)configureView
...@@ -50,7 +45,6 @@ ...@@ -50,7 +45,6 @@
-(void)viewWillAppear:(BOOL)animated -(void)viewWillAppear:(BOOL)animated
{ {
//if(self.initialModel != nil) {
if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]) { if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]) {
_loadingAlert = [[UIAlertView alloc] initWithTitle:@"Please wait..." message: @"The model is loading" delegate: self cancelButtonTitle: nil otherButtonTitles: nil]; _loadingAlert = [[UIAlertView alloc] initWithTitle:@"Please wait..." message: @"The model is loading" delegate: self cancelButtonTitle: nil otherButtonTitles: nil];
[_loadingAlert show]; [_loadingAlert show];
...@@ -316,7 +310,7 @@ ...@@ -316,7 +310,7 @@
-(void)addError:(std::string)msg -(void)addError:(std::string)msg
{ {
[_errors addObject:[NSString stringWithCString:msg.c_str() encoding:[NSString defaultCStringEncoding]]]; [_errors addObject:[NSString stringWithCString:msg.c_str() encoding:NSUTF8StringEncoding]];
} }
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
...@@ -335,20 +329,13 @@ ...@@ -335,20 +329,13 @@
#pragma mark - Split view #pragma mark - Split view
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(@"Parameters", @"Parameters");
[self.navigationItem setLeftBarButtonItem:barButtonItem];
self.masterPopoverController = popoverController;
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem -(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{ {
// Called when the view is shown again in the split view, invalidating the button and popover controller. return NO;
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;
} }
void messageFromCpp (void *self, std::string level, std::string msg) void messageFromCpp (void *self, std::string level, std::string msg)
{ {
if(level == "RequestRender"){ if(level == "RequestRender"){
...@@ -356,7 +343,7 @@ void messageFromCpp (void *self, std::string level, std::string msg) ...@@ -356,7 +343,7 @@ void messageFromCpp (void *self, std::string level, std::string msg)
[[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParameters" object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParameters" object:nil];
} }
else if(level == "Progress"){ else if(level == "Progress"){
[(__bridge id)self performSelectorOnMainThread:@selector(setProgress:) withObject:[NSString stringWithCString:msg.c_str() encoding:[NSString defaultCStringEncoding]] waitUntilDone:YES]; [(__bridge id)self performSelectorOnMainThread:@selector(setProgress:) withObject:[NSString stringWithCString:msg.c_str() encoding:NSUTF8StringEncoding] waitUntilDone:YES];
} }
else if(level == "Error") else if(level == "Error")
[(__bridge id)self addError:msg]; [(__bridge id)self addError:msg];
......
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
[showHide setTag:i]; [showHide setTag:i];
[showHide addTarget:self action:@selector(PViewVisible:) forControlEvents:UIControlEventValueChanged]; [showHide addTarget:self action:@selector(PViewVisible:) forControlEvents:UIControlEventValueChanged];
[lbl setBackgroundColor: [UIColor clearColor]]; [lbl setBackgroundColor: [UIColor clearColor]];
[lbl setText:[NSString stringWithCString:PView::list[i]->getData()->getName().c_str() encoding:[NSString defaultCStringEncoding]]]; [lbl setText:[NSString stringWithCString:PView::list[i]->getData()->getName().c_str() encoding:NSUTF8StringEncoding]];
[cell addSubview:showHide]; [cell addSubview:showHide];
[cell addSubview:lbl]; [cell addSubview:lbl];
} }
......
...@@ -59,8 +59,8 @@ ...@@ -59,8 +59,8 @@
self = [super init]; self = [super init];
if(self){ if(self){
label.alpha = (string.getReadOnly())? 0.439216f : 1.0f; label.alpha = (string.getReadOnly())? 0.439216f : 1.0f;
[label setText:[NSString stringWithCString:string.getShortName().c_str() encoding:[NSString defaultCStringEncoding]]]; [label setText:[NSString stringWithCString:string.getShortName().c_str() encoding:NSUTF8StringEncoding]];
name = [NSString stringWithCString:string.getName().c_str() encoding:[NSString defaultCStringEncoding]]; name = [NSString stringWithCString:string.getName().c_str() encoding:NSUTF8StringEncoding];
button = [UIButton buttonWithType:UIButtonTypeSystem]; button = [UIButton buttonWithType:UIButtonTypeSystem];
[button addTarget:self action:@selector(selectValue) forControlEvents:UIControlEventTouchDown]; [button addTarget:self action:@selector(selectValue) forControlEvents:UIControlEventTouchDown];
[button setTitle:[NSString stringWithFormat:@"%s", string.getValue().c_str()] forState:UIControlStateNormal]; [button setTitle:[NSString stringWithFormat:@"%s", string.getValue().c_str()] forState:UIControlStateNormal];
...@@ -131,8 +131,8 @@ ...@@ -131,8 +131,8 @@
self = [super init]; self = [super init];
if(self) { if(self) {
label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; label.alpha = (number.getReadOnly())? 0.439216f : 1.0f;
[label setText:[NSString stringWithCString:number.getShortName().c_str() encoding:[NSString defaultCStringEncoding]]]; [label setText:[NSString stringWithCString:number.getShortName().c_str() encoding:NSUTF8StringEncoding]];
name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]]; name = [NSString stringWithCString:number.getName().c_str() encoding:NSUTF8StringEncoding];
button = [UIButton buttonWithType:UIButtonTypeSystem]; button = [UIButton buttonWithType:UIButtonTypeSystem];
[button addTarget:self action:@selector(selectValue) forControlEvents:UIControlEventTouchDown]; [button addTarget:self action:@selector(selectValue) forControlEvents:UIControlEventTouchDown];
[button setTitle:[NSString stringWithFormat:@"%s", number.getValueLabel(number.getValue()).c_str()] forState:UIControlStateNormal]; [button setTitle:[NSString stringWithFormat:@"%s", number.getValueLabel(number.getValue()).c_str()] forState:UIControlStateNormal];
...@@ -218,8 +218,8 @@ ...@@ -218,8 +218,8 @@
self = [super init]; self = [super init];
if(self) { if(self) {
label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; label.alpha = (number.getReadOnly())? 0.439216f : 1.0f;
[label setText:[NSString stringWithCString:number.getShortName().c_str() encoding:[NSString defaultCStringEncoding]]]; [label setText:[NSString stringWithCString:number.getShortName().c_str() encoding:NSUTF8StringEncoding]];
name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]]; name = [NSString stringWithCString:number.getName().c_str() encoding:NSUTF8StringEncoding];
checkbox = [[UISwitch alloc] init]; checkbox = [[UISwitch alloc] init];
[checkbox setOn:(number.getValue() == 1)]; [checkbox setOn:(number.getValue() == 1)];
[checkbox addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventValueChanged]; [checkbox addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventValueChanged];
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
{ {
self = [super init]; self = [super init];
if(self) { if(self) {
name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]]; name = [NSString stringWithCString:number.getName().c_str() encoding:NSUTF8StringEncoding];
label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; label.alpha = (number.getReadOnly())? 0.439216f : 1.0f;
stepper = [[UIStepper alloc] init]; stepper = [[UIStepper alloc] init];
[stepper setValue:number.getValue()]; [stepper setValue:number.getValue()];
...@@ -328,7 +328,7 @@ ...@@ -328,7 +328,7 @@
self = [super init]; self = [super init];
if(self) { if(self) {
label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; label.alpha = (number.getReadOnly())? 0.439216f : 1.0f;
name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]]; name = [NSString stringWithCString:number.getName().c_str() encoding:NSUTF8StringEncoding];
slider = [[UISlider alloc] init]; slider = [[UISlider alloc] init];
[slider setMaximumValue:number.getMax()]; [slider setMaximumValue:number.getMax()];
[slider setMinimumValue:number.getMin()]; [slider setMinimumValue:number.getMin()];
...@@ -336,7 +336,7 @@ ...@@ -336,7 +336,7 @@
//TODO add step ? //TODO add step ?
[slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpOutside]; [slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpOutside];
[slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpInside]; [slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventTouchUpInside];
[label setText:[NSString stringWithFormat:@"%@ %g", [NSString stringWithCString:number.getShortName().c_str() encoding:[NSString defaultCStringEncoding]], number.getValue()]]; [label setText:[NSString stringWithFormat:@"%@ %g", [NSString stringWithCString:number.getShortName().c_str() encoding:NSUTF8StringEncoding], number.getValue()]];
} }
return self; return self;
} }
...@@ -349,7 +349,7 @@ ...@@ -349,7 +349,7 @@
[slider setMaximumValue:number[0].getMax()]; [slider setMaximumValue:number[0].getMax()];
[slider setMinimumValue:number[0].getMin()]; [slider setMinimumValue:number[0].getMin()];
[slider setValue:number[0].getValue()]; [slider setValue:number[0].getValue()];
[label setText:[NSString stringWithFormat:@"%@ %g", [NSString stringWithCString:number[0].getShortName().c_str() encoding:[NSString defaultCStringEncoding]], number[0].getValue()]]; [label setText:[NSString stringWithFormat:@"%@ %g", [NSString stringWithCString:number[0].getShortName().c_str() encoding:NSUTF8StringEncoding], number[0].getValue()]];
} }
-(void)sliderValueChanged:(UISlider *)sender -(void)sliderValueChanged:(UISlider *)sender
...@@ -393,8 +393,8 @@ ...@@ -393,8 +393,8 @@
self = [super init]; self = [super init];
if(self) { if(self) {
label.alpha = (number.getReadOnly())? 0.439216f : 1.0f; label.alpha = (number.getReadOnly())? 0.439216f : 1.0f;
[label setText:[NSString stringWithCString:number.getShortName().c_str() encoding:[NSString defaultCStringEncoding]]]; [label setText:[NSString stringWithCString:number.getShortName().c_str() encoding:NSUTF8StringEncoding]];
name = [NSString stringWithCString:number.getName().c_str() encoding:[NSString defaultCStringEncoding]]; name = [NSString stringWithCString:number.getName().c_str() encoding:NSUTF8StringEncoding];
textbox = [[UITextField alloc] init]; textbox = [[UITextField alloc] init];
[textbox setBorderStyle:UITextBorderStyleRoundedRect]; [textbox setBorderStyle:UITextBorderStyleRoundedRect];
[textbox setText:[NSString stringWithFormat:@"%g", number.getValue()]]; [textbox setText:[NSString stringWithFormat:@"%g", number.getValue()]];
......
...@@ -179,7 +179,7 @@ ...@@ -179,7 +179,7 @@
// check for new/updated parameters (number) // check for new/updated parameters (number)
for(int i=0;i<number.size();i++) { for(int i=0;i<number.size();i++) {
if(!number[i].getVisible()) continue; // Do not add invisible parameter if(!number[i].getVisible()) continue; // Do not add invisible parameter
NSString *name=[NSString stringWithCString:number[i].getName().c_str() encoding:[NSString defaultCStringEncoding]]; NSString *name=[NSString stringWithCString:number[i].getName().c_str() encoding:NSUTF8StringEncoding];
NSString *sectiontitle = [[name componentsSeparatedByString:@"/"] objectAtIndex:0]; NSString *sectiontitle = [[name componentsSeparatedByString:@"/"] objectAtIndex:0];
Boolean found = false; Boolean found = false;
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
// check for new/updated parameters (string) // check for new/updated parameters (string)
for(int i=0;i<string.size();i++) { for(int i=0;i<string.size();i++) {
if(!string[i].getVisible() || string[i].getKind() == "file") continue; // Do not add invisible parameter if(!string[i].getVisible() || string[i].getKind() == "file") continue; // Do not add invisible parameter
NSString *name=[NSString stringWithCString:string[i].getName().c_str() encoding:[NSString defaultCStringEncoding]]; NSString *name=[NSString stringWithCString:string[i].getName().c_str() encoding:NSUTF8StringEncoding];
NSString *sectiontitle = [[name componentsSeparatedByString:@"/"] objectAtIndex:0]; NSString *sectiontitle = [[name componentsSeparatedByString:@"/"] objectAtIndex:0];
Boolean found = false; Boolean found = false;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
if(_pview) { if(_pview) {
[_Name setText:[NSString stringWithCString:_pview->getData()->getName().c_str() encoding:[NSString defaultCStringEncoding]]]; [_Name setText:[NSString stringWithCString:_pview->getData()->getName().c_str() encoding:NSUTF8StringEncoding]];
[_IntervalsType setDataSource:self]; [_IntervalsType setDataSource:self];
[_IntervalsType setDelegate:self]; [_IntervalsType setDelegate:self];
[_Intervals setText:[NSString stringWithFormat:@"%d",_pview->getOptions()->nbIso]]; [_Intervals setText:[NSString stringWithFormat:@"%d",_pview->getOptions()->nbIso]];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment