void MemberExpiration::render_main(zr_window *window) { zr_context context; zr_context layout; zr_begin(&context, window); { zr_header(&context, "Get member expiration", 0, 0, ZR_HEADER_LEFT); zr_layout_row_dynamic(&context, 30, 1); zr_label(&context, "Please select a month:", ZR_TEXT_LEFT); zr_label(&context, "Months:", ZR_TEXT_LEFT); zr_layout_row_dynamic(&context, 30, 3); zr_combo_begin(&context, &layout, patch::to_string(months[selected]).c_str(), &active); { zr_layout_row_dynamic(&layout, 25, 3); for (int i = 0; i < size; ++i) { if (selected == i) continue; if (zr_combo_item(&layout, ZR_TEXT_LEFT, patch::to_string(months[i]).c_str())) { selected = i; } } } zr_combo_end(&context, &layout, &active); for(int i = 0; i < *num_members; i++) { if(members[i]->expiration_date.month == (selected + 1)) { zr_layout_row_dynamic(&context, 30, 2); zr_label(&context, ("Member Name: " + members[i]->name).c_str(), ZR_TEXT_LEFT); if(members[i]->member_type == 1) zr_label(&context, "Renewal Cost: $111.00", ZR_TEXT_LEFT); else zr_label(&context, "Renewal Cost: $55.00", ZR_TEXT_LEFT); } } zr_layout_row_static(&context, 30, 240, 6); if (zr_button_text(&context, "Back", ZR_BUTTON_DEFAULT)) { changeWindow(MAIN);} } zr_end(&context, window); }
void AddUser::render_main(zr_window *window) { zr_context context; zr_begin(&context, window); { static const char *ratings[] = { "very interested", "somewhat interested", "not interested", "never call again" }; zr_header(&context, "Add Customer", 0, 0, ZR_HEADER_LEFT); zr_layout_row_dynamic(&context, 30, 1); zr_label(&context, "Note: Username and Password will be auto-generated " "upon adding customer if fields left empty", ZR_TEXT_LEFT); // name box zr_layout_row_static(&context, 30, 240, 3); zr_label(&context, "Name:", ZR_TEXT_LEFT); zr_editbox(&context, &nameBox); if (isNameDuplicate) { zr_label(&context, "Could not add: Name already exists", ZR_TEXT_LEFT); } else if (isNameEmpty) { zr_label(&context, "Could not add: Please enter a name", ZR_TEXT_LEFT); } // street box zr_layout_row_static(&context, 30, 240, 3); zr_label(&context, "Street:", ZR_TEXT_LEFT); zr_editbox(&context, &streetBox); if (isStreetEmpty) { zr_label(&context, "Could not add: Please enter an address", ZR_TEXT_LEFT); } // state zipcode box zr_layout_row_static(&context, 30, 240, 3); zr_label(&context, "State and Zip Code:", ZR_TEXT_LEFT); zr_editbox(&context, &stateZipCodeBox); if (isStateEmpty) { zr_label(&context, "Could not add: Please enter an address", ZR_TEXT_LEFT); } // username box zr_layout_row_static(&context, 30, 240, 3); zr_label(&context, "Username:"******"Could not add: Username already exists", ZR_TEXT_LEFT); } else if (isUsernameInvalid) { zr_label(&context, "Could not add: Spaces disallowed", ZR_TEXT_LEFT); } // password box zr_layout_row_static(&context, 30, 240, 3); zr_label(&context, "Password:"******"Could not add: Spaces disallowed", ZR_TEXT_LEFT); } // product spinners zr_layout_row_static(&context, 30, 240, 3); zr_label(&context, "Minimal Packages:", ZR_TEXT_LEFT); zr_spinner_int(&context, 0, &product1Value, 9999, 1, &product1State); zr_layout_row_static(&context, 30, 240, 3); zr_label(&context, "Extreme Packages:", ZR_TEXT_LEFT); zr_spinner_int(&context, 0, &product2Value, 9999, 1, &product2State); zr_layout_row_static(&context, 30, 240, 3); zr_label(&context, "Ultimate Packages:", ZR_TEXT_LEFT); zr_spinner_int(&context, 0, &product3Value, 9999, 1, &product3State); // Rating drop down menu zr_layout_row_static(&context, 30, 240, 3); zr_label(&context, "Rating: ", ZR_TEXT_LEFT); zr_combo_begin(&context, &ratingComboBox, ratings[currentRatingInt], &ratingComboBoxState); { zr_layout_row_dynamic(&ratingComboBox, 25, 1); for (int i = 0; i < 4; i++) { if (zr_combo_item(&ratingComboBox, ratings[i], ZR_TEXT_LEFT)) { currentRatingInt = i; } } } zr_combo_end(&context, &ratingComboBox, &ratingComboBoxState); // Received Pamphlet and Key Customer Box checkboxes zr_layout_row_static(&context, 30, 240, 3); zr_checkbox(&context, "Requested Pamphlet", &isPamphletBoxUnTicked); zr_checkbox(&context, "Key Customer", &isKeyBoxUnTicked); // submit box row zr_layout_row_dynamic(&context, 30, 1); if (zr_button_text(&context, "Submit", ZR_BUTTON_DEFAULT)) { // initialize isNewCustomerAdded = false; isNameDuplicate = false; isNameEmpty = false; isInvalidCustomer = false; isNameEmpty = false; isStateEmpty = false; isStreetEmpty = false; isUsernameDuplicate = false; isUsernameInvalid = false; isPasswordInvalid = false; name = ""; street = ""; stateZipCode = ""; username = ""; password = ""; // get the characters in the name box for (unsigned int i = 0; i < nameBox.glyphes; i++) { name += ((char*) nameBox.buffer.memory.ptr)[i]; } // trim spaces name = trimSpaces(name); // check if name empty if (name.length() == 0) { isNameEmpty = true; isInvalidCustomer = true; } else { // else search for duplicates SearchCustomerVector = *customers; while (!SearchCustomerVector.empty() && !isNameDuplicate) { if (SearchCustomerVector.front().GetName() == name) { isNameDuplicate = true; isInvalidCustomer = true; } else { SearchCustomerVector.erase( SearchCustomerVector.begin()); } } } // get the characters in the street box for (unsigned int i = 0; i < streetBox.glyphes; i++) { street += ((char*) streetBox.buffer.memory.ptr)[i]; } // trim spaces street = trimSpaces(street); // check if street empty if (street.length() == 0) { isStreetEmpty = true; isInvalidCustomer = true; } // get the characters in the state zip code box for (unsigned int i = 0; i < stateZipCodeBox.glyphes; i++) { stateZipCode += ((char*) stateZipCodeBox.buffer.memory.ptr)[i]; } // trim spaces stateZipCode = trimSpaces(stateZipCode); // check if state zip code empty if (stateZipCode.length() == 0) { isStateEmpty = true; isInvalidCustomer = true; } // get the characters in the username box for (unsigned int i = 0; i < usernameBox.glyphes; i++) { username += ((char*) usernameBox.buffer.memory.ptr)[i]; } // check if username empty, if so generate a default username if (username.length() == 0 && !isNameEmpty) { username = GenerateUsername(name); } else if (hasSpaces(username)) { // otherwise search for spaces isUsernameInvalid = true; isInvalidCustomer = true; } else { // otherwise search for duplicates SearchCustomerVector = *customers; while (!SearchCustomerVector.empty() && !isUsernameDuplicate) { if (SearchCustomerVector.front().GetUsername() == username) { isUsernameDuplicate = true; isInvalidCustomer = true; } else { SearchCustomerVector.erase( SearchCustomerVector.begin()); } } } // get the characters in the password box for (unsigned int i = 0; i < passwordBox.glyphes; i++) { password += ((char*) passwordBox.buffer.memory.ptr)[i]; } // check if password empty, if so generate a default password if (password.length() == 0) { password = GeneratePassword(); } else if (hasSpaces(password)) { // otherwise check for spaces isPasswordInvalid = true; isInvalidCustomer = true; } // get whether key if (!isKeyBoxUnTicked) { isKey = true; } else { isKey = false; } // get pamphlet if (!isPamphletBoxUnTicked) { isPamphletReceived = true; } else { isPamphletReceived = false; } // get rating rating = ratings[currentRatingInt]; if (!isInvalidCustomer) { newCustomer = new Customer(name, street, stateZipCode, isPamphletReceived, isKey, rating, username, password, product1Value, product2Value, product3Value); customers->push_back(*newCustomer); std::sort(customers->begin(), customers->end()); SaveCustomers(customers); issue_update(); isNewCustomerAdded = true; } } zr_layout_row_dynamic(&context, 30, 1); if (zr_button_text(&context, "Main Menu", ZR_BUTTON_DEFAULT)) { changeWindow(ADMIN); } if (isNewCustomerAdded) { newCustomerNotification = "You have added customer " + newCustomer->GetName() + " with username " + newCustomer->GetUsername(); zr_layout_row_dynamic(&context, 30, 1); zr_label(&context, newCustomerNotification.c_str(), ZR_TEXT_LEFT); } } zr_end(&context, window); }
static int control_window(struct zr_context *ctx, struct demo *gui) { int i; struct zr_panel layout; if (zr_begin(ctx, &layout, "Control", zr_rect(0, 0, 350, 520), ZR_WINDOW_CLOSABLE|ZR_WINDOW_MINIMIZABLE|ZR_WINDOW_MOVABLE| ZR_WINDOW_SCALABLE|ZR_WINDOW_BORDER)) { /* Style */ if (zr_layout_push(ctx, ZR_LAYOUT_TAB, "Metrics", ZR_MINIMIZED)) { zr_layout_row_dynamic(ctx, 20, 2); zr_label(ctx,"Total:", ZR_TEXT_LEFT); zr_labelf(ctx, ZR_TEXT_LEFT, "%lu", gui->status.size); zr_label(ctx,"Used:", ZR_TEXT_LEFT); zr_labelf(ctx, ZR_TEXT_LEFT, "%lu", gui->status.allocated); zr_label(ctx,"Required:", ZR_TEXT_LEFT); zr_labelf(ctx, ZR_TEXT_LEFT, "%lu", gui->status.needed); zr_label(ctx,"Calls:", ZR_TEXT_LEFT); zr_labelf(ctx, ZR_TEXT_LEFT, "%lu", gui->status.calls); zr_layout_pop(ctx); } if (zr_layout_push(ctx, ZR_LAYOUT_TAB, "Properties", ZR_MINIMIZED)) { zr_layout_row_dynamic(ctx, 22, 3); for (i = 0; i <= ZR_PROPERTY_SCROLLBAR_SIZE; ++i) { zr_label(ctx, zr_get_property_name((enum zr_style_properties)i), ZR_TEXT_LEFT); zr_property_float(ctx, "#X:", 0, &ctx->style.properties[i].x, 20, 1, 1); zr_property_float(ctx, "#Y:", 0, &ctx->style.properties[i].y, 20, 1, 1); } zr_layout_pop(ctx); } if (zr_layout_push(ctx, ZR_LAYOUT_TAB, "Rounding", ZR_MINIMIZED)) { zr_layout_row_dynamic(ctx, 22, 2); for (i = 0; i < ZR_ROUNDING_MAX; ++i) { zr_label(ctx, zr_get_rounding_name((enum zr_style_rounding)i), ZR_TEXT_LEFT); zr_property_float(ctx, "#R:", 0, &ctx->style.rounding[i], 20, 1, 1); } zr_layout_pop(ctx); } if (zr_layout_push(ctx, ZR_LAYOUT_TAB, "Color", ZR_MINIMIZED)) { struct zr_panel tab, combo; enum theme old = gui->theme; static const char *themes[] = {"Black", "White", "Red", "Blue", "Dark", "Grey"}; zr_layout_row_dynamic(ctx, 25, 2); zr_label(ctx, "THEME:", ZR_TEXT_LEFT); if (zr_combo_begin_text(ctx, &combo, themes[gui->theme], 300)) { zr_layout_row_dynamic(ctx, 25, 1); gui->theme = zr_combo_item(ctx, themes[THEME_BLACK], ZR_TEXT_CENTERED) ? THEME_BLACK : gui->theme; gui->theme = zr_combo_item(ctx, themes[THEME_WHITE], ZR_TEXT_CENTERED) ? THEME_WHITE : gui->theme; gui->theme = zr_combo_item(ctx, themes[THEME_RED], ZR_TEXT_CENTERED) ? THEME_RED : gui->theme; gui->theme = zr_combo_item(ctx, themes[THEME_BLUE], ZR_TEXT_CENTERED) ? THEME_BLUE : gui->theme; gui->theme = zr_combo_item(ctx, themes[THEME_DARK], ZR_TEXT_CENTERED) ? THEME_DARK : gui->theme; if (old != gui->theme) set_style(ctx, gui->theme); zr_combo_end(ctx); } zr_layout_row_dynamic(ctx, 300, 1); if (zr_group_begin(ctx, &tab, "Colors", 0)) { for (i = 0; i < ZR_COLOR_COUNT; ++i) { zr_layout_row_dynamic(ctx, 25, 2); zr_label(ctx, zr_get_color_name((enum zr_style_colors)i), ZR_TEXT_LEFT); if (zr_combo_begin_color(ctx, &combo, ctx->style.colors[i], 200)) { zr_layout_row_dynamic(ctx, 25, 1); ctx->style.colors[i].r = (zr_byte)zr_propertyi(ctx, "#R:", 0, ctx->style.colors[i].r, 255, 1,1); ctx->style.colors[i].g = (zr_byte)zr_propertyi(ctx, "#G:", 0, ctx->style.colors[i].g, 255, 1,1); ctx->style.colors[i].b = (zr_byte)zr_propertyi(ctx, "#B:", 0, ctx->style.colors[i].b, 255, 1,1); ctx->style.colors[i].a = (zr_byte)zr_propertyi(ctx, "#A:", 0, ctx->style.colors[i].a, 255, 1,1); zr_combo_end(ctx); } } zr_group_end(ctx); } zr_layout_pop(ctx); } } zr_end(ctx); return !zr_window_is_closed(ctx, "Control"); }