Exemplo n.º 1
0
Simulator::Simulator()
{
    fprintf(stderr, "Creating simulator.\n");
    
    // Translate height map to surface polygons
    // Map dimensions are currently hardcoded
    double xs = 10;
    double ys = 4;
    double zs = 10;
    int size = 10;
    Vector3 tl, tr, bl, br;
    for (int i = 0; i < size - 1; i++)
    {
        for (int j = 0; j < size - 1; j++)
        {
            // Calculate the world coordinates of surface from map
            tl = Vector3((-size / 2 + i) * xs + xs/2, map[i][j] * ys, (-size / 2 + j) * zs + zs/2);
            tr = Vector3((-size / 2 + i + 1) * xs + xs/2, map[i + 1][j] * ys, (-size / 2 + j) * zs + zs/2);
            bl = Vector3((-size / 2 + i) * xs + xs/2, map[i][j + 1] * ys, (-size / 2 + j + 1) * zs + zs/2);
            br = Vector3((-size / 2 + i + 1) * xs + xs/2, map[i + 1][j + 1] * ys, (-size / 2 + j + 1) * zs + zs/2);
            
            // Add surfaces to surface lookup
            this->surfacemap[i * 2 + j * 10 * 2 + 0] = Surface(tl, tr - tl, bl - tl);
            this->surfacemap[i * 2 + j * 10 * 2 + 1] = Surface(br, bl - br, tr - br);
            
            // Add surfaces to surface list
            this->surfaces.addFirst(&this->surfacemap[i * 2 + j * 10 * 2 + 0]); 
            this->surfaces.addFirst(&this->surfacemap[i * 2 + j * 10 * 2 + 1]);
        }
    }
    
    this->iterations = 0;
    this->rigidSprings = true;
}
Exemplo n.º 2
0
void Flagaccess(int order)
{
    long i, k;
    double f;
    long FORLIM;
    Backbone *WITH;
    long FORLIM1;
    CAS *cas= CASCreate(order);
    AddToAllAtomRadii(RWATER); /* add the water radius :-) */
    CalcResidueCenters();
    FORLIM = lchain;
    for (i = 1; i <= FORLIM; i++) {
	if (chain[i].aa != '!') {
	    WITH = &chain[i];
	    FindNeighbourRes(WITH->boxmin, WITH->boxmax);
	    f = Surface(cas,WITH->n) + Surface(cas, WITH->ca) +
		Surface(cas, WITH->c) + Surface(cas, WITH->o);
	    if (WITH->nsideatoms > 0) {
		FORLIM1 = WITH->nsideatoms;
		for (k = 0; k < FORLIM1; k++)
		    f += Surface(cas, sidechain[WITH->atompointer + k]);
	    }
	    WITH->access = (long)floor(f + 0.5);
	}
    }
    AddToAllAtomRadii(-RWATER);   /* remove the water :-) */
    CASDelete(cas);
}  /* Flagaccess */
Exemplo n.º 3
0
BOOL display::SetDisplayMode(WORD _width, WORD _height, BYTE _bpp)
{
    int error = 0;

    set_color_depth(_bpp);
    error = set_gfx_mode(this->mode, _width, _height, 0, 0);

    if(error != 0)
    {
        LogError("Error setting graphics resolution.");
        LogError("Allegro returned this error message: %s", allegro_error);
        return false;
    }

    this->back = Surface(new surface(_width, _height, _bpp));
    this->_screen = Surface(new surface(::screen));
    this->_screen->Acquire();
    this->_screen->ShowMouse();
    this->_screen->Release();

    this->width = _width;
    this->height = _height;
    this->bpp = _bpp;
    /*LogMessage("Screen resolution succesfully changed.");
    LogMessage("Display Width: %d", this->width);
    LogMessage("Display Height: %d", this->height);
    LogMessage("Display bits per pixel: %d", this->bpp);
    LogMessage("Display mode: %d",  this->mode);*/
    //queue a message stating that the gfx has been changed.
    QueueMessage(Message(new message(0, MSG_GFX_SCREEN_RES_CHANGED, MAKEDWORD(_width, _height), MAKEDWORD((WORD)_bpp, (WORD)this->mode), NULL)));

    return true;
}
Exemplo n.º 4
0
BOOL display::SetDisplayMode(WORD _mode, WORD _width, WORD _height, BYTE _bpp)
{
    int error = 0;

    set_color_depth(_bpp);
    if((error = set_gfx_mode(_mode, _width, _height, 0, 0)) != 0)
    {
        LogError("Error setting graphics resolution.");
        LogError("Allegro returned this error message: %s", allegro_error);
        return false;
    }

    this->back = Surface(new surface(_width, _height, _bpp));
    this->_screen = Surface(new surface(::screen));
    acquire_screen();
    show_mouse(::screen);
    acquire_screen();
    this->mode = _mode;
    this->width = _width;
    this->height = _height;
    this->bpp = _bpp;
    LogMessage("Screen resolution succesfully changed.");

    return true;
}
Exemplo n.º 5
0
void Framework3D::CreateSplashWindow(const uint WindowIcon,
                                     const char* const Title) {
  XTRACE_FUNCTION;

  STATICHASH(Framework);
  STATICHASH(SplashImage);
  const char* const pSplashImage =
      ConfigManager::GetString(sSplashImage, nullptr, sFramework);
  if (!pSplashImage) {
    return;
  }

  const Surface SplashSurface =
      Surface(PackStream(pSplashImage), Surface::ESFT_BMP);
  const int SplashWindowWidth = SplashSurface.GetWidth();
  const int SplashWindowHeight = SplashSurface.GetHeight();

  ASSERT(!m_SplashWindow);
  m_SplashWindow = new Window;

#if BUILD_WINDOWS_NO_SDL
  const DWORD WindowStyle = WS_POPUP;
  const DWORD WindowExStyle =
      WS_EX_TOOLWINDOW;  // Prevents this window appearing in the taskbar
  const int ScreenWidth =
      m_Display->m_Fullscreen ? m_Display->m_Width : m_Display->m_ScreenWidth;
  const int ScreenHeight =
      m_Display->m_Fullscreen ? m_Display->m_Height : m_Display->m_ScreenHeight;

  m_SplashWindow->Init(Title, "SplashWindowClass", WindowStyle, WindowExStyle,
                       SplashWindowWidth, SplashWindowHeight, m_hInstance, NULL,
                       WindowIcon, ScreenWidth, ScreenHeight);

  // The window needs to be shown before we can blit to it.
  m_SplashWindow->Show(m_CmdShow);
#endif
#if BUILD_SDL
  // TODO SDL: Unify interface?
  const uint Flags = SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS;
  m_SplashWindow->Init(Title, Flags, SplashWindowWidth, SplashWindowHeight);

  // Load icon from package file instead of compiled resource.
  Unused(WindowIcon);
  STATICHASH(IconImage);
  const char* const pIconImage =
      ConfigManager::GetString(sIconImage, nullptr, sFramework);
  if(pIconImage) {
    ASSERT(pIconImage);
    const Surface IconSurface =
        Surface(PackStream(pIconImage), Surface::ESFT_BMP);
    SDL_SetWindowIcon(m_SplashWindow->GetSDLWindow(),
                      IconSurface.GetSDLSurface());
  }
#endif

  SplashSurface.BlitToWindow(m_SplashWindow);
}
Exemplo n.º 6
0
void SurfaceImage::initCinderSurface( bool alpha, uint8_t *data, int32_t stride )
{
#if defined( BOOST_BIG_ENDIAN )
	if( alpha )
		mCinderSurface = Surface( data, mWidth, mHeight, stride, SurfaceChannelOrder::ARGB );
	else
		mCinderSurface = Surface( data, mWidth, mHeight, stride, SurfaceChannelOrder::RGBX );
#else
	if( alpha )
		mCinderSurface = Surface( data, mWidth, mHeight, stride, SurfaceChannelOrder::BGRA );
	else
		mCinderSurface = Surface( data, mWidth, mHeight, stride, SurfaceChannelOrder::BGRX );
#endif
}
Exemplo n.º 7
0
display::display()
{
	this->mode = GFX_AUTODETECT_WINDOWED;
	this->width = 800;
	this->height = 600;
	this->bpp = 32;
	this->number_of_surfaces = 0;
	this->hsync = 0;
	this->vsync = 0;
	this->_screen = Surface(new surface());
	this->back = Surface(new surface());
	this->background_image = Surface(new surface());
	this->devCaps = null;
    LogMessage("Display initialized.");
}
Exemplo n.º 8
0
Surface Font::GenerateSurface(const std::string & txt,
                              const Color & color,
                              font_size_t font_size,
                              font_style_t font_style)
{
  return Surface(Font::GetInstance(font_size, font_style)->CreateSurface(txt, color));
}
Exemplo n.º 9
0
void VideoSystem::DrawRectAlpha(SDL_Rect *r, Uint32 color) {
#if 0
    SDL_Surface *surf = Surface(r->w, r->h, screen->format->BitsPerPixel);
    if (!surf)
        return;

    for (int y=0;y<surf->h;y++) {
        Uint16 *src = (Uint16*)(screen->pixels + ((r->y+y)*screen->pitch) + (r->x*2));
        Uint16 *dst = (Uint16*)(surf->pixels + (y*surf->pitch));
        for (int x=0;x<surf->w;x++) {
            Uint8 r1, g1, b1;
            Uint8 r2, g2, b2;
            int r3, g3, b3;
            Uint16 px;
            SDL_GetRGB(*src, screen->format, &r1, &g1, &b1);
            SDL_GetRGB(color, surf->format, &r2, &g2, &b2);
            r3 = std::min(255, ((r1*256)/256 + (r2*256)/256));
            g3 = std::min(255, ((g1*256)/256 + (g2*256)/256));
            b3 = std::min(255, ((b1*256)/256 + (b2*256)/256));
            px = SDL_MapRGB(surf->format, r3, g3, b3);
            *dst = px;
            src++;
        }
    }
    Blit(surf, NULL, r);
    SDL_FreeSurface(surf);
#endif
}
Exemplo n.º 10
0
void
ModelTravelTimeDynamic::processHorizons(std::vector<Surface>   & horizons,
                                        const InputFiles       * inputFiles,
                                        std::string            & errTxt,
                                        bool                   & failed)
{

  const std::vector<std::string> & travel_time_horizons = inputFiles->getTravelTimeHorizons(thisTimeLapse_);

  int n_horizons = static_cast<int>(travel_time_horizons.size());

  if(n_horizons == 1) {
    if(travel_time_horizons[0] != "") {
      errTxt += "Only one surface is given for inversion of the horizons in the travel time data. At least two surfaces should be given\n";
      failed = true;
    }
  }

  else {
    horizons.resize(n_horizons);
    for(int i=0; i<n_horizons; i++)
      horizons[i] = Surface(travel_time_horizons[i]);
  }

}
Exemplo n.º 11
0
FramebufferSurface& load_framebuffer_surface(const Pathname& filename, ResourceModifier::Enum modifier)
{
  //a little bit awkward to have map in map, but that's easier than writing special Key type
  static std::map<std::string, std::map<ResourceModifier::Enum, FramebufferSurface> > cache;
  static FramebufferSurface image404 = Display::get_framebuffer()->create_surface(Surface(Pathname("images/core/misc/404.png", Pathname::DATA_PATH)));

  std::string pathname = filename.get_sys_path();
  if(cache.count(pathname) && cache[pathname].count(modifier))
    return cache[pathname][modifier];

  try
  {
    Surface surface(filename);
    if(modifier != ResourceModifier::ROT0)
      surface = surface.mod(modifier);    
    cache[pathname][modifier] = Display::get_framebuffer()->create_surface(surface);
    return cache[pathname][modifier];
  }
  catch(const std::exception& err)
  {
    // return a dummy surface for cases where the image file can't be found
    log_error("%1%", err.what());
    return image404;
  }
}
Exemplo n.º 12
0
 Surface make_surface(float width, float height) {
   auto ics = plx::CreateDCoSurface(
       dc_device_,
       static_cast<unsigned int>(dpi_.to_physical_x(width)),
       static_cast<unsigned int>(dpi_.to_physical_x(height)));
   return Surface(ics, dpi_, width, height);
 }
