コード例 #1
0
ファイル: ProductionWnd.cpp プロジェクト: Ouaz/freeorion
void ProductionWnd::DoLayout() {
    GG::X queue_width(GetOptionsDB().Get<int>("UI.queue-width"));
    GG::Y info_height(ClientUI::Pts()*6 + 34);

    m_production_info_panel->MoveTo(GG::Pt(GG::X0, GG::Y0));
    m_production_info_panel->Resize(GG::Pt(queue_width, info_height));

    m_queue_wnd->MoveTo(GG::Pt(GG::X0, info_height));
    m_queue_wnd->Resize(GG::Pt(queue_width, ClientSize().y - info_height));

    m_build_designator_wnd->Resize(ClientSize());
}
コード例 #2
0
ファイル: rimg_rw_bmp.cpp プロジェクト: JolinZh/previewbox
      void write_mono8( vector<uint8_t>& buf, tSize size, vector<uint8_t*> const& rows )  {

         FILEHEADER& bitmapfileheader = *referenceToFILEHEADER( buf );
         bitmapfileheader.signature = BMP_signature;
         bitmapfileheader.size =   static_cast<uint32_t>( buf.size() );
         bitmapfileheader.reserved1 = 0;
         bitmapfileheader.reserved2 = 0;
         bitmapfileheader.offset_bits = offsetpixeldata8;

         INFO& bitmapinfoheader = *referenceToINFO( buf );
         bitmapinfoheader.size = infoheader_size;
         bitmapinfoheader.width = size.x();
         bitmapinfoheader.height = size.y();
         bitmapinfoheader.bit_count = 8;
         bitmapinfoheader.planes = 1;
         bitmapinfoheader.colors_used = 0;
         bitmapinfoheader.colors_important = 0;
         bitmapinfoheader.compression = bmpBI_RGB;
         bitmapinfoheader.size_image = 0;
         bitmapinfoheader.xPelsPerMeter = 0;
         bitmapinfoheader.yPelsPerMeter = 0;

         tBGRA*    bmiColors = referenceToLUT( buf );

         // LUT is not supported, write a gray lut
         for( size_t i = 0; i < 256; i++ ) {
            bmiColors[i].r  = static_cast<uint8_t>( i );
            bmiColors[i].g  = static_cast<uint8_t>( i );
            bmiColors[i].b  = static_cast<uint8_t>( i );
            bmiColors[i].a  = 255;
         }

         uint8_t* dataptr = &buf[0] + bitmapfileheader.offset_bits;
         uint32_t h = info_height( &bitmapinfoheader );
         uint32_t w = info_width( &bitmapinfoheader );
         size_t aligned_w = bmp_intern::align32( w );

         for( size_t y = 0; y < h; y++ ) {
            size_t data_offset = ( h - y - 1 ) * aligned_w;
            uint8_t* target = dataptr + data_offset;
            uint8_t const* source = rows[ y ];
            size_t count = w;

            while( count-- ) {
               *target++ = *source++;
            }
         }
      }
