1. wxBitmap - Linux vs Windows, part 1

The wxBitmap in the original program works on Linux but not on Windows.

Here is a minimal program to illustrate the problem.
I expected it to not work on Windows, but to my surprise it worked on Windows.
No clue about the original program.

I post this for comparison with the 2nd minimal program, which I succeeded in
getting to not work. I will post the 2nd minimal program in a separate message.

-- splash_sample.exw

-- Replace "bigkick.bmp" with something you have.

----------------------------------------------------------
global constant
 PROGRAM_TITLE = "Diet Monger Ass Kicker   October 1, 2006    public domain"
----------------------------------------------------------
include wxEuphoria.e
include wxSizer.e
include wxText.e
include wxButton.e
include wxGraphics.e

global object void
global sequence SLASH,path_dmak

procedure getSLASH()
integer p

  p = platform()
  if p = LINUX then
    SLASH = "/"
  else
    SLASH = "\\"
  end if
end procedure
getSLASH()

function GetPath()  -- Get the path that the program is in.
sequence cmd,path

  cmd = command_line()
  path = ""
  for stop = length(cmd[2]) to 1 by -1 do
    if cmd[2][stop] = '/' then
      path = cmd[2][1..stop]
      exit
    end if
  end for
  return path
end function  -- GetPath()
path_dmak = GetPath()
--------------------------------------------------------------------

global constant
 splash_width = 600,
 splash_height = 600,
frameWin = create(wxFrame,{0,-1, PROGRAM_TITLE, -1, -1, splash_width,
 splash_height}),
 Win = create( wxPanel, {frameWin}),
 boxMain = create(wxBoxSizer,{wxHORIZONTAL}),

frmSplash = create(wxFrame,{0,-1,"Loading USDA data
 ...",-1,-1,splash_width,splash_height}),
 pnlSplash = create(wxPanel,{frmSplash}),
 boxSplash = create(wxBoxSizer,{wxVERTICAL}),
 lblSplash = create(wxStaticText,{pnlSplash,-1,"..",-1,-1,200,20,
   wx_or_all({wxALIGN_CENTER_VERTICAL, wxST_NO_AUTORESIZE})}),
 bmpSplash = create(wxBitmap,{BM_FROM_FILE,"bigkick.bmp",wxBITMAP_TYPE_BMP}),
 fontSplash = create(wxFont,{14,wxDEFAULT,wxNORMAL,wxNORMAL,0,"Arial"})

 set_default_font(lblSplash,fontSplash)

 set_sizer(pnlSplash,boxSplash)

 add_window_to_sizer(boxSplash,lblSplash,0,wxGROW,0)

set_sizer(Win,boxMain)
-----------------------------------------------------------------------------
procedure onPaint_pnlSplash( atom this, atom id, atom event_type, atom event )
sequence extent
atom dc,x,y

dc = create(wxPaintDC, {this})

extent = get_bitmap_size( bmpSplash )

  x = (splash_width - extent[1]) / 2
  y = ((splash_height - 100) - extent[2]) /2
  y += 100
x = floor(x)
y = floor(y)
draw_bitmap( dc, bmpSplash, x, y, 0)

delete_instance( dc )
end procedure
set_event_handler(pnlSplash,get_id(pnlSplash),wxEVT_PAINT,routine_id("onPaint_pnlSplash"))
-----------------------------------------------------------------------------

global integer win_width,win_height
  win_width = 800
  win_height = 600

constant TIME_TO_READ = 2

  set_label(lblSplash,sprintf("%d seconds to read",{TIME_TO_READ}))
show_window(frmSplash,1)
  for i = 1 to 3 do
  void = call_member( wxApp_Yield, myApp_this, {1})
end for

  sleep(TIME_TO_READ)

delete_instance(frmSplash)
----------------------------------------------------------------------------
set_size(frameWin,win_width,win_height)
wxMain( frameWin )


new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu