TheDummyAssistant(openfluid::machine::SimulationBlob* SimBlob) : Gtk::Assistant(), mp_SimBlob(SimBlob), mp_TestUnitsColl(0), m_Applied(false) { set_title("Dummy assistant"); set_default_size(400, 300); set_modal(true); Gtk::Label* Label1 = Gtk::manage(new Gtk::Label( "I'm a Dummy assistant for tests")); append_page(*Label1); set_page_title(*Label1, "Page 1/2"); set_page_type(*Label1, Gtk::ASSISTANT_PAGE_INTRO); set_page_complete(*Label1, true); Gtk::Label* Label2 = Gtk::manage(new Gtk::Label()); if (!mp_SimBlob) { Label2->set_text("Nb of units in TestUnits class: no CoreRepository\n" "Nothing to do"); signal_apply().connect(sigc::mem_fun(*this, &Gtk::Assistant::hide)); } else { unsigned int Size = 0; mp_TestUnitsColl = mp_SimBlob->getCoreRepository().getUnits("TestUnits"); if (mp_TestUnitsColl) Size = mp_TestUnitsColl->getList()->size(); Label2->set_text(Glib::ustring::compose( "Nb of units in TestUnits class: %1\n" "Clicking ok will add a Unit of class \"TestUnits\"", Size)); signal_apply().connect( sigc::mem_fun(*this, &TheDummyAssistant::m_apply)); } append_page(*Label2); set_page_title(*Label2, "Page 2/2"); set_page_type(*Label2, Gtk::ASSISTANT_PAGE_CONFIRM); set_page_complete(*Label2, true); signal_cancel().connect(sigc::mem_fun(*this, &Gtk::Assistant::hide)); signal_close().connect(sigc::mem_fun(*this, &Gtk::Assistant::hide)); show_all_children(); }
string aggregator_page_source() { map <string, string> feed; aggregator_feed_load( feed, arg(2) ); set_page_title( check_plain( feed["title"] ) ); template_preprocess_aggregator_feed_source( feed ); string feed_source = theme("aggregator_feed_source", feed); vector <map <string, string> > items; aggregator_feed_items_load( items, intval(feed["fid"]), 20 ); return _aggregator_page_list( items, "", feed_source); }
string aggregator_admin_overview() { map <string, map <string, string> > form; vector < map <string, string> > feeds; map <string, string> feed; set_page_title( "Feed aggregator" ); form["feeds"]["#type"] = "table"; form["feeds"]["#header"] = "Title,Items,Last update,Next update,Operations, , "; form["feeds"]["#weight"] = "1"; form["feeds"]["#prefix"] = "<h3>Feed overview</h3>"; if(DB_TYPE==1) { REDIS_RES *result = redis_query_fields("SORT aggregator_feed BY aggregator_feed:*->title ALPHA", "GET aggregator_feed:*->", "#fid,title,url,refresh,checked,link,description,etag,modified,image,block"); while( redis_fetch_fields( result, feed ) ) { feed["items"] = redis_str("SCARD aggregator_item:fid:%d", intval(feed["fid"]) ); feeds.push_back( feed ); } } if(DB_TYPE==2) { MYSQL_RES * result = db_querya("SELECT f.*, COUNT(i.iid) AS items FROM aggregator_feed f LEFT JOIN aggregator_item i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.etag, f.modified, f.image, f.block ORDER BY f.title"); while ( db_fetch( result, feed ) ) { feeds.push_back( feed ); } } for(size_t n=0; n< feeds.size(); n++) { form["tit_"+str(n)]["#type"] = "markup"; form["tit_"+str(n)]["#value"] = "<a href=\""+url("aggregator/sources/"+feeds[n]["fid"])+"\">"+feeds[n]["title"]+"</a>"; form["tit_"+str(n)]["#table"] = "feeds"; form["ite_"+str(n)]["#type"] = "markup"; form["ite_"+str(n)]["#value"] = format_plural( intval(feeds[n]["items"]), "%i item", "%i items" ); form["ite_"+str(n)]["#table"] = "feeds"; form["ago_"+str(n)]["#type"] = "markup"; form["ago_"+str(n)]["#value"] = intval( feeds[n]["checked"] ) ? format_interval(time() - intval(feeds[n]["checked"]) )+" ago" : "never"; form["ago_"+str(n)]["#table"] = "feeds"; form["lef_"+str(n)]["#type"] = "markup"; form["lef_"+str(n)]["#value"] = intval( feeds[n]["checked"] ) ? format_interval( intval(feeds[n]["checked"]) + intval(feeds[n]["refresh"]) - time()) + " left" : "never"; form["lef_"+str(n)]["#table"] = "feeds"; form["edi_"+str(n)]["#type"] = "markup"; form["edi_"+str(n)]["#value"] = "<a href=\""+url("admin/aggregator/edit/feed/"+feeds[n]["fid"])+"\">edit</a>"; form["edi_"+str(n)]["#table"] = "feeds"; form["rem_"+str(n)]["#type"] = "markup"; form["rem_"+str(n)]["#value"] = "<a href=\""+url("admin/aggregator/remove/feed/"+feeds[n]["fid"])+"\">remove items</a>"; form["rem_"+str(n)]["#table"] = "feeds"; form["upd_"+str(n)]["#type"] = "markup"; form["upd_"+str(n)]["#value"] = "<a href=\""+url("admin/aggregator/update/feed/"+feeds[n]["fid"])+"\">update items</a>"; form["upd_"+str(n)]["#table"] = "feeds"; form["feeds"]["#row"+str(n)] = "tit_"+str(n)+",ite_"+str(n)+",ago_"+str(n)+",lef_"+str(n)+",edi_"+str(n)+",rem_"+str(n)+",upd_"+str(n); } return get_form("aggregator_admin_overview", form); }
/* window procedure of the property sheet. */ static int PropSheetCtrlProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam) { PCONTROL ctrl; PPROPSHEETDATA propsheet; ctrl = gui_Control (hwnd); propsheet = (PROPSHEETDATA *) ctrl->dwAddData2; switch (message) { case MSG_CREATE: { #ifdef __TARGET_MSTUDIO__ SetWindowBkColor(hwnd, GetWindowElementPixel (hwnd, WE_MAINC_THREED_BODY)); #endif if (!(propsheet = calloc (1, sizeof (PROPSHEETDATA)))) { return -1; } ctrl->dwAddData2 = (DWORD)propsheet; break; } /* make the client size same as window size */ case MSG_SIZECHANGED: { const RECT* rcWin = (RECT *)wParam; RECT* rcClient = (RECT *)lParam; /* cale the width of content page */ *rcClient = *rcWin; propsheet->head_rc.right = RECTWP (rcClient); if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { propsheet->head_rc.top = RECTHP (rcClient) - get_metrics (MWM_ICONY) - 2 - _ICON_OFFSET * 2; propsheet->head_rc.bottom = RECTHP (rcClient); } else { propsheet->head_rc.bottom = get_metrics (MWM_ICONY) + 2 + _ICON_OFFSET * 2; } if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); } else { HDC hdc; propsheet->head_width = propsheet->head_rc.right; if (propsheet->head) { PPROPPAGE page; hdc = GetClientDC(hwnd); page = propsheet->head; while(page) { page->width = tab_required_width (hdc, propsheet, page); page = page->next; } ReleaseDC (hdc); update_propsheet (propsheet); } } resize_children (propsheet, rcClient, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 1; } case MSG_DESTROY: { PPROPPAGE page, temp; page = propsheet->head; while (page) { temp = page->next; destroy_page (page); free (page); page = temp; } free (propsheet); break; } case MSG_GETDLGCODE: { return DLGC_WANTTAB | DLGC_WANTARROWS; } case PSM_SHEETCMD: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (SendMessage (page->hwnd, MSG_SHEETCMD, wParam, lParam)) /* when encounter an error, return page index plus 1. */ return index + 1; index++; page = page->next; } return 0; /* success */ } case PSM_SETACTIVEINDEX: { PPROPPAGE page; if ((page = get_page (propsheet, wParam)) && page != propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); propsheet->active = page; update_propsheet (propsheet); NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return PS_OKAY; } return PS_ERR; } case PSM_GETACTIVEINDEX: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (page == propsheet->active) { return index; } index ++; page = page->next; } return PS_ERR; } case PSM_GETACTIVEPAGE: { return (propsheet->active) ? propsheet->active->hwnd : HWND_INVALID; } case PSM_GETPAGE: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (index == wParam) { return page->hwnd; } index ++; page = page->next; } return HWND_INVALID; } case PSM_GETPAGEINDEX: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (page->hwnd == wParam) { return index; } index ++; page = page->next; } return PS_ERR; } case PSM_GETPAGECOUNT: { return propsheet->page_count; } case PSM_GETTITLELENGTH: { int len = PS_ERR; PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { len = strlen (page->title); } return len; } case PSM_GETTITLE: { char* buffer = (char*)lParam; PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { strcpy (buffer, page->title); return PS_OKAY; } return PS_ERR; } case PSM_SETTITLE: { BOOL rc = PS_ERR; char* buffer = (char*)lParam; PPROPPAGE page; HDC hdc; if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { if ((page = get_page (propsheet, wParam))) { rc = set_page_title (page, buffer); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); } } else { if ((page = get_page (propsheet, wParam))) { hdc = GetClientDC (hwnd); rc = set_page_title_normal_style (hdc, propsheet, page, buffer); ReleaseDC (hdc); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); } } return rc; } case PSM_ADDPAGE: { if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { int index; PPROPPAGE page; if ((propsheet->head_rc.right / (propsheet->page_count + 1)) < _MIN_TAB_WIDTH) { return PS_ERR; } if (!(page = calloc (1, sizeof (PROPPAGE)))) { return PS_ERR; } if (!create_page (hwnd, ctrl->dwStyle, propsheet, page, (DLGTEMPLATE *)wParam, (WNDPROC)lParam)) { free (page); return PS_ERR; } index = append_page (propsheet, page); if (propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); } propsheet->active = page; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return index; } else { return add_new_page_normal_style (hwnd, ctrl, propsheet, (DLGTEMPLATE *)wParam, (WNDPROC)lParam); } } case PSM_REMOVEPAGE: { if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { remove_page (propsheet, page); destroy_page (page); free (page); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); } else { return PS_ERR; } if (propsheet->active == page) { propsheet->active = propsheet->head; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); if (propsheet->active) { show_hide_page (propsheet->active, SW_SHOW); } } InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return PS_OKAY; } else { return delete_page (hwnd, ctrl, propsheet, wParam); } } case MSG_LBUTTONDOWN: { click_tab_bar (hwnd, ctrl, propsheet, lParam); /* dump_propsheetdata (propsheet); */ break; } case MSG_KEYDOWN: { PPROPPAGE page, new_active = NULL; if (!(lParam & KS_CTRL) || (propsheet->head == NULL)) { break; } /* Key borad message for PSS_COMPACTTAB and PSS_SIMPLE */ switch (LOWORD (wParam)) { case SCANCODE_CURSORBLOCKDOWN: case SCANCODE_CURSORBLOCKRIGHT: if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { new_active = propsheet->active->next; if (new_active == NULL) new_active = propsheet->head; break; } else { scroll_tab_right (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } case SCANCODE_CURSORBLOCKUP: case SCANCODE_CURSORBLOCKLEFT: if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { page = propsheet->head; if (propsheet->head == propsheet->active) { while (page && page->next) { page = page->next; } } else { while (page) { if (page->next == propsheet->active) break; page = page->next; } } new_active = page; break; } else { scroll_tab_left (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } } /* switch */ if (new_active == NULL) { break; } show_hide_page (propsheet->active, SW_HIDE); propsheet->active = new_active; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (new_active, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } case MSG_NCPAINT: case MSG_PAINT: { HDC hdc = BeginPaint (hwnd); PPROPPAGE page = ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) ? propsheet->first_display_page : propsheet->head; draw_propsheet (hwnd, hdc, ctrl, propsheet, page); EndPaint (hwnd, hdc); return 0; } default: break; } return DefaultControlProc (hwnd, message, wParam, lParam); }