/* * Reply to a series of messages by simply mailing to the senders * and not messing around with the To: and Cc: lists as in normal * reply. */ int doRespond(int *msgvec) { struct header head; struct message *mp; int *ap; char *cp, *mid; head.h_to = NULL; for (ap = msgvec; *ap != 0; ap++) { mp = &message[*ap - 1]; touch(mp); dot = mp; if ((cp = skin(hfield("from", mp))) == NULL) cp = skin(nameof(mp, 2)); head.h_to = cat(head.h_to, extract(cp, GTO)); mid = skin(hfield("message-id", mp)); } if (head.h_to == NULL) return (0); mp = &message[msgvec[0] - 1]; if ((head.h_subject = hfield("subject", mp)) == NULL) head.h_subject = hfield("subj", mp); head.h_subject = reedit(head.h_subject); head.h_cc = NULL; head.h_bcc = NULL; head.h_smopts = NULL; head.h_replyto = value("REPLYTO"); head.h_inreplyto = mid; mail1(&head, 1); return (0); }
size_t NanoInk::caretIndex(float posX, float posY) { const char* start = mFrame.widget().label().c_str(); const char* end = start + mFrame.widget().label().size(); float pwidth = mFrame.pwidth(); float x = skin().padding()[DIM_X]; float y = skin().padding()[DIM_Y]; float lineh = 0.f; nvgTextMetrics(mCtx, NULL, NULL, &lineh); for(NVGtextRow& row : mTextRows) { if(posY < y + lineh) { NVGalign halign = NVG_ALIGN_LEFT; if(halign & NVG_ALIGN_LEFT) x = x; else if(halign & NVG_ALIGN_CENTER) x = x + pwidth*0.5f - row.width*0.5f; else if(halign & NVG_ALIGN_RIGHT) x = x + pwidth - row.width; return nvgTextGlyphIndex(mCtx, x, y, row.start, row.end, posX) + row.start - start; } y += lineh; } return end - start; //return nvgTextGlyphIndex(mCtx, skin().padding()[DIM_X], skin().padding()[DIM_Y], mFrame.widget().label().c_str(), nullptr, posX); }
void NanoInk::caretCoords(size_t index, float& caretX, float& caretY, float& caretHeight) { float lineh = 0.f; nvgTextMetrics(mCtx, NULL, NULL, &lineh); const char* start = mFrame.widget().label().c_str(); float x = skin().padding()[DIM_X]; float y = skin().padding()[DIM_Y]; float pwidth = mFrame.pwidth(); for(NVGtextRow& row : mTextRows) { if(index <= row.end - start) { NVGglyphPosition position; nvgTextGlyphPosition(mCtx, 0.f, 0.f, row.start, row.end, index - (row.start - start), &position); caretX = x + position.x; caretY = y; nvgTextMetrics(mCtx, nullptr, nullptr, &caretHeight); return; } y += lineh; } caretX = 0.f; caretY = y; return; NVGglyphPosition position; nvgTextGlyphPosition(mCtx, 0.f, 0.f, mFrame.widget().label().c_str(), nullptr, index, &position); caretX = skin().padding()[DIM_X] + position.x; caretY = skin().padding()[DIM_Y] + 0.f; nvgTextMetrics(mCtx, nullptr, nullptr, &caretHeight); }
void NanoInk::updateStyle() { mTextUpdate = true; mImageUpdate = true; this->styleCorners(); if(skin().mEmpty) return; if(mFrame.widget().image()) mImage = &fetchImage(*mFrame.widget().image()); else mImage = 0; if(skin().overlay()) mOverlay = &fetchImage(*skin().overlay()); else mOverlay = 0; if(skin().tile()) mTile = &fetchImage(*skin().tile(), true); else mTile = 0; if(!skin().imageSkin().null()) { mSkin = &fetchImage(*skin().imageSkin().d_image); if(!skin().imageSkin().d_prepared) skin().imageSkin().prepare(mSkin->d_width, mSkin->d_height); } }
void KaimanPrefDlg::save() { KConfig *config=KGlobal::config(); config->setGroup("Kaiman"); config->writeEntry("SkinResource", skin() ); config->sync(); Kaiman *l=Kaiman::kaiman; if ( l ) { l->changeStyle( skin() ); } }
void NanoInk::updateFrame() { if(mFrame.dirty() >= Frame::DIRTY_ABSOLUTE) mMoved = true; if(mFrame.dirty() < Frame::DIRTY_CLIP) return; mTextUpdate = true; mImageUpdate = true; if(skin().mEmpty || !mVisible || mFrame.dsize(DIM_X) == 0.f || mFrame.dsize(DIM_Y) == 0.f) return; if(!mFrame.widget().label().empty() && skin().textWrap()) { mTextRows.clear(); this->setupText(); const char* first = mFrame.widget().label().c_str(); const char* end = first + mFrame.widget().label().size(); int nrows = 0; mTextRows.resize(1); while((nrows = nvgTextBreakLines(mCtx, first, end, mFrame.pwidth(), &mTextRows.back(), 1))) { first = mTextRows.back().next; mTextRows.resize(mTextRows.size() + 1); } mTextRows.pop_back(); } else if(!mFrame.widget().label().empty()) { mTextRows.resize(1); mTextRows[0].start = mFrame.widget().label().c_str(); mTextRows[0].end = mTextRows[0].start + mFrame.widget().label().size(); mTextRows[0].width = this->contentSize(DIM_X); } else { mTextRows.clear(); } this->updateCorners(); }
int QtScrollWheel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractSlider::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = skin(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setSkin(*reinterpret_cast< QString*>(_v)); break; } _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
static char * dispname(const char *hdr) // made it a const char * instead of a char * { char *cp, *cp2; if (hdr == 0) return 0; if (((cp = const_cast <char *> (strchr(hdr, '<'))) != 0) && (cp > hdr)) { *cp = 0; if ((*hdr == '"') && ((cp = const_cast <char *> (strrchr(++hdr, '"'))) != 0)) *cp = 0; return (char *)hdr; } else if ((cp = const_cast <char *> (strchr(hdr, '('))) != 0) { hdr = ++cp; if ((cp = const_cast <char *> (strchr(hdr, '+'))) != 0) *cp = 0; if ((cp = const_cast <char *> (strrchr(hdr, ')'))) != 0) *cp = 0; return (char *)hdr; } cp = skin((char *)hdr); if ((cp2 = strrchr(cp, '!')) != 0) { while (cp2 >= cp && *--cp2 != '!'); cp = ++cp2; } return cp; }
void RenderSkinApplication::initialise(const String& commandLineParameters) { app = new RenderSkin(); StringArray parms; parms.addTokens(commandLineParameters, " "); if(parms.contains("-produce")) { File inputfile(parms[parms.size()-1]); if(inputfile.existsAsFile()) { EditableSkin skin(app); skin.loadFromFile(inputfile); DBG("producing:" + skin.getName()); skin.produce(); DBG("done producing:" + skin.getName()); this->quit(); } } else { this->window = new RenderSkinMainWindow(app); } }
context::context(booster::shared_ptr<impl::cgi::connection> conn) : conn_(conn) { d.reset(new _data(*this)); d->response.reset(new http::response(*this)); skin(service().views_pool().default_skin()); d->cache.reset(new cache_interface(*this)); d->session.reset(new session_interface(*this)); }
int QtSvgDialGauge::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = skin(); break; case 1: *reinterpret_cast< int*>(_v) = minimum(); break; case 2: *reinterpret_cast< int*>(_v) = maximum(); break; case 3: *reinterpret_cast< qreal*>(_v) = startAngle(); break; case 4: *reinterpret_cast< qreal*>(_v) = endAngle(); break; } _id -= 5; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setSkin(*reinterpret_cast< QString*>(_v)); break; case 1: setMinimum(*reinterpret_cast< int*>(_v)); break; case 2: setMaximum(*reinterpret_cast< int*>(_v)); break; case 3: setStartAngle(*reinterpret_cast< qreal*>(_v)); break; case 4: setEndAngle(*reinterpret_cast< qreal*>(_v)); break; } _id -= 5; } else if (_c == QMetaObject::ResetProperty) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 5; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 5) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 5; } #endif // QT_NO_PROPERTIES return _id; }
float NanoInk::contentSize(Dimension dim) { if(mImage) { return dim == DIM_X ? float(mImage->d_width) : float(mImage->d_height); } else if(skin().textColour().a() != 0.f) { float bounds[4]; float height; this->setupText(); nvgTextBounds(mCtx, 0.f, 0.f, mFrame.widget().label().c_str(), nullptr, bounds); nvgTextMetrics(mCtx, nullptr, nullptr, &height); return dim == DIM_X ? bounds[2] - bounds[0] : height; } else if(!skin().imageSkin().null()) { if(skin().imageSkin().d_stretch == DIM_X) return skin().imageSkin().d_height; else if(skin().imageSkin().d_stretch == DIM_Y) return skin().imageSkin().d_width; } return 0.f; }
/* * Reply to a list of messages. Extract each name from the * message header and send them off to mail1() */ int dorespond(int *msgvec) { struct message *mp; char *cp, *rcv, *replyto; char **ap; struct name *np; struct header head; if (msgvec[1] != 0) { printf("Sorry, can't reply to multiple messages at once\n"); return (1); } mp = &message[msgvec[0] - 1]; touch(mp); dot = mp; if ((rcv = skin(hfield("from", mp))) == NULL) rcv = skin(nameof(mp, 1)); if ((replyto = skin(hfield("reply-to", mp))) != NULL) np = extract(replyto, GTO); else if ((cp = skin(hfield("to", mp))) != NULL) np = extract(cp, GTO); else np = NULL; np = elide(np); /* * Delete my name from the reply list, * and with it, all my alternate names. */ np = delname(np, myname); if (altnames) for (ap = altnames; *ap != NULL; ap++) np = delname(np, *ap); if (np != NULL && replyto == NULL) np = cat(np, extract(rcv, GTO)); else if (np == NULL) { if (replyto != NULL) printf("Empty reply-to field -- replying to author\n"); np = extract(rcv, GTO); } head.h_to = np; if ((head.h_subject = hfield("subject", mp)) == NULL) head.h_subject = hfield("subj", mp); head.h_subject = reedit(head.h_subject); if (replyto == NULL && (cp = skin(hfield("cc", mp))) != NULL) { np = elide(extract(cp, GCC)); np = delname(np, myname); if (altnames != 0) for (ap = altnames; *ap != NULL; ap++) np = delname(np, *ap); head.h_cc = np; } else head.h_cc = NULL; head.h_bcc = NULL; head.h_smopts = NULL; head.h_replyto = value("REPLYTO"); head.h_inreplyto = skin(hfield("message-id", mp)); mail1(&head, 1); return (0); }
int QtMultiSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QProgressBar::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: maximumExceeded((*reinterpret_cast< bool(*)>(_a[1]))); break; case 1: minimumExceeded((*reinterpret_cast< bool(*)>(_a[1]))); break; case 2: setMaximumRange((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: setMinimumRange((*reinterpret_cast< int(*)>(_a[1]))); break; case 4: setValue((*reinterpret_cast< int(*)>(_a[1]))); break; case 5: checkMinimumRange((*reinterpret_cast< int(*)>(_a[1]))); break; case 6: checkMaximumRange((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } _id -= 7; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = skin(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setSkin(*reinterpret_cast< QString*>(_v)); break; } _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
int QtMultiSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QProgressBar::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 7) qt_static_metacall(this, _c, _id, _a); _id -= 7; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 7) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 7; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = skin(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setSkin(*reinterpret_cast< QString*>(_v)); break; } _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
void receipt(struct message *mp) { char head[LINESIZE]; char buf[BUFSIZ]; FILE *pp, *fp; char *mail, *s; if ((mail = value("sendmail")) == 0) #ifdef SENDMAIL mail = SENDMAIL; #else mail = MAIL; #endif if (icsubstr(hfield("default-options", mp, addone), "/receipt") || icsubstr(hfield(">to", mp, addto), "/receipt")) { snprintf(buf, sizeof (buf), "%s %s", mail, skin(nameof(mp))); if (pp = npopen(buf, "w")) { headline_t *hl; if (headline_alloc(&hl) != 0) { err(1, "could not allocate memory"); } fp = setinput(mp); readline(fp, head); if (parse_headline(head, hl) != 0) { headline_reset(hl); } if (custr_len(hl->hl_date) > 0) { fprintf(pp, "Original-Date: %s\n", custr_cstr(hl->hl_date)); } if (s = hfield("message-id", mp, addone)) fprintf(pp, "Original-Message-ID: %s\n", s); s = hfield("subject", mp, addone); fprintf(pp, "Subject: RR: %s\n", s ? s : "(none)"); npclose(pp); headline_free(hl); } } }
/* * Print out the header of a specific message. * This is a slight improvement to the standard one. */ void printhead(int mesg) { struct message *mp; char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind; char pbuf[BUFSIZ]; struct headline hl; int subjlen; char *name; mp = &message[mesg-1]; (void)readline(setinput(mp), headline, LINESIZE); if ((subjline = hfield("subject", mp)) == NULL) subjline = hfield("subj", mp); /* * Bletch! */ curind = dot == mp ? '>' : ' '; dispc = ' '; if (mp->m_flag & MSAVED) dispc = '*'; if (mp->m_flag & MPRESERVE) dispc = 'P'; if ((mp->m_flag & (MREAD|MNEW)) == MNEW) dispc = 'N'; if ((mp->m_flag & (MREAD|MNEW)) == 0) dispc = 'U'; if (mp->m_flag & MBOX) dispc = 'M'; parse(headline, &hl, pbuf); sprintf(wcount, "%3ld/%-5ld", mp->m_lines, mp->m_size); subjlen = screenwidth - 50 - strlen(wcount); name = value("show-rcpt") != NULL ? skin(hfield("to", mp)) : nameof(mp, 0); if (subjline == NULL || subjlen < 0) /* pretty pathetic */ printf("%c%c%3d %-20.20s %16.16s %s\n", curind, dispc, mesg, name, hl.l_date, wcount); else printf("%c%c%3d %-20.20s %16.16s %s \"%.*s\"\n", curind, dispc, mesg, name, hl.l_date, wcount, subjlen, subjline); }
int QtSvgSlideSwitch::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractButton::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: setSwitchPosition((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: updateSwitchPosition((*reinterpret_cast< bool(*)>(_a[1]))); break; default: ; } _id -= 2; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = skin(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setSkin(*reinterpret_cast< QString*>(_v)); break; } _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
// // Program starts here // int main() { // // Note: Order is important here. you need to create the WindowCanvas before // you setup the skin - because the renderer won't be properly set up // if you try to do it before (The window canvas initializes the renderer) // // Create the skin and renderer // //gwen::Renderer::GDIPlusBuffered renderer; //gwen::Renderer::Direct2D renderer; //gwen::Renderer::DirectX9 renderer; gwen::Renderer::OpenGL_DebugFont renderer; gwen::Skin::TexturedBase skin( &renderer ); // // The window canvas is a cross between a window and a canvas // It's cool because it takes care of creating an OS specific // window - so we don't have to bother with all that crap. // // gwen::Controls::WindowCanvas window_canvas( -1, -1, 700, 500, &skin, "gwen's Cross Platform Example" ); // // Now it's safe to set up the skin // skin.Init( "DefaultSkin.png" ); // // Create our unittest control // UnitTest* pUnit = new UnitTest( &window_canvas ); pUnit->SetPos( 10, 10 ); while ( !window_canvas.WantsQuit() ) { window_canvas.DoThink(); } // Everything should be automatically released // pUnit is a child of Canvas - which releases all of its children }
void CEggClockAppView::Draw(const TRect& aRect) const { // Get the standard graphics context CWindowGc& gc(SystemGc()); // Clears the screen if (m_pFlashTimer && m_pFlashTimer->IsActive() && m_bFlash) { gc.SetBrushColor(KRgbRed); gc.Clear(Rect()); } else { if (m_bUseSkin) { // Skin support MAknsSkinInstance* skin(AknsUtils::SkinInstance()); MAknsControlContext* cc(AknsDrawUtils::ControlContext(this)); AknsDrawUtils::Background(skin, cc, this, gc, aRect); } else { // Use white background gc.SetBrushColor(KRgbWhite); gc.Clear(Rect()); } } // Calculate numbers to show TInt iLargeNumber((m_iRemainingDuration > 0) ? m_iRemainingDuration : 0); TInt iSmallNumber((m_iRemainingDuration < 0) ? (0 - m_iRemainingDuration) : 0); // Large numbers TRAP_IGNORE( DrawLargeNumberL(aRect, iLargeNumber); DrawSmallNumberL(aRect, iSmallNumber); DrawVolumeL(aRect); );
void NanoInk::drawSkinImage(ImageSkin::Section section, float left, float top, float width, float height) { left -= skin().imageSkin().d_margin; top -= skin().imageSkin().d_margin; float xoffset = -skin().imageSkin().d_coords[section].x0(); float yoffset = -skin().imageSkin().d_coords[section].y0(); float xratio = 1.f; float yratio = 1.f; if(section == ImageSkin::TOP || section == ImageSkin::BOTTOM || section == ImageSkin::FILL) xratio = width / skin().imageSkin().d_fillWidth; //float(imgwidth); if(section == ImageSkin::LEFT || section == ImageSkin::RIGHT || section == ImageSkin::FILL) yratio = height / skin().imageSkin().d_fillHeight; //float(imgheight); this->drawImageStretch(*mSkin, left, top, width, height, xoffset, yoffset, xratio, yratio); }
/** * initSkin(), Reloads the skin after a skin change **/ void AudioBrowserScreen::initSkin() { Skin skin("audio_browser.skin"); if (skin.isNull()) { return; } skin.set(*this); for (int i=0; i<NUM_BUTTONS; i++) { buttons[i]->close(); buttons[i] = skin.getButton(buttonKeys[i], *this); } buttons[UP]->setAutoRepeat(true); buttons[DOWN]->setAutoRepeat(true); buttons[PGUP]->setAutoRepeat(true); buttons[PGDOWN]->setAutoRepeat(true); cover->close(); cover = skin.getAlbumArt(*this); listView->close(); listView = skin.getSelectionList(slKey, *this); rootDir = settings.readEntry( "headunit/musicpath" , "./" ); QDir dir(rootDir); rootDir = dir.canonicalPath(); }
//////////////////////////////////////////////////////////// /// Entry point of application /// /// \return Application exit code /// //////////////////////////////////////////////////////////// int main() { // Create the window of the application sf::RenderWindow App( sf::VideoMode( 1004, 650, 32 ), "GWEN: SFML", sf::Style::Close ); Gwen::Renderer::SFML GwenRenderer( App ); // // Create a GWEN skin // //Gwen::Skin::Simple skin; //skin.SetRender( &GwenRenderer ); Gwen::Skin::TexturedBase skin( &GwenRenderer ); skin.Init( "DefaultSkin.png" ); // The fonts work differently in SFML - it can't use // system fonts. So force the skin to use a local one. skin.SetDefaultFont( L"OpenSans.ttf", 11 ); // // Create a Canvas (it's root, on which all other GWEN panels are created) // Gwen::Controls::Canvas* pCanvas = new Gwen::Controls::Canvas( &skin ); pCanvas->SetSize( App.GetWidth(), App.GetHeight() ); pCanvas->SetDrawBackground( true ); pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) ); // // Create our unittest control (which is a Window with controls in it) // UnitTest* pUnit = new UnitTest( pCanvas ); //pUnit->SetPos( 10, 10 ); // // Create an input processor // Gwen::Input::SFML GwenInput; GwenInput.Initialize( pCanvas ); #if SFML_VERSION_MAJOR == 2 while ( App.IsOpen() ) #else while ( App.IsOpened() ) #endif { // Handle events sf::Event Event; #if SFML_VERSION_MAJOR == 2 while ( App.PollEvent(Event) ) #else while ( App.GetEvent(Event) ) #endif { // Window closed or escape key pressed : exit #if SFML_VERSION_MAJOR == 2 if ((Event.Type == sf::Event::Closed) || ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))) #else if ((Event.Type == sf::Event::Closed) || ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))) #endif { App.Close(); break; } GwenInput.ProcessMessage( Event ); } // Clear the window App.Clear(); pCanvas->RenderCanvas(); App.Display(); } return EXIT_SUCCESS; }
static CERTCertificate * get_signer_cert(char *addr) { CERTCertDBHandle *handle; CERTCertList *list; CERTCertListNode *node; CERTCertificate *cert = NULL; const char *cp; char *nick; char *vn; int vs, found = 0; addr = skin(addr); vn = ac_alloc(vs = strlen(addr) + 30); snprintf(vn, vs, "smime-sign-nickname-%s", addr); if ((nick = value(vn)) == NULL) nick = value("smime-sign-nickname"); ac_free(vn); handle = CERT_GetDefaultCertDB(); if (nick) { cert = CERT_FindCertByNickname(handle, nick); if (cert == NULL) fprintf(stderr, "No certificate \"%s\" found.\n", nick); return cert; } if ((list = CERT_FindUserCertsByUsage(handle, certUsageEmailSigner, PR_TRUE, PR_TRUE, NULL)) == NULL) { fprintf(stderr, "Cannot find any certificates for signing.\n"); return NULL; } for (node = CERT_LIST_HEAD(list); !CERT_LIST_END(node, list); node = CERT_LIST_NEXT(node)) { if ((cp = CERT_GetCertEmailAddress(&node->cert->subject)) != NULL && asccasecmp(cp, addr) == 0) { cert = node->cert; found++; } } if (cert == NULL) { for (node = CERT_LIST_HEAD(list); !CERT_LIST_END(node, list) && cert == NULL; node = CERT_LIST_NEXT(node)) { cp = CERT_GetFirstEmailAddress(node->cert); while (cp) { if (asccasecmp(cp, addr) == 0) { cert = node->cert; found++; } cp = CERT_GetNextEmailAddress(node->cert, cp); } } } if (found > 1) { fprintf(stderr, "More than one signing certificate found for <%s>.\n" "Use the smime-sign-nickname variable.\n", addr); return NULL; } if (cert == NULL) fprintf(stderr, "Cannot find a signing certificate for <%s>.\n", addr); return cert; }
void GfDriver::getPossibleSkinsInFolder(const std::string& strCarId, const std::string& strFolderPath, std::vector<GfDriverSkin>& vecPossSkins) const { //GfLogDebug(" getPossibleSkinsInFolder(%s, %s) ...\n", // strCarId.c_str(), strFolderPath.c_str()); // Search for skinned livery files, and associated preview files if any. tFList *pLiveryFileList = GfDirGetListFiltered(strFolderPath.c_str(), strCarId.c_str(), pszLiveryTexExt); if (pLiveryFileList) { tFList *pCurLiveryFile = pLiveryFileList; do { pCurLiveryFile = pCurLiveryFile->next; // Extract the skin name from the livery file name. const int nSkinNameLen = // Expecting "<car name>-<skin name>.png" strlen(pCurLiveryFile->name) - strCarId.length() - 1 - strlen(pszLiveryTexExt); std::string strSkinName; if (nSkinNameLen > 0) // Otherwise, default/standard "<car name>.png" { strSkinName = std::string(pCurLiveryFile->name) .substr(strCarId.length() + 1, nSkinNameLen); // Ignore skins with an excluded prefix. int nExclPrfxInd = 0; for (; nExclPrfxInd < nExcludedSkinNamePrefixes; nExclPrfxInd++) if (strSkinName.find(apszExcludedSkinNamePrefixes[nExclPrfxInd]) == 0) break; if (nExclPrfxInd < nExcludedSkinNamePrefixes) continue; } // Ignore skins that are already in the list (path search priority). if (findSkin(vecPossSkins, strSkinName) == vecPossSkins.end()) { // Create the new skin. GfDriverSkin skin(strSkinName); // Add the whole car livery to the skin targets. skin.addTargets(RM_CAR_SKIN_TARGET_WHOLE_LIVERY); GfLogDebug(" Found %s%s livery\n", strSkinName.empty() ? "standard" : strSkinName.c_str(), strSkinName.empty() ? "" : "-skinned"); // Add associated preview image, without really checking file existence // (warn only ; up to the client GUI to do what to do if it doesn't exist). std::ostringstream ossPreviewName; ossPreviewName << strFolderPath << '/' << strCarId; if (!strSkinName.empty()) ossPreviewName << '-' << strSkinName; ossPreviewName << pszPreviewTexSufx; skin.setCarPreviewFileName(ossPreviewName.str()); if (!GfFileExists(ossPreviewName.str().c_str())) GfLogWarning("Preview file not found for %s %s skin (%s)\n", strCarId.c_str(), strSkinName.c_str(), ossPreviewName.str().c_str()); //else // GfLogDebug("* found skin=%s, preview=%s\n", // strSkinName.c_str(), ossPreviewName.str().c_str()); // Add the new skin to the list. vecPossSkins.push_back(skin); } } while (pCurLiveryFile != pLiveryFileList); } GfDirFreeList(pLiveryFileList, NULL, true, true); // Search for skinned interior files, if any. std::string strInteriorPrefix(strCarId); strInteriorPrefix += pszInteriorTexSufx; tFList *pIntFileList = GfDirGetListFiltered(strFolderPath.c_str(), strInteriorPrefix.c_str(), pszInteriorTexExt); if (pIntFileList) { tFList *pCurIntFile = pIntFileList; do { pCurIntFile = pCurIntFile->next; // Extract the skin name from the interior file name. const int nSkinNameLen = // Expecting "<car name>-int-<skin name>.png" strlen(pCurIntFile->name) - strInteriorPrefix.length() - 1 - strlen(pszInteriorTexExt); std::string strSkinName; if (nSkinNameLen > 0) { strSkinName = std::string(pCurIntFile->name) .substr(strInteriorPrefix.length() + 1, nSkinNameLen); // If a skin with such name already exists in the list, update it. std::vector<GfDriverSkin>::iterator itSkin = findSkin(vecPossSkins, strSkinName); if (itSkin != vecPossSkins.end()) { itSkin->addTargets(RM_CAR_SKIN_TARGET_INTERIOR); GfLogDebug(" Found %s-skinned interior (targets:%x)\n", strSkinName.c_str(), itSkin->getTargets()); } } } while (pCurIntFile != pIntFileList); } GfDirFreeList(pIntFileList, NULL, true, true); // Search for skinned logo files if any. tFList *pLogoFileList = GfDirGetListFiltered(strFolderPath.c_str(), pszLogoTexName, pszLogoTexExt); if (pLogoFileList) { tFList *pCurLogoFile = pLogoFileList; do { pCurLogoFile = pCurLogoFile->next; // Extract the skin name from the logo file name. const int nSkinNameLen = // Expecting "logo-<skin name>.png" strlen(pCurLogoFile->name) - strlen(pszLogoTexName) - 1 - strlen(pszLogoTexExt); if (nSkinNameLen > 0) { const std::string strSkinName = std::string(pCurLogoFile->name) .substr(strlen(pszLogoTexName) + 1, nSkinNameLen); // If a skin with such name already exists in the list, update it. std::vector<GfDriverSkin>::iterator itSkin = findSkin(vecPossSkins, strSkinName); if (itSkin != vecPossSkins.end()) { itSkin->addTargets(RM_CAR_SKIN_TARGET_PIT_DOOR); GfLogDebug(" Found %s-skinned logo (targets:%x)\n", strSkinName.c_str(), itSkin->getTargets()); } } } while (pCurLogoFile != pLogoFileList); } GfDirFreeList(pLogoFileList, NULL, true, true); // Search for skinned 3D wheel files if any. tFList *pWheel3DFileList = GfDirGetListFiltered(strFolderPath.c_str(), pszWheel3DTexName, pszWheel3DTexExt); if (pWheel3DFileList) { tFList *pCurWheel3DFile = pWheel3DFileList; do { pCurWheel3DFile = pCurWheel3DFile->next; // Extract the skin name from the 3D wheel texture file name. const int nSkinNameLen = // Expecting "wheel3d-<skin name>.png" strlen(pCurWheel3DFile->name) - strlen(pszWheel3DTexName) - 1 - strlen(pszWheel3DTexExt); if (nSkinNameLen > 0) { const std::string strSkinName = std::string(pCurWheel3DFile->name) .substr(strlen(pszWheel3DTexName) + 1, nSkinNameLen); // If a skin with such name already exists in the list, update it. std::vector<GfDriverSkin>::iterator itSkin = findSkin(vecPossSkins, strSkinName); if (itSkin != vecPossSkins.end()) { itSkin->addTargets(RM_CAR_SKIN_TARGET_3D_WHEELS); GfLogDebug(" Found %s-skinned 3D wheels (targets:%x)\n", strSkinName.c_str(), itSkin->getTargets()); } } } while (pCurWheel3DFile != pWheel3DFileList); } GfDirFreeList(pWheel3DFileList, NULL, true, true); // Search for skinned driver files if any. tFList *pDriverFileList = GfDirGetListFiltered(strFolderPath.c_str(), pszDriverTexName, pszDriverTexExt); if (pDriverFileList) { tFList *pCurDriverFile = pDriverFileList; do { pCurDriverFile = pCurDriverFile->next; // Extract the skin name from the 3D wheel texture file name. const int nSkinNameLen = // Expecting "driver-<skin name>.png" strlen(pCurDriverFile->name) - strlen(pszDriverTexName) - 1 - strlen(pszDriverTexExt); if (nSkinNameLen > 0) { const std::string strSkinName = std::string(pCurDriverFile->name) .substr(strlen(pszDriverTexName) + 1, nSkinNameLen); // If a skin with such name already exists in the list, update it. std::vector<GfDriverSkin>::iterator itSkin = findSkin(vecPossSkins, strSkinName); if (itSkin != vecPossSkins.end()) { itSkin->addTargets(RM_CAR_SKIN_TARGET_DRIVER); GfLogDebug(" Found %s-skinned driver (targets:%x)\n", strSkinName.c_str(), itSkin->getTargets()); } } } while (pCurDriverFile != pDriverFileList); } GfDirFreeList(pDriverFileList, NULL, true, true); }
void GuiDropDownList::setRect(const Rect2D& rect) { m_rect = rect; m_clickRect = skin()->dropDownListToClickBounds(rect); }
bool ExtensionsExtension::init(const ExtensionID &id, const Path &path) { OS_ASSERT(path.empty() == false); OS_ASSERT(m_path.empty()); m_path = path; //String filename = utils::makeFilePath(path, id.toUTF16() + ".xml"); // 0.13 String filename = utils::makeFilePath(path, OS_MANIFESTXML); // 0.14 if(FileSystem::instance()->fileExists(filename) == false) return false; shared_ptr<XMLDocument> document(OS_NEW XMLDocument(XMLSchema::fromFile(utils::makeFilePath(utils::makeFolderPath(Options::instance()->getSharePath(), OS_SCHEMAS_PATH), OS_EXTENSIONS_EXTENSION_SCHEMA)))); if(document->parseFile(filename) == false) return false; String languagesPath = utils::makeFolderPath(path.path(), OS_LANGUAGES_PATH); if(FileSystem::instance()->directoryExists(languagesPath)) { m_languageFolder.reset(OS_NEW LanguageFolder()); m_languageFolder->addPath(languagesPath); } String htdocsPath = utils::makeFolderPath(path.path(), OS_HTDOCS_PATH); if(FileSystem::instance()->directoryExists(htdocsPath)) { // TODO: Qui dovrei fare un'opzione a livello di xml extension, che stabilisce il nome della virtual-directory. Se omesso, è l'ID. // Per ora, forzo l'unico caso in cui mi servirebbe. String virtualName = id.toUTF16(); if(id.toUTF16() == OS_EXTENSIONS_CORE) virtualName = OS_HTDOCS_PATH; m_httpDirectory.reset(OS_NEW HttpPhysicalDirectory(virtualName, htdocsPath)); } // Auto-discovery IdeSkinSimple String skinsPath = utils::makeFolderPath(path.path(), "skins"); { if(FileSystem::instance()->directoryExists(skinsPath)) { StringList skins; FileSystem::instance()->getFiles(skinsPath, skins, false); for(StringList::const_iterator i = skins.begin(); i != skins.end(); ++i) { String config = "/skins/" + *i; String title = FileSystem::instance()->getFileTitle(*i); shared_ptr<IdeSkinSimple> skin(OS_NEW IdeSkinSimple()); if(skin->init(get_this_ptr(), config, title)) m_skins.push_back(skin); } } } shared_ptr<XMLNode> root = document->getRoot(); if(root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_ID) != id.getString()) // Ensure that the directory name is equal to ID. return false; m_id = id; m_name = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_NAME); m_description = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_DESCRIPTION); m_content = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_CONTENT); m_category = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_CATEGORY); m_tags = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_TAGS); m_trust = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_TRUST); m_author = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_AUTHOR); m_versionCode = root->getAttributeInt32(OS_EXTENSION_XML_NODE_ROOT_VERSION_CODE); m_versionName = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_VERSION_NAME); m_compatibility = root->getAttributeInt32(OS_EXTENSION_XML_NODE_ROOT_COMPATIBILITY); /* if(m_version.fromString(root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_VERSION).to_ascii()) == false) return false; String compatibility = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_COMPATIBILITY); if( (compatibility.empty() == false) && (m_compatibility.fromString(compatibility.to_ascii()) == false) ) return false; */ m_homepage = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_HOMEPAGE); m_icon = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_ICON); m_logo = root->getAttributeString(OS_EXTENSION_XML_NODE_ROOT_LOGO); NotificationsManager::instance()->notify(_S("Loading extension: ") + m_name); shared_ptr<XMLNode> nodeFiles = document->getRoot()->getNode(OS_EXTENSION_XML_NODE_SCRIPTS); if(nodeFiles != nullptr) { shared_ptr<XMLNodes> files = nodeFiles->getNodes(); for(XMLNodes::const_iterator i = files->begin(); i != files->end(); ++i) { String scriptPath = utils::makeFilePath(path, (*i)->getAttributeString(OS_EXTENSION_XML_NODE_SCRIPT_PATH)); String scriptLanguage = (*i)->getAttributeString(OS_EXTENSION_XML_NODE_SCRIPT_LANGUAGE); shared_ptr<IExtensionsCodeProvider> codeProvider = ExtensionsSystem::instance()->getCodeProvider(scriptLanguage); if(codeProvider == nullptr) { OS_LOG_ERROR(_S("Invalid script language '") + scriptLanguage + _S("'")); return false; } shared_ptr<IExtensionsCodeContext> context = codeProvider->createContext(); if(context == nullptr) { OS_LOG_ERROR(_S("Cannot create context for script language '") + scriptLanguage + _S("'")); return false; } if(context->parseFile(scriptPath)) m_contexts.push_back(context); else OS_LOG_ERROR(_S("Cannot parse extension file '") + scriptPath + _S("'")); } } return true; }
LADSPAView::LADSPAView(QWidget * parent) : QWidget(parent) { setObjectName("LADSPA"); m_pGridLayout = new QGridLayout(); this->setLayout(m_pGridLayout); QDomDocument skin("LADSPASkin"); QFile file(WWidget::getPath("ladspa_skin.xml")); if (!file.open(IO_ReadOnly)) { qDebug() << "Could not open skin definition file: " << file.fileName(); } if (!skin.setContent(&file)) { qDebug() << "Error parsing skin definition file: " << file.fileName(); } file.close(); QDomElement docElement = skin.documentElement(); QDomElement bgElement = docElement.firstChildElement("Background"); QString filename = bgElement.firstChildElement("Path").text(); QPixmap *background = WPixmapStore::getPixmapNoCache(WWidget::getPath(filename)); //QLabel *bg = new QLabel(this); //bg->move(0, 0); //bg->setPixmap(*background); //bg->lower(); //this->setFixedSize(background->width(), background->height()); //parent->setMinimumSize(background->width(), background->height()); QDomElement bgColorNode = docElement.firstChildElement("BgColor"); QDomElement fgColorNode = docElement.firstChildElement("FgColor"); QPalette palette; QColor c(0,0,0); c.setNamedColor(bgColorNode.text()); palette.setBrush(QPalette::Window, WSkinColor::getCorrectColor(c)); QColor c2(255,255,255); c2.setNamedColor(fgColorNode.text()); palette.setBrush(foregroundRole(), WSkinColor::getCorrectColor(c2)); setBackgroundRole(QPalette::Window); setPalette(palette); setAutoFillBackground(true); palette.setColor(QPalette::Base, WSkinColor::getCorrectColor(c)); palette.setColor(QPalette::Text, WSkinColor::getCorrectColor(c2)); m_pPresetList = new QListWidget(this); m_pPresetList->setDragEnabled(true); QDomElement presetListElement = docElement.firstChildElement("PresetList"); QDomElement posElement = presetListElement.firstChildElement("Pos"); QString pos = posElement.text(); int x = pos.left(pos.indexOf(",")).toInt(); int y = pos.mid(pos.indexOf(",") + 1).toInt(); if (x < 0) { x = this->width() + x; } if (y < 0) { y = this->height() + y; } //m_pPresetList->move(x, y); QDomElement sizeElement = presetListElement.firstChildElement("Size"); QString size = sizeElement.text(); int width = size.left(size.indexOf(",")).toInt(); int height = size.mid(size.indexOf(",") + 1).toInt(); if (width <= 0) { width = this->width() + width; } if (height <= 0) { height = this->height() + height; } //m_pPresetList->resize(width, height); m_pPresetList->setMinimumSize(65, 200); m_pPresetList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding); m_pPresetManager = new LADSPAPresetManager(); for (unsigned int i = 0; i < m_pPresetManager->getPresetCount(); i++) { LADSPAPreset *preset = m_pPresetManager->getPreset(i); if (preset->isValid()) m_pPresetList->addItem(preset->getName()); else m_pPresetList->addItem("-" + preset->getName()); } m_pSlotTable = new QWidget(this); QDomElement slotTableElement = docElement.firstChildElement("SlotTable"); posElement = slotTableElement.firstChildElement("Pos"); pos = posElement.text(); x = pos.left(pos.indexOf(",")).toInt(); y = pos.mid(pos.indexOf(",") + 1).toInt(); if (x < 0) { x = this->width() + x; } if (y < 0) { y = this->height() + y; } m_pSlotTable->move(x, y); sizeElement = slotTableElement.firstChildElement("Size"); size = sizeElement.text(); width = size.left(size.indexOf(",")).toInt(); height = size.mid(size.indexOf(",") + 1).toInt(); if (width <= 0) { width = this->width() + width; } if (height <= 0) { height = this->height() + height; } //m_pSlotTable->resize(width, height); m_pSlotTable->setMinimumSize(400, 200); m_pSlotTable->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_pSlotTable->show(); QDomElement slotsElement = slotTableElement.firstChildElement("Slots"); int numberOfSlots = slotsElement.text().toInt(); QDomElement slotElement = slotTableElement.firstChildElement("Slot"); for (int i = 0; i < numberOfSlots; i++) { LADSPAPresetSlot *p = new LADSPAPresetSlot(m_pSlotTable, slotElement, i, m_pPresetManager, palette); p->show(); } m_pPresetList->updateGeometry(); //Notify Qt that the preset list has changed. m_pPresetList->setBackgroundRole(QPalette::Window); m_pPresetList->setPalette(palette); m_pPresetList->setAutoFillBackground(true); //parent->setPalette(palette); m_pGridLayout->addWidget(m_pPresetList, 0, 0);//, //row 0, col 0 //1, 1); //span 1 row, span 1 col m_pGridLayout->addWidget(m_pSlotTable, 0, 1);//, //row 0, col 1 //1, 2); //span 1 row, span 2 cols }
void runSample() { RECT FrameBounds; GetClientRect( g_pHWND, &FrameBounds ); // // Create a GWEN skin // gwen::Skin::TexturedBase skin( g_pRenderer ); skin.Init( "DefaultSkin.png" ); // // Create a Canvas (it's root, on which all other GWEN panels are created) // gwen::Controls::Canvas* pCanvas = new gwen::Controls::Canvas( &skin ); pCanvas->SetSize( FrameBounds.right, FrameBounds.bottom ); pCanvas->SetDrawBackground( true ); pCanvas->SetBackgroundColor( gwen::Color( 150, 170, 170, 255 ) ); // // Create our unittest control (which is a Window with controls in it) // UnitTest* pUnit = new UnitTest( pCanvas ); pUnit->SetPos( 10, 10 ); // // Create a Windows Control helper // (Processes Windows MSG's and fires input at GWEN) // gwen::Input::Windows gwenInput; gwenInput.Initialize( pCanvas ); // // Begin the main game loop // MSG msg; while ( true ) { // Skip out if the window is closed if ( !IsWindowVisible( g_pHWND ) ) { break; } // If we have a message from windows.. if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { // .. give it to the input handler to process gwenInput.ProcessMessage( msg ); // if it's QUIT then quit.. if ( msg.message == WM_QUIT ) { break; } // Handle the regular window stuff.. TranslateMessage( &msg ); DispatchMessage( &msg ); } { if ( SUCCEEDED( createDeviceResources() ) ) { g_pRT->BeginDraw(); g_pRT->SetTransform( D2D1::Matrix3x2F::Identity() ); g_pRT->Clear( D2D1::ColorF( D2D1::ColorF::White ) ); // This is how easy it is to render GWEN! pCanvas->RenderCanvas(); HRESULT hr = g_pRT->EndDraw(); if ( hr == D2DERR_RECREATE_TARGET ) { discardDeviceResources(); g_pRenderer->DeviceLost(); } } } } delete pCanvas; }
static void hprf(const char *fmt, int mesg, FILE *f, int threaded, const char *attrlist) { struct message *mp = &message[mesg-1]; char *headline = NULL, *subjline, *name, *cp, *pbuf = NULL; struct headline hl; size_t headsize = 0; const char *fp; int B, c, i, n, s; int headlen = 0; struct str in, out; int subjlen = scrnwidth, fromlen, isto = 0, isaddr = 0; FILE *ibuf; if ((mp->m_flag & MNOFROM) == 0) { if ((ibuf = setinput(&mb, mp, NEED_HEADER)) == NULL) return; if ((headlen = readline(ibuf, &headline, &headsize)) < 0) return; } if ((subjline = hfield("subject", mp)) == NULL) subjline = hfield("subj", mp); if (subjline == NULL) { out.s = NULL; out.l = 0; } else { in.s = subjline; in.l = strlen(subjline); mime_fromhdr(&in, &out, TD_ICONV | TD_ISPR); subjline = out.s; } if ((mp->m_flag & MNOFROM) == 0) { pbuf = ac_alloc(headlen + 1); parse(headline, headlen, &hl, pbuf); } else { hl.l_from = /*fakefrom(mp);*/NULL; hl.l_tty = NULL; hl.l_date = fakedate(mp->m_time); } if (value("datefield") && (cp = hfield("date", mp)) != NULL) hl.l_date = fakedate(rfctime(cp)); if (Iflag) { if ((name = hfield("newsgroups", mp)) == NULL) if ((name = hfield("article-id", mp)) == NULL) name = "<>"; name = prstr(name); } else if (value("show-rcpt") == NULL) { name = name1(mp, 0); isaddr = 1; if (value("showto") && name && is_myname(skin(name))) { if ((cp = hfield("to", mp)) != NULL) { name = cp; isto = 1; } } } else { isaddr = 1; if ((name = hfield("to", mp)) != NULL) isto = 1; } if (name == NULL) { name = ""; isaddr = 0; } if (isaddr) { if (value("showname")) name = realname(name); else { name = prstr(skin(name)); } } for (fp = fmt; *fp; fp++) { if (*fp == '%') { if (*++fp == '-') { fp++; } else if (*fp == '+') fp++; while (digitchar(*fp&0377)) fp++; if (*fp == '\0') break; } else { #if defined (HAVE_MBTOWC) && defined (HAVE_WCWIDTH) if (mb_cur_max > 1) { wchar_t wc; if ((s = mbtowc(&wc, fp, mb_cur_max)) < 0) n = s = 1; else { if ((n = wcwidth(wc)) < 0) n = 1; } } else #endif /* HAVE_MBTOWC && HAVE_WCWIDTH */ { n = s = 1; } subjlen -= n; while (--s > 0) fp++; } } for (fp = fmt; *fp; fp++) { if (*fp == '%') { B = 0; n = 0; s = 1; if (*++fp == '-') { s = -1; fp++; } else if (*fp == '+') fp++; if (digitchar(*fp&0377)) { do n = 10*n + *fp - '0'; while (fp++, digitchar(*fp&0377)); } if (*fp == '\0') break; n *= s; switch (*fp) { case '%': putc('%', f); subjlen--; break; case '>': case '<': c = dot == mp ? *fp&0377 : ' '; putc(c, f); subjlen--; break; case 'a': c = dispc(mp, attrlist); putc(c, f); subjlen--; break; case 'm': if (n == 0) { n = 3; if (threaded) for (i=msgCount; i>999; i/=10) n++; } subjlen -= fprintf(f, "%*d", n, mesg); break; case 'f': if (n <= 0) n = 18; fromlen = n; if (isto) fromlen -= 3; fprintf(f, "%s%s", isto ? "To " : "", colalign(name, fromlen, 1)); subjlen -= n; break; case 'd': if (n <= 0) n = 16; subjlen -= fprintf(f, "%*.*s", n, n, hl.l_date); break; case 'l': if (n == 0) n = 4; if (mp->m_xlines) subjlen -= fprintf(f, "%*ld", n, mp->m_xlines); else { subjlen -= n; while (n--) putc(' ', f); } break; case 'o': if (n == 0) n = -5; subjlen -= fprintf(f, "%*lu", n, (long)mp->m_xsize); break; case 'i': if (threaded) subjlen -= putindent(f, mp, scrnwidth - 60); break; case 'S': B = 1; /*FALLTHRU*/ case 's': n = n>0 ? n : subjlen - 2; if (B) n -= 2; if (subjline != NULL && n >= 0) { /* pretty pathetic */ fprintf(f, B ? "\"%s\"" : "%s", colalign(subjline, n, 0)); } break; case 'U': if (n == 0) n = 9; subjlen -= fprintf(f, "%*lu", n, mp->m_uid); break; case 'e': if (n == 0) n = 2; subjlen -= fprintf(f, "%*u", n, threaded == 1 ? mp->m_level : 0); break; case 't': if (n == 0) { n = 3; if (threaded) for (i=msgCount; i>999; i/=10) n++; } fprintf(f, "%*ld", n, threaded ? mp->m_threadpos : mesg); subjlen -= n; break; case 'c': if (n == 0) n = 6; subjlen -= fprintf(f, "%*g", n, mp->m_score); break; } } else putc(*fp&0377, f); } putc('\n', f); if (out.s) free(out.s); if (headline) free(headline); if (pbuf) ac_free(pbuf); }