コード例 #3
0
ファイル: ProductionWnd.cpp プロジェクト: Ouaz/freeorion
//////////////////////////////////////////////////
// ProductionWnd                                //
//////////////////////////////////////////////////
ProductionWnd::ProductionWnd(GG::X w, GG::Y h) :
    GG::Wnd(GG::X0, GG::Y0, w, h, GG::INTERACTIVE | GG::ONTOP),
    m_production_info_panel(0),
    m_queue_wnd(0),
    m_build_designator_wnd(0),
    m_order_issuing_enabled(false),
    m_empire_shown_id(ALL_EMPIRES)
{
    //DebugLogger() << "ProductionWindow:  app-width: "<< GetOptionsDB().Get<int>("app-width")
    //              << " ; windowed width: " << GetOptionsDB().Get<int>("app-width-windowed");

    GG::X queue_width(GetOptionsDB().Get<int>("UI.queue-width"));
    GG::Y info_height(ClientUI::Pts()*8);

    m_production_info_panel = new ProductionInfoPanel(UserString("PRODUCTION_WND_TITLE"), UserString("PRODUCTION_INFO_PP"),
                                                      GG::X0, GG::Y0, queue_width, info_height,
                                                      "production.InfoPanel");
    m_queue_wnd = new ProductionQueueWnd(GG::X0, info_height, queue_width, ClientSize().y - info_height);
    m_build_designator_wnd = new BuildDesignatorWnd(ClientSize().x, ClientSize().y);

    SetChildClippingMode(ClipToClient);

    GG::Connect(m_build_designator_wnd->AddBuildToQueueSignal,              &ProductionWnd::AddBuildToQueueSlot, this);
    GG::Connect(m_build_designator_wnd->BuildQuantityChangedSignal,         &ProductionWnd::ChangeBuildQuantitySlot, this);
    GG::Connect(m_build_designator_wnd->SystemSelectedSignal,               SystemSelectedSignal);
    GG::Connect(m_queue_wnd->GetQueueListBox()->QueueItemMovedSignal,       &ProductionWnd::QueueItemMoved, this);
    GG::Connect(m_queue_wnd->GetQueueListBox()->QueueItemDeletedSignal,     &ProductionWnd::DeleteQueueItem, this);
    GG::Connect(m_queue_wnd->GetQueueListBox()->LeftClickedSignal,          &ProductionWnd::QueueItemClickedSlot, this);
    GG::Connect(m_queue_wnd->GetQueueListBox()->DoubleClickedSignal,        &ProductionWnd::QueueItemDoubleClickedSlot, this);
    GG::Connect(m_queue_wnd->GetQueueListBox()->QueueItemRalliedToSignal,   &ProductionWnd::QueueItemRallied, this);
    GG::Connect(m_queue_wnd->GetQueueListBox()->ShowPediaSignal,            &ProductionWnd::ShowPedia, this);
    GG::Connect(m_queue_wnd->GetQueueListBox()->QueueItemPausedSignal,      &ProductionWnd::QueueItemPaused, this);

    AttachChild(m_production_info_panel);
    AttachChild(m_queue_wnd);
    AttachChild(m_build_designator_wnd);
}
コード例 #4
0
ファイル: rimg_rw_bmp.cpp プロジェクト: JolinZh/previewbox
      void read( string fn, tImgLinear& rimg ) {


         std::vector<uint8_t> buf;

         bin_read::t_bin_read reader;
         reader( fn, buf );


         FILEHEADER const* fileheader = referenceToFILEHEADER( buf );
         uint16_t sig = fileheader->signature;


         if( sig != BMP_signature ) {
            return ;
         }

         if( buf.size() == fileheader->size ) {
            try {
               INFO const* bitmapinfoheader = referenceToINFO( buf );
               uint32_t w = info_width( bitmapinfoheader );
               uint32_t h = info_height( bitmapinfoheader );
               // copy data to tImgLinear
               rimg.size() = tSize( w, h );

               uint8_t const* pbuf = &buf[0];
               uint8_t const* dataptr = pbuf + fileheader->offset_bits;


               // 8 bit
               if( bitmapinfoheader->bit_count == 8 ) {
                  // LUT is not supported, convert to rgb, if lut is not an gray ramp lut
                  tBGRA const* lut = referenceToLUT( buf );

                  if( is_ramp( lut ) ) {
                     rimg.set_mono8();
                     rimg.alloc_data_buffer();
                     read_8bit( dataptr, rimg.size(), rimg.rows() );
                     return;
                  }

                  if( is_zero( lut ) ) {
                     rimg.set_mono8();
                     rimg.alloc_data_buffer();
                     read_8bit( dataptr, rimg.size(), rimg.rows() );
                     return;
                  }

                  rimg.set_rgb();
                  rimg.alloc_data_buffer();
                  read_8bit_as_rgb( lut, dataptr, rimg.size(), rimg.rows() );
                  return;
               }

               // 24 bit
               if( bitmapinfoheader->bit_count == 24 ) {
                  rimg.set_rgb();
                  rimg.alloc_data_buffer();
                  read_rgb( dataptr, rimg.size(), rimg.rows() );
               }

               if( bitmapinfoheader->bit_count == 32 ) {
                  // read an rgba image, write an rgb image, alpha is lost
                  rimg.set_rgba();
                  rimg.alloc_data_buffer();
                  read_rgba( dataptr, rimg.size(), rimg.rows() );
               }



            } catch( tImgAllocEx& ex ) {
               throw tImgReadEx( ex.what() );
            }

         }
      }