// Transparent Bitmap Container Class // Pointer Only Button Class based on the transparent bitmap container class and // a 3DContainer class, // // Authors: Sergey V. Natarov and Wil van Antwerpen // // Special thanks to Stuart Booth and Michael Kurz for helping me and Wil // with the correct API calls to use. // // This package needs at least VDF7 to compile // // Copyright (c) 2001, by VDF-GUIdance // Please see our disclaimer at www.vdf-guidance.com for details. // // Aug 10, 2001 SVN: Initial internal publication // Oct 14, 2001 WvA: Code cleanup, // Procedure Set Button_bitmap renamed to Set Bitmap for better compatibility with IDE // and the normal button class. // Set default size to 14 50 // The ability to set the transparent color directly in the ctBitmap class. // Added Bitmap_Col_Offset and Bitmap_Justification_Mode Use cvBitmapContainer.pkg Use tWinStructs.pkg // We are using the jmode_left/ jmode_right and jmode_center constants for aligning the bitmap Class ctButtonBitmap Is a cvBitmapContainer Procedure Construct_Object Forward Send Construct_Object Property Integer Bitmap_Col_Offset 0 Property Integer Bitmap_Justification_Mode Jmode_Center Set piTransparentColor To (rgb(192,192,192)) // Light Grey End_Procedure // Construct_Object Procedure OnResize Integer cxy cx cy iBorder iMode iOffset Integer bxy bx by lx ly Delegate Get Border_Style To iBorder Delegate Get GuiSize To cxy Get Bitmap_Justification_Mode To iMode Get Bitmap_Col_Offset To iOffset Move (hi(cxy)) To cy Move (low(cxy)) To cx Get piBitmapHeight To by Get piBitmapWidth To bx If (iMode = jMode_Center) Begin Move ((cx/2)-(bx/2)+iOffset) To lx End Else If (iMode = jMode_Left) Begin Move ((cx/2)-(bx/2)+iOffset) To lx End Else If (iMode = jMode_Right) Begin Move (cx-bx+iOffset) To lx End Move ((cy/2)-(by/2)) To ly If (iBorder=Border_Normal) Set GuiLocation To ly lx Else If (iBorder=Border_Dialog) Set GuiLocation To (ly-2) (lx-2) Send Adjust_Logicals End_Procedure // OnResize End_Class // ctButtonBitmap Class ctButton Is a Container3D Procedure Construct_Object Forward Send Construct_Object Send Define_Dflabel_Mixin Object oBitmap Is a ctButtonBitmap End_Object // oBitmap Set Border_Style To Border_Dialog Set Size To 14 50 Set Label_Col_Offset To 2 // Set Label_Offset To 1 0 Set Label_Justification_Mode To Jmode_Right End_Procedure // Construct_Object Import_Class_Protocol Dflabel_Mixin Procedure Resize_Button Broadcast Send OnResize End_Procedure // Resize_Button // This must be set in the topcode of the object (e.g. before the object is created) Procedure Set Bitmap_Col_Offset Integer icCol Set Bitmap_Col_Offset Of (oBitmap(Self)) to icCol Send Resize_Button End_Procedure // Set Bitmap_Col_Offset Function Bitmap_col_offset returns integer function_return (Bitmap_col_offset(oBitmap(Self))) End_Function // Bitmap_col_offset // This must be set in the topcode of the object (e.g. before the object is created) Procedure Set Bitmap_Justification_Mode integer mode Set Bitmap_Justification_mode Of (oBitmap(Self)) to mode Send Resize_Button end_procedure Function Bitmap_Justification_mode returns integer function_return (Bitmap_Justification_mode(oBitmap(Self))) End_Function // Bitmap_Justification_mode Procedure Set Bitmap String sBitmap Set Bitmap Of (oBitmap(Self)) To sBitmap End_Procedure // Set Bitmap // This must be set in the topcode of the object (e.g. before the object is created) Procedure Set piTransparentColor Integer iRgbColor Set piTransparentColor Of (oBitmap(Self)) To iRgbColor End_Procedure // Set piTransparentColor Function piTransparentColor Returns Integer Integer iRgbColor Get piTransparentColor Of (oBitmap(Self)) To iRgbColor Function_Return iRgbColor End_Function // piTransparentColor Procedure Mouse_Down Integer i1 Set Border_Style To Border_Normal // ClientEdge Forward Set Bitmap To (Bitmap(Self)) Send Set_Mouse_Capture End_Procedure // Mouse_Down Procedure Mouse_Up Integer iWnd Integer iClr iRet Integer iObj Get ObjectUnderCursor To iObj If (iObj=Self) Begin Send OnClick End // if iObj=self ? Set Border_Style To Border_Dialog Forward Set Bitmap To (Bitmap(Self)) Send Release_Mouse_Capture End_Procedure // Mouse_Up Procedure Activating Send Resize_Button Forward Send Activating End_Procedure // Activating Procedure Set Border_Style Integer iBorder Forward Set Border_Style To iBorder Send Resize_Button End_Procedure // Set Border_Style Function ObjectUnderCursor Returns Integer Handle hWnd Integer x y hoDrop tWinPoint wPoint Move 0 to wPoint.x Move (GetCursorPos(AddressOf(wPoint))) to windowindex Move wPoint.x to x Move wPoint.y to y Move (WindowFromPoint(x,y)) To hWnd GET_OBJECT_FROM_WINDOW hWnd To hoDrop Function_Return hoDrop End_Function // ObjectUnderCursor // Hook procedure Procedure OnClick End_Procedure // OnClick End_Class // ctButton