Jelajahi Sumber

More classes and methods added

mingodad 13 tahun lalu
induk
melakukan
500637a587

+ 0 - 12
ourbiz/edit-order-window.nut

@@ -1,15 +1,3 @@
-class Fl_Box_ClearLabel extends Fl_Box {
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-	}
-}
-
-class Flu_Combo_List extends Fl_Box {
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-	}
-}
-
 class Fl_Choice_Int extends Fl_Button {
 	constructor(px, py, pw, ph, pl=""){
 		base.constructor(px, py, pw, ph, pl);

+ 0 - 29
ourbiz/edit-product-window.nut

@@ -1,25 +1,3 @@
-class Flu_Tree_Browser extends Flv_Table {
-	_forPrint = null;
-	
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-		_forPrint=false;
-	}
-}
-
-
-class Fl_Box_ClearLabel extends Fl_Box {
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-	}
-}
-
-class Flu_Combo_List extends Fl_Box {
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-	}
-}
-
 class Fl_Image_Box extends Fl_Box {
 	constructor(px, py, pw, ph, pl=""){
 		base.constructor(px, py, pw, ph, pl);
@@ -58,13 +36,6 @@ class Fl_Choice_Str extends Fl_Button {
 	}
 }
 
-class Flu_Combo_Box extends Fl_Button {
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-	}
-}
-
-
 function add_input_field_to_map(tbl, fldname, fld){
 }
 	

+ 0 - 6
ourbiz/invoice-A4.nut

