Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_text.c ewl_text.h 


Log Message:
- you can now set a font source for a font. the regualr font_set will just
  call font_source_set with the source == NULL which means read from the
  theme .edj file.

- the font source is the full path to the font directory and the font is the 
  name of the font file in the directory (with extension)

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -3 -r1.124 -r1.125
--- ewl_text.c  9 Sep 2006 17:18:41 -0000       1.124
+++ ewl_text.c  9 Sep 2006 18:06:59 -0000       1.125
@@ -858,6 +858,68 @@
 void
 ewl_text_font_set(Ewl_Text *t, const char *font)
 {
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("t", t);
+       DCHECK_TYPE("t", t, EWL_TEXT_TYPE);
+
+       ewl_text_font_source_set(t, NULL, font);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param t: The Ewl_Text to set the font too
+ * @param font: The font to set
+ * @param char_len: The distance to set the font over
+ * @return Returns no value
+ * @brief This will apply the specfied @a font from the current cursor 
position to
+ * the length specified
+ */
+void
+ewl_text_font_apply(Ewl_Text *t, const char *font, unsigned int char_len)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("t", t);
+       DCHECK_TYPE("t", t, EWL_TEXT_TYPE);
+
+       ewl_text_font_source_apply(t, NULL, font, char_len);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param t: The Ewl_Text to get the font from
+ * @param char_idx: The index to get the font at
+ * @return Returns no value
+ * @brief This will retrive the font used at the specified index in the text
+ */
+char *
+ewl_text_font_get(Ewl_Text *t, unsigned int char_idx)
+{
+       char *font = NULL;
+       Ewl_Text_Context *tx;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("t", t, NULL);
+       DCHECK_TYPE_RET("t", t, EWL_TEXT_TYPE, NULL);
+
+       tx = ewl_text_tree_context_get(t->formatting.tree, char_idx);
+       if (tx && tx->font)
+               font = strdup(tx->font);
+
+       DRETURN_PTR(font, DLEVEL_STABLE);
+}
+
+/**
+ * @param t: The Ewl_Widget to set the font into
+ * @param souce: The font source to set
+ * @param font: The font to set
+ * @return Returns no value
+ * @brief This will set the current font to be used when we insert more text
+ */
+void
+ewl_text_font_source_set(Ewl_Text *t, const char *source, const char *font)
+{
        Ewl_Text_Context *change;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -866,6 +928,8 @@
 
        change = ewl_text_context_new();
 
+       if (source) change->font_source = strdup(source);
+
        /* null font will go back to the theme default */
        if (!font) change->font = ewl_theme_data_str_get(EWL_WIDGET(t), "font");
        else change->font = strdup(font);
@@ -878,6 +942,7 @@
 
 /**
  * @param t: The Ewl_Text to set the font too
+ * @param source: The font souce
  * @param font: The font to set
  * @param char_len: The distance to set the font over
  * @return Returns no value
@@ -885,7 +950,8 @@
  * the length specified
  */
 void
-ewl_text_font_apply(Ewl_Text *t, const char *font, unsigned int char_len)
+ewl_text_font_source_apply(Ewl_Text *t, const char *source, const char *font, 
+                                                       unsigned int char_len)
 {
        Ewl_Text_Context *tx;
 
@@ -899,6 +965,8 @@
 
        tx = ewl_text_context_new();
 
+       if (source) tx->font_source = strdup(source);
+
        /* null font will go back to the theme default */
        if (!font) tx->font = ewl_theme_data_str_get(EWL_WIDGET(t), "font");
        else tx->font = strdup(font);
@@ -917,12 +985,12 @@
  * @param t: The Ewl_Text to get the font from
  * @param char_idx: The index to get the font at
  * @return Returns no value
- * @brief This will retrive the font used at the specified index in the text
+ * @brief This will retrive the font source used at the specified index in the 
text
  */
 char *
-ewl_text_font_get(Ewl_Text *t, unsigned int char_idx)
+ewl_text_font_source_get(Ewl_Text *t, unsigned int char_idx)
 {
-       char *font = NULL;
+       char *source = NULL;
        Ewl_Text_Context *tx;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -930,10 +998,10 @@
        DCHECK_TYPE_RET("t", t, EWL_TEXT_TYPE, NULL);
 
        tx = ewl_text_tree_context_get(t->formatting.tree, char_idx);
-       if (tx && tx->font)
-               font = strdup(tx->font);
+       if (tx && tx->font_source)
+               source = strdup(tx->font_source);
 
-       DRETURN_PTR(font, DLEVEL_STABLE);
+       DRETURN_PTR(source, DLEVEL_STABLE);
 }
 
 /**
@@ -2629,12 +2697,24 @@
        fmt[pos].val = t;
        fmt[pos++].free = FALSE;
 
+       t = NEW(char, 128);
+
        fmt[pos].key = "font_source";
-       fmt[pos].val = ewl_theme_path_get();
-       fmt[pos++].free = TRUE;
+       if (ctx->font_source)
+       {
+               fmt[pos].val = ctx->font_source;
+               fmt[pos++].free = FALSE;
+
+               t = strdup(ctx->font);
+       }
+       else
+       {
+               fmt[pos].val = ewl_theme_path_get();
+               fmt[pos++].free = TRUE;
+
+               snprintf(t, 128, "fonts/%s", ctx->font);
+       }
 
-       t = NEW(char, 128);
-       snprintf(t, 128, "fonts/%s", ctx->font);
        fmt[pos].key = "font";
        fmt[pos].val = t;
        fmt[pos++].free = TRUE;
@@ -4267,6 +4347,7 @@
 
        /* handle default values */
        tmp->font = ewl_theme_data_str_get(EWL_WIDGET(t), "font");
+       tmp->font_source = NULL;
        tmp->size = ewl_theme_data_int_get(EWL_WIDGET(t), "font_size");
 
        tmp->color.r = ewl_theme_data_int_get(EWL_WIDGET(t), "color/r");
@@ -4405,7 +4486,7 @@
                                                Ewl_Text_Context *tx_change)
 {
        char name[2048];
-       char *t = NULL, *t2 = NULL;
+       char *t = NULL, *t2 = NULL, *s = NULL, *s2 = NULL;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("tx", tx, NULL);
@@ -4413,16 +4494,24 @@
        if (context_mask > 0)
        {
                DCHECK_PARAM_PTR_RET("tx_change", tx_change, NULL);
+
                if (!tx_change->font) t2 = "";
                else t2 = tx_change->font;
+
+               if (!tx_change->font_source) s2 = "";
+               else s2 = tx_change->font_source;
        }
 
        if (!tx->font) t = "";
        else t = tx->font;
 
-       snprintf(name, sizeof(name), 
"f%ss%ds%da%dw%dr%dg%db%da%dcbg%d%d%d%dcg%d%d%d%d"
+       if (!tx->font_source) s = "";
+       else s = tx->font_source;
+
+       snprintf(name, sizeof(name), 
"f%s%ss%ds%da%dw%dr%dg%db%da%dcbg%d%d%d%dcg%d%d%d%d"
                                
"co%d%d%d%dcs%d%d%d%dcst%d%d%d%dcu%d%d%d%dcdu%d%d%d%d", 
-               ((context_mask & EWL_TEXT_CONTEXT_MASK_FONT) ? t2: t),
+               ((context_mask & EWL_TEXT_CONTEXT_MASK_FONT) ? s2 : s),
+               ((context_mask & EWL_TEXT_CONTEXT_MASK_FONT) ? t2 : t),
                ((context_mask & EWL_TEXT_CONTEXT_MASK_SIZE) ? tx_change->size 
: tx->size),
                ((context_mask & EWL_TEXT_CONTEXT_MASK_STYLES) ? 
tx_change->styles : tx->styles),
                ((context_mask & EWL_TEXT_CONTEXT_MASK_ALIGN) ? 
tx_change->align : tx->align),
@@ -4515,6 +4604,10 @@
                        {
                                IF_FREE(new_tx->font);
                                new_tx->font = strdup(tx_change->font);
+
+                               IF_FREE(new_tx->font_source);
+                               if (tx_change->font_source)
+                                       new_tx->font_source = 
strdup(tx_change->font_source);
                        }
                        else if (context_mask & EWL_TEXT_CONTEXT_MASK_SIZE)
                                new_tx->size = tx_change->size;
@@ -4664,7 +4757,7 @@
 static void
 ewl_text_context_print(Ewl_Text_Context *tx, const char *indent)
 {
-       char *t;
+       char *t, *s;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("tx", tx);
@@ -4672,7 +4765,10 @@
        if (!tx->font) t = "";
        else t = tx->font;
 
-       printf("%sfont: %s\n"
+       if (!tx->font_source) s = "";
+       else s = tx->font_source;
+
+       printf("%sfont: %s (source: %s)\n"
                "%ssize %d\n"
                "%sstyle %d\n"
                "%salign %d\n"
@@ -4680,13 +4776,12 @@
                "%sred %d\n"
                "%sgreen %d\n"
                "%sblue %d\n" 
-               "%salpha %d\n"
-               "%s\n", 
-                       indent, t, indent, tx->size, indent, 
+               "%salpha %d",
+                       indent, t, s, indent, tx->size, indent, 
                        tx->styles, indent, tx->align, 
                        indent, tx->wrap, indent, tx->color.r, 
                        indent, tx->color.g, indent, tx->color.b, 
-                       indent, tx->color.a, tx->format);
+                       indent, tx->color.a);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- ewl_text.h  9 Sep 2006 17:18:41 -0000       1.42
+++ ewl_text.h  9 Sep 2006 18:06:59 -0000       1.43
@@ -146,6 +146,13 @@
                                                        unsigned int char_len);
 char           *ewl_text_font_get(Ewl_Text *t, unsigned int char_idx);
 
+void            ewl_text_font_source_set(Ewl_Text *t, const char *source, 
+                                                       const char *font);
+void            ewl_text_font_source_apply(Ewl_Text *t, const char *source,
+                                                       const char *font,
+                                                       unsigned int char_len);
+char           *ewl_text_font_source_get(Ewl_Text *t, unsigned int char_idx);
+
 void            ewl_text_font_size_set(Ewl_Text *t, unsigned int size);
 void            ewl_text_font_size_apply(Ewl_Text *t, unsigned int size,
                                                        unsigned int char_len);
@@ -322,6 +329,7 @@
 struct Ewl_Text_Context
 {
        char *font;                             /**< Font name */
+       char *font_source;                      /**< The font source */
        unsigned int styles;                    /**< Styles set in this node */
        unsigned int align;                     /**< Text alignment */
        Ewl_Text_Wrap wrap;                     /**< Text wrap setting */



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to