Exemplo n.º 13
0
    void Image::beginLoad()
    {
        this->loading = true;

        AssetManager::Options opts;
        opts.watch(false).asynchronous(true);

        AssetManager::load<ImageSourceRef>(
            this->path,
            [](DataSourceRef dataSourceRef) {
                ImageSourceRef imageSource = loadImage(dataSourceRef);
                return imageSource;
            },
            [&](ImageSourceRef imgSourceRef) {
                this->data = Surface(imgSourceRef);
                this->texture = gl::Texture::create(this->data);

                this->loading = false;
                this->loadCompleted = true;

                if (this->loadCallback) {
                    this->loadCallback();
                }
            },
            opts
        );
    }
Exemplo n.º 14
0
void
MapTile::put(Surface src, int x, int y)
{
  if (!surface)
    surface = Surface(globals::tile_size, globals::tile_size);
  
  surface.blit(src, x, y);
  sprite_needs_update = true;
}
Exemplo n.º 15
0
Surface ImageImporter::toSurface(const QPoint &p) const
{
	if (!isValid())
		return Surface();
	
	Surface surface;
	pasteFIBITMAPToImage(p, &surface, d->bitmap);
	return surface;
}
Exemplo n.º 16
0
HRESULT MainMenu::initialize()
{
	setDimensions(UVector2(225, 100), UVector2(350, 470));
	setName("MainMenu");
	
	Font    standardFont;
	Texture fontTexture;

	Surface()->loadTexture(fontTexture, "ui\\standardFont.png");
	if(FAILED(standardFont.initialize("..\\data\\userinterface\\standardfont.ini", fontTexture, 20)))
		return E_FAIL;

	//Initialize buttons (children)	
	m_pStartSPButton.initialize(this, "btnStartSP", "ui\\standardButton.png");
	m_pStartSPButton.setDimensions(UVector2(40, 130), UVector2(250, 50));
	m_pStartSPButton.setText("Singleplayer", standardFont);

	m_pStartMPButton.initialize(this, "btnStartMP", "ui\\standardButton.png");
	m_pStartMPButton.setDimensions(UVector2(40, 130 + 55), UVector2(250, 50));
	m_pStartMPButton.setText("Multiplayer", standardFont);

	m_pEditorButton.initialize(this, "btnEditor", "ui\\standardButton.png");
	m_pEditorButton.setDimensions(UVector2(40, 130 + 110), UVector2(250, 50));
	m_pEditorButton.setText("Editor", standardFont);
	
	m_pOptionsButton.initialize(this, "btnOptions", "ui\\standardButton.png");
	m_pOptionsButton.setDimensions(UVector2(40, 130 + 165), UVector2(250, 50));
	m_pOptionsButton.setText("Options", standardFont);

	m_pQuitButton.initialize(this, "btnQuit", "ui\\standardButton.png");
	m_pQuitButton.setDimensions(UVector2(40, 130 + 220), UVector2(250, 50));
	m_pQuitButton.setText("Quit", standardFont);

	//Initialize background	
	m_sprite.pos        = m_elementPos;
	m_sprite.size       = m_elementSize;
	m_sprite.uLayer     = m_elementLayer; 
	m_sprite.texCoord   = glm::vec2(0.0f, 0.0f);
	m_sprite.texSize    = glm::vec2(1.0f, 1.0f);
	m_sprite.color      = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
	Surface()->loadTexture(m_sprite.texture, "ui\\mainMenu.png");

	return S_OK;
}
Exemplo n.º 17
0
//---------------------------------------------------------------------------
Surface Texture::getLevel (uint uiLevel/*=0*/)
{
  IDirect3DSurface9* pSurf;

  GLB_ASSERT(this->getRef());
  GLB_DXTEST(this->getRef()->GetSurfaceLevel(uiLevel, &pSurf));
  pSurf->Release(); // GetSurfaceLevel() incremented the ref counter

  return Surface(pSurf);
}
Exemplo n.º 18
0
void House::Build()
{
	double max_step = 8.f;
	if (sqrt(Surface(*vertices))/City::HumanSize >= 20.f)
	{
		max_step = 3.f;
	}
	
	CreatePyramid(rand_double(1.f, max_step));
}
Exemplo n.º 19
0
//Sets the background of the screen to the specified image
void display::SetBackground(const std::string& File)
{
    //char *file_name = File.c_str();
    LogMessage("Attempting to change the background.");
    this->background_image = Surface(new surface(File));
    if(this->background_image->Size() != 0)
        this->_screen->Blit(this->background_image, 0, 0, 0, 0, this->background_image->Width(), this->background_image->Height());
    else
        return;
}
Exemplo n.º 20
0
void Message::Resize() {
  SIZE tsize;
  const size_t size = msgText.size();
  RECT rthis;
  //  RECT mRc;

  if (size==0) {
    if (!hidden) {
        WndMsg.SetVisible(false);
#ifndef USE_GDI
        MainWindow.Refresh();
#endif        
    }
    hidden = true;
  } else {
    
    WndMsg.SetWndText(msgText.c_str());

    LKWindowSurface Surface(WndMsg);
    const auto oldfont = Surface.SelectObject(ScreenLandscape
                                              ? LK8InfoBigFont
                                              : MapWindowBoldFont);

    Surface.GetTextSize(msgText.c_str(), &tsize);

    Surface.SelectObject(oldfont); // 100215

    const int linecount = max(nvisible, max(1, WndMsg.GetLineCount()));

    int width =// min((rcmsg.right-rcmsg.left)*0.8,tsize.cx);
      (int)((rcmsg.right-rcmsg.left)*0.9);
    int height = (int)min((rcmsg.bottom-rcmsg.top)*0.8,(double)tsize.cy*(linecount+1));
    int h1 = height/2;
    int h2 = height-h1;

    int midx = (rcmsg.right+rcmsg.left)/2;
    int midy = (rcmsg.bottom+rcmsg.top)/2;

    rthis.left = midx-width/2;
    rthis.right = midx+width/2;
    rthis.top = midy-h1;
    rthis.bottom = midy+h2;

    WndMsg.SetTopWnd();
    WndMsg.Move(rthis);
    WndMsg.SetVisible(true);
    hidden = false;
    
#ifndef USE_GDI
    MainWindow.Refresh();
#endif     

  }

}
Exemplo n.º 21
0
Surface Font::CreateSurface(const std::string & txt,
                            const Color & color)
{
#ifdef HAVE_HANDHELD // would be HAVE_HANDHELD if ANDROID didn't misteriously crash because of it
  SDL_Surface *surf = TTF_RenderUTF8_Solid(m_font, txt.c_str(), color.GetSDLColor());
#else
  SDL_Surface *surf = TTF_RenderUTF8_Blended(m_font, txt.c_str(), color.GetSDLColor());
#endif

  if (!surf) {
    // SDL_ttf or freetype might be missing some feature, report it
    Error(Format("Unable to render text: %s", TTF_GetError()));
  }
  
#ifdef HAVE_HANDHELD
  return Surface(surf).DisplayFormat();
#else
  return Surface(surf).DisplayFormatAlpha();
#endif
}
Exemplo n.º 22
0
void
LayerRegion::merge_slices()
{
    // without safety offset, artifacts are generated (GH #2494)
    ExPolygons expp = union_ex((Polygons)this->slices, true);
    this->slices.surfaces.clear();
    this->slices.surfaces.reserve(expp.size());
    
    for (ExPolygons::const_iterator expoly = expp.begin(); expoly != expp.end(); ++expoly)
        this->slices.surfaces.push_back(Surface(stInternal, *expoly));
}
Exemplo n.º 23
0
Surface
Resource::load_surface(const ResDescriptor& desc_)
{
  SpriteDescription* desc = resmgr.get_sprite_description(desc_.res_name);
  if (desc)
  {
    if (desc->array != Size(1, 1) ||
        desc->frame_pos != Vector2i(0, 0) ||
        desc->frame_size != Size(-1, -1))
    {
      Surface surface(desc->filename);

      surface = surface.subsection(Rect(desc->frame_pos, desc->frame_size));

      if (desc_.modifier == ResourceModifier::ROT0)
      {
        return surface;
      }
      else
      {
        return surface.mod(desc_.modifier);
      }
    }
    else
    {
      if (desc_.modifier == ResourceModifier::ROT0)
      {
        return Surface(desc->filename);
      }
      else
      {
        return Surface(desc->filename).mod(desc_.modifier);
      }
    }
  }
  else
  {
    log_error("failed to load surface: %1%", desc_.res_name);
    return Surface(Pathname("images/core/misc/404.png", Pathname::DATA_PATH));
  }
}
Exemplo n.º 24
0
void
SLAPrint::_infill_layer(size_t i, const Fill* _fill)
{
    Layer &layer = this->layers[i];
    
    const float shell_thickness = this->config.get_abs_value("perimeter_extrusion_width", this->config.layer_height.value);
    
    // In order to detect what regions of this layer need to be solid,
    // perform an intersection with layers within the requested shell thickness.
    Polygons internal = layer.slices;
    for (size_t j = 0; j < this->layers.size(); ++j) {
        const Layer &other = this->layers[j];
        if (abs(other.print_z - layer.print_z) > shell_thickness) continue;
    
        if (j == 0 || j == this->layers.size()-1) {
            internal.clear();
            break;
        } else if (i != j) {
            internal = intersection(internal, other.slices);
            if (internal.empty()) break;
        }
    }
    
    // If we have no internal infill, just print the whole layer as a solid slice.
    if (internal.empty()) return;
    layer.solid = false;
    
    const Polygons infill = offset(layer.slices, -scale_(shell_thickness));
    
    // Generate solid infill
    layer.solid_infill << diff_ex(infill, internal, true);
    
    // Generate internal infill
    {
        std::auto_ptr<Fill> fill(_fill->clone());
        fill->layer_id = i;
        fill->z        = layer.print_z;
        
        ExtrusionPath templ(erInternalInfill);
        templ.width = fill->spacing;
        const ExPolygons internal_ex = intersection_ex(infill, internal);
        for (ExPolygons::const_iterator it = internal_ex.begin(); it != internal_ex.end(); ++it) {
            Polylines polylines = fill->fill_surface(Surface(stInternal, *it));
            layer.infill.append(polylines, templ);
        }
    }
    
    // Generate perimeter(s).
    layer.perimeters << diff_ex(
        layer.slices,
        offset(layer.slices, -scale_(shell_thickness))
    );
}
Exemplo n.º 25
0
    PerlinContent::PerlinContent() :
    TextureContent()
    ,mSeed(1221) //clock() & 65535)
	,mOctaves(4)
    ,mPosition(0,0)
	,mFrequency(1.0f / 20.0f)
    ,mPerlin( mOctaves, mSeed )
    {
        Vec2i noiseSize = getTextureSize();
        mNoiseSurface = Surface( noiseSize.x, noiseSize.y, false);
        mTexture = gl::TextureRef( new gl::Texture(noiseSize.x, noiseSize.y) );
    }
