diff --git a/pe/pe0400.cpp b/pe/pe0400.cpp index 27af68d5f..0481a07bf 100755 --- a/pe/pe0400.cpp +++ b/pe/pe0400.cpp @@ -17,6 +17,10 @@ #define F_DETTAGLIO F_USERFLD+2 #define F_COPIA F_USERFLD+3 #define F_INCOLLA F_USERFLD+4 +#define F_SHRINK_ALL F_USERFLD+5 +#define F_ZOOM_ALL F_USERFLD+6 +#define F_SHRINK_ROW F_USERFLD+7 +#define F_ZOOM_ROW F_USERFLD+8 #define FOR_EACH_DOC_ROW_BACK(d, r, row) const TRiga_documento* row = NULL; for (int r = d.rows(); r > 0 && (row = &d[r]) != NULL; r--) ////////////////////////////////////////// @@ -43,6 +47,8 @@ protected: const TString & build_tree_string(int level); public: + static bool pe_espandi_handler(TMask_field& f, KEY k); + static bool pe_espandi_riga_handler(TMask_field& f, KEY k); static bool pe_copia_handler(TMask_field& f, KEY k); static bool pe_incolla_handler(TMask_field& f, KEY k); @@ -284,6 +290,57 @@ bool TGestione_preventivo_msk::pe_data_handler(TMask_field& f, KEY k) return ok; } +bool TGestione_preventivo_msk::pe_espandi_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&)f.mask(); + TSheet_field& sh = mask.sfield(F_SHEET); + const int r = sh.selected(); + const int size = f.dlg() == F_SHRINK_ALL ? 1 : -1; + int row_to_select = 0; + FOR_EACH_SHEET_ROW(sh, i, row) + { + const int row_level = mask.doc()[i + 1].get_int(RDOC_LEVEL); + if (row_level > 0) + sh.set_row_height(i, size); + else + if (i <= r) + row_to_select = i; + } + if (size < 0) + sh.select(row_to_select); + sh.force_update(); + } + return true; +} + +bool TGestione_preventivo_msk::pe_espandi_riga_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&)f.mask(); + TSheet_field& sh = mask.sfield(F_SHEET); + const int r = sh.selected(); + const int level = mask.doc()[r + 1].get_int(RDOC_LEVEL); + + if (r >= 0 && r < sh.items()) + { + const int size = f.dlg() == F_SHRINK_ROW ? 1 : -1; + for (int i = r + 1; i < sh.items(); i++) + { + const int child_level = mask.doc()[i + 1].get_int(RDOC_LEVEL); + if (child_level > level) + sh.set_row_height(i, size); + else + break; + } + } + sh.force_update(); + } + return true; +} + bool TGestione_preventivo_msk::pe_copia_handler(TMask_field& f, KEY k) { bool ok = true; @@ -563,14 +620,24 @@ TMask* TGestione_preventivo_app::get_mask( int mode ) } TSheet_field & sh = m->sfield(F_SHEET); const int y = m->sh_y() - 1; + + m->add_button(F_SHRINK_ALL, sh.page(), "--", 61, y - 1, 1, 1); + m->set_handler(F_SHRINK_ALL, TGestione_preventivo_msk::pe_espandi_handler); + m->add_button(F_ZOOM_ALL, sh.page(), "++", 66, y -1, 1, 1); + m->set_handler(F_ZOOM_ALL, TGestione_preventivo_msk::pe_espandi_handler); + m->add_button(F_SHRINK_ROW, sh.page(), "-", 71, y - 1, 1, 1); + m->set_handler(F_SHRINK_ROW, TGestione_preventivo_msk::pe_espandi_riga_handler); + m->add_button(F_ZOOM_ROW, sh.page(), "+", 76, y -1, 1, 1); + m->set_handler(F_ZOOM_ROW, TGestione_preventivo_msk::pe_espandi_riga_handler); + TEdit_field & k = m->add_string(F_K, sh.page(), "K ", 2, y, 25); k.set_field(DOC_K); m->add_number(F_LIVELLO, sh.page(), "Livello Successivo ", 33, y, 1); m->add_boolean(F_DETTAGLIO, sh.page(), "Dettaglia ", 58, y); - TButton_field & b1 = m->add_button(F_COPIA, sh.page(), "~Copia", 70, y, 1, 1, "", BMP_COPY); + m->add_button(F_COPIA, sh.page(), "~Copia", 71, y, 1, 1, "", BMP_COPY); m->set_handler(F_COPIA, TGestione_preventivo_msk::pe_copia_handler); - TButton_field & b2 = m->add_button(F_INCOLLA, sh.page(), "~Incolla", 76, y, 1, 1, "", BMP_PASTE); + m->add_button(F_INCOLLA, sh.page(), "~Incolla", 76, y, 1, 1, "", BMP_PASTE); m->set_handler(F_INCOLLA, TGestione_preventivo_msk::pe_incolla_handler); sh.enable_column(sh.cid2index(FR_JOLLY1), false); }