int html404Document( char *header, char *html, char *requestString, char *queryString ){ header404NF( header ); int appVer, xplmVer; XPLMHostApplicationID appId; XPLMGetVersions( &appVer, &xplmVer, &appId ); sprintf(html, "<html><head><title>404 - File not found.</title></head>" "<body>\n" "\t<b>404 - File not found.</b><br/>\n" // "\tRequest(%i): (%s)<br/>\n" "\tQueryString(%i): (%s)<br/>\n" "<hr/>" "<font size='-1'>\n" // "\t" X_HTTPD_VERSION_STRING " - Compiled: " __DATE__ " " __TIME__ "<br/>\n" "\tX-Plane Version: %2.2f - " #if APL "Mac" #elif IBM "PC" #elif LIN "Linux" #endif "<br/>\n" "XPLM Version: %2.2f<br/>\n" "</font>" "</body>" "</html>", // (int)strlen(requestString), // requestString, (int)strlen(queryString), queryString, appVer/100.0f, xplmVer/100.0f ); return strlen( html ); }
int XPPopupButtonProc( XPWidgetMessage inMessage, XPWidgetID inWidget, long inParam1, long inParam2) { // Select if we're in the background. if (XPUSelectIfNeeded(inMessage, inWidget, inParam1, inParam2, 1/*eat*/)) return 1; int fh, fv; int l, t, r, b; char buf[4096]; XPGetWidgetGeometry(inWidget, &l, &t, &r, &b); XPLMGetFontDimensions(xplmFont_Basic, &fh, &fv, NULL); int curItem = XPGetWidgetProperty(inWidget, xpProperty_PopupCurrentItem, NULL); switch(inMessage) { case xpMsg_Create: case xpMsg_DescriptorChanged: case xpMsg_PropertyChanged: // If our data changes, reparse our descriptor to change our current item. if (inMessage != xpMsg_PropertyChanged || inParam1 == xpProperty_PopupCurrentItem) { XPGetWidgetDescriptor(inWidget, buf, sizeof(buf)); char * p = buf; int picksToSkip = curItem; while (picksToSkip > 0) { while (*p && *p != ';') ++p; if (*p == 0) break; ++p; --picksToSkip; } char * term = p; while (*term && *term != ';') ++term; // Store an offset and length of our descriptor that will show as our current text. XPSetWidgetProperty(inWidget, xpProperty_OffsetToCurrentItem, p - buf); XPSetWidgetProperty(inWidget, xpProperty_CurrentItemLen, term - p); XPSetWidgetProperty(inWidget, xpProperty_Enabled, 1); } return 1; case xpMsg_Draw: { float white [4]; float gray [4]; int itemOffset = XPGetWidgetProperty(inWidget, xpProperty_OffsetToCurrentItem, NULL); int itemLen = XPGetWidgetProperty(inWidget, xpProperty_CurrentItemLen, NULL); // Drawing time. Find the sim version once. static int sim; static float firstTime = true; static int charWidth; if (firstTime) { firstTime = false; int plugin; XPLMHostApplicationID id; XPLMGetVersions(&sim, &plugin, &id); XPLMGetFontDimensions(xplmFont_Basic, &charWidth, NULL, NULL); } // If we are version 7 of the sim, use Sergio's great new popup item. // Since there is no UI element code for this, we must draw it by hand! if (sim >= 700) { /* XPLMSetGraphicsState(0, 1, 0, 0, 1, 0, 0); XPLMBindTexture2d(XPLMGetTexture(xplm_Tex_GeneralInterface), 0); glColor4f(1.0, 1.0, 1.0, 1.0);*/ int center = (t + b) / 2; /// This is in the new widgets lib /* XPDrawElement( l - 4, center - 13, r + 4, center + 13, xpElement_PushButtonWithSelector, 0); */ XPDrawElement( l - 4, center - 13, r + 4, center + 13, xpElement_PushButton, 0); /* // These are offsets for the popup button in the texture DrawStretchedQuad(l - 4, center - 13, r + 4, center + 13, 357, 357+12,357+12+30, 357+12+30+26, 486, 486+8, 486+8+6, 486+8+6+12);*/ } else // If we are version 6, use a window drag bar as a fake popup button. XPDrawElement(l+2, b, r-2, t, xpElement_WindowDragBarSmooth, 0); // Now draw the button label. long titleLen = XPGetWidgetDescriptor(inWidget, buf, sizeof(buf)); SetupAmbientColor(xpColor_MenuText, white); SetupAmbientColor(xpColor_MenuTextDisabled, gray); if (charWidth) { long maxCharCapacity = (r - l - 24) / charWidth; if (itemLen > maxCharCapacity) itemLen = maxCharCapacity; } buf[itemOffset + itemLen] = 0; if (buf[itemOffset] == '(') ++itemOffset; titleLen = strlen(buf + itemOffset); XPLMDrawString(XPGetWidgetProperty(inWidget, xpProperty_Enabled, 0) ? white : gray, l + 4, //(l + r) / 2 - (fh * titleLen / 2), (t + b) / 2 - (fv / 2) + 2, buf + itemOffset, NULL, xplmFont_Basic); } return 1; case xpMsg_MouseDown: // If the mouse is clicked, do a popup pick. if (XPGetWidgetProperty(inWidget, xpProperty_Enabled, 0)) { XPGetWidgetDescriptor(inWidget, buf, sizeof(buf)); XPPickPopup(l, t, buf, XPGetWidgetProperty(inWidget, xpProperty_PopupCurrentItem, NULL), XPPopupWidgetProc, inWidget); return 1; } default: return 0; } }