@@ -1,9 +1,3 @@
-class Fl_Box_ClearLabel extends Fl_Box {
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-	}
-}
-	
 //class InvoiceA4 extends Fl_Group {
 class InvoiceA4 extends Fl_Window {
 	page=null;

+ 2 - 21
ourbiz/list-search-window.nut

@@ -1,15 +1,3 @@
-class Fl_Box_ClearLabel extends Fl_Box {
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-	}
-}
-
-class Flu_Combo_List extends Fl_Box {
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-	}
-}
-
 class Fl_Image_Box extends Fl_Box {
 	constructor(px, py, pw, ph, pl=""){
 		base.constructor(px, py, pw, ph, pl);
@@ -35,7 +23,6 @@ class My_Fl_Float_Input extends Fl_Float_Input {
 	}
 }
 
-
 class My_Fl_Return_Button extends Fl_Button {
 	constructor(px, py, pw, ph, pl=""){
 		base.constructor(px, py, pw, ph, pl);
@@ -48,12 +35,6 @@ class Fl_Choice_Str extends Fl_Button {
 	}
 }
 
-class Flu_Combo_Box extends Fl_Button {
-	constructor(px, py, pw, ph, pl=""){
-		base.constructor(px, py, pw, ph, pl);
-	}
-}
-
 
 function add_input_field_to_map(tbl, fldname, fld){
 }
@@ -90,7 +71,7 @@ this->align((FL_ALIGN_TOP));
 this->when(FL_WHEN_RELEASE);
 { topGroup = new Fl_Group(0, 0, 800, 35);
   topGroup->labelsize(16);
-  { group_filter = new Flu_Combo_Box(5, 5, 675, 25);
+  { group_filter = new Flu_Combo_List(5, 5, 675, 25);
     group_filter->resize(5, 5, 675, 25);
     group_filter->box(FL_DOWN_BOX);
     group_filter->color(FL_BACKGROUND2_COLOR);
@@ -102,7 +83,7 @@ this->when(FL_WHEN_RELEASE);
     group_filter->textsize(16);
     group_filter->align((FL_ALIGN_LEFT));
     group_filter->when(FL_WHEN_RELEASE);
-  } // Flu_Combo_Box* group_filter
+  } // Flu_Combo_List* group_filter
   { local o = query_limit = new Fl_Int_Input(690, 6, 60, 25);
     query_limit->type(2);
     query_limit->labeltype(FL_NO_LABEL);

+ 134 - 4
ourbiz/ourbiz-fltk.nut

@@ -23,6 +23,11 @@ function create_popup_menu_for (wgt, yOffset=0, options=null){
 	return o;
 }
 
+class Fl_Box_ClearLabel extends Fl_Box {
+	constructor(px, py, pw, ph, pl=""){
+		base.constructor(px, py, pw, ph, pl);
+	}
+}
 
 class MyBaseWindow extends Fl_Window {
 	childWindows=null;
@@ -42,7 +47,80 @@ class MyBaseWindow extends Fl_Window {
 		}
 		win->show();
 		return win;
-	}	
+	}
+	
+	function fill_parent_size(wdg, xOffset=0, yOffset=0){
+		local my_parent = wdg->parent();
+		local newWidth =0;
+		local oldRight = my_parent->x()+my_parent->w();
+		local newRight = wdg->x()+wdg->w();
+		if( newRight >  (oldRight - xOffset))
+		{
+		    newWidth = wdg->w() - (newRight - oldRight + xOffset);
+		}
+		else if(newRight <  (oldRight - xOffset))
+		{
+		    newWidth = wdg->w() + (oldRight - xOffset - newRight);
+		}
+
+		local newHeight =0;
+		local oldBottom = my_parent->y()+my_parent->h();
+		local newBottom = wdg->y()+wdg->h();
+		if( newBottom >  (oldBottom - xOffset))
+		{
+		    newHeight = wdg->h() - (newBottom - oldBottom + xOffset);
+		}
+		else if(newBottom <  (oldBottom - xOffset))
+		{
+		    newHeight = wdg->h() + (oldBottom - xOffset - newBottom);
+		}
+
+		if(newWidth || newHeight)
+		{
+		    wdg->size(
+			newWidth ? newWidth : wdg->w(),
+			newHeight ? newHeight : wdg->h()
+		    );
+		}
+	}
+	
+	function copy_widget_properties(src, dest){
+		dest->labeltype(src->labeltype());
+		dest->label(src->label());
+		dest->labelfont(src->labelfont());
+		dest->labelsize(src->labelsize());
+		dest->textfont(src->textfont());
+		dest->textsize(src->textsize());
+		dest->color(src->color());
+	}
+
+	function replace_widget_for(wold, wnew){
+		local xOffset=5, yOffset=10;
+		copy_widget_properties(wold, wnew);
+		wold->parent()->insert(wnew, wold);
+		wnew->position(wold->x()+xOffset, wold->y()+yOffset);
+		wnew->parent()->remove(wold);
+		fill_parent_size(wnew, xOffset, yOffset);
+		//delete wold;
+	}
+
+	function replace_widget_by(wold, wnew)
+	{
+		copy_widget_properties(wold, wnew);
+		wold->parent()->insert(wnew, wold);
+		wnew->parent()->remove(wold);
+		wnew->resize(wold->x(), wold->y(), wold->w(), wold->h());
+		//delete wold;
+	}
+	
+	function fill_combolist_by_data (choice, data)
+	{
+		for(local i=0, max_count = data.size(); i<max_count; ++i)
+		{
+			local rec = data[i];
+			choice->add_item(rec[0].tointeger(), rec[1]);
+		}
+	}		
 }
 
 class Fl_Data_Table extends Flv_Data_Table {
@@ -206,6 +284,7 @@ dofile("edit-order-window.nut");
 dofile("list-search-window.nut");
 
 class MyListSearchWindow extends ListSearch {
+	_popup = null;
 	_search_options = null;
 	_sab = null;
 
@@ -244,6 +323,50 @@ class MyListSearchWindow extends ListSearch {
 		local sb = create_search_by0(name, Fl_Check_Button, pack_search_options2);
 		return sb;
 	}
+	function on_first_time_show()
+	{
+		local filter_data = [];
+		get_data_group_filter(filter_data);
+		fill_group_filter(filter_data);
+		//fill_search_options();
+		mk_popup();
+		//Fl::add_timeout(0.1, &do_delayed_on_search, this);
+	}
+	
+	function get_data_group_filter(data){}
+	function mk_popup(){}
+	function fill_group_filter(data)
+	{
+		group_filter->clear_items();
+		group_filter->add_item(0, "---");
+		fill_combolist_by_data(group_filter, data);
+		group_filter->select_by_data(0);
+		group_filter.callback(on_filter);
+	}
+	function on_filter(sender, udata){
+		local pr = sender.parent_root();
+		pr->cb_btnSearch(sender, udata);
+	}
+	
+	function setFilterComboTree(){
+		local ctree = new Flu_Combo_Tree(0,0, 25,25);
+		replace_widget_by(group_filter, ctree);
+
+		ctree->textfont(ctree->labelfont());
+		ctree->textsize(ctree->labelsize());
+
+		local tree = ctree->tree();
+		tree.auto_branches(true);
+		tree.show_branches(true);
+		tree.all_branches_always_open(true);
+		tree.branch_text(ctree->labelcolor(), ctree->labelfont(), ctree->labelsize());
+		tree.leaf_text(ctree->labelcolor(), ctree->labelfont(), ctree->labelsize());
+		tree.shaded_entry_colors( FL_WHITE, FL_GRAY );
+		//tree.label("----");
+
+		ctree.callback(on_filter);
+		group_filter = ctree;
+	}
 }
 
 
@@ -312,13 +435,14 @@ class EntitiesListSearch extends MyListSearchWindow {
 		_search_options.product_id = _search_by_product.value() == 1;
 		_search_options.id = _search_by_id.value() == 1;
 		_search_options.active = _search_by_active.value() == 1;
+		_search_options.group_id = group_filter->get_data_at();
 		appServer.entities_get_list(grid->_data, _search_options);
 	}
 	
 	function cb_btnInsert(sender, udata){
 		local pr = sender.parent_root();
 		local win = pr.showChildWindow("Entity Edit", EditEntitiesWindow);
-	}
+	}	
 }
 
 class ProductsListSearch extends MyListSearchWindow {
@@ -346,6 +470,7 @@ class ProductsListSearch extends MyListSearchWindow {
 			"image_id|image_id|0",
 		];
 		grid->set_cols(cols_info);
+		//setFilterComboTree();
 		_search_by_description = create_search_by("Description");
 		_search_by_notes = create_search_by("Notes");
 		_search_by_reference = create_search_by("Reference");
@@ -365,6 +490,7 @@ class ProductsListSearch extends MyListSearchWindow {
 		_search_options.entities = _search_by_entities.value() == 1;
 		_search_options.id = _search_by_id.value() == 1;
 		_search_options.active = _search_by_active.value() == 1;
+		_search_options.group_id = group_filter->get_data_at();
 		appServer.products_get_list(grid->_data, _search_options);
 	}
 
@@ -381,7 +507,6 @@ class OrdersListSearch extends MyListSearchWindow {
 	_search_by_date = null;
 	_search_by_total = null;
 	_search_wp = null;
-	_popup = null;
 
 	constructor() {
 		base.constructor();
@@ -405,7 +530,11 @@ class OrdersListSearch extends MyListSearchWindow {
 		_search_wp = create_search_by2("WP");
 		_search_by_entities->setonly();
 		fill_grid();
-		mk_popup();
+	}
+	
+	function get_data_group_filter(data)
+	{
+		appServer.order_types_list_short(data, 0);
 	}
 	
 	function get_search_data(data){
@@ -415,6 +544,7 @@ class OrdersListSearch extends MyListSearchWindow {
 		_search_options.products = _search_by_products.value() == 1;
 		_search_options.date = _search_by_date.value() == 1;
 		_search_options.total = _search_by_total.value() == 1;
+		_search_options.group_id = group_filter->get_data_at();
 		appServer.orders_get_list(grid->_data, _search_options);
 	}
 

+ 1 - 0
ourbiz/utils-fltk.nut

@@ -94,3 +94,4 @@ Fl.visual(FL_RGB);
 Fl.option(Fl.OPTION_ARROW_FOCUS, true);
 setAppFont("erdana");
 Fl.add_focus_changing_handler(fltk_focus_changing);
+Fl.fl_preferences(Fl.FL_PREFERENCES_USER, "dadbiz", "ourbiz");

+ 6 - 0
squilu.cbp

@@ -102,6 +102,7 @@
 					<Add option="-DWITH_FLTK=1" />
 					<Add directory="../zeromq-3.2.2/include" />
 					<Add directory="../dadbiz++/third-party/fltk" />
+					<Add directory="../dadbiz++/third-party/flu" />
 				</Compiler>
 				<Linker>
 					<Add option="-s" />
@@ -110,6 +111,7 @@
 					<Add library="rt" />
 					<Add library="dl" />
 					<Add library="axtls" />
+					<Add library="fltkutils" />
 					<Add library="fltk" />
 					<Add library="fltk_images" />
 					<Add library="fltk_png" />
@@ -121,6 +123,7 @@
 					<Add library="mpdecimal" />
 					<Add directory="../zeromq-3.2.2" />
 					<Add directory="../dadbiz++/third-party/fltk/lib" />
+					<Add directory="../dadbiz++/third-party/flu" />
 				</Linker>
 			</Target>
 			<Target title="Debug FLTK">
@@ -136,6 +139,7 @@
 					<Add option="-DWITH_FLTK=1" />
 					<Add directory="../zeromq-3.2.2/include" />
 					<Add directory="../dadbiz++/third-party/fltk" />
+					<Add directory="../dadbiz++/third-party/flu" />
 				</Compiler>
 				<Linker>
 					<Add library="../zeromq-3.2.2/libzmq3.a" />
@@ -143,6 +147,7 @@
 					<Add library="rt" />
 					<Add library="dl" />
 					<Add library="axtls" />
+					<Add library="fltkutils" />
 					<Add library="fltk" />
 					<Add library="fltk_images" />
 					<Add library="fltk_png" />
@@ -154,6 +159,7 @@
 					<Add library="mpdecimal" />
 					<Add directory="../zeromq-3.2.2" />
 					<Add directory="../dadbiz++/third-party/fltk/lib" />
+					<Add directory="../dadbiz++/third-party/flu" />
 				</Linker>
 			</Target>
 		</Build>