Merge branch 'hotfix-1.4.1' into feature-listbox
This commit is contained in:
@@ -237,7 +237,7 @@ namespace detail
|
||||
if(wd_manager().available(wd) == false)
|
||||
return false;
|
||||
|
||||
core_window_t * prev_wd;
|
||||
core_window_t * prev_wd = nullptr;
|
||||
if(thrd)
|
||||
{
|
||||
prev_wd = thrd->event_window;
|
||||
|
||||
@@ -760,7 +760,7 @@ namespace detail
|
||||
if (bedrock::instance().wd_manager().available(wd) == false)
|
||||
return;
|
||||
|
||||
basic_window* prev_event_wd;
|
||||
basic_window* prev_event_wd = nullptr;
|
||||
if (thrd)
|
||||
{
|
||||
prev_event_wd = thrd->event_window;
|
||||
@@ -1630,7 +1630,7 @@ namespace detail
|
||||
if (wd_manager().available(wd) == false)
|
||||
return false;
|
||||
|
||||
basic_window* prev_event_wd;
|
||||
basic_window* prev_event_wd = nullptr;
|
||||
if (thrd)
|
||||
{
|
||||
prev_event_wd = thrd->event_window;
|
||||
|
||||
@@ -318,6 +318,7 @@ namespace nana
|
||||
data_impl_->realizer = &realizer;
|
||||
realizer._m_reset_overrided();
|
||||
realizer.attached(wd, graphics);
|
||||
realizer.typeface_changed(graphics);
|
||||
}
|
||||
|
||||
drawer_trigger* drawer::detached()
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace nana
|
||||
{
|
||||
std::wstring type;
|
||||
ires>>m.name>>type>>type;
|
||||
m.directory = (type == L"Directory");
|
||||
m.directory = (to_utf8(type) == internationalization()("NANA_FILEBOX_DIRECTORY"));
|
||||
return ires;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ namespace nana
|
||||
_m_add(tm, item.modified_time.tm_min)<<':';
|
||||
_m_add(tm, item.modified_time.tm_sec);
|
||||
|
||||
internationalization i18n;
|
||||
|
||||
ores<<item.name<<tm.str();
|
||||
if(!item.directory)
|
||||
{
|
||||
@@ -72,12 +74,12 @@ namespace nana
|
||||
if(pos != item.name.npos && (pos + 1 < item.name.size()))
|
||||
ores<<item.name.substr(pos + 1);
|
||||
else
|
||||
ores<<L"File";
|
||||
ores<<i18n("NANA_FILEBOX_FILE");
|
||||
|
||||
ores<<_m_trans(item.bytes);
|
||||
}
|
||||
else
|
||||
ores<<L"Directory";
|
||||
ores << i18n("NANA_FILEBOX_DIRECTORY");
|
||||
return ores;
|
||||
}
|
||||
|
||||
@@ -114,7 +116,8 @@ namespace nana
|
||||
|
||||
return s + ustr[uid];
|
||||
}
|
||||
ss<<bytes<<" Bytes";
|
||||
internationalization i18n;
|
||||
ss<<bytes<<" "<<i18n("NANA_FILEBOX_BYTES");
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
@@ -138,6 +141,7 @@ namespace nana
|
||||
filebox_implement(window owner, bool io_read, const std::string& title)
|
||||
: form(owner, API::make_center(owner, 630, 440)), io_read_(io_read)
|
||||
{
|
||||
internationalization i18n;
|
||||
path_.create(*this);
|
||||
path_.splitstr("/");
|
||||
path_.events().selected.connect_unignorable([this](const arg_categorize<int>&)
|
||||
@@ -157,7 +161,7 @@ namespace nana
|
||||
|
||||
filter_.create(*this);
|
||||
filter_.multi_lines(false);
|
||||
filter_.tip_string("Filter");
|
||||
filter_.tip_string(i18n("NANA_FILEBOX_FILTER"));
|
||||
|
||||
filter_.events().key_release.connect_unignorable([this](const arg_keyboard&)
|
||||
{
|
||||
@@ -165,23 +169,23 @@ namespace nana
|
||||
});
|
||||
|
||||
btn_folder_.create(*this);
|
||||
btn_folder_.caption("&New Folder");
|
||||
btn_folder_.i18n(i18n_eval("NANA_FILEBOX_NEW_FOLDER_SHORTKEY"));
|
||||
|
||||
btn_folder_.events().click.connect_unignorable([this](const arg_click&)
|
||||
{
|
||||
form fm(this->handle(), API::make_center(*this, 300, 35));
|
||||
fm.caption("Name the new folder");
|
||||
fm.i18n(i18n_eval("NANA_FILEBOX_NEW_FOLDER_CAPTION"));
|
||||
|
||||
textbox folder(fm, nana::rectangle(5, 5, 160, 25));
|
||||
folder.multi_lines(false);
|
||||
|
||||
button btn(fm, nana::rectangle(170, 5, 60, 25));
|
||||
btn.caption("Create");
|
||||
btn.i18n(i18n_eval("NANA_BUTTON_CREATE"));
|
||||
|
||||
btn.events().click.connect_unignorable(folder_creator(*this, fm, folder));
|
||||
|
||||
button btn_cancel(fm, nana::rectangle(235, 5, 60, 25));
|
||||
btn_cancel.caption("Cancel");
|
||||
btn_cancel.i18n(i18n_eval("NANA_BUTTON_CANCEL"));
|
||||
|
||||
btn_cancel.events().click.connect_unignorable([&fm](const arg_click&)
|
||||
{
|
||||
@@ -193,10 +197,10 @@ namespace nana
|
||||
tree_.create(*this);
|
||||
|
||||
ls_file_.create(*this);
|
||||
ls_file_.append_header("Name", 190);
|
||||
ls_file_.append_header("Modified", 145);
|
||||
ls_file_.append_header("Type", 80);
|
||||
ls_file_.append_header("Size", 70);
|
||||
ls_file_.append_header(i18n("NANA_FILEBOX_HEADER_NAME"), 190);
|
||||
ls_file_.append_header(i18n("NANA_FILEBOX_HEADER_MODIFIED"), 145);
|
||||
ls_file_.append_header(i18n("NANA_FILEBOX_HEADER_TYPE"), 80);
|
||||
ls_file_.append_header(i18n("NANA_FILEBOX_HEADER_SIZE"), 70);
|
||||
|
||||
auto fn_sel_file = [this](const arg_mouse& arg){
|
||||
_m_sel_file(arg);
|
||||
@@ -274,7 +278,7 @@ namespace nana
|
||||
});
|
||||
|
||||
lb_file_.create(*this);
|
||||
lb_file_.caption("File:");
|
||||
lb_file_.i18n(i18n_eval("NANA_FILEBOX_FILE_COLON"));
|
||||
|
||||
tb_file_.create(*this);
|
||||
tb_file_.multi_lines(false);
|
||||
@@ -290,14 +294,15 @@ namespace nana
|
||||
cb_types_.events().selected.connect_unignorable([this](const arg_combox&){ _m_list_fs(); });
|
||||
|
||||
btn_ok_.create(*this);
|
||||
btn_ok_.caption("&OK");
|
||||
btn_ok_.i18n(i18n_eval("NANA_BUTTON_OK_SHORTKEY"));
|
||||
|
||||
|
||||
btn_ok_.events().click.connect_unignorable([this](const arg_click&)
|
||||
{
|
||||
_m_ok();
|
||||
});
|
||||
btn_cancel_.create(*this);
|
||||
btn_cancel_.caption("&Cancel");
|
||||
btn_cancel_.i18n(i18n_eval("NANA_BUTTON_CANCEL_SHORTKEY"));
|
||||
|
||||
btn_cancel_.events().click.connect_unignorable([this](const arg_click&)
|
||||
{
|
||||
@@ -309,7 +314,7 @@ namespace nana
|
||||
_m_init_tree();
|
||||
|
||||
if(0 == title.size())
|
||||
caption(io_read ? "Open" : "Save As");
|
||||
this->i18n(i18n_eval(io_read ? "NANA_FILEBOX_OPEN" : "NANA_FILEBOX_SAVE_AS"));
|
||||
else
|
||||
caption(title);
|
||||
}
|
||||
@@ -640,11 +645,12 @@ namespace nana
|
||||
{
|
||||
auto path = tx_path_.caption();
|
||||
|
||||
msgbox mb(fm_, "Create Folder");
|
||||
internationalization i18n;
|
||||
msgbox mb(fm_, i18n("NANA_FILEBOX_NEW_FOLDER"));
|
||||
mb.icon(msgbox::icon_warning);
|
||||
if(0 == path.size() || path[0] == '.' || path[0] == '/')
|
||||
{
|
||||
mb<<L"Please input a valid name for the new folder.";
|
||||
mb << i18n("NANA_FILEBOX_ERROR_INVALID_FOLDER_NAME");
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
@@ -657,14 +663,14 @@ namespace nana
|
||||
|
||||
if(fst.type() != file_type::not_found && fst.type() != file_type::none)
|
||||
{
|
||||
mb<<L"The folder is existing, please rename it.";
|
||||
mb<<i18n("NANA_FILEBOX_ERROR_RENAME_FOLDER_BECAUSE_OF_EXISTING");
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
|
||||
if(false == fs::create_directory(fspath))
|
||||
{
|
||||
mb<<L"Failed to create the folder, please rename it.";
|
||||
mb<<i18n("NANA_FILEBOX_ERROR_RENAME_FOLDER_BECAUSE_OF_FAILED_CREATION");
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
@@ -741,11 +747,12 @@ namespace nana
|
||||
auto file = tb_file_.caption();
|
||||
if(file.size())
|
||||
{
|
||||
internationalization i18n;
|
||||
if(file[0] == '.')
|
||||
{
|
||||
msgbox mb(*this, caption());
|
||||
mb.icon(msgbox::icon_warning);
|
||||
mb<<file<<std::endl<<"The filename is invalid.";
|
||||
mb<<file<<std::endl<<i18n("NANA_FILEBOX_ERROR_INVALID_FILENAME");
|
||||
mb();
|
||||
return;
|
||||
}
|
||||
@@ -780,7 +787,7 @@ namespace nana
|
||||
{
|
||||
msgbox mb(*this, caption());
|
||||
mb.icon(msgbox::icon_information);
|
||||
mb<<"The file \""<<tar<<"\"\n is not existing. Please check and retry.";
|
||||
mb << i18n("NANA_FILEBOX_ERROR_NOT_EXISTING_AND_RETRY", tar);
|
||||
mb();
|
||||
|
||||
return;
|
||||
@@ -792,7 +799,7 @@ namespace nana
|
||||
{
|
||||
msgbox mb(*this, caption(), msgbox::yes_no);
|
||||
mb.icon(msgbox::icon_question);
|
||||
mb<<"The input file is existing, do you want to overwrite it?";
|
||||
mb<<i18n("NANA_FILEBOX_ERROR_QUERY_REWRITE_BECAUSE_OF_EXISTING");
|
||||
if(msgbox::pick_no == mb())
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,14 +61,14 @@ namespace nana
|
||||
{
|
||||
_m_click(arg);
|
||||
});
|
||||
yes_.i18n(i18n_eval("OK"));
|
||||
yes_.i18n(i18n_eval("NANA_BUTTON_OK"));
|
||||
width_pixel += 77;
|
||||
|
||||
if(msgbox::yes_no == btn || msgbox::yes_no_cancel == btn)
|
||||
{
|
||||
yes_.i18n(i18n_eval("Yes"));
|
||||
yes_.i18n(i18n_eval("NANA_BUTTON_YES"));
|
||||
no_.create(*this);
|
||||
no_.i18n(i18n_eval("No"));
|
||||
no_.i18n(i18n_eval("NANA_BUTTON_NO"));
|
||||
no_.events().click.connect_unignorable([this](const arg_click& arg)
|
||||
{
|
||||
_m_click(arg);
|
||||
@@ -79,7 +79,7 @@ namespace nana
|
||||
if(msgbox::yes_no_cancel == btn)
|
||||
{
|
||||
cancel_.create(*this);
|
||||
cancel_.i18n(i18n_eval("Cancel"));
|
||||
cancel_.i18n(i18n_eval("NANA_BUTTON_CANCEL"));
|
||||
cancel_.events().click.connect_unignorable([this](const arg_click& arg)
|
||||
{
|
||||
_m_click(arg);
|
||||
@@ -493,7 +493,7 @@ namespace nana
|
||||
auto desc_extent = desc_.measure(470);
|
||||
|
||||
btn_ok_.create(*this);
|
||||
btn_ok_.i18n(i18n_eval("OK"));
|
||||
btn_ok_.i18n(i18n_eval("NANA_BUTTON_OK"));
|
||||
btn_ok_.events().click.connect_unignorable([this]{
|
||||
|
||||
if (verifier_ && !verifier_(handle()))
|
||||
@@ -504,7 +504,7 @@ namespace nana
|
||||
});
|
||||
|
||||
btn_cancel_.create(*this);
|
||||
btn_cancel_.i18n(i18n_eval("Cancel"));
|
||||
btn_cancel_.i18n(i18n_eval("NANA_BUTTON_CANCEL"));
|
||||
btn_cancel_.events().click.connect_unignorable([this]{
|
||||
close();
|
||||
});
|
||||
@@ -1141,7 +1141,7 @@ namespace nana
|
||||
impl->path_edit.multi_lines(false);
|
||||
|
||||
impl->browse.create(impl->dock);
|
||||
impl->browse.i18n(i18n_eval("Browse"));
|
||||
impl->browse.i18n(i18n_eval("NANA_BUTTON_BROWSE"));
|
||||
impl->browse.events().click.connect_unignorable([wd, impl](const arg_click&)
|
||||
{
|
||||
impl->fbox.owner(wd);
|
||||
|
||||
@@ -1039,6 +1039,49 @@ namespace nana
|
||||
return result;
|
||||
}
|
||||
|
||||
struct revised_division
|
||||
{
|
||||
division * div;
|
||||
double min_px;
|
||||
double max_px;
|
||||
};
|
||||
|
||||
static double _m_find_lowest_revised_division(const std::vector<revised_division>& revises, double level_px)
|
||||
{
|
||||
double v = (std::numeric_limits<double>::max)();
|
||||
|
||||
for(auto & rev : revises)
|
||||
{
|
||||
if (rev.min_px >= 0 && rev.min_px < v && rev.min_px > level_px)
|
||||
v = rev.min_px;
|
||||
else if (rev.max_px >= 0 && rev.max_px < v)
|
||||
v = rev.max_px;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
static std::size_t _m_remove_revised(std::vector<revised_division>& revises, double value, std::size_t& full_count)
|
||||
{
|
||||
full_count = 0;
|
||||
std::size_t reached_mins = 0;
|
||||
auto i = revises.begin();
|
||||
while (i != revises.end())
|
||||
{
|
||||
if (i->max_px == value)
|
||||
{
|
||||
++full_count;
|
||||
i = revises.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i->min_px == value)
|
||||
++reached_mins;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return reached_mins;
|
||||
}
|
||||
|
||||
double _m_revise_adjustable(std::pair<unsigned, std::size_t>& fa, unsigned area_px)
|
||||
{
|
||||
if (fa.first >= area_px || 0 == fa.second)
|
||||
@@ -1046,16 +1089,20 @@ namespace nana
|
||||
|
||||
double var_px = area_px - fa.first;
|
||||
|
||||
struct revise_t
|
||||
/*
|
||||
struct revise_t //deprecated
|
||||
{
|
||||
division * div;
|
||||
double min_px;
|
||||
double max_px;
|
||||
};
|
||||
*/
|
||||
|
||||
std::size_t min_count = 0;
|
||||
double sum_min_px = 0;
|
||||
std::vector<revise_t> revises;
|
||||
//std::vector<revise_t> revises; //deprecated
|
||||
std::vector<revised_division> revises;
|
||||
|
||||
for (auto& child : children)
|
||||
{
|
||||
if ((!child->weight.empty()) || !child->display)
|
||||
@@ -1088,7 +1135,8 @@ namespace nana
|
||||
if (revises.empty())
|
||||
return var_px / fa.second;
|
||||
|
||||
auto find_lowest = [&revises](double level_px)
|
||||
/*
|
||||
auto find_lowest = [&revises](double level_px) //deprecated
|
||||
{
|
||||
double v = (std::numeric_limits<double>::max)();
|
||||
|
||||
@@ -1102,7 +1150,9 @@ namespace nana
|
||||
}
|
||||
return v;
|
||||
};
|
||||
*/
|
||||
|
||||
/*
|
||||
auto remove_full = [&revises](double value, std::size_t& full_count)
|
||||
{
|
||||
full_count = 0;
|
||||
@@ -1124,6 +1174,7 @@ namespace nana
|
||||
}
|
||||
return reached_mins;
|
||||
};
|
||||
*/
|
||||
|
||||
double block_px = 0;
|
||||
double level_px = 0;
|
||||
@@ -1132,7 +1183,8 @@ namespace nana
|
||||
|
||||
while ((rest_px > 0) && blocks)
|
||||
{
|
||||
auto lowest = find_lowest(level_px);
|
||||
//auto lowest = find_lowest(level_px); //deprecated
|
||||
auto lowest = _m_find_lowest_revised_division(revises, level_px);
|
||||
double fill_px = 0;
|
||||
//blocks may be equal to min_count. E.g, all child divisions have min/max attribute.
|
||||
if (blocks > min_count)
|
||||
@@ -1150,7 +1202,8 @@ namespace nana
|
||||
rest_px -= (lowest-level_px) * (blocks - min_count);
|
||||
|
||||
std::size_t full_count;
|
||||
min_count -= remove_full(lowest, full_count);
|
||||
//min_count -= remove_full(lowest, full_count); //deprecated
|
||||
min_count -= _m_remove_revised(revises, lowest, full_count);
|
||||
blocks -= full_count;
|
||||
level_px = lowest;
|
||||
}
|
||||
@@ -1578,10 +1631,7 @@ namespace nana
|
||||
name = child->name;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto & child : div->children)
|
||||
{
|
||||
auto depth = _m_search_name(child.get(), name);
|
||||
if (depth >= 0)
|
||||
return depth + 1;
|
||||
@@ -2700,7 +2750,8 @@ namespace nana
|
||||
max_px.reset();
|
||||
}
|
||||
|
||||
//The weight will be ignored if one of min and max is specified.
|
||||
/*
|
||||
//The weight will be ignored if one of min and max is specified. //deprecated
|
||||
if (min_px.empty() && max_px.empty())
|
||||
{
|
||||
div->weight = weight;
|
||||
@@ -2710,6 +2761,23 @@ namespace nana
|
||||
div->min_px = min_px;
|
||||
div->max_px = max_px;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!min_px.empty())
|
||||
div->min_px = min_px;
|
||||
|
||||
if (!max_px.empty())
|
||||
div->max_px = max_px;
|
||||
|
||||
if ((!min_px.empty()) && (!weight.empty()) && (weight.get_value(100) < min_px.get_value(100)))
|
||||
weight.reset();
|
||||
|
||||
if ((!max_px.empty()) && (!weight.empty()) && (weight.get_value(100) > max_px.get_value(100)))
|
||||
weight.reset();
|
||||
|
||||
if(!weight.empty())
|
||||
div->weight = weight;
|
||||
|
||||
|
||||
div->gap = std::move(gap);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2311,7 +2311,7 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
auto text = _m_make_select_string();
|
||||
if (!text.empty())
|
||||
nana::system::dataexch().set(text);
|
||||
nana::system::dataexch().set(text, API::root(this->window_));
|
||||
}
|
||||
|
||||
void text_editor::cut()
|
||||
|
||||
Reference in New Issue
Block a user