|
@@ -306,36 +306,36 @@ typedef enum {
|
|
|
NSMutableDictionary * control =self.page_controlTemplate [[NSString stringWithFormat:@"control_%d",i] ];
|
|
NSMutableDictionary * control =self.page_controlTemplate [[NSString stringWithFormat:@"control_%d",i] ];
|
|
|
if([control[@"type"] isEqualToString:@"TextView"])
|
|
if([control[@"type"] isEqualToString:@"TextView"])
|
|
|
{
|
|
{
|
|
|
- [self addTextView:control destView:self.editControlView index:i];
|
|
|
|
|
|
|
+ [self addTextView:control destView:self.editControlView index:i update:NO];
|
|
|
}
|
|
}
|
|
|
else if([control[@"type"] isEqualToString:@"Button"])
|
|
else if([control[@"type"] isEqualToString:@"Button"])
|
|
|
{
|
|
{
|
|
|
- [self addButton:control destView:self.editControlView index:i];
|
|
|
|
|
|
|
+ [self addButton:control destView:self.editControlView index:i update:NO];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else if([control[@"type"] isEqualToString:@"Check"])
|
|
else if([control[@"type"] isEqualToString:@"Check"])
|
|
|
{
|
|
{
|
|
|
- [self addCheck:control destView:self.editControlView index:i];
|
|
|
|
|
|
|
+ [self addCheck:control destView:self.editControlView index:i update:NO];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else if([control[@"type"] isEqualToString:@"Signature"])
|
|
else if([control[@"type"] isEqualToString:@"Signature"])
|
|
|
{
|
|
{
|
|
|
- [self addSignatureButton:control destView:self.editControlView index:i];
|
|
|
|
|
|
|
+ [self addSignatureButton:control destView:self.editControlView index:i update:NO];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else if([control[@"type"] isEqualToString:@"Image"])
|
|
else if([control[@"type"] isEqualToString:@"Image"])
|
|
|
{
|
|
{
|
|
|
- [self addImage:control destView:self.editControlView index:i];
|
|
|
|
|
|
|
+ [self addImage:control destView:self.editControlView index:i update:NO];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else if([control[@"type"] isEqualToString:@"Label"])
|
|
else if([control[@"type"] isEqualToString:@"Label"])
|
|
|
{
|
|
{
|
|
|
- [self addLabel:control destView:self.editControlView index:i];
|
|
|
|
|
|
|
+ [self addLabel:control destView:self.editControlView index:i update:NO];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else if([control[@"type"] isEqualToString:@"DatePicker"])
|
|
else if([control[@"type"] isEqualToString:@"DatePicker"])
|
|
|
{
|
|
{
|
|
|
- [self addDatePicker:control destView:self.editControlView index:i];
|
|
|
|
|
|
|
+ [self addDatePicker:control destView:self.editControlView index:i update:NO];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -468,6 +468,7 @@ typedef enum {
|
|
|
int d_idx = [controlName intValue];
|
|
int d_idx = [controlName intValue];
|
|
|
return [self.view viewWithTag:d_idx+CONTROL_BASE];
|
|
return [self.view viewWithTag:d_idx+CONTROL_BASE];
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
-(UITextView*) findNextTV:(UITextView*)tv
|
|
-(UITextView*) findNextTV:(UITextView*)tv
|
|
|
{
|
|
{
|
|
|
long index = tv.tag - CONTROL_BASE;
|
|
long index = tv.tag - CONTROL_BASE;
|
|
@@ -495,12 +496,19 @@ typedef enum {
|
|
|
return nil;
|
|
return nil;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
--(void) addTextView:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
|
|
|
|
|
|
|
+-(void) addTextView:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
|
|
|
+
|
|
|
|
|
+ UITextView* tv = nil;
|
|
|
|
|
+ tv = (UITextView *)[destView viewWithTag:index+ CONTROL_BASE];
|
|
|
|
|
+ if (tv) {
|
|
|
|
|
+ tv.frame = srect;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ tv = [[UITextView alloc] initWithFrame:srect];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- UITextView* tv = [[UITextView alloc] initWithFrame:srect];
|
|
|
|
|
if([template[@"next_end"] boolValue])
|
|
if([template[@"next_end"] boolValue])
|
|
|
tv.returnKeyType=UIReturnKeyDefault;
|
|
tv.returnKeyType=UIReturnKeyDefault;
|
|
|
else
|
|
else
|
|
@@ -516,9 +524,12 @@ typedef enum {
|
|
|
// tv.editable = !isdisable;
|
|
// tv.editable = !isdisable;
|
|
|
tv.editable = true; // for update frame
|
|
tv.editable = true; // for update frame
|
|
|
NSString* text= template[@"value"];
|
|
NSString* text= template[@"value"];
|
|
|
- if(text.length==0)
|
|
|
|
|
- text=@" ";
|
|
|
|
|
- tv.text =text;
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+
|
|
|
|
|
+ if(text.length==0)
|
|
|
|
|
+ text=@" ";
|
|
|
|
|
+ tv.text =text;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
float tv_vmargin= [template[@"tv_vmargin"] floatValue];
|
|
float tv_vmargin= [template[@"tv_vmargin"] floatValue];
|
|
|
NSString* capital= template[@"capital"];
|
|
NSString* capital= template[@"capital"];
|
|
@@ -554,8 +565,10 @@ typedef enum {
|
|
|
[attr_str addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,attr_str.length)];
|
|
[attr_str addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,attr_str.length)];
|
|
|
|
|
|
|
|
tv.attributedText=attr_str;
|
|
tv.attributedText=attr_str;
|
|
|
- if([text isEqualToString:(@" ")])
|
|
|
|
|
- tv.text=@"";
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ if([text isEqualToString:(@" ")])
|
|
|
|
|
+ tv.text=@"";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
tv.tag = index+ CONTROL_BASE;
|
|
tv.tag = index+ CONTROL_BASE;
|
|
|
|
|
|
|
@@ -583,7 +596,11 @@ typedef enum {
|
|
|
|
|
|
|
|
//UIColorFromARGB(0x4066ccff);
|
|
//UIColorFromARGB(0x4066ccff);
|
|
|
|
|
|
|
|
- tv.backgroundColor = UIColorFromRGB(TV_BG);//[UIColor lightGrayColor];
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ tv.backgroundColor = UIColorFromRGB(TV_BG);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //[UIColor lightGrayColor];
|
|
|
// tv.place
|
|
// tv.place
|
|
|
// [btn setTitle:template[@"title"] forState:UIControlStateNormal];
|
|
// [btn setTitle:template[@"title"] forState:UIControlStateNormal];
|
|
|
// ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
|
|
// ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
|
|
@@ -599,10 +616,16 @@ typedef enum {
|
|
|
}
|
|
}
|
|
|
[destView addSubview:tv];
|
|
[destView addSubview:tv];
|
|
|
}
|
|
}
|
|
|
--(void) addLabel:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
|
|
|
|
|
|
|
+-(void) addLabel:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
|
|
|
{
|
|
{
|
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
|
- UILabel* label = [[UILabel alloc] initWithFrame:srect];
|
|
|
|
|
|
|
+ UILabel* label = (UILabel *)[destView viewWithTag:index+ CONTROL_BASE];
|
|
|
|
|
+ if (label) {
|
|
|
|
|
+ label.frame = srect;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ label = [[UILabel alloc] initWithFrame:srect];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
float fontsize = [template[@"size"] floatValue];
|
|
float fontsize = [template[@"size"] floatValue];
|
|
|
if(fontsize==0)
|
|
if(fontsize==0)
|
|
|
fontsize=10;
|
|
fontsize=10;
|
|
@@ -618,7 +641,9 @@ typedef enum {
|
|
|
label.textAlignment=NSTextAlignmentRight;
|
|
label.textAlignment=NSTextAlignmentRight;
|
|
|
|
|
|
|
|
|
|
|
|
|
- label.text =template[@"value"];
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ label.text =template[@"value"];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
label.tag = index+ CONTROL_BASE;
|
|
label.tag = index+ CONTROL_BASE;
|
|
|
|
|
|
|
@@ -636,26 +661,41 @@ typedef enum {
|
|
|
if(DEBUG_PDFSIG)
|
|
if(DEBUG_PDFSIG)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- [label setBackgroundColor:[UIColor grayColor]];
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ [label setBackgroundColor:[UIColor grayColor]];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
|
|
|
|
|
- [label addGestureRecognizer:tap];
|
|
|
|
|
- label.userInteractionEnabled = YES;
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
|
|
|
|
|
+ [label addGestureRecognizer:tap];
|
|
|
|
|
+ label.userInteractionEnabled = YES;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
[destView addSubview:label];
|
|
[destView addSubview:label];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
--(void) addButton:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
|
|
|
|
|
|
|
+-(void) addButton:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
|
|
|
{
|
|
{
|
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
|
- UIButton* btn = [[UIButton alloc] initWithFrame:srect];
|
|
|
|
|
- [btn setTitle:template[@"title"] forState:UIControlStateNormal];
|
|
|
|
|
|
|
+ UIButton* btn = (UIButton *)[destView viewWithTag:index+ CONTROL_BASE];
|
|
|
|
|
+ if (btn) {
|
|
|
|
|
+ btn.frame = srect;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ btn = [[UIButton alloc] initWithFrame:srect];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ [btn setTitle:template[@"title"] forState:UIControlStateNormal];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
btn.tag = index+ CONTROL_BASE;
|
|
btn.tag = index+ CONTROL_BASE;
|
|
|
// ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
|
|
// ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
|
|
|
- btn.backgroundColor = UIColorFromRGB(BT_BG);
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ btn.backgroundColor = UIColorFromRGB(BT_BG);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
[btn addTarget:self action:@selector(ControlButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
[btn addTarget:self action:@selector(ControlButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
if(DEBUG_PDFSIG)
|
|
if(DEBUG_PDFSIG)
|
|
|
{
|
|
{
|
|
@@ -665,13 +705,19 @@ typedef enum {
|
|
|
}
|
|
}
|
|
|
[destView addSubview:btn];
|
|
[destView addSubview:btn];
|
|
|
}
|
|
}
|
|
|
--(void) addDatePicker:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
|
|
|
|
|
|
|
+-(void) addDatePicker:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
|
|
|
{
|
|
{
|
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
|
- UIButton* btn = [[UIButton alloc] initWithFrame:srect];
|
|
|
|
|
-
|
|
|
|
|
|
|
+ UIButton* btn = (UIButton *)[destView viewWithTag:index + CONTROL_BASE];
|
|
|
|
|
+ if (btn) {
|
|
|
|
|
+ btn.frame = srect;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ btn = [[UIButton alloc] initWithFrame:srect];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- [btn setTitle:template[@"value"] forState:UIControlStateNormal];
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ [btn setTitle:template[@"value"] forState:UIControlStateNormal];
|
|
|
|
|
+ }
|
|
|
float fontsize = [template[@"size"] floatValue];
|
|
float fontsize = [template[@"size"] floatValue];
|
|
|
if(fontsize==0)
|
|
if(fontsize==0)
|
|
|
fontsize=10;
|
|
fontsize=10;
|
|
@@ -682,7 +728,9 @@ typedef enum {
|
|
|
btn.tag = index+ CONTROL_BASE;
|
|
btn.tag = index+ CONTROL_BASE;
|
|
|
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
|
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
|
|
// ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
|
|
// ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
|
|
|
- btn.backgroundColor = UIColorFromRGB(BT_BG);
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ btn.backgroundColor = UIColorFromRGB(BT_BG);
|
|
|
|
|
+ }
|
|
|
[btn addTarget:self action:@selector(ControlDatePickerClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
[btn addTarget:self action:@selector(ControlDatePickerClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
if(DEBUG_PDFSIG)
|
|
if(DEBUG_PDFSIG)
|
|
|
{
|
|
{
|
|
@@ -701,11 +749,16 @@ typedef enum {
|
|
|
return v;
|
|
return v;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
--(void) addCheck:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
|
|
|
|
|
|
|
+-(void) addCheck:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
|
- UIButton* btn = [[UIButton alloc] initWithFrame:srect];
|
|
|
|
|
|
|
+ UIButton* btn = (UIButton *)[destView viewWithTag:index+ CONTROL_BASE];
|
|
|
|
|
+ if (btn) {
|
|
|
|
|
+ btn.frame = srect;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ btn = [[UIButton alloc] initWithFrame:srect];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
|
|
// ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
|
|
|
btn.tag = index+ CONTROL_BASE;
|
|
btn.tag = index+ CONTROL_BASE;
|
|
@@ -713,9 +766,11 @@ typedef enum {
|
|
|
UIColor* marker_bg=UIColorFromRGB(CK_BG);//[UIColor clearColor];
|
|
UIColor* marker_bg=UIColorFromRGB(CK_BG);//[UIColor clearColor];
|
|
|
if(DEBUG_PDFSIG)
|
|
if(DEBUG_PDFSIG)
|
|
|
{
|
|
{
|
|
|
- btn.backgroundColor = [UIColor lightGrayColor];
|
|
|
|
|
- btn.alpha = 0.5;
|
|
|
|
|
- [btn setTitle:template[@"title"] forState:UIControlStateNormal];
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ btn.backgroundColor = [UIColor lightGrayColor];
|
|
|
|
|
+ btn.alpha = 0.5;
|
|
|
|
|
+ [btn setTitle:template[@"title"] forState:UIControlStateNormal];
|
|
|
|
|
+ }
|
|
|
// marker_bg = [UIColor redColor];
|
|
// marker_bg = [UIColor redColor];
|
|
|
|
|
|
|
|
// [btn setBackgroundImage:[UIColor grayColor] forState:UIControlStateNormal];
|
|
// [btn setBackgroundImage:[UIColor grayColor] forState:UIControlStateNormal];
|
|
@@ -737,51 +792,76 @@ typedef enum {
|
|
|
{
|
|
{
|
|
|
NSArray* item = cadedate[i];
|
|
NSArray* item = cadedate[i];
|
|
|
NSArray* checkmarker = item[1];
|
|
NSArray* checkmarker = item[1];
|
|
|
- if(checkmarker.count==0)
|
|
|
|
|
- {
|
|
|
|
|
- [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
|
|
|
|
- btn.titleLabel.font = [UIFont systemFontOfSize: fontsize];
|
|
|
|
|
- btn.backgroundColor = UIColorFromRGB(CK_BG);
|
|
|
|
|
- if([checkedData containsObject:[NSNumber numberWithLong:i]])
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ if(checkmarker.count==0)
|
|
|
{
|
|
{
|
|
|
- [btn setTitle:item[0][0] forState:UIControlStateNormal];
|
|
|
|
|
-
|
|
|
|
|
|
|
+ [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
|
|
|
|
+ btn.titleLabel.font = [UIFont systemFontOfSize: fontsize];
|
|
|
|
|
+ btn.backgroundColor = UIColorFromRGB(CK_BG);
|
|
|
|
|
+ if([checkedData containsObject:[NSNumber numberWithLong:i]])
|
|
|
|
|
+ {
|
|
|
|
|
+ [btn setTitle:item[0][0] forState:UIControlStateNormal];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [btn setTitle:@"" forState:UIControlStateNormal];
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ if(checkmarker.count==0) {
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
- continue;
|
|
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- [btn setTitle:@"" forState:UIControlStateNormal];
|
|
|
|
|
|
|
+ UIView* marker= (UIView *)[destView viewWithTag:CHECK_BASE+index*1000+i];
|
|
|
|
|
+
|
|
|
|
|
+ if (marker) {
|
|
|
|
|
+ int x = [item[1][0] intValue];
|
|
|
|
|
+ int y = [item[1][1] intValue];
|
|
|
|
|
+ int size = [template[@"marker_size"] intValue];
|
|
|
|
|
+ CGRect srect = [self scaleControl:CGRectMake(x,y,size,size) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
|
|
|
+ marker.frame = srect;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ marker = [self createMarker:[template[@"marker_size"] intValue] x:[item[1][0] intValue] y:[item[1][1] intValue] destView:destView];
|
|
|
}
|
|
}
|
|
|
- UIView* marker=[self createMarker:[template[@"marker_size"] intValue] x:[item[1][0] intValue] y:[item[1][1] intValue] destView:destView];
|
|
|
|
|
-
|
|
|
|
|
- marker.backgroundColor = marker_bg;
|
|
|
|
|
- marker.tag = CHECK_BASE+index*1000+i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- if([checkedData containsObject:[NSNumber numberWithLong:i]])
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- marker.backgroundColor= UIColorFromRGB(CK_MK);
|
|
|
|
|
|
|
+ marker.tag = CHECK_BASE+index*1000+i;
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ marker.backgroundColor = marker_bg;
|
|
|
|
|
+ if([checkedData containsObject:[NSNumber numberWithLong:i]])
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ marker.backgroundColor= UIColorFromRGB(CK_MK);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ marker.backgroundColor= marker_bg;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
|
|
|
|
|
+ [marker addGestureRecognizer:tap];
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- marker.backgroundColor= marker_bg;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
|
|
|
|
|
- [marker addGestureRecognizer:tap];
|
|
|
|
|
|
|
|
|
|
[destView addSubview:marker];
|
|
[destView addSubview:marker];
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
--(void) addSignatureButton:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
|
|
|
|
|
|
|
+-(void) addSignatureButton:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
|
|
|
{
|
|
{
|
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
|
- TouchImageView* btn = [[TouchImageView alloc] initWithFrame:srect];
|
|
|
|
|
|
|
+ TouchImageView* btn = (TouchImageView*)[destView viewWithTag:index+ CONTROL_BASE];
|
|
|
|
|
+
|
|
|
|
|
+ if (btn) {
|
|
|
|
|
+ btn.frame = srect;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ btn = [[TouchImageView alloc] initWithFrame:srect];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
btn.contentMode = UIViewContentModeScaleAspectFit;
|
|
btn.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
btn.delegate = self;
|
|
btn.delegate = self;
|
|
@@ -813,7 +893,9 @@ typedef enum {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- btn.backgroundColor = UIColorFromRGB(SIG_BG);
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ btn.backgroundColor = UIColorFromRGB(SIG_BG);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if(DEBUG_PDFSIG)
|
|
if(DEBUG_PDFSIG)
|
|
|
{
|
|
{
|
|
@@ -823,10 +905,16 @@ typedef enum {
|
|
|
}
|
|
}
|
|
|
[destView addSubview:btn];
|
|
[destView addSubview:btn];
|
|
|
}
|
|
}
|
|
|
--(void) addImage:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
|
|
|
|
|
|
|
+-(void) addImage:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index update:(BOOL)update
|
|
|
{
|
|
{
|
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
CGRect srect=[self scaleControl:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue]) from:CGSizeMake(768, 960) to:destView.frame.size];
|
|
|
- UIImageView* btn = [[UIImageView alloc] initWithFrame:srect];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ UIImageView* btn = (UIImageView *)[destView viewWithTag:index+ CONTROL_BASE];
|
|
|
|
|
+ if (btn) {
|
|
|
|
|
+ btn.frame = srect;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ btn = [[UIImageView alloc] initWithFrame:srect];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
btn.contentMode = UIViewContentModeScaleAspectFit;
|
|
btn.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
|
|
|
|
@@ -847,7 +935,9 @@ typedef enum {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- btn.backgroundColor = UIColorFromRGB(SIG_BG);
|
|
|
|
|
|
|
+ if (!update) {
|
|
|
|
|
+ btn.backgroundColor = UIColorFromRGB(SIG_BG);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if(DEBUG_PDFSIG)
|
|
if(DEBUG_PDFSIG)
|
|
|
{
|
|
{
|
|
@@ -2114,6 +2204,30 @@ typedef enum {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (NSDictionary *)updatePageControl:(NSDictionary *)control_dic forIndex:(NSInteger)index {
|
|
|
|
|
+
|
|
|
|
|
+ [self.page_controlTemplate setObject:control_dic forKey:[NSString stringWithFormat:@"control_%ld",index]];
|
|
|
|
|
+ NSMutableDictionary * control = [control_dic mutableCopy];
|
|
|
|
|
+ if([control[@"type"] isEqualToString:@"TextView"]) {
|
|
|
|
|
+ [self addTextView:control destView:self.editControlView index:(int)index update:YES];
|
|
|
|
|
+ } else if ([control[@"type"] isEqualToString:@"Signature"]) {
|
|
|
|
|
+ [self addSignatureButton:control destView:self.editControlView index:(int)index update:YES];
|
|
|
|
|
+ } else if ([control[@"type"] isEqualToString:@"Image"]) {
|
|
|
|
|
+ [self addImage:control destView:self.editControlView index:(int)index update:YES];
|
|
|
|
|
+ } else if([control[@"type"] isEqualToString:@"Button"]) {
|
|
|
|
|
+ [self addButton:control destView:self.editControlView index:(int)index update:YES];
|
|
|
|
|
+ } else if([control[@"type"] isEqualToString:@"Check"]) {
|
|
|
|
|
+ [self addCheck:control destView:self.editControlView index:(int)index update:YES];
|
|
|
|
|
+ } else if([control[@"type"] isEqualToString:@"Label"]) {
|
|
|
|
|
+ [self addLabel:control destView:self.editControlView index:(int)index update:YES];
|
|
|
|
|
+ } else if([control[@"type"] isEqualToString:@"DatePicker"]) {
|
|
|
|
|
+ [self addDatePicker:control destView:self.editControlView index:(int)index update:YES];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return self.page_controlTemplate;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
- (NSDictionary *)updatePageControl:(UIView*) control {
|
|
- (NSDictionary *)updatePageControl:(UIView*) control {
|
|
|
|
|
|
|
|
// int count = [self.page_controlTemplate[@"count"] intValue];
|
|
// int count = [self.page_controlTemplate[@"count"] intValue];
|
|
@@ -2293,4 +2407,138 @@ typedef enum {
|
|
|
return self.page_controlTemplate;
|
|
return self.page_controlTemplate;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#pragma mark - Add & Delete
|
|
|
|
|
+
|
|
|
|
|
+- (NSInteger)addNewControl:(NSDictionary *)control {
|
|
|
|
|
+ NSInteger count = [[self.page_controlTemplate objectForKey:@"count"] integerValue];
|
|
|
|
|
+
|
|
|
|
|
+ // 更新视图
|
|
|
|
|
+ if([control[@"type"] isEqualToString:@"TextView"])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self addTextView:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
|
|
|
|
|
+ }
|
|
|
|
|
+ else if([control[@"type"] isEqualToString:@"Button"])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self addButton:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if([control[@"type"] isEqualToString:@"Check"])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self addCheck:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if([control[@"type"] isEqualToString:@"Signature"])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self addSignatureButton:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if([control[@"type"] isEqualToString:@"Image"])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self addImage:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if([control[@"type"] isEqualToString:@"Label"])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self addLabel:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if([control[@"type"] isEqualToString:@"DatePicker"])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self addDatePicker:[control mutableCopy] destView:self.editControlView index:(int)count update:NO];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 更新数据
|
|
|
|
|
+ NSString *key = [NSString stringWithFormat:@"control_%ld",count];
|
|
|
|
|
+ [self.page_controlTemplate setObject:control forKey:key];
|
|
|
|
|
+ [self.page_controlTemplate setObject:@(++count) forKey:@"count"];
|
|
|
|
|
+
|
|
|
|
|
+ // 返回新Control的Tag
|
|
|
|
|
+ return --count + CONTROL_BASE;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void) deleteControl:(UIView *)controlView {
|
|
|
|
|
+ if (controlView == nil) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 更新数据
|
|
|
|
|
+ NSInteger index = controlView.tag - CONTROL_BASE;
|
|
|
|
|
+ NSInteger count = [[self.page_controlTemplate objectForKey:@"count"] integerValue];
|
|
|
|
|
+ // 删除旧数据
|
|
|
|
|
+ NSString *key = [NSString stringWithFormat:@"control_%ld",index];
|
|
|
|
|
+// [self.page_controlTemplate removeObjectForKey:key];
|
|
|
|
|
+ // 重新排序
|
|
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
|
|
+ if (i > index) {
|
|
|
|
|
+ key = [NSString stringWithFormat:@"control_%d",i];
|
|
|
|
|
+ id value = [self.page_controlTemplate objectForKey:key];
|
|
|
|
|
+ key = [NSString stringWithFormat:@"control_%d",i - 1];
|
|
|
|
|
+ [self.page_controlTemplate setObject:value forKey:key];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ [self.page_controlTemplate setObject:@(--count) forKey:@"count"];
|
|
|
|
|
+
|
|
|
|
|
+ // 更新视图
|
|
|
|
|
+ [self viewWillLayoutSubviews];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void) deleteCheckItemAtSection:(NSInteger)section Row:(NSInteger)row {
|
|
|
|
|
+
|
|
|
|
|
+ // 数据在Cell删除操作时已经更新,再删除就会删除下一个
|
|
|
|
|
+// NSString *control_key = [NSString stringWithFormat:@"control_%ld",section];
|
|
|
|
|
+// // 更新数据
|
|
|
|
|
+// NSMutableDictionary *control = [[self.page_controlTemplate objectForKey:control_key] mutableCopy];
|
|
|
|
|
+// NSMutableArray* cadedate = [control[@"cadedate"] mutableCopy];
|
|
|
|
|
+// [cadedate removeObjectAtIndex:row];
|
|
|
|
|
+// [control setObject:cadedate forKey:@"cadedate"];
|
|
|
|
|
+// [self.page_controlTemplate setObject:control forKey:control_key];
|
|
|
|
|
+
|
|
|
|
|
+ // 刷新视图
|
|
|
|
|
+ [self viewWillLayoutSubviews];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (NSInteger)addCheckOption:(NSArray *)option ForSection:(NSInteger)section {
|
|
|
|
|
+ NSString *control_key = [NSString stringWithFormat:@"control_%ld",section];
|
|
|
|
|
+ NSMutableDictionary *control = [[self.page_controlTemplate objectForKey:control_key] mutableCopy];
|
|
|
|
|
+ NSMutableArray *cadedate = [[control objectForKey:@"cadedate"] mutableCopy];
|
|
|
|
|
+ [cadedate addObject:option];
|
|
|
|
|
+ [control setObject:cadedate forKey:@"cadedate"];
|
|
|
|
|
+ [self.page_controlTemplate setObject:control forKey:control_key];
|
|
|
|
|
+
|
|
|
|
|
+ return [self addCheck:control Marker:option AtSection:section Row:cadedate.count - 1];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (NSInteger)addCheck:(NSDictionary *)template Marker:(NSArray *)item AtSection:(NSInteger)section Row:(NSInteger)row {
|
|
|
|
|
+
|
|
|
|
|
+ NSInteger index = section;
|
|
|
|
|
+ NSInteger i = row;
|
|
|
|
|
+
|
|
|
|
|
+ UIView *destView = self.editControlView;
|
|
|
|
|
+ UIView* marker= [self createMarker:[template[@"marker_size"] intValue] x:[item[1][0] intValue] y:[item[1][1] intValue] destView:destView];;
|
|
|
|
|
+
|
|
|
|
|
+ NSArray* checkedData = self.page_controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value"];
|
|
|
|
|
+
|
|
|
|
|
+ NSInteger tag = CHECK_BASE+index*1000+i;
|
|
|
|
|
+ marker.tag = tag;
|
|
|
|
|
+ UIColor *marker_bg=UIColorFromRGB(CK_BG);
|
|
|
|
|
+ marker.backgroundColor = marker_bg;
|
|
|
|
|
+ if([checkedData containsObject:[NSNumber numberWithLong:i]])
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ marker.backgroundColor= UIColorFromRGB(CK_MK);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ marker.backgroundColor= marker_bg;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer:)];
|
|
|
|
|
+ [marker addGestureRecognizer:tap];
|
|
|
|
|
+
|
|
|
|
|
+ [destView addSubview:marker];
|
|
|
|
|
+
|
|
|
|
|
+ return tag;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
@end
|
|
@end
|