]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/os2/statbmp.cpp
Replaced an old ifndef FWD_ONLY_CURSORS with the new wxODBC_FWD_ONLY_CURSORS setup...
[wxWidgets.git] / src / os2 / statbmp.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: statbmp.cpp
3// Purpose: wxStaticBitmap
4// Author: David Webster
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#include "wx/window.h"
16#include "wx/os2/private.h"
17
18#ifndef WX_PRECOMP
19 #include "wx/icon.h"
20 #include "wx/statbmp.h"
21#endif
22
23#include <stdio.h>
24
25// ---------------------------------------------------------------------------
26// macors
27// ---------------------------------------------------------------------------
28
29#if !USE_SHARED_LIBRARY
30IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
31#endif
32
33// ---------------------------------------------------------------------------
34// wxStaticBitmap
35// ---------------------------------------------------------------------------
36
37bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
38 const wxBitmap& bitmap,
39 const wxPoint& pos,
40 const wxSize& size,
41 long style,
42 const wxString& name)
43{
44 Init();
45
46 SetName(name);
47 if (parent) parent->AddChild(this);
48
49 m_backgroundColour = parent->GetBackgroundColour() ;
50 m_foregroundColour = parent->GetForegroundColour() ;
51
52 if ( id == -1 )
53 m_windowId = (int)NewControlId();
54 else
55 m_windowId = id;
56
57 m_windowStyle = style;
58
59 int x = pos.x;
60 int y = pos.y;
61 int width = size.x;
62 int height = size.y;
63
64 m_windowStyle = style;
65
66 m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
67
68 // TODO: create static bitmap control
69 wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create static bitmap") );
70
71 SetBitmap(bitmap);
72
73 // Subclass again for purposes of dialog editing mode
74 SubclassWin(m_hWnd);
75
76 SetFont(GetParent()->GetFont());
77
78 SetSize(x, y, width, height);
79
80 return FALSE;
81}
82
83bool wxStaticBitmap::ImageIsOk() const
84{
85 if ( m_isIcon && m_image.icon )
86 return m_image.icon->Ok();
87 else if ( m_image.bitmap )
88 return m_image.bitmap->Ok();
89 else
90 return FALSE;
91}
92
93void wxStaticBitmap::Free()
94{
95 if ( m_isIcon )
96 delete m_image.icon;
97 else
98 delete m_image.bitmap;
99
100 m_image.icon = NULL;
101}
102
103wxSize wxStaticBitmap::DoGetBestSize()
104{
105 // reuse the current size (as wxWindow does) instead of using some
106 // arbitrary default size (as wxControl, our immediate base class, does)
107 return wxWindow::DoGetBestSize();
108}
109
110void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
111{
112 Free();
113
114 m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
115 if ( m_isIcon )
116 m_image.icon = new wxIcon((const wxIcon&)bitmap);
117 else
118 m_image.bitmap = new wxBitmap(bitmap);
119
120 int x, y;
121 int w, h;
122 GetPosition(&x, &y);
123 GetSize(&w, &h);
124
125 // TODO: redraw bitmap
126}
127
128