Module Dfbitmap.pkg
1//*******************************************************************
2//
3// Confidential Trade Secret.
4// Copyright (c) 1997 Data Access Corporation, Miami Florida
5// All rights reserved.
6// DataFlex is a registered trademark of Data Access Corporation.
7//
8//*******************************************************************
9//
10// File : dfbitmap.pkg
11// Version : 2.0
12//
13// Created : 10/10/96
14//
15// Author : Michael Salzlechner / John Tuohy
16//
17// Creates : BitMapContainer Class
18//
19// Rem : Bitmap the filename of a
20// : bitmap in MS-Windows BMP-Format.
21// : This class will automatically display
22// : the stored bitmap when finding a record
23// : Mouseclick on the object starts a common
24// : filedialog to set a new bitmap
25//
26// Object xxx is a BitMapContainer
27// Set Size to height width
28// Set Location to column row
29// Set Bitmap to "bitmapname.bmp"
30// Set Bitmap_Style to Style
31// Set Allow_Select_Bitmap_State to True | False
32// Set Dialog_Caption to "Name of for common file dialog"
33// Set Initial_Folder to "intitial file directory"
34// End_object
35//
36// Bitmap-styles are BITMAP_ACTUAL
37// BITMAP_STRETCH
38// BITMAP_TILE
39// CENTER
40//
41// Function Select_Bitmap returns string
42//
43// By default this pops up a common file dialog allowing user to
44// select a bitmap. This is suitable for augmentation. Return the
45// file name of the bitmap to use. Invoked by Invoke_Select_Bitmap.
46//
47//*******************************************************************
48Use LanguageText.pkg
49Use Windows.pkg
50use File_Dlg.pkg
51
52{ OverrideProperty=Caption_Bar DesignTime=False }
53{ OverrideProperty=Maximize_Icon DesignTime=False }
54{ OverrideProperty=Minimize_Icon DesignTime=False }
55{ OverrideProperty=Sysmenu_Icon DesignTime=False }
56{ OverrideProperty=Auto_Locate_State DesignTime=False }
57{ OverrideProperty=MDI_State DesignTime=False }
58{ OverrideProperty=View_Mode DesignTime=False }
59{ HelpTopic=BitmapContainer }
60Class BitmapContainer is a Container3D
61
62 Procedure Construct_Object
63 Forward Send Construct_Object
64
65 { DesignTime=False }
66 { PropertyType=Boolean }
67 Property Integer Changed_State False
68
69 // If true, double click sends Get Select_Bitmap which invokes
70 // an open file dialog
71 { Category=Behavior }
72 { PropertyType=Boolean }
73 Property Integer Allow_Select_Bitmap_State False
74
75 // title for common file dialog
76 { Category=Appearance }
77 Property String Dialog_Caption C_$SelectBitmapFile
78
79 // start-up directory for common file dialog
80 { Category=Behavior }
81 Property String Initial_Folder ""
82
83 Send Define_ToolTip_Support_Mixin
84
85 // this object should not take the focus
86 Set Focus_Mode TO NonFocusable
87 Set Client_Area_State to False
88 Set pbUseFormWindowHandle to False // must come after Define_ToolTip_Support_Mixin
89 End_Procedure
90
91 Import_Class_Protocol ToolTip_Support_Mixin
92
93 // Although this is not a client it should add child objects to
94 // the focus tree. Should only be textboxes!
95 //
96 { NoDoc=True }
97 Procedure Add_Focus Integer Obj
98 Forward Send Add_Focus Obj
99 Broadcast Send Add_Focus self
100 End_Procedure
101
102 // Popup an open file dialog and select a bitmap file. Returns file
103 // name
104 //
105 { Visibility=Private }
106 Function Select_Bitmap Returns string
107 String sFileName
108 String sPropVal
109 Integer iRet
110 Handle hoOpenFile
111
112 Get Create U_OpenDialog to hoOpenFile
113 // Mask will look like this: "Bitmaps (.bmp;*.rle)|*.bmp;*.rle|All Files (*.*)|*.*"
114 Set Filter_String of hoOpenFile To (C_$Bitmaps * "(.bmp;*.rle)|*.bmp;*.rle|" + C_$AllFiles * "(*.*)|*.*")
115 Get Dialog_Caption to sPropVal
116 Set Dialog_Caption of hoOpenFile to sPropVal
117 Get Initial_Folder to sPropVal
118 Set Initial_Folder of hoOpenFile to sPropVal
119 Get Show_Dialog of hoOpenFile to iRet
120 If iRet ;
121 Get File_Name of hoOpenFile to sFileName
122 Send Destroy of hoOpenFile
123 Function_Return sFileName
124 End_Procedure
125
126 // Purpose: Public message to cause bitmap selection dialog to
127 // appear and, if selected, displays the bitmap.
128 //
129 // Ken Ross 11/15/96 10:03PM
130 //
131 Procedure Invoke_Select_Bitmap
132 String sFileName
133 Get Select_Bitmap To sFileName
134 If (sFileName<>"") Begin
135 Set Bitmap TO sFileName
136 Set Changed_State to true
137 End
138 End_Procedure
139
140
141 // Augmented to invoke the filedialog to retrieve a new bitmap
142 //
143 { MethodType=Event NoDoc=True }
144 Procedure Mouse_Click integer i1 integer i2
145 Forward Send Mouse_Click i1 i2
146 if (Allow_Select_Bitmap_State(self)) begin
147 send Invoke_Select_Bitmap
148 end
149 End_Procedure
150
151 { Visibility=Private }
152 Procedure Page_Object Integer iState
153 Forward Send Page_Object iState
154
155 // Handle tooltip support....
156 If (iState = 0) Begin
157 Send RequestDeleteToolTip
158 End
159 Else Begin
160 Send RequestAddToolTip
161 End
162 End_Procedure
163
164
165 // Called by Page_Object. Handles tooltip creation. We use a dedicated
166 // method to perform AddToolTip because it is often the case that Page_Object
167 // is implemented in a mixin class.
168 { Visibility=Private }
169 Procedure RequestAddToolTip
170 Send AddToolTip
171 End_Procedure // RequestAddToolTip
172
173
174 // Called by Page_Object. Handles tooltip removal.
175 { Visibility=Private }
176 Procedure RequestDeleteToolTip
177 Send DeleteToolTip
178 End_Procedure // RequestDeleteToolTip
179End_Class
180
181