DEV Community

Peter + AI
Peter + AI

Posted on

🎨 Creating and Managing Glyphs in Uniface 10.4: A Simple Guide

Creating and Managing Glyphs in Uniface 10.4

Note: This blog post was created with AI assistance.

What Are Glyphs? πŸ–ΌοΈ

Glyphs in Uniface are special images stored in a proprietary format. Think of them as optimized pictures that you can use in your applications. They work great for icons, buttons, backgrounds, and menu items. The best part? They load fast and work smoothly in desktop applications.

Unlike regular image files, glyphs are compiled and stored in runtime libraries, which makes them super efficient for your Uniface applications.

Why Use Glyphs? ⚑

Glyphs offer several advantages:

  • Fast loading times in desktop applications
  • Consistent appearance across your application
  • Can be stored directly in UAR files or the Repository
  • Support for multiple color depths (16-bit, 32-bit)
  • No need to manage separate image files

Getting Started: Creating Your First Glyph πŸš€

Before you start, you'll need to create your image files using your favorite graphics tool like Photoshop, GIMP, or Paint.NET. Once you have your images ready, follow these steps:

Step 1: Open the Glyph Editor

In Uniface IDE, navigate to More Editors and select Glyphs. This opens the glyph editor where all the magic happens.

Step 2: Select or Create a Library

Glyphs must be stored in a runtime library. If you don't have one yet, create a new library. If the library is empty, Uniface will automatically show you the Insert Glyph dialog.

Step 3: Define Your Glyph

Click the New button in the glyph editor to create a new glyph. This opens the Insert Glyph dialog where you can configure your glyph.

Step 4: Load Your Image

Click the >> button next to Primary File and select your image. Uniface automatically detects the size and colors of your image. Pretty smart, right? 😊

Example: If you have an icon called "save_icon.png", browse to it and select it as your primary file.

Step 5: Add a Secondary Version (Optional)

You can add a secondary file for different display environments. For example, you might want a 16-bit color version for older systems and a 32-bit version for modern displays. Uniface will automatically choose the right one at runtime.

Step 6: Enable Display

Important: Make sure the Display checkbox is selected for each source file. If you forget this step, your glyph won't show up at runtime. This is a common mistake, so double-check it! ⚠️

Step 7: Name Your Glyph

Uniface generates a default name by adding "U_" to your image filename. For better organization, edit the Glyph Name to something meaningful.

Example: Instead of "U_save_icon", you might name it "ICON_SAVE" or "BTN_SAVE_32".

Step 8: Save and Compile

Choose File > Save to compile and save your glyph. Alternatively, click OK to save and close the editor in one step.

Using Glyphs in Your Application πŸ’Ό

Once your glyph is created and compiled, you can use it throughout your application. In Uniface, you reference glyphs using the caret symbol (^) followed by the glyph name.

Example:

^ICON_SAVE
^BTN_OK
^BACKGROUND_IMAGE
Enter fullscreen mode Exit fullscreen mode

This syntax tells Uniface to load the pre-compiled glyph from the runtime library.

Common Problems and Solutions πŸ”§

Problem 1: Glyph Not Displaying

Solution: Check if the Display checkbox was selected when you created the glyph. This is the most common reason for invisible glyphs.

Problem 2: Need to Change Glyph Properties

Solution: You cannot modify a glyph after it's saved. You must delete it and create it again with the correct settings. To delete a glyph, select it in the editor and choose Edit > Delete Glyph.

Problem 3: Wrong Image Quality

Solution: Add multiple versions of your glyph with different color depths. Uniface will automatically select the best version for the runtime environment.

Best Practices πŸ“‹

  • Use meaningful names: Name your glyphs clearly (like ICON_DELETE, BTN_SAVE) so other developers understand what they are.
  • Organize by purpose: Group related glyphs in the same library (e.g., all button icons in one library).
  • Create multiple versions: Provide different color depths for better compatibility.
  • Test before deployment: Always test your glyphs in the target runtime environment.
  • Document your glyphs: Use the Description field to explain what each glyph is used for.

Quick Reference: Glyph Creation Steps πŸ“

  1. Create image file(s) with your graphics tool
  2. Open Uniface IDE β†’ More Editors β†’ Glyphs
  3. Select or create a runtime library
  4. Click New to create a glyph
  5. Load primary image file
  6. Optionally load secondary image file
  7. Ensure Display checkbox is checked
  8. Edit glyph name and language
  9. Save and compile

Conclusion 🎯

Glyphs are a powerful feature in Uniface 10.4 for managing images efficiently in your applications. They provide fast loading times, consistent appearance, and easy maintenance. While they're especially useful for desktop applications, remember that for web applications, you might want to use URL-based images instead.

The key things to remember are: always check the Display checkbox, use meaningful names, and remember that glyphs cannot be modified after creationβ€”you need to delete and recreate them if changes are needed.

Happy coding! πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

Top comments (0)