Exemplo n.º 26
0
void SizeCursor::ModifyCursor(const u8 w, const u8 h)
{
    if(cursor.w() == w && cursor.h() == h) return;

    cursor = Surface(w * TILEWIDTH, h * TILEWIDTH);

    cursor.SetColorKey();

    Cursor::DrawCursor(cursor, 0x40);

    SetSprite(cursor);
}
Exemplo n.º 27
0
static void NextPage(WndForm* pForm, int Step){
  if(!pForm) {
    return;
  }

  TCHAR buffer[200];
  page += Step;
  if (page>=nLists) {
    page=0;
  }
  if (page<0) {
    page= nLists-1;
  }

  WndOwnerDrawFrame* wDetailsEntry = (WndOwnerDrawFrame*)pForm->FindByName(TEXT("frmDetailsEntry"));
  if(!wDetailsEntry) {
    return;
  }

  LKWindowSurface Surface(*wDetailsEntry);
  Surface.SelectObject(wDetailsEntry->GetFont());
  aTextLine.update(Surface, wDetailsEntry->GetWidth(), ChecklistText[page]);

  switch(nLists) {
	case 0:
		_stprintf(buffer, _T("%s %s"),NoteModeTitle,MsgToken(1750)); // empty
		break;
	case 1:
		_stprintf(buffer, _T("%s"),NoteModeTitle);
		break;
	default:
		_stprintf(buffer, _T("%s %d/%d"),NoteModeTitle,page+1,nLists);
		break;
  }

  if (ChecklistTitle[page] &&
      (_tcslen(ChecklistTitle[page])>0)
      && (_tcslen(ChecklistTitle[page])<60)) {
	_tcscat(buffer, TEXT(": "));
	_tcscat(buffer, ChecklistTitle[page]);
  }

  pForm->SetCaption(buffer);

  WndListFrame* wDetails = (WndListFrame*)pForm->FindByName(TEXT("frmDetails"));
  if(wDetails) {
    wDetails->ResetList();
    wDetails->Redraw();
  }
}
Exemplo n.º 28
0
void dlgHelpShowModal(const TCHAR* Caption, const TCHAR* HelpText) {
  if (!Caption || !HelpText) {
    return;
  }

  std::unique_ptr<WndForm> wf(dlgLoadFromXML(CallBackTable, ScreenLandscape ? IDR_XML_HELP_L : IDR_XML_HELP_P));
  if(!wf) {
    return;
  }
  WndListFrame* wHelp = static_cast<WndListFrame*>(wf->FindByName(TEXT("frmDetails")));
  if(!wHelp) {
    return;
  }
  wHelp->SetBorderKind(BORDERLEFT);

  WndOwnerDrawFrame* wHelpEntry = static_cast<WndOwnerDrawFrame*>(wf->FindByName(TEXT("frmDetailsEntry")));
  if (!wHelpEntry) {
    return;
  };
  wHelpEntry->SetCanFocus(true);

  DrawListIndex=0;

  TCHAR fullcaption[100];
  _stprintf(fullcaption,TEXT("%s: %s"), MsgToken(336), Caption); // Help
  wf->SetCaption(fullcaption);

  aTextLine.clear();

  {
    LKWindowSurface Surface(*wHelpEntry);

    const auto oldFont = Surface.SelectObject(wHelpEntry->GetFont());
    const int minHeight = Surface.GetTextHeight(_T("dp")) + 2 * DLGSCALE(2);
    const int wHeight = wHelpEntry->GetHeight();
    if(minHeight != wHeight) {
      wHelpEntry->SetHeight(minHeight);
    }

    aTextLine.update(Surface, wHelpEntry->GetWidth(), LKgethelptext(HelpText));

    Surface.SelectObject(oldFont);
  }

  wHelp->ResetList();
  wHelp->Redraw();
  wf->ShowModal();

  aTextLine.clear();
}
Exemplo n.º 29
0
void dlgHelpShowModal(const TCHAR* Caption, const TCHAR* HelpText) {
  if (!Caption || !HelpText) {
    return;
  }
  InitHelp();

  wf = dlgLoadFromXML(CallBackTable, 
                        ScreenLandscape ? TEXT("dlgHelp_L.xml") : TEXT("dlgHelp_P.xml"),
                        ScreenLandscape ? IDR_XML_HELP_L : IDR_XML_HELP_P);

  LKASSERT(wf);
  if (!wf) goto _getout;

  TCHAR fullcaption[100];
  _stprintf(fullcaption,TEXT("%s: %s"), gettext(TEXT("_@M336_")), Caption); // Help
  wf->SetCaption(fullcaption);

  wHelp = (WndListFrame*)wf->FindByName(TEXT("frmDetails"));
  wHelpEntry = (WndOwnerDrawFrame *)NULL;
  DrawListIndex=0;

  LKASSERT(wHelp!=NULL);
  if (!wHelp) goto _getout;

  wHelp->SetBorderKind(BORDERLEFT);
  
  wHelpEntry = (WndOwnerDrawFrame*)wf->FindByName(TEXT("frmDetailsEntry"));
  LKASSERT(wHelpEntry);
  if (!wHelpEntry) goto _getout;
  wHelpEntry->SetCanFocus(true);

  {
    LKWindowSurface Surface(*wHelpEntry);
    Surface.SelectObject(wHelpEntry->GetFont());
    aTextLine.update(Surface, wHelpEntry->GetWidth(), LKgethelptext(HelpText));
  }

  wHelp->ResetList();
  wHelp->Redraw();
  wf->ShowModal();
  delete wf;
  
  aTextLine.clear();
  

_getout:
  wf = NULL;

}
Exemplo n.º 30
0
    void Image::toSurface(flowerpot::Surface& surface, const Real exposure) {
        lock_guard<mutex> lock(_dataLock);

        if (surface.getWidth() != getWidth() || surface.getHeight() != surface.getHeight()) {
            surface = Surface(getWidth(), getHeight());
        }

        surface.loop([&](RGBA32& pixel, const int x, const int y) {
            pixel = RGBA32(
                sampleComponentToPixelComponent(at(x, y).color.x, exposure),
                sampleComponentToPixelComponent(at(x, y).color.y, exposure),
                sampleComponentToPixelComponent(at(x, y).color.z, exposure),
                255
            );
        });
    }