// creates a new MandelPod window void new_mandel_window(void) { // get the graphics context mandel_gc = pz_get_gc(1); // create the main window mandel_wid = pz_new_window (0, 21, screen_info.cols, screen_info.rows - (HEADER_TOPLINE+1), draw_header, handle_event); #ifdef MANDELPOD_STATUS // create the status window status_wid = pz_new_window (22, 4, 12, 12, draw_idle_status, handle_event); #endif // get screen info GrGetWindowInfo(mandel_wid, &wi); // select the event types GrSelectEvents (mandel_wid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_TIMER); // display the window GrMapWindow (mandel_wid); #ifdef MANDELPOD_STATUS GrMapWindow (status_wid); #endif // create the timer for the busy status animation mandel_timer_id = GrCreateTimer (mandel_wid, 250); // start main app init_values(); create_status(); draw_header(); calculate_mandel(); }
void make_ui() { ui_initialising = true; RECT rc; GetWindowRect(g_main_window, &rc); g_layout_window.create(g_main_window); create_rebar(); create_status(); if (settings::show_status_pane) g_status_pane.create(g_main_window); g_layout_window.set_focus(); ui_initialising = false; }
void make_ui() { ui_initialising = true; RECT rc; GetWindowRect(g_main_window, &rc); long flags = 0; if (cfg_frame == 1) flags |= WS_EX_CLIENTEDGE; if (cfg_frame == 2) flags |= WS_EX_STATICEDGE; g_layout_window.create(g_main_window); create_rebar(); create_status(); if (settings::show_status_pane) g_status_pane.create(g_main_window); g_layout_window.set_focus(); ui_initialising = false; }
static Ret_t prv_start_message_cb(InstanceID_t id, VoidPtr_t userData, SmlSyncHdrPtr_t headerP) { internals_t * internP = (internals_t *)userData; SmlStatusPtr_t statusP; SmlChalPtr_t challengeP = NULL; char * dataStr; if (internP->reply_ref) { free(internP->reply_ref); } internP->sequence = NULL; internP->seq_code = 0; internP->reply_ref = smlPcdata2String(headerP->msgID); if (headerP->cred) { internP->srv_auth = check_credentials(headerP->cred, internP->account->toClientCred); challengeP= get_challenge(internP->account->toClientCred); store_nonce(internP->dmtreeH->MOs, internP->account, false); } dataStr = smlPcdata2String(headerP->respURI); if (dataStr) { set_new_uri(internP, dataStr); free(dataStr); } statusP = create_status(internP, internP->srv_auth, NULL); statusP->chal = challengeP; add_target_ref(statusP, headerP->target); add_source_ref(statusP, headerP->source); add_element(internP, (basicElement_t *)statusP); return SML_ERR_OK; }
static Ret_t prv_do_generic_cmd_cb(InstanceID_t id, VoidPtr_t userData, SmlGenericCmdPtr_t cmdP) { internals_t * internP = (internals_t *)userData; SmlStatusPtr_t statusP; SmlItemListPtr_t itemCell; if (internP->sequence && internP->seq_code != OMADM_SYNCML_ERROR_NOT_MODIFIED && internP->seq_code != OMADM_SYNCML_ERROR_SUCCESS) { // do not treat this command return SML_ERR_OK; } if (OMADM_SYNCML_ERROR_AUTHENTICATION_ACCEPTED != internP->srv_auth) { statusP = create_status(internP, internP->srv_auth, cmdP); add_element(internP, (basicElement_t *)statusP); return SML_ERR_OK; } itemCell = cmdP->itemList; while (itemCell) { int code; if (internP->sequence && internP->seq_code == OMADM_SYNCML_ERROR_NOT_MODIFIED) { code = OMADM_SYNCML_ERROR_NOT_EXECUTED; } else { switch (cmdP->elementType) { case SML_PE_ADD: code = add_node(internP, itemCell->item); break; case SML_PE_COPY: code = copy_node(internP, itemCell->item); break; case SML_PE_DELETE: code = delete_node(internP, itemCell->item); break; case SML_PE_REPLACE: code = replace_node(internP, itemCell->item); break; default: code = OMADM_SYNCML_ERROR_COMMAND_NOT_IMPLEMENTED; } } statusP = create_status(internP, code, cmdP); add_target_ref(statusP, itemCell->item->target); add_element(internP, (basicElement_t *)statusP); itemCell = itemCell->next; } return SML_ERR_OK; }
static PyObject * ResponseObject_call(PyObject *obj, PyObject *args, PyObject *kw) { PyObject *status = NULL, *headers = NULL, *exc_info = NULL, *bytes = NULL; char *status_code = NULL; char *status_line = NULL; int bytelen = 0, int_code; ResponseObject *self = NULL; char *buf = NULL; self = (ResponseObject *)obj; #ifdef PY3 if (!PyArg_ParseTuple(args, "UO|O:start_response", &status, &headers, &exc_info)){ return NULL; } #else if (!PyArg_ParseTuple(args, "SO|O:start_response", &status, &headers, &exc_info)){ return NULL; } #endif if (self->cli->headers != NULL && exc_info && exc_info != Py_None) { // Re-raise original exception if headers sent PyObject *type = NULL; PyObject *value = NULL; PyObject *traceback = NULL; if (!PyArg_ParseTuple(exc_info, "OOO", &type, &value, &traceback)) { return NULL; } Py_INCREF(type); Py_INCREF(value); Py_INCREF(traceback); //raise PyErr_Restore(type, value, traceback); return NULL; } if(self->cli->headers != NULL){ PyErr_SetString(PyExc_TypeError, "headers already set"); return NULL; } if (!PyList_Check(headers)) { PyErr_SetString(PyExc_TypeError, "response headers must be a list"); return NULL; } bytes = wsgi_to_bytes(status); bytelen = PyBytes_GET_SIZE(bytes); buf = PyMem_Malloc(sizeof(char*) * bytelen); if (!buf) { return NULL; } status_line = buf; strcpy(status_line, PyBytes_AS_STRING(bytes)); /* DEBUG("%s :%d", (char*)status_line, bytelen); */ if (!*status_line) { PyErr_SetString(PyExc_ValueError, "status message was not supplied"); Py_XDECREF(bytes); if (buf) { PyMem_Free(buf); } return NULL; } status_code = strsep((char **)&status_line, " "); errno = 0; int_code = strtol(status_code, &status_code, 10); if (*status_code || errno == ERANGE) { PyErr_SetString(PyExc_TypeError, "status value is not an integer"); Py_XDECREF(bytes); if (buf) { PyMem_Free(buf); } return NULL; } if (int_code < 100 || int_code > 999) { PyErr_SetString(PyExc_ValueError, "status code is invalid"); Py_XDECREF(bytes); if (buf) { PyMem_Free(buf); } return NULL; } self->cli->status_code = int_code; Py_XDECREF(self->cli->headers); self->cli->headers = headers; Py_INCREF(self->cli->headers); Py_XDECREF(self->cli->http_status); self->cli->http_status = create_status(bytes, bytelen, self->cli->http_parser->http_minor); /* if(self->cli->http_parser->http_minor == 1){ */ /* self->cli->http_status = PyBytes_FromFormat("HTTP/1.1 %s\r\n", PyBytes_AS_STRING(bytes)); */ /* }else{ */ /* self->cli->http_status = PyBytes_FromFormat("HTTP/1.0 %s\r\n", PyBytes_AS_STRING(bytes)); */ /* } */ /* DEBUG("set http_status %p", self->cli); */ Py_XDECREF(bytes); if (buf) { PyMem_Free(buf); } Py_RETURN_NONE; }
/* erstellt die Bedienungsoberfläche */ GtkWidget *gui_create(void) { gint i, scr_width, scr_height; GdkScreen *screen; GtkWidget *window, *box[N_BOXES]; /* ruft die Abmessungen des Bildschirms (screen) ab */ screen = gdk_screen_get_default(); scr_width = gdk_screen_get_width(screen); scr_height = gdk_screen_get_height(screen); /* erstellt das Hauptfenster, und setzt Größe, Namen und Randabstand */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), scr_width * 0.85, scr_height * 0.85); gtk_window_set_title(GTK_WINDOW(window), _("Simulation of radioactive decay")); gtk_container_set_border_width(GTK_CONTAINER(window), 5); /* verknüpft das Hauptfenster mit Callback-Funktionen */ g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gui_delete), NULL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gui_destroy), NULL); /* erstellt Layout Skizze der Kästen (box) |-0---------------------------------------------------| | |-1-----------------------------------------------| | | | |-2-------------| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |-3---------| | | | | | | | | | | | | | | |-----------| | | | | | |---------------| | | | |-------------------------------------------------| | | | | |-4-----------------------------------------------| | | | |-5---| |-6------------------------| |-7------| | | | | | | | | | | | | | | |-----| |--------------------------| |--------| | | | |-------------------------------------------------| | |-----------------------------------------------------| */ box[0] = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), box[0]); box[1] = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(box[0]), box[1], TRUE, TRUE, 0); box[2] = gtk_vbox_new(FALSE, 0); /* erstellt die beiden Zeichenbereiche */ create_dareas(window, box[1], box[2]); box[3] = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(box[2]), box[3], FALSE, FALSE, 0); /* erstellt die Status-Anzeigen */ create_status(window, box[3]); box[4] = gtk_hbox_new(FALSE, 20); gtk_box_pack_start(GTK_BOX(box[0]), box[4], FALSE, FALSE, 0); box[5] = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(box[4]), box[5], FALSE, FALSE, 0); /* erstellt die Eingabefelder */ create_sim_input(window, box[5]); box[6] = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(box[4]), box[6], FALSE, FALSE, 0); /* erstellt die Graphen-Auswahl */ create_graph_input(window, box[6]); box[7] = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(box[4]), box[7], TRUE, TRUE, 0); toggle_states(g_object_get_data(G_OBJECT(window), "spin_states"), window); /* erstellt die Buttons */ create_buttons(window, box[7]); /* gibt die Widgets zum Zeichnen auf dem Bildschirm frei */ for (i = 0; i < N_BOXES; i++) gtk_widget_show(box[i]); gtk_widget_show(window); /* erstellt eine Liste mit ein paar Farben, die dann später im Programm benutzt werden (das _muss_ nach dem Zeichnen auf den Bildschirm passieren) */ create_colors(window); /* setzt die Farben der Checkboxen der Graphen */ color_graph_input(window); return window; }