/* bitmap_button.coh ** ** Made by yann koeth ** Wed Mar 31 14:48:57 2010 */ AddBitmapButton(id, dialog, name, flags); class BitmapButton : GeUserArea { private: var bitmap; var dialog; var id; public: BitmapButton(id, dialog, name); GetUserWidth(); GetUserHeight(); Draw(x1, y1, x2, y2); InputEvent(msg); } BitmapButton::BitmapButton(id, dialog, name) { this->dialog = dialog; if (!dialog) return ; this->id = id; bitmap = new(BaseBitmap, 1, 1); var file = new(Filename); file->SetFullString(name); if (bitmap->Load(file) == FALSE) // test absolute path { file = GeGetRootFilename(); file->RemoveLast(); file->AddLast(name); if (bitmap->Load(file) == FALSE) // test relative path TextDialog(name + " can't be loaded.", DLG_OK | DLG_ICONEXCLAMATION); } super(id, dialog); } BitmapButton::GetUserWidth() { return bitmap->GetWidth(); } BitmapButton::GetUserHeight() { return bitmap->GetHeight(); } BitmapButton::Draw(x1, y1, x2, y2) { DrawBitmap(bitmap, 0, 0, GetUserWidth() - 1, GetUserHeight() - 1, x1, y1, x2, y2, BMP_NORMALSCALED); return TRUE; } BitmapButton::InputEvent(msg) { if (msg->GetData(BFM_INPUT_DEVICE) == BFM_INPUT_MOUSE) dialog->Command(id, msg); return TRUE; } AddBitmapButton(id, dialog, name, flags) { dialog->AddUserArea(id, flags, 0, 0); new(BitmapButton, id, dialog, name); return TRUE; }