mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-06-11 12:43:17 +08:00
Fixed issue 1099
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1067 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
a9f483cffc
commit
4decc0f405
@ -132,22 +132,22 @@ const char* ParamContent::GetDescription() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Getter for the value.
|
// Getter for the value.
|
||||||
const char* ParamContent::GetValue() const {
|
STRING ParamContent::GetValue() const {
|
||||||
char* msg = new char[1024];
|
STRING result;
|
||||||
if (param_type_ == VT_INTEGER) {
|
if (param_type_ == VT_INTEGER) {
|
||||||
sprintf(msg, "%d", ((inT32) *(iIt)));
|
result.add_str_int("", *iIt);
|
||||||
} else if (param_type_ == VT_BOOLEAN) {
|
} else if (param_type_ == VT_BOOLEAN) {
|
||||||
sprintf(msg, "%d", ((BOOL8) * (bIt)));
|
result.add_str_int("", *bIt);
|
||||||
} else if (param_type_ == VT_DOUBLE) {
|
} else if (param_type_ == VT_DOUBLE) {
|
||||||
sprintf(msg, "%g", ((double) * (dIt)));
|
result.add_str_double("", *dIt);
|
||||||
} else if (param_type_ == VT_STRING) {
|
} else if (param_type_ == VT_STRING) {
|
||||||
if (((STRING) * (sIt)).string() != NULL) {
|
if (((STRING) * (sIt)).string() != NULL) {
|
||||||
sprintf(msg, "%s", ((STRING) * (sIt)).string());
|
result = sIt->string();
|
||||||
} else {
|
} else {
|
||||||
sprintf(msg, "Null");
|
result = "Null";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return msg;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setter for the value.
|
// Setter for the value.
|
||||||
@ -246,19 +246,19 @@ SVMenuNode* ParamsEditor::BuildListOfAllLeaves(tesseract::Tesseract *tess) {
|
|||||||
STRING tag3;
|
STRING tag3;
|
||||||
GetPrefixes(vc->GetName(), &tag, &tag2, &tag3);
|
GetPrefixes(vc->GetName(), &tag, &tag2, &tag3);
|
||||||
|
|
||||||
if (amount[tag.string()] == 1) { other->AddChild(vc->GetName(), vc->GetId(),
|
if (amount[tag.string()] == 1) {
|
||||||
vc->GetValue(),
|
other->AddChild(vc->GetName(), vc->GetId(), vc->GetValue().string(),
|
||||||
vc->GetDescription());
|
vc->GetDescription());
|
||||||
} else { // More than one would use this submenu -> create submenu.
|
} else { // More than one would use this submenu -> create submenu.
|
||||||
SVMenuNode* sv = mr->AddChild(tag.string());
|
SVMenuNode* sv = mr->AddChild(tag.string());
|
||||||
if ((amount[tag.string()] <= MAX_ITEMS_IN_SUBMENU) ||
|
if ((amount[tag.string()] <= MAX_ITEMS_IN_SUBMENU) ||
|
||||||
(amount[tag2.string()] <= 1)) {
|
(amount[tag2.string()] <= 1)) {
|
||||||
sv->AddChild(vc->GetName(), vc->GetId(),
|
sv->AddChild(vc->GetName(), vc->GetId(),
|
||||||
vc->GetValue(), vc->GetDescription());
|
vc->GetValue().string(), vc->GetDescription());
|
||||||
} else { // Make subsubmenus.
|
} else { // Make subsubmenus.
|
||||||
SVMenuNode* sv2 = sv->AddChild(tag2.string());
|
SVMenuNode* sv2 = sv->AddChild(tag2.string());
|
||||||
sv2->AddChild(vc->GetName(), vc->GetId(),
|
sv2->AddChild(vc->GetName(), vc->GetId(),
|
||||||
vc->GetValue(), vc->GetDescription());
|
vc->GetValue().string(), vc->GetDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ void ParamsEditor::Notify(const SVEvent* sve) {
|
|||||||
sve->command_id);
|
sve->command_id);
|
||||||
vc->SetValue(param);
|
vc->SetValue(param);
|
||||||
sv_window_->AddMessage("Setting %s to %s",
|
sv_window_->AddMessage("Setting %s to %s",
|
||||||
vc->GetName(), vc->GetValue());
|
vc->GetName(), vc->GetValue().string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,8 +344,8 @@ void ParamsEditor::WriteParams(char *filename,
|
|||||||
++iter) {
|
++iter) {
|
||||||
ParamContent* cur = iter->second;
|
ParamContent* cur = iter->second;
|
||||||
if (!changes_only || cur->HasChanged()) {
|
if (!changes_only || cur->HasChanged()) {
|
||||||
fprintf (fp, "%-25s %-12s # %s\n",
|
fprintf(fp, "%-25s %-12s # %s\n",
|
||||||
cur->GetName(), cur->GetValue(), cur->GetDescription());
|
cur->GetName(), cur->GetValue().string(), cur->GetDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -62,7 +62,7 @@ class ParamContent : public ELIST_LINK {
|
|||||||
|
|
||||||
// Getters and Setters.
|
// Getters and Setters.
|
||||||
void SetValue(const char* val);
|
void SetValue(const char* val);
|
||||||
const char* GetValue() const;
|
STRING GetValue() const;
|
||||||
const char* GetName() const;
|
const char* GetName() const;
|
||||||
const char* GetDescription() const;
|
const char* GetDescription() const;
|
||||||
|
|
||||||
|
@ -44,19 +44,14 @@
|
|||||||
// be added to this or one of the submenus.
|
// be added to this or one of the submenus.
|
||||||
SVMenuNode::SVMenuNode() {
|
SVMenuNode::SVMenuNode() {
|
||||||
cmd_event_ = -1;
|
cmd_event_ = -1;
|
||||||
text_ = NULL;
|
|
||||||
child_ = NULL;
|
child_ = NULL;
|
||||||
next_ = NULL;
|
next_ = NULL;
|
||||||
parent_ = NULL;
|
parent_ = NULL;
|
||||||
toggle_value_ = false;
|
toggle_value_ = false;
|
||||||
is_check_box_entry_ = false;
|
is_check_box_entry_ = false;
|
||||||
value_ = NULL;
|
|
||||||
description_ = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SVMenuNode::~SVMenuNode() {
|
SVMenuNode::~SVMenuNode() {
|
||||||
delete[] text_;
|
|
||||||
// delete[] description_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new sub menu node with just a caption. This is used to create
|
// Create a new sub menu node with just a caption. This is used to create
|
||||||
@ -94,16 +89,10 @@ void SVMenuNode::AddChild(const char* txt, int command_event, int tv) {
|
|||||||
// the different values of the menu node.
|
// the different values of the menu node.
|
||||||
SVMenuNode::SVMenuNode(int command_event, const char* txt,
|
SVMenuNode::SVMenuNode(int command_event, const char* txt,
|
||||||
int tv, bool check_box_entry, const char* val,
|
int tv, bool check_box_entry, const char* val,
|
||||||
const char* desc) {
|
const char* desc)
|
||||||
|
: text_(txt), value_(val), description_(desc) {
|
||||||
cmd_event_ = command_event;
|
cmd_event_ = command_event;
|
||||||
|
|
||||||
text_ = new char[strlen(txt) + 1];
|
|
||||||
strncpy(text_, txt, strlen(txt));
|
|
||||||
text_[strlen(txt)] = '\0';
|
|
||||||
|
|
||||||
value_ = val;
|
|
||||||
description_ = desc;
|
|
||||||
|
|
||||||
child_ = NULL;
|
child_ = NULL;
|
||||||
next_ = NULL;
|
next_ = NULL;
|
||||||
parent_ = NULL;
|
parent_ = NULL;
|
||||||
@ -132,15 +121,24 @@ void SVMenuNode::AddChild(SVMenuNode* svmn) {
|
|||||||
void SVMenuNode::BuildMenu(ScrollView* sv, bool menu_bar) {
|
void SVMenuNode::BuildMenu(ScrollView* sv, bool menu_bar) {
|
||||||
if ((parent_ != NULL) && (menu_bar)) {
|
if ((parent_ != NULL) && (menu_bar)) {
|
||||||
if (is_check_box_entry_) {
|
if (is_check_box_entry_) {
|
||||||
sv->MenuItem(parent_->text_, text_, cmd_event_, toggle_value_);
|
sv->MenuItem(parent_->text_.string(), text_.string(), cmd_event_,
|
||||||
} else { sv->MenuItem(parent_->text_, text_, cmd_event_); }
|
toggle_value_);
|
||||||
|
} else {
|
||||||
|
sv->MenuItem(parent_->text_.string(), text_.string(), cmd_event_); }
|
||||||
} else if ((parent_ != NULL) && (!menu_bar)) {
|
} else if ((parent_ != NULL) && (!menu_bar)) {
|
||||||
if (description_ != NULL) { sv->PopupItem(parent_->text_, text_,
|
if (description_.length() > 0) {
|
||||||
cmd_event_, value_, description_);
|
sv->PopupItem(parent_->text_.string(), text_.string(), cmd_event_,
|
||||||
} else { sv->PopupItem(parent_->text_, text_); }
|
value_.string(), description_.string());
|
||||||
|
} else {
|
||||||
|
sv->PopupItem(parent_->text_.string(), text_.string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (child_ != NULL) {
|
||||||
|
child_->BuildMenu(sv, menu_bar); delete child_;
|
||||||
|
}
|
||||||
|
if (next_ != NULL) {
|
||||||
|
next_->BuildMenu(sv, menu_bar); delete next_;
|
||||||
}
|
}
|
||||||
if (child_ != NULL) { child_->BuildMenu(sv, menu_bar); delete child_; }
|
|
||||||
if (next_ != NULL) { next_->BuildMenu(sv, menu_bar); delete next_; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // GRAPHICS_DISABLED
|
#endif // GRAPHICS_DISABLED
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#ifndef TESSERACT_VIEWER_SVMNODE_H__
|
#ifndef TESSERACT_VIEWER_SVMNODE_H__
|
||||||
#define TESSERACT_VIEWER_SVMNODE_H__
|
#define TESSERACT_VIEWER_SVMNODE_H__
|
||||||
|
|
||||||
|
#include "strngs.h"
|
||||||
|
|
||||||
class ScrollView;
|
class ScrollView;
|
||||||
|
|
||||||
class SVMenuNode {
|
class SVMenuNode {
|
||||||
@ -82,13 +84,13 @@ class SVMenuNode {
|
|||||||
// The command event associated with a specific menu node. Should be unique.
|
// The command event associated with a specific menu node. Should be unique.
|
||||||
int cmd_event_;
|
int cmd_event_;
|
||||||
// The caption associated with a specific menu node.
|
// The caption associated with a specific menu node.
|
||||||
char* text_;
|
STRING text_;
|
||||||
// The value of the flag (if this menu node is a flag).
|
// The value of the flag (if this menu node is a flag).
|
||||||
bool toggle_value_;
|
bool toggle_value_;
|
||||||
// The value of the menu node. (optional)
|
// The value of the menu node. (optional)
|
||||||
const char* value_;
|
STRING value_;
|
||||||
// A description_ of the value. (optional)
|
// A description_ of the value. (optional)
|
||||||
const char* description_;
|
STRING description_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TESSERACT_VIEWER_SVMNODE_H__
|
#endif // TESSERACT_VIEWER_SVMNODE_H__
|
||||||
|
Loading…
Reference in New Issue
Block a user